|
6 | 6 |
|
7 | 7 | from __future__ import annotations
|
8 | 8 |
|
| 9 | +import time |
| 10 | +from datetime import datetime as D_T |
| 11 | + |
9 | 12 | import pytest
|
10 | 13 | from sssd_test_framework.roles.ad import AD
|
11 | 14 | from sssd_test_framework.roles.client import Client
|
@@ -305,7 +308,66 @@ def test_netgroup__uid_gt_2147483647(client: Client, provider: GenericProvider):
|
305 | 308 | result = client.tools.getent.passwd(username)
|
306 | 309 | assert result is not None, f"getent passwd for user '{username}' is empty!"
|
307 | 310 | assert result.name == username, f"User name '{username}' did not match result '{result.name}'!"
|
| 311 | + |
308 | 312 | for grpname in ["biggroup1", "biggroup2", "biggroup3"]:
|
309 | 313 | result = client.tools.getent.group(grpname)
|
310 | 314 | assert result is not None, f"getent group for group '{grpname}' is empty!"
|
311 | 315 | 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