From: Rishabh Dave Date: Wed, 3 Jan 2024 06:56:19 +0000 (+0530) Subject: qa/cephfs: improvements for helper methods for clone state X-Git-Tag: v20.0.0~1215^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=10949bf68d2cacf8db241fb47df467f15891569a;p=ceph.git qa/cephfs: improvements for helper methods for clone state 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 --- diff --git a/qa/tasks/cephfs/test_volumes.py b/qa/tasks/cephfs/test_volumes.py index 037b046304e..56410b3a081 100644 --- a/qa/tasks/cephfs/test_volumes.py +++ b/qa/tasks/cephfs/test_volumes.py @@ -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)