* [PATCH] test: fix box/push.test sporadic hang
@ 2019-02-28 11:05 Vladimir Davydov
2019-02-28 11:10 ` Vladimir Davydov
0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Davydov @ 2019-02-28 11:05 UTC (permalink / raw)
To: tarantool-patches
This patch fixes the following test failure:
| --- box/push.result Thu Jan 24 13:10:04 2019
| +++ var/001_box/push.result Thu Jan 24 13:13:08 2019
| @@ -536,17 +536,3 @@
| ---
| ...
| chan_disconnected:get()
| ----
| -- true
| -...
| -chan_push:put(true)
| ----
| -- true
| -...
| -chan_push:get()
| ----
| -- Session is closed
| -...
| -box.schema.func.drop('do_long_and_push')
| ----
| -...
The problem occurs because the main fiber may close the connection
before do_long_and_push sets the session.on_disconnect trigger, in
which case chan_disconnected:get() will never return. Fix this by
setting the trigger in the main fiber and adding another channel
to wait for do_long_and_push function to start. Also, don't forget
to clear the trigger once the test is complete.
Fixes commit 43af2de2b129 ("session: outdate a session of a closed
connection").
Closes #3947
---
https://github.com/tarantool/tarantool/issues/3947
https://github.com/tarantool/tarantool/commits/dv/test-fixes
test/box/push.result | 15 ++++++++++++++-
test/box/push.test.lua | 6 +++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/test/box/push.result b/test/box/push.result
index 8919a3f5..aebcb750 100644
--- a/test/box/push.result
+++ b/test/box/push.result
@@ -501,18 +501,24 @@ s:drop()
-- gh-3859: box.session.push() succeeds even after the connection
-- is closed.
--
+chan_func = fiber.channel()
+---
+...
chan_push = fiber.channel()
---
...
chan_disconnected = fiber.channel()
---
...
+on_disconnect = box.session.on_disconnect(function() chan_disconnected:put(true) end)
+---
+...
test_run:cmd("setopt delimiter ';'")
---
- true
...
function do_long_and_push()
- box.session.on_disconnect(function() chan_disconnected:put(true) end)
+ chan_func:put(true)
chan_push:get()
ok, err = box.session.push(100)
chan_push:put(err)
@@ -532,6 +538,10 @@ box.schema.user.grant('guest', 'execute', 'function', 'do_long_and_push')
f = fiber.create(function() c:call('do_long_and_push') end)
---
...
+chan_func:get()
+---
+- true
+...
c:close()
---
...
@@ -550,3 +560,6 @@ chan_push:get()
box.schema.func.drop('do_long_and_push')
---
...
+box.session.on_disconnect(nil, on_disconnect)
+---
+...
diff --git a/test/box/push.test.lua b/test/box/push.test.lua
index 514c08b3..7ae6f4a8 100644
--- a/test/box/push.test.lua
+++ b/test/box/push.test.lua
@@ -242,11 +242,13 @@ s:drop()
-- gh-3859: box.session.push() succeeds even after the connection
-- is closed.
--
+chan_func = fiber.channel()
chan_push = fiber.channel()
chan_disconnected = fiber.channel()
+on_disconnect = box.session.on_disconnect(function() chan_disconnected:put(true) end)
test_run:cmd("setopt delimiter ';'")
function do_long_and_push()
- box.session.on_disconnect(function() chan_disconnected:put(true) end)
+ chan_func:put(true)
chan_push:get()
ok, err = box.session.push(100)
chan_push:put(err)
@@ -255,8 +257,10 @@ test_run:cmd("setopt delimiter ''");
box.schema.func.create('do_long_and_push')
box.schema.user.grant('guest', 'execute', 'function', 'do_long_and_push')
f = fiber.create(function() c:call('do_long_and_push') end)
+chan_func:get()
c:close()
chan_disconnected:get()
chan_push:put(true)
chan_push:get()
box.schema.func.drop('do_long_and_push')
+box.session.on_disconnect(nil, on_disconnect)
--
2.11.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] test: fix box/push.test sporadic hang
2019-02-28 11:05 [PATCH] test: fix box/push.test sporadic hang Vladimir Davydov
@ 2019-02-28 11:10 ` Vladimir Davydov
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Davydov @ 2019-02-28 11:10 UTC (permalink / raw)
To: tarantool-patches
On Thu, Feb 28, 2019 at 02:05:05PM +0300, Vladimir Davydov wrote:
> This patch fixes the following test failure:
>
> | --- box/push.result Thu Jan 24 13:10:04 2019
> | +++ var/001_box/push.result Thu Jan 24 13:13:08 2019
> | @@ -536,17 +536,3 @@
> | ---
> | ...
> | chan_disconnected:get()
> | ----
> | -- true
> | -...
> | -chan_push:put(true)
> | ----
> | -- true
> | -...
> | -chan_push:get()
> | ----
> | -- Session is closed
> | -...
> | -box.schema.func.drop('do_long_and_push')
> | ----
> | -...
>
> The problem occurs because the main fiber may close the connection
> before do_long_and_push sets the session.on_disconnect trigger, in
> which case chan_disconnected:get() will never return. Fix this by
> setting the trigger in the main fiber and adding another channel
> to wait for do_long_and_push function to start. Also, don't forget
> to clear the trigger once the test is complete.
>
> Fixes commit 43af2de2b129 ("session: outdate a session of a closed
> connection").
>
> Closes #3947
> ---
> https://github.com/tarantool/tarantool/issues/3947
> https://github.com/tarantool/tarantool/commits/dv/test-fixes
>
> test/box/push.result | 15 ++++++++++++++-
> test/box/push.test.lua | 6 +++++-
> 2 files changed, 19 insertions(+), 2 deletions(-)
Pushed to 2.1 and 1.10.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-28 11:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-28 11:05 [PATCH] test: fix box/push.test sporadic hang Vladimir Davydov
2019-02-28 11:10 ` Vladimir Davydov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox