From b44e556d0aa08abd0c252f64d5d201db46c117a2 Mon Sep 17 00:00:00 2001 From: Xav Paice Date: Tue, 13 Oct 2020 20:21:46 +1300 Subject: [PATCH] Add tests for NRPE checks in aodh Adds a test to ensure that Aodh units related to nrpe get service check files created. --- zaza/openstack/charm_tests/aodh/tests.py | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/zaza/openstack/charm_tests/aodh/tests.py b/zaza/openstack/charm_tests/aodh/tests.py index e0178dff9..3b966e523 100644 --- a/zaza/openstack/charm_tests/aodh/tests.py +++ b/zaza/openstack/charm_tests/aodh/tests.py @@ -25,6 +25,7 @@ import zaza.openstack.configure.guest import zaza.openstack.charm_tests.glance.setup as glance_setup import zaza.openstack.charm_tests.test_utils as test_utils +import zaza.openstack.utilities.generic as generic_utils import zaza.openstack.utilities.openstack as openstack_utils import zaza.openstack.configure.telemetry as telemetry_utils @@ -70,6 +71,13 @@ def query_aodh_api(self): """Check that aodh api is responding.""" self.aodh_client.alarm.list() + @tenacity.retry( + retry=tenacity.retry_if_result(lambda ret: ret is not None), + wait=tenacity.wait_fixed(120), + stop=tenacity.stop_after_attempt(2)) + def _retry_check_commands_on_units(self, cmds, units): + return generic_utils.check_commands_on_units(cmds, units) + @property def services(self): """Return a list of the service that should be running.""" @@ -139,6 +147,26 @@ def test_901_pause_resume(self): logging.info("Testing pause resume") self.query_aodh_api() + def test_902_nrpe_service_checks(self): + """Confirm that the NRPE service check files are created.""" + units = zaza.model.get_units('aodh') + cmds = [] + if self.release >= self.xenial_ocata: + services = ['aodh-evaluator', 'aodh-notifier', + 'aodh-listener', 'apache2'] + else: + services = ['aodh-api', 'aodh-evaluator', + 'aodh-notifier', 'aodh-listener'] + for check_name in services: + cmds.append( + 'egrep -oh /usr/local.* /etc/nagios/nrpe.d/' + 'check_{}.cfg'.format(check_name) + ) + ret = self._retry_check_commands_on_units(cmds, units) + if ret: + logging.info(ret) + self.assertIsNone(ret, msg=ret) + class AodhServerAlarmTest(test_utils.OpenStackBaseTest): """Test server events trigger Aodh alarms."""