CA-146822: fix intermittent test failures

As the lock test was querying the GC for the collected locks, it might
be possible that when the test starts, there is already an uncollected
lock in the GC. To avoid this situation, run the GC, so only the garbage
created by the test will be collected.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Flavien Quesnel <flavien.quesnel@citrix.com>

GitHub: closes #222 on xapi-project/sm
CA-146138: don't refresh slaves for local SRs

Don't try to synchronise logical volumes on other slaves for a SR that
is local to the host, it doesn't make any sense and can cause all sorts
of problems.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>
CA-146138: improve error message when srcmd.params is malformed

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>
CA-146138: unit test for LV refresh on other hosts

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>
CA-146138: various improvements over unit test

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>
Merge branch 'CA-146138' into xs64bit

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #221 on xapi-project/sm
CA-146822: Remove TestLockDestruction

Remove TestLockDestruction to avoid intermittent test failures

Signed-off-by: Flavien Quesnel <flavien.quesnel@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>

GitHub: closes #224 on xapi-project/sm
CP-8514: [UnitTest] Add fake LVM subsystem

This test helper makes it possible to fake the lvm layer. This first
patch emulates the lvcreate command.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
CP-8514: [UnitTest] Add tests for lvutil.create

These changes test the lvutil.create method just before the TRIM
functionality was added.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
CP-8514: [UnitTest] Mock out os.stat

As the LVM operations use os.stat to detect the existence of a given
path, it needs to be mocked out. This change adds a simple
implementation, which does not return the expected stat information,
just raises an OSError if the file does not exists.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
CP-8514: [UnitTest] Mock out lvremove and dmsetup

To test lvutil.remove, the /usr/bin/lvremove and /sbin/dmsetup system
utilities mocked out with a primitive implementation. dmsetup will just
return 0 with empty stdout and stderr, which seems to be enough for now.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
CP-8514: [UnitTest] Cover lvutil.remove

Testing the behavior of lvutil.remove.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
CP-8514: [UnitTest] lvutil.lvcreate and lvremove

Test functionality for lvcreate size_in_percentage, additional
config_param arg for lvremove

Signed-off-by: Vineeth Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>
Merge branch 'TRIM-UNITTESTS' into xs64bit

GitHub: closes #178 on xapi-project/sm
CA-145685: Create a tap disk to pass the host DVD drive to a PV guest

Signed-off-by: Flavien Quesnel <flavien.quesnel@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
CA-145685: [UnitTest] Add unit tests

Signed-off-by: Flavien Quesnel <flavien.quesnel@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Merge CA-145685 into xs64bit

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>

GitHub: closes #223 on xapi-project/sm
Pin coverage's version

Coverage 4 appeared on pypi, which is not compatible with old python
interpreters. Pinning coverage to 3.7.1

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Flavien Quesnel <flavien.quesnel@citrix.com>

GitHub: closes #225 on xapi-project/sm
Revert "Merge CA-145685 into xs64bit"

This reverts commit e409963be9a44636fb2a4ade304bbb2d3e4056bc, reversing
changes made to b4fa67284dd6a14dde5982d1a5934e7ff816964e.

Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>
CA-145177: [UnitTest] unit tests for flock.py

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>