Skip to content

Commit

Permalink
Merge pull request openstack-charmers#558 from freyes/bug/1922195
Browse files Browse the repository at this point in the history
Add support for testing CephFS and ceph-proxy.
  • Loading branch information
ajkavanagh authored Aug 8, 2023
2 parents 8991edd + 7ec9b91 commit 6896da2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
13 changes: 11 additions & 2 deletions zaza/openstack/charm_tests/ceph/fs/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CephFSTests(unittest.TestCase):

mounts_share = False
mount_dir = '/mnt/cephfs'
CEPH_MON = 'ceph-mon'

def tearDown(self):
"""Cleanup after running tests."""
Expand Down Expand Up @@ -69,9 +70,9 @@ def _mount_share(self, unit_name: str,
def _install_keyring(self, unit_name: str):

keyring = model.run_on_leader(
'ceph-mon', 'cat /etc/ceph/ceph.client.admin.keyring')['Stdout']
self.CEPH_MON, 'cat /etc/ceph/ceph.client.admin.keyring')['Stdout']
config = model.run_on_leader(
'ceph-mon', 'cat /etc/ceph/ceph.conf')['Stdout']
self.CEPH_MON, 'cat /etc/ceph/ceph.conf')['Stdout']
commands = [
'sudo mkdir -p /etc/ceph',
"echo '{}' | sudo tee /etc/ceph/ceph.conf".format(config),
Expand Down Expand Up @@ -176,6 +177,14 @@ def _change_conf_check(mds_config):
_change_conf_check(mds_config)


class CephFSWithCephProxyTests(CephFSTests):
"""Extend CephFSTests to use ceph-proxy instead of ceph-mon."""

# when ceph-proxy is being used it will be the one acting as a ceph-mon
# for the other charms holding the admin key and ceph.conf
CEPH_MON = 'ceph-proxy'


def _indent(text, amount, ch=' '):
padding = amount * ch
return ''.join(padding+line for line in text.splitlines(True))
Expand Down
10 changes: 8 additions & 2 deletions zaza/openstack/charm_tests/ceph/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import tenacity

import zaza.charm_lifecycle.utils as lifecycle_utils
import zaza.openstack.charm_tests.test_utils as test_utils
import zaza.model as zaza_model
import zaza.openstack.utilities.ceph as zaza_ceph
Expand Down Expand Up @@ -1204,10 +1205,14 @@ def setUpClass(cls):
"""Run class setup for running tests."""
super(CephProxyTest, cls).setUpClass()

test_config = lifecycle_utils.get_charm_config(fatal=False)
cls.target_deploy_status = test_config.get('target_deploy_status', {})

def test_ceph_health(self):
"""Make sure ceph-proxy can communicate with ceph."""
logging.info('Wait for idle/ready status...')
zaza_model.wait_for_application_states()
zaza_model.wait_for_application_states(
states=self.target_deploy_status)

self.assertEqual(
zaza_model.run_on_leader("ceph-proxy", "sudo ceph health")["Code"],
Expand All @@ -1217,7 +1222,8 @@ def test_ceph_health(self):
def test_cinder_ceph_restrict_pool_setup(self):
"""Make sure cinder-ceph restrict pool was created successfully."""
logging.info('Wait for idle/ready status...')
zaza_model.wait_for_application_states()
zaza_model.wait_for_application_states(
states=self.target_deploy_status)

pools = zaza_ceph.get_ceph_pools('ceph-mon/0')
if 'cinder-ceph' not in pools:
Expand Down

0 comments on commit 6896da2

Please sign in to comment.