@@ -477,6 +477,44 @@ def test_scrub_split_dirfrags(self):
477477 timeout = 30
478478 )
479479
480+ def test_scrub_remote_link (self ):
481+ """
482+ test scrub remote link
483+ """
484+ test_dir_path = "test_dir"
485+ self .mount_a .run_shell (["mkdir" , test_dir_path ])
486+ file_dir_path = os .path .join (test_dir_path , "file_dir" )
487+ self .mount_a .run_shell (["mkdir" , file_dir_path ])
488+ file_path = os .path .join (file_dir_path , "test_file.txt" )
489+ link_path = os .path .join (test_dir_path , "test_link" )
490+ abs_link_path = "/" + link_path
491+ self .mount_a .run_shell (["touch" , file_path ])
492+ self .mount_a .run_shell (["ln" , file_path , link_path ])
493+ file_ino = self .mount_a .path_to_ino (file_path )
494+ dir_ino = self .mount_a .path_to_ino (file_dir_path )
495+ rados_obj_file = "{ino:x}.00000000" .format (ino = file_ino )
496+ rados_obj_dir = "{ino:x}.00000000" .format (ino = dir_ino )
497+ self .fs .flush ()
498+ self .fs .rados (["rm" , rados_obj_file ], pool = self .fs .get_data_pool_name ())
499+ self .fs .rados (["rm" , rados_obj_dir ], pool = self .fs .get_metadata_pool_name ())
500+ self .fs .mds_fail_restart ()
501+ self .fs .wait_for_daemons ()
502+ status = self .fs .mds_asok (['status' ])
503+ self .assertEqual ("up:active" , str (status ['state' ]))
504+ mds_rank = self .fs .get_rank ()['rank' ]
505+ success_validator = lambda j , r : self .json_validator (j , r , "return_code" , 0 )
506+ scrub_json = self .tell_command (mds_rank ,
507+ "scrub start /{0} recursive force" .format (test_dir_path ),
508+ success_validator )
509+ self .assertEqual (
510+ self .fs .wait_until_scrub_complete (tag = scrub_json ["scrub_tag" ]), True )
511+ damage_json = self .tell_command (mds_rank , "damage ls" )
512+ found_remote_link_damage = False
513+ for entry in damage_json :
514+ if entry ["path" ] == abs_link_path :
515+ found_remote_link_damage = True
516+ self .assertEqual (found_remote_link_damage , True )
517+
480518 def test_stray_evaluation_with_scrub (self ):
481519 """
482520 test that scrub can iterate over ~mdsdir and evaluate strays
@@ -501,7 +539,7 @@ def json_validator(json_out, rc, element, expected_value):
501539 jv = element_value , ev = expected_value )
502540 return True , "Succeeded"
503541
504- def tell_command (self , mds_rank , command , validator ):
542+ def tell_command (self , mds_rank , command , validator = None ):
505543 log .info ("Running command '{command}'" .format (command = command ))
506544
507545 command_list = command .split ()
@@ -510,9 +548,10 @@ def tell_command(self, mds_rank, command, validator):
510548 log .info ("command '{command}' returned '{jout}'" .format (
511549 command = command , jout = jout ))
512550
513- success , errstring = validator (jout , 0 )
514- if not success :
515- raise AsokCommandFailedError (command , 0 , jout , errstring )
551+ if validator :
552+ success , errstring = validator (jout , 0 )
553+ if not success :
554+ raise AsokCommandFailedError (command , 0 , jout , errstring )
516555 return jout
517556
518557 @staticmethod
0 commit comments