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/common_services_fixtures.py b/tcp_tests/fixtures/common_services_fixtures.py
index ed00574..2547a08 100644
--- a/tcp_tests/fixtures/common_services_fixtures.py
+++ b/tcp_tests/fixtures/common_services_fixtures.py
@@ -36,6 +36,7 @@
return common_services_manager.CommonServicesManager(config, underlay)
+@pytest.mark.revert_snapshot(ext.SNAPSHOT.common_services_deployed)
@pytest.fixture(scope='function')
def common_services_deployed(revert_snapshot, request, config,
hardware, underlay, salt_deployed,
@@ -67,15 +68,6 @@
If you want to revert 'common_services_deployed' snapshot, please use mark:
@pytest.mark.revert_snapshot("common_services_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.common_services_deployed) and \
- hardware.has_snapshot_config(
- ext.SNAPSHOT.common_services_deployed):
- hardware.revert_snapshot(ext.SNAPSHOT.common_services_deployed)
-
# Create Salt cluster
if not config.common_services.common_services_installed:
steps_path = config.common_services_deploy.common_services_steps_path