From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Sergei Voronezhskii Subject: [PATCH v2 4/5] test: use wait_cond to check follow status Date: Fri, 19 Oct 2018 19:17:20 +0300 Message-Id: <20181019161721.49560-5-sergw@tarantool.org> In-Reply-To: <20181019161721.49560-1-sergw@tarantool.org> References: <20181019161721.49560-1-sergw@tarantool.org> To: tarantool-patches@freelists.org Cc: Alexander Turenko , Vladimir Davydov List-ID: If `test_run:wait_cond()` found a not 'follow` status it returns true. Which immediately causes an error. Fixes #3734 Part of #2436, #3232 --- test/replication/misc.result | 17 +++++++++++------ test/replication/misc.test.lua | 15 +++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/test/replication/misc.result b/test/replication/misc.result index 02f4d47f4..58e512c30 100644 --- a/test/replication/misc.result +++ b/test/replication/misc.result @@ -146,15 +146,20 @@ 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() for i = 0, 99 do + 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 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 06ad974db..3866eb3ac 100644 --- a/test/replication/misc.test.lua +++ b/test/replication/misc.test.lua @@ -53,15 +53,18 @@ 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() for i = 0, 99 do + 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 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