From: Serge Petrenko <sergepetrenko@tarantool.org>
To: vdavydov.dev@gmail.com
Cc: tarantool-patches@freelists.org,
Serge Petrenko <sergepetrenko@tarantool.org>
Subject: [PATCH v2 2/2] test: rework box/on_shutdown test
Date: Fri, 12 Apr 2019 17:33:40 +0300 [thread overview]
Message-ID: <96a2be98df4042a166dbd94784b179633f182e29.1555079382.git.sergepetrenko@tarantool.org> (raw)
In-Reply-To: <cover.1555079382.git.sergepetrenko@tarantool.org>
The test is flaky under high load (e.g. when is run in parallel with a
lot of workers). Make it less dependent on arbitrary timeouts to improve
stability.
Part of #4134
---
test/box/on_shutdown.result | 22 +++++++++-------------
test/box/on_shutdown.test.lua | 11 ++++++-----
2 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/test/box/on_shutdown.result b/test/box/on_shutdown.result
index 2a9f3fe17..4992b7de6 100644
--- a/test/box/on_shutdown.result
+++ b/test/box/on_shutdown.result
@@ -76,7 +76,7 @@ box.space.shutdown:select{}
box.space.shutdown:drop()
---
...
--- Check that os.exit invokes triggers
+-- Check that os.exit invokes on_shutdown triggers
fiber = require("fiber")
---
...
@@ -116,13 +116,17 @@ _ = box.ctl.on_shutdown(function() print("on_shutdown 5") end)
fiber = require("fiber")
---
...
-_ = fiber.create(function() fiber.sleep(0.05) os.exit() while true do end end)
----
-...
test_run:cmd("switch default")
---
- true
...
+-- eval the command on the 'test' instance while we're on default
+-- instance to make sure test_run doesn't lose connection to the
+-- shutting down instance.
+test_run:eval("test", "_ = fiber.new(function() os.exit() while true do end end)")
+---
+- []
+...
fiber.sleep(0.1)
---
...
@@ -136,11 +140,7 @@ test_run:cmd("start server test")
---
- true
...
-test_run:cmd("switch test")
----
-- true
-...
-test_run:grep_log('test', 'on_shutdown 5', nil, {noreset=true})
+test_run:wait_log('test', 'on_shutdown 5', nil, 30, {noreset=true})
---
- on_shutdown 5
...
@@ -149,10 +149,6 @@ test_run:grep_log('test', 'signal', nil, {noreset=true})
---
- null
...
-test_run:cmd("switch default")
----
-- true
-...
test_run:cmd("stop server test")
---
- true
diff --git a/test/box/on_shutdown.test.lua b/test/box/on_shutdown.test.lua
index b2247cf13..9c3726dce 100644
--- a/test/box/on_shutdown.test.lua
+++ b/test/box/on_shutdown.test.lua
@@ -33,7 +33,7 @@ test_run:grep_log('default', 'on_shutdown 4', nil, {noreset=true})
box.space.shutdown:select{}
box.space.shutdown:drop()
--- Check that os.exit invokes triggers
+-- Check that os.exit invokes on_shutdown triggers
fiber = require("fiber")
test_run:cmd("create server test with script='box/proxy.lua'")
test_run:cmd("start server test")
@@ -47,18 +47,19 @@ _ = box.ctl.on_shutdown(function() print("on_shutdown 5") end)
-- Check that we don't hang infinitely after os.exit()
-- even if the following code doesn't yield.
fiber = require("fiber")
-_ = fiber.create(function() fiber.sleep(0.05) os.exit() while true do end end)
test_run:cmd("switch default")
+-- eval the command on the 'test' instance while we're on default
+-- instance to make sure test_run doesn't lose connection to the
+-- shutting down instance.
+test_run:eval("test", "_ = fiber.new(function() os.exit() while true do end end)")
fiber.sleep(0.1)
-- The server should be already stopped by os.exit(),
-- but start doesn't work without a prior call to stop.
test_run:cmd("stop server test")
test_run:cmd("start server test")
-test_run:cmd("switch test")
-test_run:grep_log('test', 'on_shutdown 5', nil, {noreset=true})
+test_run:wait_log('test', 'on_shutdown 5', nil, 30, {noreset=true})
-- make sure we exited because of os.exit(), not a signal.
test_run:grep_log('test', 'signal', nil, {noreset=true})
-test_run:cmd("switch default")
test_run:cmd("stop server test")
test_run:cmd("cleanup server test")
test_run:cmd("delete server test")
--
2.20.1 (Apple Git-117)
next prev parent reply other threads:[~2019-04-12 14:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-12 14:33 [PATCH v2 0/2] Rework on_shutdown test for better stability Serge Petrenko
2019-04-12 14:33 ` [PATCH v2 1/2] test: extract on_shutdown tests from box/misc Serge Petrenko
2019-04-12 14:33 ` Serge Petrenko [this message]
2019-04-12 14:49 ` [PATCH v2 0/2] Rework on_shutdown test for better stability Vladimir Davydov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=96a2be98df4042a166dbd94784b179633f182e29.1555079382.git.sergepetrenko@tarantool.org \
--to=sergepetrenko@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [PATCH v2 2/2] test: rework box/on_shutdown test' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox