[PATCH 1/2] test: wait until expected value appear in log

Sergei Voronezhskii sergw at tarantool.org
Thu Oct 18 01:04:53 MSK 2018


Sleep for the constant time can't fit the case when we need to wait for
snapshot. System load may change app timings and we got flaky test.
Need to check logfile with delay until timeout or log has expected
entry.

Fixes #3684

Part of #2436, #3232
---
 test/xlog/checkpoint_daemon.result   | 10 +---------
 test/xlog/checkpoint_daemon.test.lua |  7 +------
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/test/xlog/checkpoint_daemon.result b/test/xlog/checkpoint_daemon.result
index d5ed666f2..64695293c 100644
--- a/test/xlog/checkpoint_daemon.result
+++ b/test/xlog/checkpoint_daemon.result
@@ -90,15 +90,7 @@ fio.basename(snaps[1], '.snap') >= fio.basename(xlogs[1], '.xlog')
 - true
 ...
 -- gh-2780 check that scheduled snapshots are performed
-fiber.sleep(3 * PERIOD)
----
-...
--- check that it's not first snapshot
-test_run:grep_log("default", "saving snapshot", 400) == nil
----
-- true
-...
-test_run:grep_log("default", "making snapshot", 400) ~= nil
+test_run:wait_log("default", "making snapshot", 400, 1.0 + PERIOD)
 ---
 - true
 ...
diff --git a/test/xlog/checkpoint_daemon.test.lua b/test/xlog/checkpoint_daemon.test.lua
index 4a0aafa84..f27f89da8 100644
--- a/test/xlog/checkpoint_daemon.test.lua
+++ b/test/xlog/checkpoint_daemon.test.lua
@@ -46,18 +46,13 @@ end;
 
 test_run:cmd("setopt delimiter ''");
 
-
-
 #snaps == 2 or snaps
 #xlogs > 0
 
 fio.basename(snaps[1], '.snap') >= fio.basename(xlogs[1], '.xlog')
 
 -- gh-2780 check that scheduled snapshots are performed
-fiber.sleep(3 * PERIOD)
--- check that it's not first snapshot
-test_run:grep_log("default", "saving snapshot", 400) == nil
-test_run:grep_log("default", "making snapshot", 400) ~= nil
+test_run:wait_log("default", "making snapshot", 400, 1.0 + PERIOD)
 
 -- restore default options
 box.cfg{checkpoint_interval = 3600 * 4, checkpoint_count = 4 }
-- 
2.18.0




More information about the Tarantool-patches mailing list