Blame SOURCES/0137-TESTS-Add-a-test-for-parallel-execution-of-klist.patch

ecf709
From 7930ee12093eae1e1ab9422c4f4f9f8c5661fcb9 Mon Sep 17 00:00:00 2001
ecf709
From: Jakub Hrozek <jhrozek@redhat.com>
ecf709
Date: Tue, 23 May 2017 13:55:01 +0200
ecf709
Subject: [PATCH 137/138] TESTS: Add a test for parallel execution of klist
ecf709
MIME-Version: 1.0
ecf709
Content-Type: text/plain; charset=UTF-8
ecf709
Content-Transfer-Encoding: 8bit
ecf709
ecf709
Integration test for:
ecf709
    https://pagure.io/SSSD/sssd/issue/3372
ecf709
ecf709
With https://pagure.io/SSSD/sssd/issue/3372 still broken, the unit test
ecf709
wold fail because one of the concurrent klist commands would trigger a
ecf709
race condition in the KCM queue code, crashing the KCM responder.
ecf709
ecf709
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
ecf709
(cherry picked from commit 274489b092bba5fc81cb0f803843d56b267c5aaf)
ecf709
---
ecf709
 src/tests/intg/krb5utils.py |  6 +++++-
ecf709
 src/tests/intg/test_kcm.py  | 22 ++++++++++++++++++++++
ecf709
 2 files changed, 27 insertions(+), 1 deletion(-)
ecf709
ecf709
diff --git a/src/tests/intg/krb5utils.py b/src/tests/intg/krb5utils.py
ecf709
index 775cffd0bbfa011f2d8ffc1169dccfef96d78fab..0349ff3829533088fb2263f84b19574127d6e809 100644
ecf709
--- a/src/tests/intg/krb5utils.py
ecf709
+++ b/src/tests/intg/krb5utils.py
ecf709
@@ -36,7 +36,7 @@ class Krb5Utils(object):
ecf709
     def __init__(self, krb5_conf_path):
ecf709
         self.krb5_conf_path = krb5_conf_path
ecf709
 
ecf709
-    def _run_in_env(self, args, stdin=None, extra_env=None):
ecf709
+    def spawn_in_env(self, args, stdin=None, extra_env=None):
ecf709
         my_env = os.environ
ecf709
         my_env['KRB5_CONFIG'] = self.krb5_conf_path
ecf709
 
ecf709
@@ -50,6 +50,10 @@ class Krb5Utils(object):
ecf709
                                stdin=subprocess.PIPE,
ecf709
                                stdout=subprocess.PIPE,
ecf709
                                stderr=subprocess.PIPE)
ecf709
+        return cmd
ecf709
+
ecf709
+    def _run_in_env(self, args, stdin=None, extra_env=None):
ecf709
+        cmd = self.spawn_in_env(args, stdin, extra_env)
ecf709
         out, err = cmd.communicate(stdin)
ecf709
         return cmd.returncode, out.decode('utf-8'), err.decode('utf-8')
ecf709
 
ecf709
diff --git a/src/tests/intg/test_kcm.py b/src/tests/intg/test_kcm.py
ecf709
index 11f80a1803b4ad9b8e8857bf9a8a244d4816f0a2..1ab2a1837687a6c2cf8676124b42538833550c91 100644
ecf709
--- a/src/tests/intg/test_kcm.py
ecf709
+++ b/src/tests/intg/test_kcm.py
ecf709
@@ -445,3 +445,25 @@ def test_kcm_sec_kdestroy_nocache(setup_for_kcm_sec,
ecf709
                                   setup_secrets):
ecf709
     testenv = setup_for_kcm_sec
ecf709
     exercise_subsidiaries(testenv)
ecf709
+
ecf709
+def test_kcm_sec_parallel_klist(setup_for_kcm_sec,
ecf709
+                                setup_secrets):
ecf709
+    """
ecf709
+    Test that parallel operations from a single UID are handled well.
ecf709
+    Regression test for https://pagure.io/SSSD/sssd/issue/3372
ecf709
+    """
ecf709
+    testenv = setup_for_kcm_sec
ecf709
+
ecf709
+    testenv.k5kdc.add_principal("alice", "alicepw")
ecf709
+    out, _, _ = testenv.k5util.kinit("alice", "alicepw")
ecf709
+    assert out == 0
ecf709
+
ecf709
+
ecf709
+    processes = []
ecf709
+    for i in range(0,10):
ecf709
+        p = testenv.k5util.spawn_in_env(['klist', '-A'])
ecf709
+        processes.append(p)
ecf709
+
ecf709
+    for p in processes:
ecf709
+        rc = p.wait()
ecf709
+        assert rc == 0
ecf709
-- 
ecf709
2.9.4
ecf709