-
Notifications
You must be signed in to change notification settings - Fork 7
/
README.dev
97 lines (57 loc) · 2.33 KB
/
README.dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Prerequisites
=============
For Fedora/CentOS install the following packages:
$ sudo yum install -y gcc make libaio-devel libblkid-devel libuuid-devel
For Ubuntu/Debian install the following packages:
$ sudo apt install -y gcc make libaio-dev libblkid-dev uuid-dev
How to test sanlock
===================
To run the python based tests, you need tox. The best way to install a
recent version is to use pip:
$ pip install tox
To run the tests with python 2.7 and 3.6:
$ tox
Note: python 3.6 tests will fail now, since sanlock extension module needs
changes to compile on python 3.
To run only python 2.7:
$ tox -e py27
To run only test from some modules:
$ tox tests/daemon_test.py
To run only tests matching the substring "foo":
$ tox -- -k foo
To run basic lint and style check:
$ tox -e flake8
Sometimes when debugging failing tests verbose mode is useful. You can
enable it using:
$ tox -e py36 tests/python_test.py -- -vv
Or using environment variable:
export PYTEST_ADDOPTS=-vv
Testing 4K support
==================
To enable the 4k tests, you need to have userstorage installed.
First, you need to create a virtual environment
(https://docs.python.org/3/library/venv.html), and then install
the userstorage library from the requirements.txt.
This only needs to be done once:
$ python3 -m venv ~/.venv/sanlock
$ source ~/.venv/sanlock/bin/activate
$ pip install --upgrade pip
$ pip install -r requirements.txt
$ deactivate
Before running the tests, you need to enter the virtual environment:
$ source ~/.venv/sanlock/bin/activate
The shell prompt will change to show the virtual environment name:
(sanlock) [user@hostname sanlock]$
Then, you just need to setup 4k storage for the tests:
$ userstorage create tests/storage.py
This creates two loop devices with 4k sector size; one for testing sanlock with
4k block device, and the other for testing with a filesystem backed by a 4k
block device.
To teardown the storage:
$ userstorage delete tests/storage.py
The script unmounts the filesystem and detaches the loop devices.
The storage helper script uses sudo to perform privileged operations. The best
way to use it is to setup the environment once at the start of the session, and
teardown when you finish.
To deactivate the virtual environment:
$ deactivate