From 761913176c50c5e2b953e944341634c3f99fa0c8 Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Tue, 9 Apr 2024 19:28:40 -0300 Subject: [PATCH] Make sure the result is the type of entity we're after --- zaza/openstack/charm_tests/ceph/tests.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/zaza/openstack/charm_tests/ceph/tests.py b/zaza/openstack/charm_tests/ceph/tests.py index 4e51d3c..c121884 100644 --- a/zaza/openstack/charm_tests/ceph/tests.py +++ b/zaza/openstack/charm_tests/ceph/tests.py @@ -1767,7 +1767,7 @@ class CephMonKeyRotationTests(test_utils.BaseCharmTest): # key contents # That's why we need to move one position ahead. if 'key:' in line and entity_filter(data[ix - 1]): - ret.add(data[ix + 1]) + ret.add((data[ix - 1], data[ix + 1])) return ret def _check_key_rotation(self, entity, unit): @@ -1784,7 +1784,13 @@ class CephMonKeyRotationTests(test_utils.BaseCharmTest): zaza_model.wait_for_application_states() new_keys = self._get_all_keys(unit, entity_filter) self.assertNotEqual(old_keys, new_keys) - self.assertEqual(len(new_keys - old_keys), 1) + diff = new_keys - old_keys + self.assertEqual(len(diff), 1) + first = next(iter(diff)) + # Check that the entity matches. The 'entity_filter' + # callable will return a true-like value if it + # matches the type of entity we're after (i.e: 'mgr') + self.assertTrue(entity_filter(first[0])) def _get_rgw_client(self, unit): cmd = 'sudo ceph auth ls | grep client.rgw' @@ -1801,5 +1807,7 @@ class CephMonKeyRotationTests(test_utils.BaseCharmTest): rgw_client = self._get_rgw_client('ceph-radosgw/0') if rgw_client: self._check_key_rotation(rgw_client, unit) + else: + logging.info('ceph-radosgw units present, but no RGW service') except KeyError: pass