[Tarantool-patches] [PATCH v2] test: fix hanging of gh.test.lua

Alexander V. Tikhonov avtikhon at tarantool.org
Mon Oct 19 11:08:42 MSK 2020


Found that the previously fixed vinyl/gh.test.lua test in commit

  94dc5bddc1fb0f9e6ebebfc5aa6be586e5b6759e ('test: gh test hangs after gh-4957-too-many-upserts')

with adding fiber.sleep(1) workaround to avoid of raise from the
previously run vinyl/gh-4957-too-many-upserts.test.lua test can be
changed in the other way. The new change from one side will leave
the found issue untouched to be able to resolve it within opened
issue in github. And from the other side it will let the test-run
tool to be able to avoid of this issue using fragile list feature
to save the stability of testing due to found issue is flaky and
can be passed on reruns.

The current fix changes the forever waiting loop to especially
created for such situations test_run:wait_cond() routine which has
timeout in it to avoid of hanging the test till global timeout will
occure. It will let the testing to be continued even after the fail.

Also added box_snapshot.test.lua() function to vinyl/gh.test.lua and
vinyl/iterator.test.lua tests to be able to avoid of printing changing
data in results file to be able to use its checksum in fragile list
of test-run to be able to rerun it as flaky issues.

Added checksum to fragile list:

  vinyl/gh.test.lua			gh-5141
  vinyl/iterator.test.lua		gh-5141

Follows up #5141
---

Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-5141-gh_test
Issue: https://github.com/tarantool/tarantool/issues/5141

 test/vinyl/gh.result         | 28 ++++++++++++++++++----------
 test/vinyl/gh.test.lua       | 19 +++++++++++++------
 test/vinyl/iterator.result   | 26 ++++++++++++++++++--------
 test/vinyl/iterator.test.lua | 17 +++++++++++++----
 test/vinyl/suite.ini         |  6 +++---
 5 files changed, 65 insertions(+), 31 deletions(-)

diff --git a/test/vinyl/gh.result b/test/vinyl/gh.result
index 0fd74af83..9806f2079 100644
--- a/test/vinyl/gh.result
+++ b/test/vinyl/gh.result
@@ -7,7 +7,14 @@ env = require('test_run')
 test_run = env.new()
 ---
 ...
-fiber.sleep(1)
+function box_snapshot()                                  \
+    local ok, err = pcall(box.snapshot)                  \
+    if (ok == false) then                                \
+        require('log').error(                            \
+            "box.snapshot() failed with error: " .. err) \
+    end                                                  \
+    return ok                                            \
+end;
 ---
 ...
 -- gh-283: hang after three creates and drops
@@ -428,9 +435,9 @@ space = box.schema.space.create('test', { engine = 'vinyl' })
 pk = space:create_index('primary', { type = 'tree', parts = {1, 'unsigned'}  })
 ---
 ...
-box.snapshot()
+box_snapshot()
 ---
-- ok
+- true
 ...
 space:drop()
 ---
@@ -556,17 +563,17 @@ s0:replace{1, 'tuple'}
 ---
 - [1, 'tuple']
 ...
-box.snapshot()
+box_snapshot()
 ---
-- ok
+- true
 ...
 s0:replace{2, 'tuple 2'}
 ---
 - [2, 'tuple 2']
 ...
-box.snapshot()
+box_snapshot()
 ---
-- ok
+- true
 ...
 s0:insert{3, 'tuple 3'}
 ---
@@ -602,9 +609,9 @@ _ = s:insert{1}
 _ = fiber.create(function() fiber.sleep(0.001) s:insert{2} end)
 ---
 ...
-box.snapshot()
+box_snapshot()
 ---
-- ok
+- true
 ...
 s:drop()
 ---
@@ -716,8 +723,9 @@ test_run:cmd("setopt delimiter ''");
 cont = false
 ---
 ...
-while finished ~= 2 do fiber.sleep(0.01) end
+test_run:wait_cond(function() fiber.sleep(0.01) return finished ~= 2 end)
 ---
