From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 0440A4696C4 for ; Tue, 26 Nov 2019 09:21:58 +0300 (MSK) From: "Alexander V. Tikhonov" Date: Tue, 26 Nov 2019 09:21:44 +0300 Message-Id: In-Reply-To: <1c42ad20160f47d942cab405ce9896d6d31cc05f.1574749278.git.avtikhon@tarantool.org> References: <1c42ad20160f47d942cab405ce9896d6d31cc05f.1574749278.git.avtikhon@tarantool.org> In-Reply-To: <1c42ad20160f47d942cab405ce9896d6d31cc05f.1574749278.git.avtikhon@tarantool.org> References: <1c42ad20160f47d942cab405ce9896d6d31cc05f.1574749278.git.avtikhon@tarantool.org> Subject: [Tarantool-patches] [PATCH v1 08/12] test: use wait_cond to check follow status List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kirill Yukhin Cc: Sergei Voronezhskii , tarantool-patches@dev.tarantool.org From: Sergei Voronezhskii 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 (cherry picked from commit f41548b7667b2f0ff28c9bb81a563f9d276f7107) --- 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 df3167991..b4af9e41f 100644 --- a/test/replication/misc.result +++ b/test/replication/misc.result @@ -163,15 +163,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 f3d0f2b95..dd374a210 100644 --- a/test/replication/misc.test.lua +++ b/test/replication/misc.test.lua @@ -58,15 +58,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.17.1