From 8e89e66f4ae42220211bc97a6d4ac16dff1c795f Mon Sep 17 00:00:00 2001 From: Dan Lavu Date: Mon, 1 Jul 2024 14:07:57 -0400 Subject: [PATCH] tests: housekeeping - test_failover.py * extended the test to the generic provider * added assertion error messages * improved some grammar and word choice --- src/tests/system/tests/test_failover.py | 61 +++++++++++++++++-------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/src/tests/system/tests/test_failover.py b/src/tests/system/tests/test_failover.py index 565cec9bc40..49f1720db63 100644 --- a/src/tests/system/tests/test_failover.py +++ b/src/tests/system/tests/test_failover.py @@ -7,53 +7,76 @@ from __future__ import annotations import pytest +from sssd_test_framework.roles.ad import AD from sssd_test_framework.roles.client import Client +from sssd_test_framework.roles.generic import GenericProvider +from sssd_test_framework.roles.ipa import IPA from sssd_test_framework.roles.ldap import LDAP -from sssd_test_framework.topology import KnownTopology +from sssd_test_framework.roles.samba import Samba +from sssd_test_framework.topology import KnownTopologyGroup @pytest.mark.parametrize("value, expected", [(None, 31), (15, 31), (60, 60)]) @pytest.mark.importance("low") @pytest.mark.ticket(gh=7375, jira="RHEL-17659") -@pytest.mark.topology(KnownTopology.LDAP) -def test_failover__retry_primary(client: Client, ldap: LDAP, value: int | None, expected: int): +@pytest.mark.topology(KnownTopologyGroup.AnyProvider) +def test_failover__reactivation_timeout_is_honored( + client: Client, provider: GenericProvider, value: int | None, expected: int +): """ - :title: Primary server reactivation timeout is respected + :title: Primary server reactivation timeout is honored :setup: - 1. Create LDAP user "user-1" + 1. Create user "user-1" 2. Set failover_primary_timeout to @value - 3. Set ldap_uri to invalid, not working server - 4. Set ldap_backup_uri to working server + 3. Set server/URI to an invalid server + 4. Set backup server/URI to the server 5. Start SSSD :steps: 1. Lookup user-1 - 2. Check that SSSD is connected to backup server + 2. Check that SSSD is connected to the backup server 3. Find "Primary server reactivation timeout set to @expected seconds" in domain logs :expectedresults: - 1. SSSD failover to backup server - 2. SSSD is indeed connected to the backup server + 1. User is found + 2. SSSD is connected to the backup server 3. String is found :customerscenario: True """ - ldap.user("user-1").add() + provider.user("user-1").add() if value is not None: client.sssd.domain["failover_primary_timeout"] = str(value) client.sssd.enable_responder("ifp") - client.sssd.domain["ldap_uri"] = "ldap://ldap.invalid" - client.sssd.domain["ldap_backup_uri"] = f"ldap://{ldap.host.hostname}" + + if isinstance(provider, LDAP): + client.sssd.domain["ldap_uri"] = "ldap://ldap.invalid" + client.sssd.domain["ldap_backup_uri"] = f"ldap://{provider.host.hostname}" + + if isinstance(provider, AD): + client.sssd.domain["ad_server"] = "invalid.ad.test" + client.sssd.domain["ad_backup_server"] = f"{provider.host.hostname}" + + if isinstance(provider, Samba): + client.sssd.domain["ad_server"] = "invalid.samba.test" + client.sssd.domain["ad_backup_server"] = f"{provider.host.hostname}" + + if isinstance(provider, IPA): + client.sssd.domain["ipa_server"] = "invalid.ipa.test" + client.sssd.domain["ipa_backup_server"] = f"{provider.host.hostname}" + client.sssd.start() - # Lookup user to make sure SSSD did correctly failover to backup server + # Lookup user to make sure SSSD did correctly failover to the backup server result = client.tools.id("user-1") - assert result is not None + assert result is not None, "User is not found!" - # Check that SSSD is indeed connected to backup server - assert client.sssd.default_domain is not None + # Check that SSSD is indeed connected to the backup server + assert client.sssd.default_domain is not None, "Default domain is not set!" status = client.sssctl.domain_status(client.sssd.default_domain, active=True) - assert ldap.host.hostname in status.stdout + assert provider.host.hostname in status.stdout, f"{provider.host.hostname} is not found in domain status!" # Check that primary server reactivation timeout was correctly created log = client.fs.read(client.sssd.logs.domain()) - assert f"Primary server reactivation timeout set to {expected} seconds" in log + assert ( + f"Primary server reactivation timeout set to {expected} seconds" in log + ), f"'Primary server reactivation timeout set to {expected} seconds' not found in logs!"