Skip to content

Commit

Permalink
Make Ceph tests more generic (#1034)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmlg authored Apr 10, 2023
1 parent 2c61ed7 commit e4a9aad
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions zaza/openstack/charm_tests/ceph/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,33 +116,6 @@ def test_pg_tuning(self):
self.assertEqual(pool['pg_autoscale_mode'], 'on')


class CephRelationTest(test_utils.BaseCharmTest):
"""Ceph's relations test class."""

@classmethod
def setUpClass(cls):
"""Run the ceph's relations class setup."""
super(CephRelationTest, cls).setUpClass()

def test_ceph_osd_ceph_relation_address(self):
"""Verify the ceph-osd to ceph relation data."""
logging.info('Checking ceph-osd:ceph-mon relation data...')
unit_name = 'ceph-osd/0'
remote_unit_name = 'ceph-mon/0'
relation_name = 'osd'
remote_unit = zaza_model.get_unit_from_name(remote_unit_name)
remote_ip = zaza_model.get_unit_public_address(remote_unit)
relation = juju_utils.get_relation_from_unit(
unit_name,
remote_unit_name,
relation_name
)
# Get private-address in relation
rel_private_ip = relation.get('private-address')
# The private address in relation should match ceph-mon/0 address
self.assertEqual(rel_private_ip, remote_ip)


class CephTest(test_utils.BaseCharmTest):
"""Ceph common functional tests."""

Expand Down Expand Up @@ -418,6 +391,12 @@ def test_pause_and_resume(self):
logging.info('Checking pause and resume actions...')
self.pause_resume(['ceph-osd'])

def get_device_for_blacklist(self, unit):
"""Return a device to be used by the blacklist tests."""
cmd = "mount | grep 'on / ' | awk '{print $1}'"
obj = zaza_model.run_on_unit(unit, cmd)
return obj.get('Stdout').strip()

def test_blacklist(self):
"""Check the blacklist action.
Expand Down Expand Up @@ -457,10 +436,15 @@ def test_blacklist(self):
)

# Attempt to add device with existent path should succeed
device = self.get_device_for_blacklist(unit_name)
if not device:
raise unittest.SkipTest(
"Skipping test because no device was found")

action_obj = zaza_model.run_action(
unit_name=unit_name,
action_name='blacklist-add-disk',
action_params={'osd-devices': '/dev/vda'}
action_params={'osd-devices': device}
)
self.assertEqual('completed', action_obj.status)
zaza_model.block_until_unit_wl_status(
Expand All @@ -472,7 +456,7 @@ def test_blacklist(self):
action_obj = zaza_model.run_action(
unit_name=unit_name,
action_name='blacklist-remove-disk',
action_params={'osd-devices': '/dev/vda'}
action_params={'osd-devices': device}
)
self.assertEqual('completed', action_obj.status)
zaza_model.block_until_unit_wl_status(
Expand Down

0 comments on commit e4a9aad

Please sign in to comment.