Skip to content

Commit 0c109f9

Browse files
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
1 parent 4c8e093 commit 0c109f9

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

test/helper.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ function helpers.get_results_list(results_map)
116116
return results_list
117117
end
118118

119-
function helpers.box_cfg()
119+
function helpers.box_cfg(opts)
120+
opts = opts or {}
121+
122+
if opts.wait_rw == nil then
123+
opts.wait_rw = true
124+
end
125+
120126
if type(box.cfg) ~= 'function' then
121127
return
122128
end
@@ -127,6 +133,13 @@ function helpers.box_cfg()
127133
wal_mode = 'none',
128134
})
129135
fio.rmtree(tempdir)
136+
137+
if opts.wait_rw then
138+
t.helpers.retrying(
139+
{timeout = 3, delay = 0.1},
140+
t.assert_equals, box.info.ro, false
141+
)
142+
end
130143
end
131144

132145
function helpers.insert_objects(g, space_name, objects)

test/integration/select_readview_test.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,6 +2308,8 @@ pgroup.test_stop_select = function(g)
23082308
g.cluster:server('s2-master'):start()
23092309

23102310
if g.params.backend == helpers.backend.VSHARD then
2311+
g.cluster:server('s2-master'):wait_for_rw()
2312+
23112313
local bootstrap_key
23122314
if type(g.params.backend_cfg) == 'table'
23132315
and g.params.backend_cfg.identification_mode == 'name_as_key' then

test/unit/sharding_metadata_test.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ g.before_each(function()
2424
{name = 'sharding_func_body', type = 'string', is_nullable = true},
2525
}
2626

27-
if type(box.cfg) ~= 'table' then
28-
helpers.box_cfg()
29-
end
27+
helpers.box_cfg()
3028

3129
-- Create a space _ddl_sharding_key with a tuple that
3230
-- contains a space name and it's sharding key.
3331
box.schema.space.create('_ddl_sharding_key', {
3432
format = sharding_key_format,
33+
if_not_exists = true,
3534
})
36-
box.space._ddl_sharding_key:create_index('pk')
35+
box.space._ddl_sharding_key:create_index('pk', {if_not_exists = true})
3736

3837
-- Create a space _ddl_sharding_func with a tuple that
3938
-- contains a space name and it's sharding func name/body.
4039
box.schema.space.create('_ddl_sharding_func', {
4140
format = sharding_func_format,
41+
if_not_exists = true,
4242
})
43-
box.space._ddl_sharding_func:create_index('pk')
43+
box.space._ddl_sharding_func:create_index('pk', {if_not_exists = true})
4444

45-
box.schema.space.create('fetch_on_storage')
45+
box.schema.space.create('fetch_on_storage', {if_not_exists = true})
4646
end)
4747

4848
-- Since Tarantool 3.0 triggers still live after a space drop. To properly

test/vshard_helpers/server.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ function Server:wait_for_readiness()
114114
end)
115115
end
116116

117+
function Server:wait_for_rw()
118+
return wait_cond('rw', self, function()
119+
local ok, is_ready = pcall(function()
120+
self:connect_net_box()
121+
return self.net_box:eval('return box.info.ro') == false
122+
end)
123+
return ok and is_ready
124+
end)
125+
end
126+
117127
function Server:wait_election_leader()
118128
-- Include read-only property too because if an instance is a leader, it
119129
-- does not mean it finished the synchro queue ownership transition. It is

test/vshard_helpers/vtest.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ local function cluster_new(g, cfg)
495495

496496
for _, master in pairs(masters) do
497497
master:wait_for_readiness()
498+
master:wait_for_rw()
498499
master:exec(function(cfg)
499500
-- Logged in as guest with 'super' access rights. Yet 'super' is not
500501
-- enough to grant 'replication' privilege. The simplest way - login

0 commit comments

Comments
 (0)