Skip to content

Commit

Permalink
tests: housekeeping - test_failover.py
Browse files Browse the repository at this point in the history
* extended the test to the generic provider
* added assertion error messages
* improved some grammar and word choice
  • Loading branch information
Dan Lavu committed Jul 1, 2024
1 parent b44cb57 commit edccffc
Showing 1 changed file with 38 additions and 19 deletions.
57 changes: 38 additions & 19 deletions src/tests/system/tests/test_failover.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,70 @@
import pytest
from sssd_test_framework.roles.client import Client
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.roles.ad import AD
from sssd_test_framework.roles.ipa import IPA
from sssd_test_framework.roles.generic import GenericProvider
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, Samba)):
client.sssd.domain["ad_server"] = "invalid.ad.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!"

0 comments on commit edccffc

Please sign in to comment.