From 1d2ed72db700c8918a5f5e98844780c8a7aa9658 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Sat, 15 Dec 2018 02:36:13 -0500 Subject: [PATCH] docker... --- openldap/tests/conftest.py | 50 +++++++++++--------------------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/openldap/tests/conftest.py b/openldap/tests/conftest.py index c298dd775f3f5..752c0d1ebdc2f 100644 --- a/openldap/tests/conftest.py +++ b/openldap/tests/conftest.py @@ -1,9 +1,7 @@ # (C) Datadog, Inc. 2018 # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -import grp import os -import pwd from copy import deepcopy import pytest @@ -16,40 +14,20 @@ @pytest.fixture(scope='session') def dd_environment(): - try: - with TempDir() as d: - host_socket_path = os.path.join(d, 'ldapi') - - if not file_exists(host_socket_path): - os.chmod(d, 0o770) - create_file(host_socket_path) - os.chmod(host_socket_path, 0o640) - stat_info = os.stat(d) - mode = stat_info.st_mode - uid = stat_info.st_uid - gid = stat_info.st_gid - - with docker_run( - compose_file=os.path.join(HERE, 'compose', 'docker-compose.yaml'), - env_vars={'HOST_SOCKET_DIR': d}, - log_patterns='slapd starting', - ): - yield DEFAULT_INSTANCE - - #os.chown(d, 2000, 2000) - os.chmod(d, 0o777) - except: - new_stat_info = os.stat(d) - raise Exception( - 'mode: {} -> {}\n' - 'uid: {} -> {}\n' - 'gid: {} -> {}' - .format( - mode, new_stat_info.st_mode, - uid, new_stat_info.st_uid, - gid, new_stat_info.st_gid, - ) - ) + with TempDir() as d: + host_socket_path = os.path.join(d, 'ldapi') + + if not file_exists(host_socket_path): + os.chmod(d, 0o770) + create_file(host_socket_path) + os.chmod(host_socket_path, 0o640) + + with docker_run( + compose_file=os.path.join(HERE, 'compose', 'docker-compose.yaml'), + env_vars={'HOST_SOCKET_DIR': d}, + log_patterns='slapd starting', + ): + yield DEFAULT_INSTANCE @pytest.fixture