From cbd39806403d4dccef98e489e459890998ed0ed2 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 22 Jan 2024 18:18:56 +0300 Subject: [PATCH] test: wait until cluster leaders are rw Tarantool 3.0 instances start in ro mode. It is possible that masters are not available for write requests right after test case has been started. Cartridge servers run only on Tarantool 1.x and 2.x, so they are expected to work fine without additional changes: Cartridge helpers checks are sophisticated enough. Part of #412 Part of #415 --- test/integration/select_readview_test.lua | 2 ++ test/vshard_helpers/server.lua | 10 ++++++++++ test/vshard_helpers/vtest.lua | 1 + 3 files changed, 13 insertions(+) diff --git a/test/integration/select_readview_test.lua b/test/integration/select_readview_test.lua index aa2b2136..59a1ad0e 100644 --- a/test/integration/select_readview_test.lua +++ b/test/integration/select_readview_test.lua @@ -2307,6 +2307,8 @@ pgroup.test_stop_select = function(g) g.cluster:server('s2-master'):start() if g.params.backend == helpers.backend.VSHARD then + g.cluster:server('s2-master'):wait_for_rw() + local bootstrap_key if type(g.params.backend_cfg) == 'table' and g.params.backend_cfg.identification_mode == 'name_as_key' then diff --git a/test/vshard_helpers/server.lua b/test/vshard_helpers/server.lua index 6ed2448f..1b504f16 100644 --- a/test/vshard_helpers/server.lua +++ b/test/vshard_helpers/server.lua @@ -114,6 +114,16 @@ function Server:wait_for_readiness() end) end +function Server:wait_for_rw() + return wait_cond('rw', self, function() + local ok, is_ready = pcall(function() + self:connect_net_box() + return self.net_box:eval('return box.info.ro') == false + end) + return ok and is_ready + end) +end + function Server:wait_election_leader() -- Include read-only property too because if an instance is a leader, it -- does not mean it finished the synchro queue ownership transition. It is diff --git a/test/vshard_helpers/vtest.lua b/test/vshard_helpers/vtest.lua index e69d8579..caa62b6d 100644 --- a/test/vshard_helpers/vtest.lua +++ b/test/vshard_helpers/vtest.lua @@ -497,6 +497,7 @@ local function cluster_new(g, cfg) for _, master in pairs(masters) do master:wait_for_readiness() + master:wait_for_rw() master:exec(function(cfg) -- Logged in as guest with 'super' access rights. Yet 'super' is not -- enough to grant 'replication' privilege. The simplest way - login