]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: improvements for helper methods for clone state
authorRishabh Dave <ridave@redhat.com>
Wed, 3 Jan 2024 06:56:19 +0000 (12:26 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 14 Aug 2024 09:35:46 +0000 (15:05 +0530)
1. Let caller check for multiple states. It might happen that clone
   finishes while it is being cancelled, in such cases user might want
    to check for both.
2. Add a helper method to check if clone is in pending state and add a
   separate method to check if clone is in cancelled state.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/test_volumes.py

index 037b046304eb97110648cb52c2edd9fb37155938..56410b3a08199dea0a9d421c66febc0ba99e71e9 100644 (file)
@@ -35,7 +35,10 @@ class TestVolumesHelper(CephFSTestCase):
     def _raw_cmd(self, *args):
         return self.get_ceph_cmd_stdout(args)
 
-    def __check_clone_state(self, state, clone, clone_group=None, timo=120):
+    def __check_clone_state(self, states, clone, clone_group=None, timo=120):
+        if isinstance(states, str):
+            states = (states, )
+
         check = 0
         args = ["clone", "status", self.volname, clone]
         if clone_group:
@@ -43,7 +46,7 @@ class TestVolumesHelper(CephFSTestCase):
         args = tuple(args)
         while check < timo:
             result = json.loads(self._fs_cmd(*args))
-            if result["status"]["state"] == state:
+            if result["status"]["state"] in states:
                 break
             check += 1
             time.sleep(1)
@@ -57,6 +60,23 @@ class TestVolumesHelper(CephFSTestCase):
         result = json.loads(self._fs_cmd(*args))
         return result
 
+    def _wait_for_clone_to_be_pending(self, clone, clone_group=None,
+                                      timo=120):
+        # check for "in-progress" state too along with "pending" state, because
+        # if former has occurred it means latter has occured before (which can
+        # happen for such a small time that it is easy to miss) and it won't
+        # occur again.
+        states = ('pending', 'in-progress')
+        self.__check_clone_state(states, clone, clone_group, timo)
+
+    def _wait_for_clone_to_be_canceled(self, clone, clone_group=None,
+                                          timo=120):
+        # check for "cancelled" state too along with "complete" state, because
+        # it takes some time for a clone job to be cancelled and in that time
+        # a clone job might finish.
+        states = ('canceled', 'complete')
+        self.__check_clone_state(states, clone, clone_group, timo)
+
     def _wait_for_clone_to_complete(self, clone, clone_group=None, timo=120):
         self.__check_clone_state("complete", clone, clone_group, timo)