diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2017-05-23 13:55:01 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2017-05-24 15:58:16 +0200 |
commit | 274489b092bba5fc81cb0f803843d56b267c5aaf (patch) | |
tree | c2694cdf273ccc5a8e70e422deca0a6c17c4722f | |
parent | fb51bb68e62de7bb8542f5d224994eb7143040a6 (diff) | |
download | sssd-274489b092bba5fc81cb0f803843d56b267c5aaf.tar.gz sssd-274489b092bba5fc81cb0f803843d56b267c5aaf.tar.xz sssd-274489b092bba5fc81cb0f803843d56b267c5aaf.zip |
TESTS: Add a test for parallel execution of klist
Integration test for:
https://pagure.io/SSSD/sssd/issue/3372
With https://pagure.io/SSSD/sssd/issue/3372 still broken, the unit test
wold fail because one of the concurrent klist commands would trigger a
race condition in the KCM queue code, crashing the KCM responder.
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
-rw-r--r-- | src/tests/intg/krb5utils.py | 6 | ||||
-rw-r--r-- | src/tests/intg/test_kcm.py | 22 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/tests/intg/krb5utils.py b/src/tests/intg/krb5utils.py index 775cffd0b..0349ff382 100644 --- a/src/tests/intg/krb5utils.py +++ b/src/tests/intg/krb5utils.py @@ -36,7 +36,7 @@ class Krb5Utils(object): def __init__(self, krb5_conf_path): self.krb5_conf_path = krb5_conf_path - def _run_in_env(self, args, stdin=None, extra_env=None): + def spawn_in_env(self, args, stdin=None, extra_env=None): my_env = os.environ my_env['KRB5_CONFIG'] = self.krb5_conf_path @@ -50,6 +50,10 @@ class Krb5Utils(object): stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + return cmd + + def _run_in_env(self, args, stdin=None, extra_env=None): + cmd = self.spawn_in_env(args, stdin, extra_env) out, err = cmd.communicate(stdin) return cmd.returncode, out.decode('utf-8'), err.decode('utf-8') diff --git a/src/tests/intg/test_kcm.py b/src/tests/intg/test_kcm.py index 11f80a180..1ab2a1837 100644 --- a/src/tests/intg/test_kcm.py +++ b/src/tests/intg/test_kcm.py @@ -445,3 +445,25 @@ def test_kcm_sec_kdestroy_nocache(setup_for_kcm_sec, setup_secrets): testenv = setup_for_kcm_sec exercise_subsidiaries(testenv) + +def test_kcm_sec_parallel_klist(setup_for_kcm_sec, + setup_secrets): + """ + Test that parallel operations from a single UID are handled well. + Regression test for https://pagure.io/SSSD/sssd/issue/3372 + """ + testenv = setup_for_kcm_sec + + testenv.k5kdc.add_principal("alice", "alicepw") + out, _, _ = testenv.k5util.kinit("alice", "alicepw") + assert out == 0 + + + processes = [] + for i in range(0,10): + p = testenv.k5util.spawn_in_env(['klist', '-A']) + processes.append(p) + + for p in processes: + rc = p.wait() + assert rc == 0 |