+- true
 ...
 s:drop()
 ---
diff --git a/test/vinyl/gh.test.lua b/test/vinyl/gh.test.lua
index c72444f5f..d2d024877 100644
--- a/test/vinyl/gh.test.lua
+++ b/test/vinyl/gh.test.lua
@@ -2,7 +2,14 @@ fiber = require('fiber')
 env = require('test_run')
 test_run = env.new()
 
-fiber.sleep(1)
+function box_snapshot()                                  \
+    local ok, err = pcall(box.snapshot)                  \
+    if (ok == false) then                                \
+        require('log').error(                            \
+            "box.snapshot() failed with error: " .. err) \
+    end                                                  \
+    return ok                                            \
+end;
 
 -- gh-283: hang after three creates and drops
 s = box.schema.space.create('space0', {engine='vinyl'})
@@ -177,7 +184,7 @@ space:drop()
 
 space = box.schema.space.create('test', { engine = 'vinyl' })
 pk = space:create_index('primary', { type = 'tree', parts = {1, 'unsigned'}  })
-box.snapshot()
+box_snapshot()
 space:drop()
 
 --
@@ -225,9 +232,9 @@ i0 = s0:create_index('primary', { type = 'tree', parts = {1, 'unsigned'}})
 
 -- integer keys
 s0:replace{1, 'tuple'}
-box.snapshot()
+box_snapshot()
 s0:replace{2, 'tuple 2'}
-box.snapshot()
+box_snapshot()
 
 s0:insert{3, 'tuple 3'}
 
@@ -245,7 +252,7 @@ s = box.schema.space.create('tweedledum', {engine='vinyl'})
 i = s:create_index('primary')
 _ = s:insert{1}
 _ = fiber.create(function() fiber.sleep(0.001) s:insert{2} end)
-box.snapshot()
+box_snapshot()
 s:drop()
 
 s = box.schema.space.create("test", {engine='vinyl'})
@@ -311,7 +318,7 @@ end;
 test_run:cmd("setopt delimiter ''");
 
 cont = false
-while finished ~= 2 do fiber.sleep(0.01) end
+test_run:wait_cond(function() fiber.sleep(0.01) return finished ~= 2 end)
 
 s:drop()
 
diff --git a/test/vinyl/iterator.result b/test/vinyl/iterator.result
index 0ef2a1b46..962b5b7fa 100644
--- a/test/vinyl/iterator.result
+++ b/test/vinyl/iterator.result
@@ -20,6 +20,16 @@ iterator_next = function(iter) return iter.next() end
 iterate_over = function(iter) return iter.iterate_over() end
 ---
 ...
+function box_snapshot()                                  \
+    local ok, err = pcall(box.snapshot)                  \
+    if (ok == false) then                                \
+        require('log').error(                            \
+            "box.snapshot() failed with error: " .. err) \
+    end                                                  \
+    return ok                                            \
+end;
+---
+...
 --
 -- Following tests verify that combinations
 -- of various commands are worked correctly.
@@ -1369,9 +1379,9 @@ space4:replace({6})
 - [6]
 ...
 -- Snapshot for all spaces
-box.snapshot()
+box_snapshot()
 ---
-- ok
+- true
 ...
 -- Continue GT
 space2:replace({6})
@@ -1442,9 +1452,9 @@ space4:select{}
   - [8]
 ...
 -- Snapshot for all spaces
-box.snapshot()
+box_snapshot()
 ---
-- ok
+- true
 ...
 -- Continue GT
 iterate_over(iter_obj_sp2)
@@ -1903,9 +1913,9 @@ iterator_next(itr)
 ---
 - [2, 1]
 ...
-box.snapshot() -- create last-level run
+box_snapshot() -- create last-level run
 ---
-- ok
+- true
 ...
 iterator_next(itr)
 ---
@@ -1918,9 +1928,9 @@ iterator_next(itr)
 ---
 - [4, 1]
 ...
