This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit b7b0fe9a2a5488798f2782a7e3ac5e24fa131b0b
Author: Nir Soffer <nsoffer(a)redhat.com>
Date: Thu Jan 11 04:46:20 2018 +0200
Start the daemon tests module
The daemon test module provide the infrastructure to run sanlock daemon
in the tests as the current user. Add a simple test to initialize a
lockspace as example how to use it.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
tests/daemon_test.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/tests/daemon_test.py b/tests/daemon_test.py
new file mode 100644
index 0000000..a3d299f
--- /dev/null
+++ b/tests/daemon_test.py
@@ -0,0 +1,63 @@
+"""
+Test sanlock client operations.
+"""
+
+import io
+import os
+import struct
+import subprocess
+
+import pytest
+
+tests_dir = os.path.dirname(__file__)
+SANLOCK = os.path.join(tests_dir, os.pardir, "src", "sanlock")
+
+ENV = dict(os.environ)
+ENV["SANLOCK_RUN_DIR"] = "/tmp/sanlock"
+ENV["SANLOCK_PRIVILEGED"] = "0"
+
+
+(a)pytest.fixture(scope="session")
+def sanlock_daemon():
+ cmd = [SANLOCK, "daemon",
+ # no fork and print all logging to stderr
+ "-D",
+ # don't use watchdog through wdmd
+ "-w", "0",
+ # don't use mlockall
+ "-l", "0",
+ # don't use high priority (RR) scheduling
+ "-h", "0",
+ # run as current user instead of "sanlock"
+ "-U", ENV["USER"],
+ "-G", ENV["USER"]]
+ p = subprocess.Popen(cmd, env=ENV)
+ try:
+ yield
+ finally:
+ p.terminate()
+ p.wait()
+
+
+def test_init_lockspace(tmpdir, sanlock_daemon):
+ path = tmpdir.join("lockspace")
+ with io.open(str(path), "wb") as f:
+ # Poison with junk data.
+ f.write(b"x" * 1024**2 + b"X" * 512)
+
+ lockspace = "name:1:%s:0" % path
+ run(SANLOCK, "client", "init", "-s", lockspace)
+
+ with io.open(str(path), "rb") as f:
+ magic, = struct.unpack("< I", f.read(4))
+ assert magic == 0x12212010
+
+ # TODO: check more stuff here...
+
+ # Do not modify data after the lockspace area.
+ f.seek(1024**2, io.SEEK_SET)
+ assert f.read(512) == b"X" * 512
+
+
+def run(*args):
+ return subprocess.check_output(args, env=ENV)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.