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/openstack_fixtures.py b/tcp_tests/fixtures/openstack_fixtures.py
index c7e648e..f0a9024 100644
--- a/tcp_tests/fixtures/openstack_fixtures.py
+++ b/tcp_tests/fixtures/openstack_fixtures.py
@@ -38,6 +38,7 @@
return openstack_manager.OpenstackManager(config, underlay)
+@pytest.mark.revert_snapshot(ext.SNAPSHOT.openstack_deployed)
@pytest.fixture(scope='function')
def openstack_deployed(revert_snapshot, request, config,
hardware, underlay, common_services_deployed,
@@ -66,14 +67,6 @@
If you want to revert 'openstack_deployed' snapshot, please use mark:
@pytest.mark.revert_snapshot("openstack_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.openstack_deployed) and \
- hardware.has_snapshot_config(ext.SNAPSHOT.openstack_deployed):
- hardware.revert_snapshot(ext.SNAPSHOT.openstack_deployed)
-
# Create Salt cluster
if not config.openstack.openstack_installed:
steps_path = config.openstack_deploy.openstack_steps_path