Ensure inventory tests are cleaned up
At the moment `tox -e inventory` may leave leftovers, which does affect consecutive runs. This is quite annoying, and also may result in extra files in tree to be added to commit accidentally. Change-Id: If7bde86e2770cc2e018376c745e4f3b8bf24dcf8 Signed-off-by: Dmitriy Rabotyagov <dmitriy.rabotyagov@cleura.com>
This commit is contained in:
@@ -70,6 +70,7 @@ releasenotes/build
|
||||
playbooks/root-include-playbook.yml
|
||||
playbooks/include-playbook.yml*
|
||||
playbooks/logs
|
||||
tests/inventory
|
||||
|
||||
# ignore zanata/sphinx cache on translation job
|
||||
.zanata-cache/
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Keep this file to keep the directory.
|
||||
@@ -69,6 +69,7 @@ def make_config():
|
||||
# Allow access here so we can populate the dictionary.
|
||||
global _BASE_CONFIG
|
||||
|
||||
os.makedirs(TARGET_DIR, exist_ok=True)
|
||||
_BASE_CONFIG = tools.make_example_config(AIO_CONFIG_FILE, CONFD)
|
||||
|
||||
tools.write_example_config(USER_CONFIG_FILE, _BASE_CONFIG)
|
||||
@@ -83,6 +84,7 @@ def tearDownModule():
|
||||
# This file should only be removed after all tests are run,
|
||||
# thus it is excluded from cleanup.
|
||||
os.remove(USER_CONFIG_FILE)
|
||||
os.rmdir(TARGET_DIR)
|
||||
|
||||
|
||||
def cleanup():
|
||||
@@ -1350,7 +1352,7 @@ class TestLxcHosts(TestConfigCheckBase):
|
||||
inventory = get_inventory()
|
||||
# insert compute1 into lxc_hosts, which mimicks bug behavior
|
||||
inventory['lxc_hosts']['hosts'].append('compute1')
|
||||
faked_path = INV_DIR
|
||||
faked_path = TARGET_DIR
|
||||
|
||||
with mock.patch('osa_toolkit.filesystem.load_inventory') as inv_mock:
|
||||
inv_mock.return_value = (inventory, faked_path)
|
||||
@@ -1367,7 +1369,7 @@ class TestLxcHosts(TestConfigCheckBase):
|
||||
|
||||
self.assertNotIn('lxc_hosts', inventory.keys())
|
||||
|
||||
faked_path = INV_DIR
|
||||
faked_path = TARGET_DIR
|
||||
with mock.patch('osa_toolkit.filesystem.load_inventory') as inv_mock:
|
||||
inv_mock.return_value = (inventory, faked_path)
|
||||
new_inventory = get_inventory()
|
||||
|
||||
@@ -93,6 +93,9 @@ deps =
|
||||
-r{toxinidir}/global-requirement-pins.txt
|
||||
|
||||
[testenv:inventory]
|
||||
allowlist_externals =
|
||||
{[testenv]allowlist_externals}
|
||||
rm
|
||||
# Use a fixed seed since some inventory tests rely on specific ordering
|
||||
deps =
|
||||
{[testenv]deps}
|
||||
@@ -103,8 +106,10 @@ install_command = pip install {opts} {packages}
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
PYTHONHASHSEED = 100
|
||||
commands =
|
||||
commands_pre =
|
||||
rm -rf {toxinidir}/tests/inventory
|
||||
coverage erase
|
||||
commands =
|
||||
coverage run -a {toxinidir}/tests/test_inventory.py
|
||||
coverage run -a {toxinidir}/tests/test_manage.py
|
||||
coverage run -a {toxinidir}/tests/test_dictutils.py
|
||||
@@ -112,6 +117,8 @@ commands =
|
||||
coverage run -a {toxinidir}/tests/test_filesystem.py
|
||||
coverage run -a {toxinidir}/tests/test_releases.py
|
||||
coverage report --show-missing --include={toxinidir}/inventory/*,{toxinidir}/osa_toolkit/*
|
||||
commands_post =
|
||||
rm -rf {toxinidir}/tests/inventory
|
||||
|
||||
[testenv:py3-inventory]
|
||||
setenv =
|
||||
|
||||
Reference in New Issue
Block a user