From 3a64ac08e1b3202bb469fcf0f2a17bd5114bab8f Mon Sep 17 00:00:00 2001 From: Michal Polovka Date: Wed, 4 Mar 2020 12:22:16 +0100 Subject: [PATCH] Test for healthcheck being run on replica with stopped master Test checks whether healthcheck reports only that master is stopped with no other false positives when services on IPA master are stopped. Related: https://bugzilla.redhat.com/show_bug.cgi?id=1727900 Signed-off-by: Michal Polovka Reviewed-By: Rob Crittenden --- .../test_integration/test_ipahealthcheck.py | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) 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