Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ceph-fs key rotation tests #1202

Merged
merged 7 commits into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion zaza/openstack/charm_tests/ceph/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,20 @@ def test_persistent_config(self):
class CephMonKeyRotationTests(test_utils.BaseCharmTest):
"""Tests for the rotate-key action."""

def setUp(self):
"""Initialize key rotation test class."""
super(CephMonKeyRotationTests, self).setUp()
try:
# Workaround for ubuntu units that don't play nicely with zaza.
zaza_model.get_application('ubuntu')
self.app_states = {
'ubuntu': {
'workload-status-message': ''
}
}
except KeyError:
self.app_states = None

def _get_all_keys(self, unit, entity_filter):
cmd = 'sudo ceph auth ls'
result = zaza_model.run_on_unit(unit, cmd)
Expand Down Expand Up @@ -1781,7 +1795,7 @@ def entity_filter(name):
action_params={'entity': entity}
)
zaza_utils.assertActionRanOK(action_obj)
zaza_model.wait_for_application_states()
zaza_model.wait_for_application_states(states=self.app_states)
new_keys = self._get_all_keys(unit, entity_filter)
self.assertNotEqual(old_keys, new_keys)
diff = new_keys - old_keys
Expand All @@ -1798,6 +1812,13 @@ def _get_rgw_client(self, unit):
return None
return next(iter(ret))[0]

def _get_fs_client(self, unit):
ret = self._get_all_keys(unit, lambda x: (x.startswith('mds.') and
x != 'mds.ceph-fs'))
if not ret:
return None
return next(iter(ret))[0]

def test_key_rotate(self):
"""Test that rotating the keys actually changes them."""
unit = 'ceph-mon/0'
Expand All @@ -1812,3 +1833,16 @@ def test_key_rotate(self):
logging.info('ceph-radosgw units present, but no RGW service')
except KeyError:
pass

try:
zaza_model.get_application('ceph-fs')
fs_svc = self._get_fs_client(unit)
if fs_svc is not None:
# Only wait for ceph-fs, as this model includes 'ubuntu'
# units, and those don't play nice with zaza (they don't
# set the workload-status-message correctly).
self._check_key_rotation(fs_svc, unit)
else:
logging.info('ceph-fs units present, but no MDS service')
except KeyError:
pass
Loading