From 85be51a9535b39ec5a67c3bc85957e95bb061a74 Mon Sep 17 00:00:00 2001
From: Ofek Lev <ofekmeister@gmail.com>
Date: Sat, 15 Dec 2018 00:46:32 -0500
Subject: [PATCH] debug

---
 openldap/tests/conftest.py | 46 ++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/openldap/tests/conftest.py b/openldap/tests/conftest.py
index 76b7ef02cab75..c298dd775f3f5 100644
--- a/openldap/tests/conftest.py
+++ b/openldap/tests/conftest.py
@@ -1,7 +1,9 @@
 # (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
@@ -14,20 +16,40 @@
 
 @pytest.fixture(scope='session')
 def dd_environment():
-    with TempDir() as d:
-        host_socket_path = os.path.join(d, 'ldapi')
+    try:
+        with TempDir() as d:
+            host_socket_path = os.path.join(d, 'ldapi')
 
-        if not file_exists(host_socket_path):
+            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)
-            create_file(host_socket_path)
-            os.chmod(host_socket_path, 0o777)
-
-        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
+    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,
+            )
+        )
 
 
 @pytest.fixture