#8439 Nightly test failure in test_integration/test_ipahealthcheck.py::TestIpaHealthCheck::test_ipa_healthcheck_expiring
Closed: fixed by rcritten. Opened by frenaud.

The nightly test test_integration/test_ipahealthcheck.py::TestIpaHealthCheck::test_ipa_healthcheck_expiring is failing in [testing_master_latest], see PR #319 with the following logs:

self = <ipatests.test_integration.test_ipahealthcheck.TestIpaHealthCheck object at 0x7f53987ccd60>
    def test_ipa_healthcheck_expiring(self):
        """
        There are two overlapping tests for expiring certs, check both.
        """
        def execute_expiring_check(check):
            """
            Test that certmonger will report warnings if expiration is near
            """
            returncode, data = run_healthcheck(
                self.master,
                "ipahealthcheck.ipa.certs",
                check,
            )
            assert returncode == 1
            assert len(data) == 9  # non-KRA is 9 tracked certs
            for check in data:
                if check["result"] == "SUCCESS":
                    # The CA is not expired
                    request = self.master.run_command(
                        ["getcert", "list", "-i", check["kw"]["key"]]
                    )
                    assert "caSigningCert cert-pki-ca" in request.stdout_text
                else:
                    assert check["result"] == "WARNING"
                    if check["kw"]["days"] == 21:
                        # the httpd, 389-ds and KDC renewal dates are later
                        certs = (paths.HTTPD_CERT_FILE, paths.KDC_CERT,
                                 '/etc/dirsrv/slapd-',)
                        request = self.master.run_command(
                            ["getcert", "list", "-i", check["kw"]["key"]]
                        )
                        assert any(cert in request.stdout_text
                                   for cert in certs)
                    else:
                        assert check["kw"]["days"] == 10
        # Pick a cert to find the upcoming expiration
        certfile = self.master.get_file_contents(paths.RA_AGENT_PEM)
        cert = x509.load_certificate_list(certfile)
        cert_expiry = cert[0].not_valid_after
        # move date to the grace period
        self.master.run_command(['systemctl', 'stop', 'chronyd'])
        grace_date = cert_expiry - timedelta(days=10)
        grace_date = datetime.strftime(grace_date, "%Y-%m-%d 00:00:01 Z")
        self.master.run_command(['date', '-s', grace_date])
        for check in ("IPACertmongerExpirationCheck",
                      "IPACertfileExpirationCheck",):
>           execute_expiring_check(check)
test_integration/test_ipahealthcheck.py:838: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
check = 'IPACertmongerExpirationCheck'
    def execute_expiring_check(check):
        """
        Test that certmonger will report warnings if expiration is near
        """
        returncode, data = run_healthcheck(
            self.master,
            "ipahealthcheck.ipa.certs",
            check,
        )
        assert returncode == 1
>       assert len(data) == 9  # non-KRA is 9 tracked certs
E       assert 12 == 9
E         +12
E         -9
test_integration/test_ipahealthcheck.py:802: AssertionError

The test expects to be run on a KRA-less instance. The test is defined on line 785 but we can see that a previous test in line 485 configures the KRA.

The test needs to be adapted to expect the KRA certificates.


Metadata Update from @frenaud:
- Issue assigned to frenaud

Metadata Update from @frenaud:
- Custom field on_review adjusted to https://github.com/freeipa/freeipa/pull/4984

master:

  • d55e339df32f35e5e37aad78eebe1bdb0fd2361d ipatests: fix test_ipahealthcheck.py::TestIpaHealthCheck

ipa-4-8:

  • 2fa03c5f583dad5f654669eb59255b0fc2991837 ipatests: fix test_ipahealthcheck.py::TestIpaHealthCheck

Metadata Update from @rcritten:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata