From fcdcc81c64731601bbaac93917a268554b0612c3 Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Wed, 14 Aug 2024 13:22:59 -0300 Subject: [PATCH 1/2] Use the new-style fields in action object for RBD tests --- .../charm_tests/ceph/rbd_mirror/tests.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zaza/openstack/charm_tests/ceph/rbd_mirror/tests.py b/zaza/openstack/charm_tests/ceph/rbd_mirror/tests.py index fc7be50..e2426ae 100644 --- a/zaza/openstack/charm_tests/ceph/rbd_mirror/tests.py +++ b/zaza/openstack/charm_tests/ceph/rbd_mirror/tests.py @@ -216,7 +216,7 @@ class CephRBDMirrorBase(test_utils.BaseCharmTest): if result.status == "failed": logging.error("status action failed: %s", result.message) return - return json.loads(result.results['output']) + return json.loads(result.get('Stdout')) def get_pools(self): """Retrieve list of pools from both sites. @@ -503,11 +503,11 @@ class CephRBDMirrorControlledFailoverTest(CephRBDMirrorBase): 'pools': ','.join(primary_site_pools) }) logging.info(result.results) - self.assertEqual(int(result.results['Code']), 0) + self.assertEqual(int(result.get('Code')), 0) # Validate that the demoted pools count matches the total primary site # pools count. - n_pools_demoted = len(result.results['output'].split('\n')) + n_pools_demoted = len(result.get('Stdout').split('\n')) self.assertEqual(len(primary_site_pools), n_pools_demoted) # At this point, both primary and secondary sites are demoted. Validate @@ -537,11 +537,11 @@ class CephRBDMirrorControlledFailoverTest(CephRBDMirrorBase): 'pools': ','.join(secondary_site_pools) }) logging.info(result.results) - self.assertEqual(int(result.results['Code']), 0) + self.assertEqual(int(result.get('Code')), 0) # Validate that the promoted pools count matches the total secondary # site pools count. - n_pools_promoted = len(result.results['output'].split('\n')) + n_pools_promoted = len(result.get('Stdout').split('\n')) self.assertEqual(len(secondary_site_pools), n_pools_promoted) # Validate that the Ceph images from the newly promoted site @@ -711,7 +711,7 @@ class CephRBDMirrorControlledFailoverTest(CephRBDMirrorBase): 'i-really-mean-it': True, }) logging.info(result.results) - self.assertEqual(int(result.results['Code']), 0) + self.assertEqual(int(result.get('Code')), 0) # Validate that the Ceph images from site-b report 'up+replaying' # (which is reported by secondary Ceph images). And check that images @@ -801,7 +801,7 @@ class CephRBDMirrorDisasterFailoverTest(CephRBDMirrorBase): action_params={ 'pools': ','.join(site_b_pools), }) - self.assertEqual(int(result.results['Code']), 0) + self.assertEqual(int(result.get('Code')), 0) # The action may not show up as 'failed' if there are no pools that # needed to be promoted. @@ -816,7 +816,7 @@ class CephRBDMirrorDisasterFailoverTest(CephRBDMirrorBase): 'force': True, 'pools': ','.join(site_b_pools), }) - self.assertEqual(int(result.results['Code']), 0) + self.assertEqual(int(result.get('Code')), 0) # Validate successful Juju action execution self.assertEqual(result.status, 'completed') From fd160e82052051b75df59a615d81ccd14c4e5225 Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Wed, 14 Aug 2024 14:41:52 -0300 Subject: [PATCH 2/2] Fix function calls --- .../charm_tests/ceph/rbd_mirror/tests.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/zaza/openstack/charm_tests/ceph/rbd_mirror/tests.py b/zaza/openstack/charm_tests/ceph/rbd_mirror/tests.py index e2426ae..1882d8d 100644 --- a/zaza/openstack/charm_tests/ceph/rbd_mirror/tests.py +++ b/zaza/openstack/charm_tests/ceph/rbd_mirror/tests.py @@ -216,7 +216,7 @@ class CephRBDMirrorBase(test_utils.BaseCharmTest): if result.status == "failed": logging.error("status action failed: %s", result.message) return - return json.loads(result.get('Stdout')) + return json.loads(result.results['output']) def get_pools(self): """Retrieve list of pools from both sites. @@ -495,14 +495,14 @@ class CephRBDMirrorControlledFailoverTest(CephRBDMirrorBase): # Run the 'demote' Juju action against the primary site pools. logging.info('Demoting {} from model {}.'.format( primary_site_app_name, primary_site_model)) - result = zaza.model.run_action_on_leader( + result = zaza.model.run_on_leader( primary_site_app_name, 'demote', model_name=primary_site_model, action_params={ 'pools': ','.join(primary_site_pools) }) - logging.info(result.results) + logging.info(result) self.assertEqual(int(result.get('Code')), 0) # Validate that the demoted pools count matches the total primary site @@ -529,14 +529,14 @@ class CephRBDMirrorControlledFailoverTest(CephRBDMirrorBase): # Run the 'promote' Juju against the secondary site. logging.info('Promoting {} from model {}.'.format( secondary_site_app_name, secondary_site_model)) - result = zaza.model.run_action_on_leader( + result = zaza.model.run_on_leader( secondary_site_app_name, 'promote', model_name=secondary_site_model, action_params={ 'pools': ','.join(secondary_site_pools) }) - logging.info(result.results) + logging.info(result) self.assertEqual(int(result.get('Code')), 0) # Validate that the promoted pools count matches the total secondary @@ -702,7 +702,7 @@ class CephRBDMirrorControlledFailoverTest(CephRBDMirrorBase): site_b_app_name = self.application_name + self.site_b_app_suffix logging.info('Re-syncing {} from model {}'.format( site_b_app_name, self.site_b_model)) - result = zaza.model.run_action_on_leader( + result = zaza.model.run_on_leader( site_b_app_name, 'resync-pools', model_name=self.site_b_model, @@ -710,7 +710,7 @@ class CephRBDMirrorControlledFailoverTest(CephRBDMirrorBase): 'pools': ','.join(site_b_pools), 'i-really-mean-it': True, }) - logging.info(result.results) + logging.info(result) self.assertEqual(int(result.get('Code')), 0) # Validate that the Ceph images from site-b report 'up+replaying' @@ -794,7 +794,7 @@ class CephRBDMirrorDisasterFailoverTest(CephRBDMirrorBase): self.kill_primary_site() # Try and promote the site-b to primary. - result = zaza.model.run_action_on_leader( + result = zaza.model.run_on_leader( site_b_app_name, 'promote', model_name=self.site_b_model, @@ -816,7 +816,6 @@ class CephRBDMirrorDisasterFailoverTest(CephRBDMirrorBase): 'force': True, 'pools': ','.join(site_b_pools), }) - self.assertEqual(int(result.get('Code')), 0) # Validate successful Juju action execution self.assertEqual(result.status, 'completed')