Skip to content

Commit

Permalink
test: wait until cluster leaders are rw
Browse files Browse the repository at this point in the history
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
  • Loading branch information
DifferentialOrange committed Jan 23, 2024
1 parent 9d3f458 commit 7d41abd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/integration/select_readview_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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([[
Expand Down
10 changes: 10 additions & 0 deletions test/vshard_helpers/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/vshard_helpers/vtest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d41abd

Please sign in to comment.