@@ -1093,6 +1093,56 @@ def test_snap_dir_name(self):
10931093 self .mount_a .run_shell (['rmdir' , TestSnapSchedulesSnapdir .TEST_DIRECTORY ])
10941094
10951095
1096+ class TestSnapSchedulesFetchForeignConfig (TestSnapSchedulesHelper ):
1097+ def test_fetch_for_mds_max_snaps_per_dir (self ):
1098+ """Test the correctness of snap directory name"""
1099+ dir_path = TestSnapSchedulesHelper .TEST_DIRECTORY
1100+ sdn = self .get_snap_dir_name ()
1101+
1102+ self .mount_a .run_shell (['mkdir' , '-p' , dir_path ])
1103+
1104+ # set a schedule on the dir
1105+ self .fs_snap_schedule_cmd ('add' , path = dir_path , snap_schedule = '1m' )
1106+
1107+ self .config_set ('mds' , 'mds_max_snaps_per_dir' , 10 )
1108+
1109+ time .sleep (11 * 60 ) # wait for 9 snaps to be retained
1110+
1111+ snap_path = f"{ dir_path } /{ sdn } "
1112+ snapshots = self .mount_a .ls (path = snap_path )
1113+ fs_count = len (snapshots )
1114+
1115+ self .assertTrue (fs_count == 9 )
1116+
1117+ self .config_set ('mds' , 'mds_max_snaps_per_dir' , 8 )
1118+
1119+ time .sleep (1 * 60 + 10 ) # wait for max_snaps_per_dir limit to be breached
1120+
1121+ snap_path = f"{ dir_path } /{ sdn } "
1122+ snapshots = self .mount_a .ls (path = snap_path )
1123+ fs_count = len (snapshots )
1124+
1125+ self .assertTrue (fs_count == 7 )
1126+
1127+ self .config_set ('mds' , 'mds_max_snaps_per_dir' , 10 )
1128+
1129+ time .sleep (2 * 60 + 10 ) # wait for more snaps to be created
1130+
1131+ snap_path = f"{ dir_path } /{ sdn } "
1132+ snapshots = self .mount_a .ls (path = snap_path )
1133+ fs_count = len (snapshots )
1134+
1135+ self .assertTrue (fs_count == 9 )
1136+
1137+ # remove snapshot schedule
1138+ self .fs_snap_schedule_cmd ('remove' , path = dir_path )
1139+
1140+ # remove all scheduled snapshots
1141+ self .remove_snapshots (dir_path , sdn )
1142+
1143+ self .mount_a .run_shell (['rmdir' , dir_path ])
1144+
1145+
10961146"""
10971147Note that the class TestSnapSchedulesMandatoryFSArgument tests snap-schedule
10981148commands only for multi-fs scenario. Commands for a single default fs should
0 commit comments