]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa: test fetching foreign config item
authorMilind Changire <mchangir@redhat.com>
Fri, 10 May 2024 09:52:51 +0000 (15:22 +0530)
committerMilind Changire <mchangir@redhat.com>
Sat, 7 Sep 2024 07:07:36 +0000 (12:37 +0530)
Signed-off-by: Milind Changire <mchangir@redhat.com>
(cherry picked from commit 1fda7cb7e23435e0387b641cd8295ff327f7270d)

qa/tasks/cephfs/test_snap_schedules.py

index 1fff047f468910dd5f40039863c41e3af55644ce..bdfec3db5400bcf47df4a7202a564ac631501542 100644 (file)
@@ -1093,6 +1093,56 @@ class TestSnapSchedulesSnapdir(TestSnapSchedulesHelper):
         self.mount_a.run_shell(['rmdir', TestSnapSchedulesSnapdir.TEST_DIRECTORY])
 
 
+class TestSnapSchedulesFetchForeignConfig(TestSnapSchedulesHelper):
+    def test_fetch_for_mds_max_snaps_per_dir(self):
+        """Test the correctness of snap directory name"""
+        dir_path = TestSnapSchedulesHelper.TEST_DIRECTORY
+        sdn = self.get_snap_dir_name()
+
+        self.mount_a.run_shell(['mkdir', '-p', dir_path])
+
+        # set a schedule on the dir
+        self.fs_snap_schedule_cmd('add', path=dir_path, snap_schedule='1m')
+
+        self.config_set('mds', 'mds_max_snaps_per_dir', 10)
+
+        time.sleep(11*60)  # wait for 9 snaps to be retained
+
+        snap_path = f"{dir_path}/{sdn}"
+        snapshots = self.mount_a.ls(path=snap_path)
+        fs_count = len(snapshots)
+
+        self.assertTrue(fs_count == 9)
+
+        self.config_set('mds', 'mds_max_snaps_per_dir', 8)
+
+        time.sleep(1*60 + 10)  # wait for max_snaps_per_dir limit to be breached
+
+        snap_path = f"{dir_path}/{sdn}"
+        snapshots = self.mount_a.ls(path=snap_path)
+        fs_count = len(snapshots)
+
+        self.assertTrue(fs_count == 7)
+
+        self.config_set('mds', 'mds_max_snaps_per_dir', 10)
+
+        time.sleep(2*60 + 10)  # wait for more snaps to be created
+
+        snap_path = f"{dir_path}/{sdn}"
+        snapshots = self.mount_a.ls(path=snap_path)
+        fs_count = len(snapshots)
+
+        self.assertTrue(fs_count == 9)
+
+        # remove snapshot schedule
+        self.fs_snap_schedule_cmd('remove', path=dir_path)
+
+        # remove all scheduled snapshots
+        self.remove_snapshots(dir_path, sdn)
+
+        self.mount_a.run_shell(['rmdir', dir_path])
+
+
 """
 Note that the class TestSnapSchedulesMandatoryFSArgument tests snap-schedule
 commands only for multi-fs scenario. Commands for a single default fs should