diff --git a/ipatests/test_integration/test_ipahealthcheck.py b/ipatests/test_integration/test_ipahealthcheck.py index 327d27413..f9ce536fe 100644 --- a/ipatests/test_integration/test_ipahealthcheck.py +++ b/ipatests/test_integration/test_ipahealthcheck.py @@ -7,14 +7,16 @@ Tests to verify that the ipa-healthcheck scenarios from __future__ import absolute_import +import json +import re + +import pytest + from ipalib import api from ipapython.ipaldap import realm_to_serverid from ipatests.pytest_ipa.integration import tasks from ipatests.test_integration.base import IntegrationTest -import json -import pytest - HEALTHCHECK_LOG = "/var/log/ipa/healthcheck/healthcheck.log" HEALTHCHECK_SYSTEMD_FILE = ( "/etc/systemd/system/multi-user.target.wants/ipa-healthcheck.timer" @@ -543,6 +545,27 @@ class TestIpaHealthCheck(IntegrationTest): output_json = json.loads(output_str) assert output_str == "{}\n".format(json.dumps(output_json, indent=2)) + @pytest.fixture + def ipactl(self): + """Stop and start IPA during test""" + self.master.run_command(["ipactl", "stop"]) + yield + self.master.run_command(["ipactl", "start"]) + + def test_run_with_stopped_master(self, ipactl): + """ + Test output of healthcheck where master IPA services are stopped + contains only errors regarding master being stopped and no other false + positives. + """ + returncode, output = run_healthcheck( + self.master, + output_type="human", + failures_only=True) + assert returncode == 1 + errors = re.findall("ERROR: .*: not running", output) + assert len(errors) == len(output.split('\n')) + def test_ipa_healthcheck_remove(self): """ This testcase checks the removal of of healthcheck tool