diff --git a/test/replication/misc.result b/test/replication/misc.result index 32676c4ea85a4fc93c981c11040b0252d1605e51..c32681a7ada4c333c8bd2e7ad1ed94c1283d7b9c 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 3bf1fc5a199468e905cd269b84c7aa657d972d65..6a8af05c37661db5a9533d32c9bb7945d256c693 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