Fix skipping test volume swap
In commit [1] option attach_encrypted_volume started to be used to skip tests for volume swap, the problem is that this option is true by default [2], and now these tests are skipped on all environments. It was
decided to skip these tests in cases when default volume type is encrypted in the same way as it is done for volume transfers [3]. The only difference is that the skip method is added inside resource_setup class method, to allow to skip all tests of the class on setUpClass stage.
[1] https://gerrit.mcp.mirantis.com/c/packaging/sources/tempest/+/173760
[2] https://gerrit.mcp.mirantis.com/plugins/gitiles/packaging/sources/tempest/+/refs/heads/mcp/caracal/tempest/config.py#598
[3] https://gerrit.mcp.mirantis.com/plugins/gitiles/packaging/sources/tempest/+/refs/heads/mcp/caracal/tempest/api/volume/test_volume_transfers.py
Change-Id: Ib0f558c024daab700c0dd4f41c669fe7c3fc3607
Related-Prod: https://mirantis.jira.com/browse/PRODX-48198
(cherry picked from commit 2d37227952d42daa3a50134b836a5940f3ecba12)
diff --git a/tempest/api/compute/admin/test_volume_swap.py b/tempest/api/compute/admin/test_volume_swap.py
index d3331bd..7ae20ce 100644
--- a/tempest/api/compute/admin/test_volume_swap.py
+++ b/tempest/api/compute/admin/test_volume_swap.py
@@ -31,14 +31,32 @@
super(TestVolumeSwapBase, cls).setup_credentials()
@classmethod
+ def setup_clients(cls):
+ super(TestVolumeSwapBase, cls).setup_clients()
+
+ cls.volume_type_client = cls.os_admin.volume_types_client_latest
+ cls.encryption_client = cls.os_admin.encryption_types_client_latest
+
+ @classmethod
def skip_checks(cls):
super(TestVolumeSwapBase, cls).skip_checks()
if not CONF.compute_feature_enabled.swap_volume:
raise cls.skipException("Swapping volumes is not supported.")
- if CONF.compute_feature_enabled.attach_encrypted_volume:
- raise cls.skipException(
- 'Volume swap is not available for OS configurations '
- 'with crypted volumes.')
+
+ @classmethod
+ def _check_default_volume_type(cls):
+ default_volume_type = cls.volume_type_client.\
+ show_default_volume_type()["volume_type"]["id"]
+ volume_encryption = cls.encryption_client.show_encryption_type(
+ default_volume_type)
+ if volume_encryption and volume_encryption.get("provider"):
+ raise cls.skipException("Not allowed to run this test with "
+ "encrypted volume")
+
+ @classmethod
+ def resource_setup(cls):
+ cls._check_default_volume_type()
+ super(TestVolumeSwapBase, cls).resource_setup()
def wait_for_server_volume_swap(self, server_id, old_volume_id,
new_volume_id):