diff --git a/test/helper.lua b/test/helper.lua index 9195226d..809e97d6 100644 --- a/test/helper.lua +++ b/test/helper.lua @@ -116,7 +116,13 @@ function helpers.get_results_list(results_map) return results_list end -function helpers.box_cfg() +function helpers.box_cfg(opts) + opts = opts or {} + + if opts.wait_rw == nil then + opts.wait_rw = true + end + if type(box.cfg) ~= 'function' then return end @@ -127,6 +133,13 @@ function helpers.box_cfg() wal_mode = 'none', }) fio.rmtree(tempdir) + + if opts.wait_rw then + t.helpers.retrying( + {timeout = 3, delay = 0.1}, + t.assert_equals, box.info.ro, false + ) + end end function helpers.insert_objects(g, space_name, objects) diff --git a/test/integration/select_readview_test.lua b/test/integration/select_readview_test.lua index d17458ce..04231879 100644 --- a/test/integration/select_readview_test.lua +++ b/test/integration/select_readview_test.lua @@ -2308,6 +2308,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/unit/sharding_metadata_test.lua b/test/unit/sharding_metadata_test.lua index be2ce2a3..d18ecb3a 100644 --- a/test/unit/sharding_metadata_test.lua +++ b/test/unit/sharding_metadata_test.lua @@ -24,25 +24,25 @@ g.before_each(function() {name = 'sharding_func_body', type = 'string', is_nullable = true}, } - if type(box.cfg) ~= 'table' then - helpers.box_cfg() - end + helpers.box_cfg() -- Create a space _ddl_sharding_key with a tuple that -- contains a space name and it's sharding key. box.schema.space.create('_ddl_sharding_key', { format = sharding_key_format, + if_not_exists = true, }) - box.space._ddl_sharding_key:create_index('pk') + box.space._ddl_sharding_key:create_index('pk', {if_not_exists = true}) -- Create a space _ddl_sharding_func with a tuple that -- contains a space name and it's sharding func name/body. box.schema.space.create('_ddl_sharding_func', { format = sharding_func_format, + if_not_exists = true, }) - box.space._ddl_sharding_func:create_index('pk') + box.space._ddl_sharding_func:create_index('pk', {if_not_exists = true}) - box.schema.space.create('fetch_on_storage') + box.schema.space.create('fetch_on_storage', {if_not_exists = true}) end) -- Since Tarantool 3.0 triggers still live after a space drop. To properly 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 70236b97..6bc5a536 100644 --- a/test/vshard_helpers/vtest.lua +++ b/test/vshard_helpers/vtest.lua @@ -495,6 +495,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