From 1181a80bf6473d3fe7ed83c0b1df7c738c2a71e5 Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Wed, 8 Feb 2017 15:51:21 -0200 Subject: [PATCH] Optimize opposite driver modes migration test Some operations do not need to be performed before validating if the test will be skipped or not. This will save time when running migration tests, as this test is skipped by several CIs. TrivialFix Change-Id: I84a6ef997c95ca041705adb661dd6b1d2d81bf82 --- .../tests/api/admin/test_migration.py | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/manila_tempest_tests/tests/api/admin/test_migration.py b/manila_tempest_tests/tests/api/admin/test_migration.py index 245360fe6d..5e29fb8c56 100644 --- a/manila_tempest_tests/tests/api/admin/test_migration.py +++ b/manila_tempest_tests/tests/api/admin/test_migration.py @@ -128,6 +128,11 @@ class MigrationNFSTest(base.BaseSharesAdminTest): self._check_migration_enabled(force_host_assisted) + share = self.create_share(self.protocol) + share = self.shares_v2_client.get_share(share['id']) + + share, dest_pool = self._setup_migration(share, opposite=True) + # If currently configured is DHSS=False, # then we need it for DHSS=True if not CONF.share.multitenancy_enabled: @@ -141,11 +146,6 @@ class MigrationNFSTest(base.BaseSharesAdminTest): else: new_share_network_id = None - share = self.create_share(self.protocol) - share = self.shares_v2_client.get_share(share['id']) - - share, dest_pool = self._setup_migration(share, opposite=True) - old_share_network_id = share['share_network_id'] old_share_type_id = share['share_type'] new_share_type_id = self.new_type_opposite['share_type']['id'] @@ -333,6 +333,22 @@ class MigrationNFSTest(base.BaseSharesAdminTest): def _setup_migration(self, share, opposite=False): + if opposite: + dest_type = self.new_type_opposite['share_type'] + else: + dest_type = self.new_type['share_type'] + + dest_pool = utils.choose_matching_backend(share, self.pools, dest_type) + + if opposite: + if not dest_pool: + raise self.skipException( + "This test requires two pools enabled with different " + "driver modes.") + else: + self.assertIsNotNone(dest_pool) + self.assertIsNotNone(dest_pool.get('name')) + old_exports = self.shares_v2_client.list_share_export_locations( share['id']) self.assertNotEmpty(old_exports) @@ -354,22 +370,6 @@ class MigrationNFSTest(base.BaseSharesAdminTest): share['id'], constants.RULE_STATE_ACTIVE, status_attr='access_rules_status') - if opposite: - dest_type = self.new_type_opposite['share_type'] - else: - dest_type = self.new_type['share_type'] - - dest_pool = utils.choose_matching_backend(share, self.pools, dest_type) - - if opposite: - if not dest_pool: - raise self.skipException( - "This test requires two pools enabled with different " - "driver modes.") - else: - self.assertIsNotNone(dest_pool) - self.assertIsNotNone(dest_pool.get('name')) - dest_pool = dest_pool['name'] share = self.shares_v2_client.get_share(share['id'])