From feed02be919d6c60399b27810297ee90d0533b98 Mon Sep 17 00:00:00 2001 From: Scott Poore Date: Thu, 8 Oct 2026 17:54:08 -0500 Subject: [PATCH] tests: clear sssd cache in teardown of AD idmap range tests Reset cache between idmap range tests to avoid invalid cache entries that cause failures for the next test. Details from Claude: The Testidmaprange tests in test_id_mapping.py set a small ldap_idmap_range_size and let sssd cache an idmap slice computed under that value. Each test restored sssd.conf at the end via sssd_conf(action='delete'), but never cleared the sssd cache, and that restore line was skipped whenever the test body failed an assertion first. As a result, the cached idmap slice (computed under the small range_size) survived into later tests. Once the default range_size was restored, the AD backend re-read the stale slice from the cache and rejected it on startup: sdap_idmap_add_domain: BUG: Range maximum exceeds the global maximum: 3082911935 > 2000200000 sdap_idmap_init: Could not add domain ... Unexpected ID map configuration ... remove the sssd cache sssm_ad_init: Unable to init AD module [22]: Invalid argument sssd_be then exited (code 3), sssd failed to start, and every subsequent AD test that performs a realm join + sssd restart failed Add an autouse teardown fixture that restores the default idmap configuration and clears the sssd cache after every test, so it runs even when a test fails. Remove the now-redundant inline sssd_conf(action='delete') cleanup from each test. Assisted-by: Claude Code (Opus 4.8) Reviewed-by: Madhuri Upadhye (cherry picked from commit 493e37fe5981e7234c0d5183be646c029ad39a89) --- src/tests/multihost/ad/test_id_mapping.py | 31 ++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/tests/multihost/ad/test_id_mapping.py b/src/tests/multihost/ad/test_id_mapping.py index dbb9c0a82f3..df3b11cf45f 100644 --- a/src/tests/multihost/ad/test_id_mapping.py +++ b/src/tests/multihost/ad/test_id_mapping.py @@ -22,6 +22,31 @@ class Testidmaprange(object): 2. Add the user using adcli user add. :bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1268902 """ + @pytest.fixture(autouse=True) + def idmap_cleanup(self, multihost): + """Restore default idmap config and wipe sssd cache after each test. + + These tests set a small ldap_idmap_range_size, which makes sssd store + an idmap slice in its cache that is invalid once the default range + size is restored. If the cache is left in place, the AD backend fails + to start on the next realm join ("BUG: Range maximum exceeds the + global maximum"), breaking every subsequent AD test in the run. As a + teardown fixture this runs even when the test body fails before + reaching its own cleanup line. + """ + yield + client = sssdTools(multihost.client[0], multihost.ad[0]) + try: + dom_section = 'domain/%s' % client.get_domain_section_name() + client.sssd_conf( + dom_section, + {'ldap_idmap_range_size': '', + 'ldap_idmap_helper_table_size': '', + 'debug_level': ''}, + action='delete') + finally: + client.clear_sssd_cache() + @pytest.mark.tier1 def test_001_findrid(self, multihost, get_rid): """ @@ -55,7 +80,6 @@ def test_002_rangelessthansid(self, multihost, get_rid): if cmd.returncode == 0: rid = client.find_rid(ad_user) assert rid != 0 or rid is not None - client.sssd_conf(dom_section, sssd_params, action='delete') @pytest.mark.tier2 def test_003_disablerange(self, multihost, get_rid): @@ -91,7 +115,6 @@ def test_003_disablerange(self, multihost, get_rid): assert True else: assert False - client.sssd_conf(dom_section, sssd_params, action='delete') @pytest.mark.tier2 def test_004_rangeequalsid(self, multihost, get_rid): @@ -123,7 +146,6 @@ def test_004_rangeequalsid(self, multihost, get_rid): assert True else: assert False - client.sssd_conf(dom_section, sssd_params, action='delete') @pytest.mark.tier2 def test_005_disablerange(self, multihost, get_rid): @@ -158,7 +180,6 @@ def test_005_disablerange(self, multihost, get_rid): assert True else: assert False - client.sssd_conf(dom_section, sssd_params, action='delete') @pytest.mark.tier2 def test_006_rangevalues(self, multihost, get_rid): @@ -196,7 +217,6 @@ def test_006_rangevalues(self, multihost, get_rid): assert True else: assert False - client.sssd_conf(dom_section, sssd_params, action='delete') @pytest.mark.tier2 def test_007_disablerangevalues(self, multihost, get_rid): @@ -240,4 +260,3 @@ def test_007_disablerangevalues(self, multihost, get_rid): assert True else: assert False - client.sssd_conf(section, sssd_params, action='delete')