diff options
author | Lukas Slebodnik <lslebodn@redhat.com> | 2017-03-01 12:38:38 +0100 |
---|---|---|
committer | Lukas Slebodnik <lslebodn@redhat.com> | 2017-03-07 21:34:26 +0100 |
commit | f09e045d46ceaa68ba14d79ec0e1a80af8dfbf5f (patch) | |
tree | 2c1613eb1831cd035f8b7123ccd1b321128e5ce3 /src/tests/intg/test_secrets.py | |
parent | 5424b90e870cf2b9d379df185cb6893c7f8b040c (diff) | |
download | sssd-f09e045d46ceaa68ba14d79ec0e1a80af8dfbf5f.tar.gz sssd-f09e045d46ceaa68ba14d79ec0e1a80af8dfbf5f.tar.xz sssd-f09e045d46ceaa68ba14d79ec0e1a80af8dfbf5f.zip |
test_secrets: Fail in child if sssd_secrets cannot start
If there is a problem to execute sssd_secrets then exception
is raised. Test will not continue in parent process because it is
waiting for socket for a second. The child process will continue
in execution of tests because parent process will kill child
in teardown after test execution.
This patch makes starting of secret service more robust
and immediately fail child process when there was a problem to start
sssd_secrets. It also adds few assertions for ensuring that setup passed
as it should.
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/tests/intg/test_secrets.py')
-rw-r--r-- | src/tests/intg/test_secrets.py | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/tests/intg/test_secrets.py b/src/tests/intg/test_secrets.py index 062dcb665..36f43cd7a 100644 --- a/src/tests/intg/test_secrets.py +++ b/src/tests/intg/test_secrets.py @@ -16,8 +16,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function import os import stat +import sys import config import signal import subprocess @@ -46,20 +48,25 @@ def create_sssd_secrets_fixture(request): resp_path = os.path.join(config.LIBEXEC_PATH, "sssd", "sssd_secrets") secpid = os.fork() + assert secpid >= 0 + if secpid == 0: if subprocess.call([resp_path, "--uid=0", "--gid=0"]) != 0: - raise Exception("sssd_secrets failed to start") - - sock_path = os.path.join(config.RUNSTATEDIR, "secrets.socket") - sck = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - for _ in range(1, 10): - try: - sck.connect(sock_path) - except: - time.sleep(0.1) - else: - break - sck.close() + print("sssd_secrets failed to start") + sys.exit(99) + else: + sock_path = os.path.join(config.RUNSTATEDIR, "secrets.socket") + sck = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + for _ in range(1, 10): + try: + sck.connect(sock_path) + except: + time.sleep(0.1) + else: + break + sck.close() + + assert os.path.exists(sock_path) def sec_teardown(): if secpid == 0: |