Skip to content

Commit

Permalink
Merge pull request openstack-charmers#445 from xavpaice/bug/1750486
Browse files Browse the repository at this point in the history
Add tests for NRPE checks in aodh
  • Loading branch information
ChrisMacNaughton authored Jun 8, 2021
2 parents 06427d9 + b44e556 commit 962e75a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions zaza/openstack/charm_tests/aodh/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 962e75a

Please sign in to comment.