From e0e6fe106d11855631a2673dbc72a670378669aa Mon Sep 17 00:00:00 2001
From: Vladimir Davydov <vdavydov@tarantool.org>
Date: Thu, 11 Nov 2021 19:09:36 +0300
Subject: [PATCH] test: fix flaky wal_off/snapshot_stress test

This commit fixes the following failure:

```
[028] --- wal_off/snapshot_stress.result	Fri Jun  5 06:49:36 2020
[028] +++ wal_off/snapshot_stress.reject	Fri Oct 16 13:48:23 2020
[028] @@ -375,7 +375,7 @@
[028]  ...
[028]  snaps_find_status;
[028]  ---
[028] -- snaps found
[028] +- where are my snapshots?
[028]  ...
[028]  snapshot_check_failed = false
[028]  while #snaps > initial_snap_count do
[028]
```

It happens, because the fiber making snapshots is started after worker
fibers and it works until all worker fibers are done so it might occur
that it doesn't make any snapshots. Fix this by replacing the while-loop
with a repeat-loop, thus ensuring that the worker fiber makes at least
one snapshot.

Closes #5431
---
 test/wal_off/snapshot_stress.result   | 4 ++--
 test/wal_off/snapshot_stress.test.lua | 4 ++--
 test/wal_off/suite.ini                | 4 ----
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/test/wal_off/snapshot_stress.result b/test/wal_off/snapshot_stress.result
index 29cea8c04c..5c9d9bd744 100644
--- a/test/wal_off/snapshot_stress.result
+++ b/test/wal_off/snapshot_stress.result
@@ -271,10 +271,10 @@ snaps_done = false;
 ---
 ...
 function snaps()
-    while (workers_done ~= workers_count) do
+    repeat
         pcall(box.snapshot)
         fiber.sleep(snapshot_interval)
-    end
+    until workers_done == workers_count
     snaps_done = true
 end;
 ---
diff --git a/test/wal_off/snapshot_stress.test.lua b/test/wal_off/snapshot_stress.test.lua
index 34b3e7b78d..4fbb7ee7ec 100644
--- a/test/wal_off/snapshot_stress.test.lua
+++ b/test/wal_off/snapshot_stress.test.lua
@@ -161,10 +161,10 @@ end;
 
 snaps_done = false;
 function snaps()
-    while (workers_done ~= workers_count) do
+    repeat
         pcall(box.snapshot)
         fiber.sleep(snapshot_interval)
-    end
+    until workers_done == workers_count
     snaps_done = true
 end;
 
diff --git a/test/wal_off/suite.ini b/test/wal_off/suite.ini
index 4fdd50ec89..af3ec2e1f5 100644
--- a/test/wal_off/suite.ini
+++ b/test/wal_off/suite.ini
@@ -12,10 +12,6 @@ fragile = {
         "iterator_lt_gt.test.lua": {
             "issues": [ "gh-3925" ]
         },
-        "snapshot_stress.test.lua": {
-            "issues": [ "gh-5431" ],
-            "checksums": [ "8facc48d54528a5144b4f7d69724adb2" ]
-        },
         "alter.test.lua": {
             "issues": [ "gh-5504" ],
             "checksums": [ "d835070c9629348f9046cdea5d27f70a" ]
-- 
GitLab