Revert only the latest snapshot that matches the test requirements
- add pytest marks 'revert_snapshot' to all required fixtures instead
of reverting the snapshots inside them
- add get_top_fixtures_marks() that extracts all the marks
'revert_snapshot' from the test and it's fixtures, order the marks
in the same way as the fixtures depends on each other,
- in the fixture 'revert_snapshot' try to find the most suitable
snapshot for reverting, from latest to earliest.
Co-Authored-By: Dmitry Tyzhnenko <dtyzhnenko@mirantis.com>
diff --git a/tcp_tests/fixtures/salt_fixtures.py b/tcp_tests/fixtures/salt_fixtures.py
index 047f106..977b38d 100644
--- a/tcp_tests/fixtures/salt_fixtures.py
+++ b/tcp_tests/fixtures/salt_fixtures.py
@@ -36,6 +36,7 @@
return saltmanager.SaltManager(config, underlay)
+@pytest.mark.revert_snapshot(ext.SNAPSHOT.salt_deployed)
@pytest.fixture(scope='function')
def salt_deployed(revert_snapshot, request, config,
hardware, underlay, salt_actions):
@@ -63,14 +64,6 @@
If you want to revert 'salt_deployed' snapshot, please use mark:
@pytest.mark.revert_snapshot("salt_deployed")
"""
- # If no snapshot was reverted, then try to revert the snapshot
- # that belongs to the fixture.
- # Note: keep fixtures in strict dependences from each other!
- if not revert_snapshot:
- if hardware.has_snapshot(ext.SNAPSHOT.salt_deployed) and \
- hardware.has_snapshot_config(ext.SNAPSHOT.salt_deployed):
- hardware.revert_snapshot(ext.SNAPSHOT.salt_deployed)
-
# Create Salt cluster
if config.salt.salt_master_host == '0.0.0.0':
with underlay.yaml_editor(