>From 771d83bd36a06aa6f270ef8188d3ba85fdd68b15 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Thu, 6 Aug 2015 11:09:38 +0200 Subject: [PATCH 1/3] test_memory_cache: Wait short time after cache invalidation The sss_cache cannot invlaidate memory cache directly because the nss responder owns file locks to memory caches. Therefore sss_cache just "tell" nss responder to invalidate memory cache. However there might be short interval between calling the utility sss_cache and stopping sssd. So nss responder needn't be so fast and therefore memory cache neend't be invalidated Resolves: https://fedorahosted.org/sssd/ticket/2748 --- src/tests/intg/test_memory_cache.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/tests/intg/test_memory_cache.py b/src/tests/intg/test_memory_cache.py index 1fd577e652d278c35211b55c871797a3dee98b13..4f61efd47afed69367460c25f7a592114416f6f3 100644 --- a/src/tests/intg/test_memory_cache.py +++ b/src/tests/intg/test_memory_cache.py @@ -618,6 +618,17 @@ def assert_missing_mc_records_for_user1(): "User %s, errno:%d" % (user, err) +def wait_till_nss_responder_invalidate_cache(): + # 1 second (200 * 0.005) should be enough time for nss responder + for _ in range(1, 200): + if os.path.isfile(config.MCACHE_PATH + "/clear_mc_flag"): + time.sleep(.005) + else: + return + + assert False, "nss responder didn't invalidate memory cache within second" + + def test_invalidate_user_before_stop(ldap_conn, sanity_rfc2307): # initialize cache with full ID (res, errno, _) = sssd_id.get_user_groups("user1") @@ -626,6 +637,7 @@ def test_invalidate_user_before_stop(ldap_conn, sanity_rfc2307): assert_mc_records_for_user1() subprocess.call(["sss_cache", "-u", "user1"]) + wait_till_nss_responder_invalidate_cache() stop_sssd() assert_missing_mc_records_for_user1() @@ -652,6 +664,7 @@ def test_invalidate_users_before_stop(ldap_conn, sanity_rfc2307): assert_mc_records_for_user1() subprocess.call(["sss_cache", "-U"]) + wait_till_nss_responder_invalidate_cache() stop_sssd() assert_missing_mc_records_for_user1() @@ -678,6 +691,7 @@ def test_invalidate_group_before_stop(ldap_conn, sanity_rfc2307): assert_mc_records_for_user1() subprocess.call(["sss_cache", "-g", "group1"]) + wait_till_nss_responder_invalidate_cache() stop_sssd() assert_missing_mc_records_for_user1() @@ -704,6 +718,7 @@ def test_invalidate_groups_before_stop(ldap_conn, sanity_rfc2307): assert_mc_records_for_user1() subprocess.call(["sss_cache", "-G"]) + wait_till_nss_responder_invalidate_cache() stop_sssd() assert_missing_mc_records_for_user1() @@ -730,6 +745,7 @@ def test_invalidate_everything_before_stop(ldap_conn, sanity_rfc2307): assert_mc_records_for_user1() subprocess.call(["sss_cache", "-E"]) + wait_till_nss_responder_invalidate_cache() stop_sssd() assert_missing_mc_records_for_user1() -- 2.5.0