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
ef5f4e01
Unverified
Commit
ef5f4e01
authored
5 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Fix occasional test failure
parent
cafb19ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/metabase/async/streaming_response_test.clj
+32
-14
32 additions, 14 deletions
test/metabase/async/streaming_response_test.clj
with
32 additions
and
14 deletions
test/metabase/async/streaming_response_test.clj
+
32
−
14
View file @
ef5f4e01
...
...
@@ -7,7 +7,8 @@
[
driver
:as
driver
]
[
http-client
:as
test-client
]
[
models
:refer
[
Database
]]
[
test
:as
mt
]]
[
test
:as
mt
]
[
util
:as
u
]]
[
metabase.async.streaming-response
:as
streaming-response
]
[
metabase.async.streaming-response.thread-pool
:as
thread-pool
]
[
metabase.query-processor.context
:as
context
])
...
...
@@ -42,11 +43,26 @@
(
with-streaming-response-thread-pool
~@
body
))))
(
def
^
:private
start-execution-chan
"A core.async channel that will get a message when query execution starts."
(
atom
nil
))
(
defmacro
^
:private
with-start-execution-chan
[[
chan-binding
]
&
body
]
`
(
mt/with-open-channels
[
chan
#
(
a/promise-chan
)]
(
try
(
reset!
start-execution-chan
chan
#
)
(
let
[
~
chan-binding
chan
#
]
~@
body
)
(
finally
(
reset!
start-execution-chan
nil
)))))
(
defmethod
driver/execute-reducible-query
::test-driver
[
_
{{{
:keys
[
sleep
]}
:query
}
:native,
database-id
:database
}
context
respond
]
{
:pre
[(
integer?
sleep
)
(
integer?
database-id
)]}
(
let
[
futur
(
future
(
try
(
when-let
[
chan
@
start-execution-chan
]
(
a/>!!
chan
::started
))
(
Thread/sleep
sleep
)
(
respond
{
:cols
[{
:name
"Sleep"
,
:base_type
:type/Integer
}]}
[[
sleep
]])
(
catch
InterruptedException
e
...
...
@@ -115,16 +131,18 @@
(
with-redefs
[
streaming-response/keepalive-interval-ms
50
]
(
with-test-driver-db
(
reset!
canceled?
false
)
(
let
[
url
(
test-client/build-url
"dataset"
nil
)
session-token
(
test-client/authenticate
(
mt/user->credentials
:lucky
))
request
(
test-client/build-request-map
session-token
{
:database
(
mt/id
)
:type
"native"
:native
{
:query
{
:sleep
5000
}}})
futur
(
http/post
url
(
assoc
request
:async?
true
)
identity
(
fn
[
e
]
(
throw
e
)))]
(
is
(
future?
futur
))
(
Thread/sleep
100
)
(
future-cancel
futur
)
(
Thread/sleep
100
)
(
is
(
=
true
@
canceled?
)))))))
(
with-start-execution-chan
[
start-chan
]
(
let
[
url
(
test-client/build-url
"dataset"
nil
)
session-token
(
test-client/authenticate
(
mt/user->credentials
:lucky
))
request
(
test-client/build-request-map
session-token
{
:database
(
mt/id
)
:type
"native"
:native
{
:query
{
:sleep
5000
}}})
futur
(
http/post
url
(
assoc
request
:async?
true
)
identity
(
fn
[
e
]
(
throw
e
)))]
(
is
(
future?
futur
))
;; wait a little while for the query to start running -- this should usually happen fairly quickly
(
mt/wait-for-result
start-chan
(
u/seconds->ms
15
))
(
future-cancel
futur
)
(
Thread/sleep
200
)
(
is
(
=
true
@
canceled?
))))))))
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