From 57ed5914c5de6f9d8dc0ba2322cf240b532ab4c3 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 973248d2..69d271ea 100644 --- a/test/integration/select_readview_test.lua +++ b/test/integration/select_readview_test.lua @@ -2319,6 +2319,8 @@ pgroup.test_stop_select = function(g) require('vshard.storage').cfg(cfg, box.info[bootstrap_key]) require('crud').init_storage{wait_until_ready = true} end, {g.cfg, bootstrap_key}) + + g.cluster:server('s2-master'):wait_for_rw() end local _, err = g.router:eval([[ 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