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


Testing 4K support
==================

This requires manual setup for creating a block device using 4k sector size,
optionally creating and mounting a file system, and passing the test path to
tests. The setup must be done as root, but the tests can run later as the
current user.

Common setup
------------

1. Create a backing file:

    $ truncate -s 1G /var/tmp/backing

2. Create a loop device with 4k sector size:

    $ sudo losetup -f /var/tmp/backing --show --sector-size=4096
    /dev/loop2

3. Change the device (or mountpoint) owner to current user

    $ sudo chown $USER:$USER /dev/loop2

Testing 4k block device
-----------------------

Run the tests with USER_4K_PATH environment variable:

    $ USER_4K_PATH=/dev/loop2 tox -e py27

Testing 4k file system
----------------------

To test file system on top of 4k block device, create a file system on the
device, mount it, and create a file for testing lockspace or resources:

    $ sudo mkfs.xfs /dev/loop2
    $ sudo mount /dev/loop2 /tmp/sanlock-4k
    $ sudo chown $USER:$USER /tmp/sanlock-4k
    $ truncate -s 128m /tmp/sanlock-4k/disk
    $ USER_4K_PATH=/tmp/sanlock-4k/disk tox -e py27
