From b7807fc5129e76f9ba0841e6a05f3f2b91b6d77d Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Mon, 1 Apr 2019 16:44:41 +0200 Subject: [PATCH] ceph/rbd_mirror: Optionally require presence of images in wait-helper When you tell Ceph to resync mirrored RBD images it will in practice remove and re-create the image. At present the image state wait helper will happilly accept no images in a pool as a positive outcome. Add optional ``require_images_in`` parameter that allows the wait helper to block even when no images are available in the pool (yet) --- zaza/charm_tests/ceph/rbd_mirror/tests.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/zaza/charm_tests/ceph/rbd_mirror/tests.py b/zaza/charm_tests/ceph/rbd_mirror/tests.py index ac0cb47..b108a62 100644 --- a/zaza/charm_tests/ceph/rbd_mirror/tests.py +++ b/zaza/charm_tests/ceph/rbd_mirror/tests.py @@ -68,7 +68,8 @@ class CephRBDMirrorBase(test_utils.OpenStackBaseTest): def wait_for_mirror_state(self, state, application_name=None, model_name=None, - check_entries_behind_master=False): + check_entries_behind_master=False, + require_images_in=[]): """Wait until all images reach requested state. This function runs the ``status`` action and examines the data it @@ -85,6 +86,8 @@ class CephRBDMirrorBase(test_utils.OpenStackBaseTest): when used with state ``up+replying``. :type check_entries_behind_master: bool + :param require_images_in: List of pools to require images in + :type require_images_in: list of str :returns: True on success, never returns on failure """ rep = re.compile(r'.*entries_behind_master=(\d+)') @@ -92,7 +95,10 @@ class CephRBDMirrorBase(test_utils.OpenStackBaseTest): pool_status = self.run_status_action( application_name=application_name, model_name=model_name) for pool, status in pool_status.items(): - for image in status.get('images', []): + images = status.get('images', []) + if not len(images) and pool in require_images_in: + break + for image in images: if image['state'] and image['state'] != state: break if check_entries_behind_master: @@ -304,7 +310,8 @@ class CephRBDMirrorControlledFailoverTest(CephRBDMirrorBase): self.wait_for_mirror_state( 'up+replaying', application_name=self.application_name + self.site_b_app_suffix, - model_name=self.site_b_model) + model_name=self.site_b_model, + require_images_in['cinder-ceph', 'glance']) class CephRBDMirrorDisasterFailoverTest(CephRBDMirrorBase):