-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: alltests/test_offline.py converted
- Loading branch information
Showing
2 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
""" | ||
Automation of offline tests | ||
:requirement: offline | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import time | ||
|
||
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, KnownTopologyGroup | ||
|
||
|
||
@pytest.mark.ticket(bz=1416150) | ||
@pytest.mark.topology(KnownTopologyGroup.AnyProvider) | ||
def test_offline__log_to_syslog(client: Client): | ||
""" | ||
:title: Log to syslog when sssd cannot contact servers goes offline | ||
:setup: | ||
1. Set sssd.conf properly | ||
2. Start SSSD | ||
:steps: | ||
1. Check domain status for default domain | ||
2. Save date and restart SSSD | ||
3. Check journalctl | ||
:expectedresults: | ||
1. Domain is offline | ||
2. Succeed | ||
3. "Backend is offline" found | ||
:customerscenario: True | ||
""" | ||
client.sssd.domain["ldap_uri"] = f"ldaps://typo.{client.host.hostname}" | ||
client.sssd.domain["ldap_sudo_random_offset"] = "0" | ||
client.sssd.start() | ||
|
||
status = client.sssctl.domain_status(client.sssd.default_domain) | ||
assert status.rc == 0, "sssctl domain-status failed" | ||
assert "Offline" in status.stdout, "'Offline' not found in command output" | ||
|
||
date = client.host.ssh.run("date --rfc-3339=s") | ||
client.sssd.restart() | ||
|
||
i = 0 | ||
while i < 80: | ||
time.sleep(1) | ||
# We shorten date output to get correct format | ||
# "2023-10-23 15:01:36+02:00" => "2023-10-23 15:01:36" | ||
log = client.tools.journalctl(unit="sssd", since=date.stdout[0:19]) | ||
if "Backend is offline" in log.stdout: | ||
break | ||
i += 1 | ||
assert "Backend is offline" in log.stdout, "'Backend is offline' is not logged after 80 attempts" | ||
|
||
|
||
@pytest.mark.ticket(bz=1928648) | ||
@pytest.mark.topology(KnownTopology.LDAP) | ||
def test_offline__timeout_setting_in_logs(client: Client, ldap: LDAP): | ||
""" | ||
:title: Each timeout setting is properly logged in logs | ||
:setup: | ||
1. Add user | ||
2. Start SSSD | ||
:steps: | ||
1. Check logs | ||
2. Fetch information about user | ||
3. Block LDAP traffic | ||
4. Connect user over SSH | ||
5. Check logs | ||
:expectedresults: | ||
1. Timeout setting is stored in logs | ||
2. User is found | ||
3. LDAP traffic is blocked | ||
4. User is unable to connect | ||
5. Each timeout setting is stored in logs | ||
:customerscenario: True | ||
""" | ||
ldap.user("user1").add(password="Secret123") | ||
client.sssd.start() | ||
|
||
log = client.fs.read(f"/var/log/sssd/sssd_{client.sssd.default_domain}.log") | ||
assert "Setting 6 seconds timeout" in log | ||
assert "ldap_network_timeout" in log | ||
|
||
assert client.tools.id("user1") is not None | ||
|
||
ldap.firewall.drop(389) | ||
|
||
with pytest.raises(Exception): | ||
client.ssh("user1", "Secret123").connect() | ||
|
||
log = client.fs.read(f"/var/log/sssd/sssd_{client.sssd.default_domain}.log") | ||
for timeout in ["ldap_opt_timeout", "ldap_search_timeout", "ldap_network_timeout", "dns_resolver_timeout"]: | ||
assert timeout in log, f"Value '{timeout}' not found in logs" |