]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: test ongoing clones counter in CloneProgressReporter
authorRishabh Dave <ridave@redhat.com>
Wed, 1 Jan 2025 12:29:39 +0000 (17:59 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 3 Apr 2025 14:45:27 +0000 (20:15 +0530)
Test that CloneProgressReporter counts number of ongoing clones works
fine.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/suites/fs/volumes/tasks/volumes/test/clone-progress.yaml
qa/tasks/cephfs/volumes/test_clone_stats.py

index 7dc5fce183c79e1fee41d839cc5147f73d65ee91..a58e219858ca0eb21363bf296b7bbf7af9a7683a 100644 (file)
@@ -3,3 +3,4 @@ tasks:
       fail_on_skip: false
       modules:
         - tasks.cephfs.volumes.test_clone_stats.TestCloneProgressReporter
+        - tasks.cephfs.volumes.test_clone_stats.TestOngoingClonesCounter
index fe8f4948f932f7a9534ec13d33af3a6e8ae5ac11..8c24b5b1650e702c08563340d2b6a0af9b914c62 100644 (file)
@@ -791,3 +791,74 @@ class TestCloneProgressReporter(CloneProgressReporterHelper):
                 pass
             else:
                 raise
+
+
+class TestOngoingClonesCounter(CloneProgressReporterHelper):
+    '''
+    Class CloneProgressReporter contains the code that lets it figure out the
+    number of ongoing clones on its own, without referring the MGR config
+    option mgr/volumes/max_concurrenr_clones. This class contains tests to
+    ensure that this code, that does the figuring out, is working fine.
+    '''
+
+    def _run_test(self, MAX_THREADS, NUM_OF_CLONES):
+        v = self.volname
+        sv = 'sv1'
+        ss = 'ss1'
+        c = self._gen_subvol_clone_name(NUM_OF_CLONES)
+
+        self.config_set('mgr', 'mgr/volumes/snapshot_clone_no_wait', 'false')
+        self.config_set('mgr', 'mgr/volumes/max_concurrent_clones', MAX_THREADS)
+        self.run_ceph_cmd(f'fs subvolume create {v} {sv} --mode=777')
+
+        sv_path = self.get_ceph_cmd_stdout(f'fs subvolume getpath {v} {sv}')
+        sv_path = sv_path[1:]
+
+        size = self._do_subvolume_io(sv, None, None, 3, 1024)
+        self.run_ceph_cmd(f'fs subvolume snapshot create {v} {sv} {ss}')
+        self.wait_till_rbytes_is_right(v, sv, size)
+
+        for i in c:
+            self.run_ceph_cmd(f'fs subvolume snapshot clone {v} {sv} {ss} {i}')
+
+        msg = ('messages for progress bars for snapshot cloning are not how '
+               'they were expected')
+        with safe_while(tries=20, sleep=1, action=msg) as proceed:
+            while proceed():
+                pevs = self.get_pevs_from_ceph_status(c)
+
+                if len(pevs) <= 1:
+                    continue # let's wait for second progress bar to appear
+                elif len(pevs) > 2:
+                    raise RuntimeError(
+                        'More than 2 progress bars were found in the output '
+                        'of "ceph status" command.\nprogress events -'
+                        f'\n{pevs}')
+
+                msg = ('"progress_events" dict in "ceph -s" output must have '
+                       f'only two entries.\n{pevs}')
+                self.assertEqual(len(pevs), 2, msg)
+                pev1, pev2 = pevs.values()
+                pev1_msg, pev2_msg = pev1['message'].lower(), pev2['message'].lower()
+                if 'ongoing clones' in pev1_msg and 'total ' in pev2_msg:
+                    if f'{MAX_THREADS} ongoing clones' in pev1_msg:
+                        break
+                elif 'ongoing clones' in pev2_msg and 'total ' in pev1_msg:
+                    if f'{MAX_THREADS} ongoing clones' in pev2_msg:
+                        break
+                else:
+                    raise RuntimeError(msg)
+
+        self.cancel_clones_and_ignore_if_finished(c)
+        for i in c:
+            self._wait_for_clone_to_be_canceled(i)
+        self._wait_for_clone_progress_bars_to_be_removed()
+
+    def test_for_2_ongoing_clones(self):
+        self._run_test(MAX_THREADS=2, NUM_OF_CLONES=5)
+
+    def test_for_4_ongoing_clones(self):
+        self._run_test(MAX_THREADS=4, NUM_OF_CLONES=8)
+
+    def test_for_6_ongoing_clones(self):
+        self._run_test(MAX_THREADS=6, NUM_OF_CLONES=16)