Skip to content

Commit

Permalink
Merge pull request openstack-charmers#436 from xavpaice/bug/1897809
Browse files Browse the repository at this point in the history
Add NRPE check tests for Designate
  • Loading branch information
lourot authored Aug 26, 2021
2 parents c759a23 + 47ada74 commit 15add17
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion zaza/openstack/charm_tests/designate/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import zaza.model
import zaza.utilities.juju as juju_utils
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.charm_tests.designate.utils as designate_utils
import zaza.charm_lifecycle.utils as lifecycle_utils
Expand Down Expand Up @@ -90,6 +91,14 @@ def setUpClass(cls, application_name=None, model_alias=None):
cls.server_create = cls.designate.servers.create
cls.server_delete = cls.designate.servers.delete

@tenacity.retry(
retry=tenacity.retry_if_result(lambda ret: ret is not None),
# sleep for 2mins to allow 1min cron job to run...
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)


class DesignateAPITests(BaseDesignateTest):
"""Tests interact with designate api."""
Expand Down Expand Up @@ -294,7 +303,26 @@ def test_910_pause_and_resume(self):
logging.info("Testing pause resume")


class DesignateTests(DesignateAPITests, DesignateCharmTests):
class DesignateMonitoringTests(BaseDesignateTest):
"""Designate charm monitoring tests."""

def test_nrpe_configured(self):
"""Confirm that the NRPE service check files are created."""
units = zaza.model.get_units(self.application_name)
cmds = []
for check_name in self.designate_svcs:
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 DesignateTests(DesignateAPITests, DesignateCharmTests,
DesignateMonitoringTests):
"""Collection of all Designate test classes."""

pass
Expand Down

0 comments on commit 15add17

Please sign in to comment.