From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Sergei Voronezhskii Subject: [PATCH 3/4] test: increase timeout to check replica status Date: Fri, 5 Oct 2018 12:02:14 +0300 Message-Id: <20181005090215.6160-4-sergw@tarantool.org> In-Reply-To: <20181005090215.6160-1-sergw@tarantool.org> References: <20181003145057.68820-1-sergw@tarantool.org> <20181005090215.6160-1-sergw@tarantool.org> Reply-To: tarantool-patches@freelists.org To: tarantool-patches@freelists.org Cc: Alexander Turenko , Vladimir Davydov List-ID: The replica status is checked 100 times, each check within `replica_timeout`. Refactor the code to get properly upstream. Then in loop with little sleep check upstreams status until it is not in follow mode. If count of checks is more than 200 break the loop with error. The value 200 and little sleep 0.001 choosed suitably to `replica_timeout` and `replica_connect_timeout`. Part of #2436, #3232 --- test/replication/misc.result | 22 ++++++++++++---------- test/replication/misc.test.lua | 22 ++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/test/replication/misc.result b/test/replication/misc.result index c0c7d482d..937ef1b24 100644 --- a/test/replication/misc.result +++ b/test/replication/misc.result @@ -113,7 +113,7 @@ test_run:cmd("switch autobootstrap1") test_run = require('test_run').new() --- ... -box.cfg{replication_timeout = 0.01, replication_connect_timeout=0.01} +box.cfg{replication_timeout = 0.2, replication_connect_timeout=0.2} --- ... test_run:cmd("switch autobootstrap2") @@ -123,7 +123,7 @@ test_run:cmd("switch autobootstrap2") test_run = require('test_run').new() --- ... -box.cfg{replication_timeout = 0.01, replication_connect_timeout=0.01} +box.cfg{replication_timeout = 0.2, replication_connect_timeout=0.2} --- ... test_run:cmd("switch autobootstrap3") @@ -136,7 +136,7 @@ test_run = require('test_run').new() fiber=require('fiber') --- ... -box.cfg{replication_timeout = 0.01, replication_connect_timeout=0.01} +box.cfg{replication_timeout = 0.2, replication_connect_timeout=0.2} --- ... _ = box.schema.space.create('test_timeout'):create_index('pk') @@ -147,15 +147,16 @@ test_run:cmd("setopt delimiter ';'") - true ... 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 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') - end + local n = 200 + repeat + fiber.sleep(0.001) + n = n - 1 + if n == 0 then return error(box.info.replication) end + until replicaA.status == 'follow' and replicaB.status == 'follow' end return true end ; @@ -165,6 +166,7 @@ test_run:cmd("setopt delimiter ''"); --- - true ... +-- the replica status is checked 100 times, each check within replication_timeout test_timeout() --- - true diff --git a/test/replication/misc.test.lua b/test/replication/misc.test.lua index 375c8b58a..cb658f6d0 100644 --- a/test/replication/misc.test.lua +++ b/test/replication/misc.test.lua @@ -43,30 +43,32 @@ test_run:create_cluster(SERVERS, "replication", {args="0.1"}) test_run:wait_fullmesh(SERVERS) test_run:cmd("switch autobootstrap1") test_run = require('test_run').new() -box.cfg{replication_timeout = 0.01, replication_connect_timeout=0.01} +box.cfg{replication_timeout = 0.2, replication_connect_timeout=0.2} test_run:cmd("switch autobootstrap2") test_run = require('test_run').new() -box.cfg{replication_timeout = 0.01, replication_connect_timeout=0.01} +box.cfg{replication_timeout = 0.2, replication_connect_timeout=0.2} test_run:cmd("switch autobootstrap3") test_run = require('test_run').new() fiber=require('fiber') -box.cfg{replication_timeout = 0.01, replication_connect_timeout=0.01} +box.cfg{replication_timeout = 0.2, replication_connect_timeout=0.2} _ = box.schema.space.create('test_timeout'):create_index('pk') test_run:cmd("setopt delimiter ';'") 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 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') - end + local n = 200 + repeat + fiber.sleep(0.001) + n = n - 1 + if n == 0 then return error(box.info.replication) end + until replicaA.status == 'follow' and replicaB.status == 'follow' end return true end ; test_run:cmd("setopt delimiter ''"); +-- the replica status is checked 100 times, each check within replication_timeout test_timeout() -- gh-3247 - Sequence-generated value is not replicated in case -- 2.18.0