URL: https://github.com/freeipa/freeipa/pull/4548
Author: rcritten
 Title: #4548: [Backport][ipa-4-8] Test for healthcheck being run on replica 
with stopped master
Action: opened

PR body:
"""
This PR was opened automatically because PR #4303 was pushed to master and 
backport to ipa-4-8 is required.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/4548/head:pr4548
git checkout pr4548
From 902f9265aa9219973bd4ef2d3986a31113fd592b Mon Sep 17 00:00:00 2001
From: Michal Polovka <mpolo...@redhat.com>
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 <mpolo...@redhat.com>
---
 .../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 327d27413b..f9ce536fe9 100644
--- a/ipatests/test_integration/test_ipahealthcheck.py
+++ b/ipatests/test_integration/test_ipahealthcheck.py
@@ -7,14 +7,16 @@
 
 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 @@ def test_ipa_healthcheck_output_indent(self):
         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
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org

Reply via email to