@@ -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)\n length 940 (0x3ac)\n write_pos 4194304 (0x400000)\n \
462+ format 1\n trimmed_pos 4194304 (0x400000)\n stripe_unit 4194304 (0x400000)\n stripe_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