Cache quota size definition tests depend on the host system
Summary
Since !563 (merged) BuildStream checks for the available space on disk. This means that certain configurations can raise exceptions on systems that have too little storage to accommodate the configurations the test cases ask for.
Steps to reproduce
Have a disk that's more than 50% full and run ./setup.py test --addopts '--no-cov tests/artifactcache/expiry.py::test_invalid_cache_quota[50%-True]'
.
What is the current bug behavior?
The test fails.
What is the expected correct behavior?
The test should succeed.
Relevant logs and/or screenshots
tests/artifactcache/expiry.py::test_invalid_cache_quota[50%-True] FAILED [100%]
======================================================================================================================================== FAILURES ========================================================================================================================================
___________________________________________________________________________________________________________________________ test_invalid_cache_quota[50%-True] ___________________________________________________________________________________________________________________________
cli = <tests.testutils.runcli.Cli object at 0x7f52253de400>, datafiles = local('/home/valentin/repos/buildstream-2/tmp/test_invalid_cache_quota_50__T0'), tmpdir = local('/home/valentin/repos/buildstream-2/tmp/test_invalid_cache_quota_50__T0'), quota = '50%', success = True
@pytest.mark.parametrize("quota,success", [
("1", True),
("1K", True),
("50%", True),
("infinity", True),
("0", True),
("-1", False),
("pony", False),
("200%", False)
])
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_cache_quota(cli, datafiles, tmpdir, quota, success):
project = os.path.join(datafiles.dirname, datafiles.basename)
element_path = os.path.join(project, 'elements')
cli.configure({
'cache': {
'quota': quota,
}
})
res = cli.run(project=project, args=['workspace', 'list'])
if success:
> res.assert_success()
tests/artifactcache/expiry.py:262:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.testutils.runcli.Result object at 0x7f5224ea5a90>, fail_message = ''
def assert_success(self, fail_message=''):
> assert self.exit_code == 0, fail_message
E AssertionError:
E assert -1 == 0
E + where -1 = <tests.testutils.runcli.Result object at 0x7f5224ea5a90>.exit_code
tests/testutils/runcli.py:82: AssertionError
---------------------------------------------------------------------------------------------------------------------------------- Captured stdout call ----------------------------------------------------------------------------------------------------------------------------------
BuildStream exited with code -1 for invocation:
bst --no-colors --config /home/valentin/repos/buildstream-2/tmp/test_invalid_cache_quota_50__T0/cache/buildstream.conf --directory /home/valentin/repos/buildstream-2/tmp/test_invalid_cache_quota_50__T0 workspace list
Program stderr was:
Error loading user configuration: Your system does not have enough available space to support the cache quota specified.
You currently have:
- 0B of cache in use at /home/valentin/repos/buildstream-2/tmp/test_invalid_cache_quota_50__T0/cache/artifacts
- 269G of available system storage
Possible fixes
Mock out calls to os.statvfs
in tests/artifactcache/expiry.py
(though only for those tests that assert parsing works).
Other relevant information
- BuildStream version affected: /milestone %BuildStream_v1.4