Skip to content
Snippets Groups Projects
Commit 7d093bb1 authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy Committed by Serge Petrenko
Browse files

test: add a test for join with self delete

Deletion of the own entry from _cluster space is allowed during
the join stage, because the remote master could have already had
the joining instance UUID in _cluster space but then deleted it.

Then for the joining instance it looks like deletion of self from
_cluster. But that is fine - in the end of join the master will
register the replica again.

The case is handled, but not covered with a test. The patch adds
one.

NO_DOC=test
NO_CHANGELOG=test
parent cb8f4715
No related branches found
No related tags found
No related merge requests found
local t = require('luatest')
local server = require('luatest.server')
local uuid = require('uuid')
local g = t.group('join')
g.before_all(function(lg)
lg.master = server:new({
alias = 'master',
box_cfg = {
replication_timeout = 0.1,
},
})
lg.master:start()
end)
g.after_all(function(lg)
lg.master:drop()
end)
--
-- New replica (or one being re-bootstrapped) can legally see deletion of self
-- from _cluster space during join. It is allowed because the master could
-- delete the replica from _cluster before the replica tried to rejoin or join
-- first time via a previously existing UUID.
--
g.test_fetch_self_delete_during_final_join = function(lg)
t.tarantool.skip_if_not_debug()
lg.master:exec(function()
local s = box.schema.create_space('test')
s:create_index('pk')
s:replace{1}
box.error.injection.set('ERRINJ_RELAY_SEND_DELAY', true)
end)
local replica_uuid = uuid.str()
local box_cfg = table.deepcopy(lg.master.box_cfg)
box_cfg.replication = {lg.master.net_box_uri}
box_cfg.instance_uuid = replica_uuid
local replica = server:new({
alias = 'replica',
box_cfg = box_cfg,
})
replica:start({wait_until_ready = false})
local msg = ('joining replica %s'):format(replica_uuid):gsub('%-', '%%-')
t.helpers.retrying({}, function()
t.assert(lg.master:grep_log(msg))
end)
lg.master:exec(function(replica_uuid)
local _cluster = box.space._cluster
_cluster:replace{2, replica_uuid}
_cluster:delete{2}
_cluster:replace{2, replica_uuid}
_cluster:delete{2}
box.error.injection.set('ERRINJ_RELAY_SEND_DELAY', false)
end, {replica_uuid})
replica:wait_until_ready()
local replica_id = replica:exec(function()
t.assert_equals(box.space.test:get{1}, {1})
return box.info.id
end)
replica:drop()
lg.master:exec(function(replica_id)
box.space.test:drop()
box.space._cluster:delete{replica_id}
end, {replica_id})
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment