Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergei Voronezhskii <sergw@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Vladimir Davydov <vdavydov@tarantool.org>
Subject: [PATCH v3 4/5] test: use wait_cond to check follow status
Date: Thu,  6 Dec 2018 16:38:51 +0300	[thread overview]
Message-ID: <20181206133852.75633-5-sergw@tarantool.org> (raw)
In-Reply-To: <20181206133852.75633-1-sergw@tarantool.org>

After setting timeouts in `box.cfg` and before making a `replace` needs
to wait for replicas in `follow` status. Then if `wait_follow()` found
not `follow` status it returns true. Which immediately causes an error.

Fixes #3734
Part of #2436, #3232
---
 test/replication/misc.result   | 21 +++++++++++++++------
 test/replication/misc.test.lua | 19 +++++++++++++------
 2 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/test/replication/misc.result b/test/replication/misc.result
index 32676c4ea..c32681a7a 100644
--- a/test/replication/misc.result
+++ b/test/replication/misc.result
@@ -146,15 +146,24 @@ test_run:cmd("setopt delimiter ';'")
 ---
 - true
 ...
+function wait_follow(replicaA, replicaB)
+    return test_run:wait_cond(function()
+        return replicaA.status ~= 'follow' or replicaB.status ~= 'follow'
+    end, 0.01)
+end ;
+---
+...
 function test_timeout()
+    local replicaA = box.info.replication[1].upstream or box.info.replication[2].upstream
+    local replicaB = box.info.replication[3].upstream or box.info.replication[2].upstream
+    local follows = test_run:wait_cond(function()
+        return replicaA.status == 'follow' or replicaB.status == 'follow'
+    end, 0.1)
+    if not follows then error('replicas not in follow status') end
     for i = 0, 99 do 
         box.space.test_timeout:replace({1})
-        fiber.sleep(0.005)
-        local rinfo = box.info.replication
-        if rinfo[1].upstream and rinfo[1].upstream.status ~= 'follow' or
-           rinfo[2].upstream and rinfo[2].upstream.status ~= 'follow' or
-           rinfo[3].upstream and rinfo[3].upstream.status ~= 'follow' then
-            return error('Replication broken')
+        if wait_follow(replicaA, replicaB) then
+            return error(box.info.replication)
         end
     end
     return true
diff --git a/test/replication/misc.test.lua b/test/replication/misc.test.lua
index 3bf1fc5a1..6a8af05c3 100644
--- a/test/replication/misc.test.lua
+++ b/test/replication/misc.test.lua
@@ -53,15 +53,22 @@ fiber=require('fiber')
 box.cfg{replication_timeout = 0.01, replication_connect_timeout=0.01}
 _ = box.schema.space.create('test_timeout'):create_index('pk')
 test_run:cmd("setopt delimiter ';'")
+function wait_follow(replicaA, replicaB)
+    return test_run:wait_cond(function()
+        return replicaA.status ~= 'follow' or replicaB.status ~= 'follow'
+    end, 0.01)
+end ;
 function test_timeout()
+    local replicaA = box.info.replication[1].upstream or box.info.replication[2].upstream
+    local replicaB = box.info.replication[3].upstream or box.info.replication[2].upstream
+    local follows = test_run:wait_cond(function()
+        return replicaA.status == 'follow' or replicaB.status == 'follow'
+    end, 0.1)
+    if not follows then error('replicas not in follow status') end
     for i = 0, 99 do 
         box.space.test_timeout:replace({1})
-        fiber.sleep(0.005)
-        local rinfo = box.info.replication
-        if rinfo[1].upstream and rinfo[1].upstream.status ~= 'follow' or
-           rinfo[2].upstream and rinfo[2].upstream.status ~= 'follow' or
-           rinfo[3].upstream and rinfo[3].upstream.status ~= 'follow' then
-            return error('Replication broken')
+        if wait_follow(replicaA, replicaB) then
+            return error(box.info.replication)
         end
     end
     return true
-- 
2.18.0

  parent reply	other threads:[~2018-12-06 13:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16  8:58 [PATCH] test: update test-run Sergei Voronezhskii
2018-11-16  9:27 ` Alexander Turenko
2018-11-16 13:58   ` Re[2]: " Sergei Voronezhskii
2018-11-16 15:41     ` Alexander Turenko
2018-11-26 11:18       ` Re[2]: " Sergei Voronezhskii
2018-11-26 11:27         ` Alexander Turenko
2018-12-04  8:33           ` Re[2]: " Сергей Воронежский
2018-12-06  9:33             ` Re[3]: " Сергей Воронежский
2018-12-06 13:38               ` [PATCH v3 0/5] enable parallel mode for replication tests Sergei Voronezhskii
2018-12-06 13:38                 ` [PATCH v3 1/5] test: cleanup " Sergei Voronezhskii
2018-12-06 13:38                 ` [PATCH v3 2/5] test: errinj for pause relay_send Sergei Voronezhskii
2018-12-06 15:44                   ` Vladimir Davydov
2018-12-06 13:38                 ` [PATCH v3 3/5] test: put require in proper places Sergei Voronezhskii
2018-12-06 13:38                 ` Sergei Voronezhskii [this message]
2018-12-06 13:38                 ` [PATCH v3 5/5] test: replication parallel mode on Sergei Voronezhskii
2018-12-06 15:44                 ` [PATCH v3 0/5] enable parallel mode for replication tests Vladimir Davydov
2018-12-18 23:47             ` Re[3]: [PATCH] test: update test-run Сергей Воронежский
2018-12-19  9:00               ` 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=20181206133852.75633-5-sergw@tarantool.org \
    --to=sergw@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov@tarantool.org \
    --subject='Re: [PATCH v3 4/5] test: use wait_cond to check follow status' \
    /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