Skip to content

Commit

Permalink
test: rework 6794 test to generate broken data files
Browse files Browse the repository at this point in the history
Instead of relying on fixed xlog / snap pair in gh_6794_data, let's
better generate the desired files right in the test. This way we won't
face the problem of the files getting out of date. For example, when
schema version changes.

Remove the now unneeded gh_6794_data files and re-enable the
gh_6794_recover_nonmatching_xlogs test.

Closes #8701

NO_DOC=test
NO_CHANGELOG=test
  • Loading branch information
sergepetrenko committed Jun 22, 2023
1 parent 98dc86c commit 0b75dcb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
Binary file removed test/box-luatest/gh_6794_data/00000000000000000000.xlog
Binary file not shown.
Binary file not shown.
62 changes: 54 additions & 8 deletions test/box-luatest/gh_6794_recover_nonmatching_xlogs_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,54 @@ local fio = require('fio')

local g = t.group()

g.before_all(function(cg)
-- We need to create such an xlog and a snap that the xlog has data both
-- before and after the snap. For example, 0...0.xlog and 0...02.snap, but
-- the xlog contains entries with lsns 1, 2 and 3. This is not possible with
-- one instance, because it rotates its xlog while making a snapshot. So,
-- create two instances with identical uuids, and make one of them generate
-- the needed snapshot and the other - the needed xlog. Then move the files
-- into one folder.
cg.box_cfg = {instance_uuid = '6f9019aa-2821-4f34-905b-51aed43def47'}
cg.snap = server:new{alias = 'snapshot', box_cfg = cg.box_cfg}
cg.xlog = server:new{alias = 'xlog', box_cfg = cg.box_cfg}

cg.snap:start()
cg.snap:exec(function()
t.assert_equals(box.info.id, 1, 'Server id is correct')
box.space._schema:replace{'aaa'}
t.assert_equals(box.info.lsn, 2, 'Exactly two entries are written')
box.snapshot()
end)
cg.snap:stop()
cg.snap_path = fio.pathjoin(cg.snap.workdir, '00000000000000000002.snap')
t.assert_equals(#fio.glob(cg.snap_path), 1, 'Snapshot is created')

cg.xlog:start()
cg.xlog:exec(function()
t.assert_equals(box.info.id, 1, 'Server id is correct')
box.space._schema:replace{'aaa'}
box.space._schema:replace{'bbb'}
t.assert_equals(box.info.lsn, 3, 'Exactly three entries are written')
end)
cg.xlog:stop()
cg.xlog_path = fio.pathjoin(cg.xlog.workdir, '00000000000000000000.xlog')
t.assert_equals(#fio.glob(cg.xlog_path), 1, 'Xlog is created')

cg.tempdir = fio.tempdir()
fio.copyfile(cg.snap_path, cg.tempdir)
fio.copyfile(cg.xlog_path, cg.tempdir)
end)

g.after_all(function(cg)
cg.snap:drop()
cg.xlog:drop()
fio.rmtree(cg.tempdir)
end)

g.before_test('test_panic_without_force_recovery', function()
g.server = server:new({alias = 'master-test_panic',
datadir = 'test/box-luatest/gh_6794_data'})
datadir = g.tempdir})
g.server:start({wait_until_ready = false})
end)

Expand All @@ -15,9 +60,8 @@ g.after_test("test_panic_without_force_recovery", function()
end)

g.before_test('test_ignore_with_force_recovery', function()
t.skip('gh-8701')
g.server = server:new({alias = 'master-test_ignore',
datadir = 'test/box-luatest/gh_6794_data',
datadir = g.tempdir,
box_cfg = {force_recovery = true}})
g.server:start()
end)
Expand All @@ -42,9 +86,11 @@ g.test_ignore_with_force_recovery = function()
"configuration option is set."
t.assert(g.server:grep_log(msg))
end)
t.assert(g.server:exec(function()
return box.info.signature >= 2 and
box.info.status == 'running' and
box.info.ro == false end),
"Failed to recover data")
g.server:exec(function()
t.assert_equals(box.info.lsn, 3, 'Lsn is correct')
t.assert(box.space._schema:get{'aaa'}, 'First tuple is recovered')
t.assert(box.space._schema:get{'bbb'}, 'Second tuple is recovered')
t.assert_equals(box.info.status, 'running', 'The server is recovered')
t.assert(not box.info.ro, 'Server is writable')
end)
end

0 comments on commit 0b75dcb

Please sign in to comment.