Skip to content

Commit d3a1f0d

Browse files
committed
qa: test 'journal import' recognizes invalid headers post journal recovery
Fixes: https://tracker.ceph.com/issues/68954 Signed-off-by: Jos Collin <[email protected]>
1 parent 756a138 commit d3a1f0d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

qa/tasks/cephfs/test_journal_repair.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,28 @@ def test_journal_import_from_invalid_dump_file(self):
450450
raise RuntimeError("Expected journal import to fail")
451451
finally:
452452
self.mount_a.run_shell(["sudo", "rm", fname], omit_sudo=False)
453+
454+
def test_header_check_after_journal_recovery(self):
455+
"""
456+
That the 'journal import' recognizes invalid headers post journal recovery and errors out.
457+
"""
458+
# Create an invalid dump file which doesn't have 'object_size' header
459+
fname = tempfile.NamedTemporaryFile(delete=False).name
460+
self.mount_a.run_shell(["sudo", "sh", "-c", f'printf "Ceph mds0 journal dump\n\
461+
start offset 4194304 (0x400000)\nlength 940 (0x3ac)\nwrite_pos 4194304 (0x400000)\n\
462+
format 1\ntrimmed_pos 4194304 (0x400000)\nstripe_unit 4194304 (0x400000)\nstripe_count 1 (0x1)\n\
463+
fsid 41334b86-2666-4269-a8ea-313bc073564c\n" > {fname}'], omit_sudo=False)
464+
self.fs.fail()
465+
try:
466+
self.fs.journal_tool(["journal", "import", fname, "--force"], 0)
467+
except CommandFailedError as e:
468+
self.fs.set_joinable()
469+
self.fs.wait_for_daemons()
470+
if e.exitstatus != 234:
471+
raise RuntimeError(f"Unexpected journal import error: {str(e)}")
472+
else:
473+
self.fs.set_joinable()
474+
self.fs.wait_for_daemons()
475+
raise RuntimeError("Expected journal import to fail")
476+
finally:
477+
self.mount_a.run_shell(["sudo", "rm", fname], omit_sudo=False)

0 commit comments

Comments
 (0)