From 435e2bee19030756c8cdc3c809426bd2172c7ce5 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Apr 06 2020 19:00:28 +0000 Subject: Perform baseline healthcheck Run healthcheck on a default installation and ensure that there are no failures. This test ensures that a fresh IPA installation will pass healthcheck. https://bugzilla.redhat.com/show_bug.cgi?id=1774032 Reviewed-By: Florence Blanc-Renaud --- diff --git a/ipatests/test_integration/test_ipahealthcheck.py b/ipatests/test_integration/test_ipahealthcheck.py index 84c02df..327d274 100644 --- a/ipatests/test_integration/test_ipahealthcheck.py +++ b/ipatests/test_integration/test_ipahealthcheck.py @@ -7,13 +7,14 @@ Tests to verify that the ipa-healthcheck scenarios from __future__ import absolute_import -import json - 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" @@ -109,7 +110,8 @@ DEFAULT_PKI_KRA_CERTS = [ ] -def run_healthcheck(host, source=None, check=None, output_type="json"): +def run_healthcheck(host, source=None, check=None, output_type="json", + failures_only=False): """ Run ipa-healthcheck on the remote host and return the result @@ -132,6 +134,9 @@ def run_healthcheck(host, source=None, check=None, output_type="json"): cmd.append("--output-type") cmd.append(output_type) + if failures_only: + cmd.append("--failures-only") + result = host.run_command(cmd, raiseonerr=False) if result.stdout_text: @@ -371,13 +376,19 @@ class TestIpaHealthCheck(IntegrationTest): check["kw"]["suffix"] == "ca" ) - def test_source_ipa_roles_check_crlmanager(self): + @pytest.fixture + def disable_crlgen(self): + """Fixture to disable crlgen then enable it once test is done""" + self.master.run_command(["ipa-crlgen-manage", "disable"]) + yield + self.master.run_command(["ipa-crlgen-manage", "enable"]) + + def test_source_ipa_roles_check_crlmanager(self, disable_crlgen): """ This testcase checks the status of healthcheck tool reflects correct information when crlgen is disabled using ipa-crl-manage disable """ - self.master.run_command(["ipa-crlgen-manage", "disable"]) returncode, data = run_healthcheck( self.master, "ipahealthcheck.ipa.roles", @@ -389,6 +400,19 @@ class TestIpaHealthCheck(IntegrationTest): assert check["kw"]["key"] == "crl_manager" assert check["kw"]["crlgen_enabled"] is False + def test_ipa_healthcheck_no_errors(self): + """ + Ensure that on a default installation with KRA and DNS + installed ipa-healthcheck runs with no errors. + """ + cmd = tasks.install_kra(self.master) + assert cmd.returncode == 0 + returncode, _unused = run_healthcheck( + self.master, + failures_only=True + ) + assert returncode == 0 + def test_ipa_healthcheck_dna_plugin_returns_warning_pagure_issue_60(self): """ This testcase checks that the status for IPADNARangeCheck on replica