Skip to content

Commit 3adc070

Browse files
committed
Tests: Test trasformation SSSD does not crash in nss responder after netgroup timeout when backend is offline
SSSD does not crash in nss responder after netgroup timeout when backend is offline
1 parent 196ad92 commit 3adc070

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

src/tests/system/tests/test_netgroups.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66

77
from __future__ import annotations
88

9+
import time
10+
from datetime import datetime as D_T
11+
912
import pytest
1013
from sssd_test_framework.roles.ad import AD
1114
from sssd_test_framework.roles.client import Client
1215
from sssd_test_framework.roles.generic import GenericProvider
16+
from sssd_test_framework.roles.ipa import IPA
1317
from sssd_test_framework.roles.ldap import LDAP
1418
from sssd_test_framework.roles.samba import Samba
1519
from sssd_test_framework.topology import KnownTopology, KnownTopologyGroup
@@ -305,7 +309,66 @@ def test_netgroup__uid_gt_2147483647(client: Client, provider: GenericProvider):
305309
result = client.tools.getent.passwd(username)
306310
assert result is not None, f"getent passwd for user '{username}' is empty!"
307311
assert result.name == username, f"User name '{username}' did not match result '{result.name}'!"
312+
308313
for grpname in ["biggroup1", "biggroup2", "biggroup3"]:
309314
result = client.tools.getent.group(grpname)
310315
assert result is not None, f"getent group for group '{grpname}' is empty!"
311316
assert result.name == grpname, f"Group name '{grpname}' did not match result '{result.name}'!"
317+
318+
319+
@pytest.mark.importance("low")
320+
@pytest.mark.topology(KnownTopologyGroup.AnyProvider)
321+
def test_netgroup__sssd_entry_cache_nowait_percentage(client: Client, provider: GenericProvider):
322+
"""
323+
:title: Test SSSD netgroup caching with 'entry_cache_nowait_percentage'
324+
:setup:
325+
1. A netgroup is created and member is added to the netgroup
326+
2. SSSD is configured with entry_cache_nowait_percentage
327+
3. The domain "test" is updated with `entry_cache_timeout` set to 30 seconds
328+
4. SSSD is restarted with the `clean=True` option to apply the new configuration
329+
:steps:
330+
1. Record the initial response time for netgroup query
331+
2. Introduce a network delay of 50 seconds
332+
3. Execute another query for netgroup
333+
4. Record the response time and verify it is faster than the initial query
334+
5. Check the SSSD NSS logs for the presence of the log entry:
335+
"Performing midpoint cache update of [netgrp_nowait@test]"
336+
:expectedresults:
337+
1. The query should return the netgroup with the correct name
338+
2. Network delayed for 50 seconds
339+
3. Query is executed
340+
4. The response time for subsequent queries should be faster than the initial query
341+
5. The expected log entries are present in the logs
342+
:customerscenario: True
343+
"""
344+
if isinstance(provider, IPA):
345+
pytest.skip("IPA does not support domain in netgroups")
346+
347+
netgroup_group = provider.netgroup("netgrp_nowait").add()
348+
netgroup_group.add_member(host="host1", user="kau10", domain="example.com")
349+
client.sssd.nss.update(
350+
filter_groups="root", filter_users="root", debug_level="9", entry_cache_nowait_percentage="50"
351+
)
352+
client.sssd.dom("test").update(entry_cache_timeout="30")
353+
client.sssd.restart(clean=True)
354+
355+
start = D_T.now()
356+
result = client.tools.getent.netgroup(netgroup_group.name)
357+
assert result is not None, "Could not get netgroup netgrp_nowait"
358+
assert result.name == "netgrp_nowait"
359+
end = D_T.now()
360+
res_time = end - start
361+
362+
client.tc.add_delay(provider, "50s")
363+
time.sleep(16)
364+
start = D_T.now()
365+
result = client.tools.getent.netgroup("netgrp_nowait")
366+
assert result is not None, "Could not get netgroup netgrp_nowait"
367+
assert result.name == "netgrp_nowait"
368+
end = D_T.now()
369+
catch_response = end - start
370+
client.tc.remove_delay(provider)
371+
372+
read_nss = client.fs.read("/var/log/sssd/sssd_nss.log")
373+
assert catch_response < res_time, "Test failed as the cache response time is higher."
374+
assert "Performing midpoint cache update of [netgrp_nowait@test]" in read_nss

0 commit comments

Comments
 (0)