From 2378c424ee966f73e046499913605ce4b1e5e9d6 Mon Sep 17 00:00:00 2001 From: Syed Mohammad Adnan Karim Date: Sat, 1 Dec 2018 00:50:54 +0000 Subject: [PATCH] Adds amulet test - ceph.conf alternatives removal Test checks for the removal of ceph.conf alternatives when ceph-mon relation is broken. If ceph.conf is not present when the relation is still joined, the test fails. If ceph.conf is not removed after the relation is broken, the test fails. The test will pass if an existing ceph.conf file is removed after the ceph-mon relation is broken. Change-Id: I3b348a58bd2e3ebbbecbd3bbb4307c490a0c4ea4 Related-Bug: 1778084 --- tests/basic_deployment.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 7378606..35f7af8 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -726,3 +726,34 @@ class CinderCephBasicDeployment(OpenStackAmuletDeployment): ret = u.check_commands_on_units(commands, sentry_units) if ret: amulet.raise_status(amulet.FAIL, msg=ret) + + def test_500_ceph_alternatives_cleanup(self): + """Check ceph alternatives are removed when ceph-mon + relation is broken""" + u.log.debug('Checking ceph alternatives are removed ' + 'upon broken ceph-mon relation') + ceph_dir = self.cinder_ceph_sentry.directory_listing('/etc/ceph') + u.log.debug(ceph_dir) + if 'ceph.conf' in ceph_dir['files']: + u.log.debug('/etc/ceph/ceph.conf exists BEFORE relation-broken') + else: + error_msg = '/etc/ceph/ceph.conf does not ' + error_msg += 'exist BEFORE relation-broken\n' + error_msg += 'test_500_ceph_alternatives_cleanup FAILED' + amulet.raise_status(amulet.FAIL, msg=error_msg) + self.d.unrelate('ceph-mon:client', 'cinder-ceph:ceph') + self.d.sentry.wait() + ceph_dir_after = self.cinder_ceph_sentry.directory_listing('/etc/ceph') + u.log.debug(ceph_dir_after) + if 'ceph.conf' in ceph_dir_after['files']: + u.log.debug('/etc/ceph/ceph.conf exists AFTER relation-broken') + error_msg = 'Did not expect /etc/ceph/ceph.conf AFTER ' + error_msg += 'relation-broken\n' + error_msg += 'test_500_ceph_alternatives_cleanup FAILED' + amulet.raise_status(amulet.FAIL, msg=error_msg) + else: + u.log.debug('/etc/ceph/ceph.conf removed AFTER relation-broken') + u.log.debug('test_500_ceph_alternatives_cleanup PASSED - (OK)') + # Restore cinder-ceph and ceph-mon relation to keep tests idempotent + self.d.relate('ceph-mon:client', 'cinder-ceph:ceph') + self.d.sentry.wait()