Skip to content

Commit 2698672

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 2698672

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

src/tests/system/tests/test_netgroups.py

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

0 commit comments

Comments
 (0)