Fix test_cache_hard_links when on tmpfs
When running with the test root on tmpfs the test_cache_hard_links
fails because in this case du reports 0 as usage for the link instead
of 1 block(s). Adapt the test for that.
Also honor the ZUUL_TEST_ROOT variable if it is present.
Change-Id: Ie5789299de4b23161d80e5375f8a94be109b67f4
diff --git a/tests/unit/test_disk_accountant.py b/tests/unit/test_disk_accountant.py
index 40b3b72..db38d45 100644
--- a/tests/unit/test_disk_accountant.py
+++ b/tests/unit/test_disk_accountant.py
@@ -33,7 +33,8 @@
class TestDiskAccountant(BaseTestCase):
def test_disk_accountant(self):
- jobs_dir = tempfile.mkdtemp()
+ jobs_dir = tempfile.mkdtemp(
+ dir=os.environ.get("ZUUL_TEST_ROOT", None))
cache_dir = tempfile.mkdtemp()
executor_server = FakeExecutor()
da = DiskAccountant(jobs_dir, 1, executor_server.stopJobByJobDir,
@@ -58,7 +59,8 @@
self.assertFalse(da.thread.is_alive())
def test_cache_hard_links(self):
- root_dir = tempfile.mkdtemp()
+ root_dir = tempfile.mkdtemp(
+ dir=os.environ.get("ZUUL_TEST_ROOT", None))
jobs_dir = os.path.join(root_dir, 'jobs')
os.mkdir(jobs_dir)
cache_dir = os.path.join(root_dir, 'cache')
@@ -88,6 +90,6 @@
try:
self.assertEqual(set(), executor_server.stopped_jobs)
self.assertIn(jobdir, executor_server.used)
- self.assertEqual(1, executor_server.used[jobdir])
+ self.assertTrue(executor_server.used[jobdir] <= 1)
finally:
da.stop()