From b6b41b347924d1ab2754ffe8445dfdf98555ae92 Mon Sep 17 00:00:00 2001 From: Michal Polovka Date: Apr 17 2020 15:57:34 +0000 Subject: 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 --- diff --git a/ipatests/test_integration/test_ipahealthcheck.py b/ipatests/test_integration/test_ipahealthcheck.py index 327d274..f9ce536 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