This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
commit f0f2a0ff50687cb06510582a845c970ab493c8f1
Author: Amit Bawer <abawer(a)redhat.com>
AuthorDate: Tue May 21 14:35:40 2019 +0300
tests: Add pytest.fixture of no_sanlock_daemon
New fixture calls util.sanlock_is_running() to check if the
pid showing in sanlock.pid file (if file exists) leads to local
sanlock executable file to conclude if sanlock is currenlty
running in test env. In case sanlock is running, a SunlockIsRunning
exception will be raised from test.
---
tests/conftest.py | 9 +++++++++
tests/util.py | 17 +++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/tests/conftest.py b/tests/conftest.py
index 93201bb..70e83d4 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -44,3 +44,12 @@ def user_4k_path(request):
"user storage available - run 'python tests/strorage.py setup'
"
"to enable 4k storage tests")
return request.param
+
+
+(a)pytest.fixture
+def no_sanlock_daemon():
+ if util.sanlock_is_running():
+ raise SanlockIsRunning
+
+class SanlockIsRunning(Exception):
+ pass
diff --git a/tests/util.py b/tests/util.py
index d944611..08db236 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -160,3 +160,20 @@ def generate_path(dirname, filename, encoding=None):
if encoding:
path = path.encode(encoding)
return path
+
+
+def sanlock_is_running():
+ """
+ Return boolean value indicating whether sanlock process
+ is currently executing within pytests run dir.
+ """
+ pid_file = os.path.join(os.environ["SANLOCK_RUN_DIR"],
"sanlock.pid")
+ try:
+ with open(pid_file, "r") as f:
+ pid = f.readline().strip()
+ executable = os.readlink("/proc/{}/exe".format(pid))
+ return os.path.samefile(executable, SANLOCK)
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
+ return False
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date