-box.snapshot() -- create not-last-level run
+box_snapshot() -- create not-last-level run
 ---
-- ok
+- true
 ...
 iterator_next(itr)
 ---
diff --git a/test/vinyl/iterator.test.lua b/test/vinyl/iterator.test.lua
index 8d2a85930..73cc62698 100644
--- a/test/vinyl/iterator.test.lua
+++ b/test/vinyl/iterator.test.lua
@@ -12,6 +12,15 @@ create_iterator = require('utils').create_iterator
 iterator_next = function(iter) return iter.next() end
 iterate_over = function(iter) return iter.iterate_over() end
 
+function box_snapshot()                                  \
+    local ok, err = pcall(box.snapshot)                  \
+    if (ok == false) then                                \
+        require('log').error(                            \
+            "box.snapshot() failed with error: " .. err) \
+    end                                                  \
+    return ok                                            \
+end;
+
 --
 -- Following tests verify that combinations
 -- of various commands are worked correctly.
@@ -468,7 +477,7 @@ iter_obj_sp4_2 = create_iterator(space4, 3, {iterator = box.index.LT})
 space4:replace({6})
 
 -- Snapshot for all spaces
-box.snapshot()
+box_snapshot()
 
 -- Continue GT
 space2:replace({6})
@@ -489,7 +498,7 @@ iterator_next(iter_obj_sp4_2)
 space4:select{}
 
 -- Snapshot for all spaces
-box.snapshot()
+box_snapshot()
 
 -- Continue GT
 iterate_over(iter_obj_sp2)
@@ -644,11 +653,11 @@ itr = create_iterator(s, {}, {})
 iterator_next(itr)
 for i=1,10 do s:upsert({i, 1}, {{'+', 2, 1}}) end
 iterator_next(itr)
-box.snapshot() -- create last-level run
+box_snapshot() -- create last-level run
 iterator_next(itr)
 for i=1,10 do s:upsert({i, 1}, {{'+', 2, 1}}) end
 iterator_next(itr)
-box.snapshot() -- create not-last-level run
+box_snapshot() -- create not-last-level run
 iterator_next(itr)
 for i=1,10 do s:upsert({i, 1}, {{'+', 2, 1}}) end
 iterator_next(itr)
diff --git a/test/vinyl/suite.ini b/test/vinyl/suite.ini
index 8e1db8ad9..f6bc77558 100644
--- a/test/vinyl/suite.ini
+++ b/test/vinyl/suite.ini
@@ -13,7 +13,7 @@ is_parallel = True
 disabled = upgrade.test.lua throttle.test.lua
 pretest_clean = True
 fragile = {
-    "retries": 10,
+    "retries": 100,
     "tests": {
         "tx_gap_lock.test.lua": {
             "issues": [ "gh-4309" ],
@@ -53,11 +53,11 @@ fragile = {
         },
         "gh.test.lua": {
             "issues": [ "gh-5141" ],
-            "checksums": [ "f1286e9e4710062ddfbffb61b2fe2743", "96b22440ab8a881d6b8d14c5ee1672fb" ]
+            "checksums": [ "f1286e9e4710062ddfbffb61b2fe2743", "96b22440ab8a881d6b8d14c5ee1672fb", "e9748a9ed290b3e522c0c180b9fc21b6", "09d5a4fdb47929888588dcca43f1ceff", "6aeee642d9521b496e8a8bbde520abf6", "1d377077c99eed97076a3b99d99bd951" ]
         },
         "iterator.test.lua": {
             "issues": [ "gh-5336" ],
-            "checksums": [ "138808fd31b68d1b1c53c6a146124856" ]
+            "checksums": [ "138808fd31b68d1b1c53c6a146124856", "73cc4b1cbb9d50010e93b5c156111b43", "a60403886f02e740a2084e5855bf63f0", "1db42ae6c8afd92bef794516c62c6679" ]
         },
         "ddl.test.lua": {
             "issues": [ "gh-5338" ],
-- 
2.25.1



More information about the Tarantool-patches mailing list