Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
80c5c19f
Commit
80c5c19f
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
cleanup a few references to old task code.
parent
368a44b3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/core.clj
+0
-3
0 additions, 3 deletions
src/metabase/core.clj
test/metabase/task_test.clj
+0
-84
0 additions, 84 deletions
test/metabase/task_test.clj
test/metabase/test_setup.clj
+2
-6
2 additions, 6 deletions
test/metabase/test_setup.clj
with
2 additions
and
93 deletions
src/metabase/core.clj
+
0
−
3
View file @
80c5c19f
...
...
@@ -115,16 +115,13 @@
;; Now start the task runner
(
task/start-scheduler!
)
(
task/start-task-runner!
)
(
log/info
"Metabase Initialization COMPLETE"
)
true
)
;; TODO - uh, when do we *stop* the task runner ?
;; ## Jetty (Web) Server
(
def
^
:private
jetty-instance
(
atom
nil
))
...
...
This diff is collapsed.
Click to expand it.
test/metabase/task_test.clj
deleted
100644 → 0
+
0
−
84
View file @
368a44b3
(
ns
metabase.task-test
(
:require
[
expectations
:refer
:all
]
(
metabase
[
task
:refer
:all
]
[
test-setup
:refer
:all
]))
(
:import
java.util.Calendar
))
(
defhook
task-test-hook
"Hook for test purposes."
)
(
def
task-test-atom-counter
(
atom
0
))
(
defn-
inc-task-test-atom-counter
[]
(
swap!
task-test-atom-counter
inc
))
(
defn-
inc-task-test-atom-counter-twice
[]
(
swap!
task-test-atom-counter
(
partial
+
2
)))
;; ## HOOK TESTS
(
expect
[
0
; (1)
1
; (2)
3
; (3)
6
; (4)
9
]
; (5)
[
;; (1) get initial value
(
do
(
reset!
task-test-atom-counter
0
)
; reset back to 0
(
run-hook
#
'task-test-hook
)
@
task-test-atom-counter
)
;; (2) now add a hook function. Should increment the counter once
(
do
(
add-hook!
#
'task-test-hook
inc-task-test-atom-counter
)
(
run-hook
#
'task-test-hook
)
@
task-test-atom-counter
)
;; (3) ok, run the hook twice. Should increment counter twice
(
do
(
run-hook
#
'task-test-hook
)
(
run-hook
#
'task-test-hook
)
@
task-test-atom-counter
)
;; (4) add another hook function that increments counter twice on each call (for a total of + 3)
(
do
(
add-hook!
#
'task-test-hook
inc-task-test-atom-counter-twice
)
(
run-hook
#
'task-test-hook
)
@
task-test-atom-counter
)
;; (5) check that we can't add duplicate hooks - should still be just +3
(
do
(
add-hook!
#
'task-test-hook
inc-task-test-atom-counter-twice
)
(
run-hook
#
'task-test-hook
)
@
task-test-atom-counter
)])
;; ## TASK RUNNER TESTS
(
defn-
system-hour
[]
(
.get
(
Calendar/getInstance
)
Calendar/HOUR
))
(
defn-
inc-task-test-atom-counter-by-system-hour
[
hour
]
(
swap!
task-test-atom-counter
(
partial
+
(
system-hour
))))
(
defhook
mock-hourly-tasks-hook
"Hook that will replace the actual hourly-tasks-hook in our unit test."
)
(
expect
[[
0
(
system-hour
)
; we can also check that the `hourly-tasks-hook` is passing the correct param to its functions
(
*
3
(
system-hour
))
:stopped
]
:restarted
]
[(
do
(
stop-task-runner!
)
(
with-redefs
[
metabase.task/hourly-task-delay
(
constantly
200
)
metabase.task/hourly-tasks-hook
mock-hourly-tasks-hook
]
(
add-hook!
#
'hourly-tasks-hook
inc-task-test-atom-counter-by-system-hour
)
(
reset!
task-test-atom-counter
0
)
(
start-task-runner!
)
[
@
task-test-atom-counter
; should be 0, since not enough time has elaspsed for the hook to be executed
(
do
(
Thread/sleep
300
)
@
task-test-atom-counter
)
; should have been called once (~100ms ago)
(
do
(
Thread/sleep
400
)
@
task-test-atom-counter
)
; should have been called two more times
(
do
(
stop-task-runner!
)
:stopped
)]))
(
do
(
start-task-runner!
)
:restarted
)])
This diff is collapsed.
Click to expand it.
test/metabase/test_setup.clj
+
2
−
6
View file @
80c5c19f
...
...
@@ -6,7 +6,6 @@
[
expectations
:refer
:all
]
(
metabase
[
core
:as
core
]
[
db
:as
db
]
[
task
:as
task
]
[
util
:as
u
])
(
metabase.models
[
table
:refer
[
Table
]])
[
metabase.test.data.datasets
:as
datasets
]))
...
...
@@ -83,16 +82,13 @@
(
let
[
setup-db
(
future
(
time
(
do
(
log/info
"Setting up test DB and running migrations..."
)
(
db/setup-db
:auto-migrate
true
)
(
load-test-datasets
)
(
metabase.models.setting/set
:site-name
"Metabase Test"
))))
start-task-runner!
(
future
(
task/start-task-runner!
))]
(
metabase.models.setting/set
:site-name
"Metabase Test"
))))]
(
core/start-jetty
)
@
setup-db
@
start-task-runner!
))
@
setup-db
))
(
defn
test-teardown
{
:expectations-options
:after-run
}
[]
(
log/info
"Shutting down Metabase unit test runner"
)
(
task/stop-task-runner!
)
(
core/stop-jetty
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment