From 05cc1e6c7208f405e04fab8e711612fcc4936c02 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Feb 26 2018 19:08:52 +0000 Subject: Add tests/constants module This module keeps constants copied from sanlock source, used by the tests. Signed-off-by: Nir Soffer --- diff --git a/tests/constants.py b/tests/constants.py new file mode 100644 index 0000000..70f4226 --- /dev/null +++ b/tests/constants.py @@ -0,0 +1,9 @@ +""" +Constants copied from sanlock source. +""" + +# src/leader.h + +PAXOS_DISK_MAGIC = 0x06152010 +PAXOS_DISK_CLEAR = 0x11282016 +DELTA_DISK_MAGIC = 0x12212010 diff --git a/tests/daemon_test.py b/tests/daemon_test.py index 1e94563..9697658 100644 --- a/tests/daemon_test.py +++ b/tests/daemon_test.py @@ -9,6 +9,7 @@ import subprocess import pytest +from . import constants from . import util @@ -53,7 +54,7 @@ def test_init_lockspace(tmpdir, sanlock_daemon): with io.open(str(path), "rb") as f: magic, = struct.unpack("< I", f.read(4)) - assert magic == 0x12212010 + assert magic == constants.DELTA_DISK_MAGIC # TODO: check more stuff here... diff --git a/tests/direct_test.py b/tests/direct_test.py index fa7c572..eca118b 100644 --- a/tests/direct_test.py +++ b/tests/direct_test.py @@ -5,6 +5,7 @@ Test sanlock direct options. import io import struct +from . import constants from . import util @@ -19,7 +20,7 @@ def test_init_lockspace(tmpdir): with io.open(str(path), "rb") as f: magic, = struct.unpack("< I", f.read(4)) - assert magic == 0x12212010 + assert magic == constants.DELTA_DISK_MAGIC # TODO: check more stuff here... diff --git a/tests/python_test.py b/tests/python_test.py index e455e11..9f1b9a0 100644 --- a/tests/python_test.py +++ b/tests/python_test.py @@ -7,6 +7,8 @@ import struct import sanlock +from . import constants + def test_write_lockspace(tmpdir, sanlock_daemon): path = tmpdir.join("lockspace") @@ -18,7 +20,7 @@ def test_write_lockspace(tmpdir, sanlock_daemon): with io.open(str(path), "rb") as f: magic, = struct.unpack("< I", f.read(4)) - assert magic == 0x12212010 + assert magic == constants.DELTA_DISK_MAGIC # TODO: check more stuff here...