From ed62a751c56b273362aa11696a3e72ae05f714f2 Mon Sep 17 00:00:00 2001 From: yogesh Date: Mon, 26 Jun 2017 13:16:12 -0400 Subject: [PATCH] [Tempest] Fix tests for pre-existing share network Currently tempest tests do not support creating and adding Security Service to newly created share networks. This causes CIFS multitenancy tests to fail on some of the backends. Therefore, having pre-existing share network helps testing such scenarios. When using a pre-existing share network, we can still test the share network API and create share networks, however, we shouldn't create shares on such networks. So, any tests that create new share networks and use them to create shares need to be skipped. - This patch makes sure that the pre-existing share_network is not cleaned up. - One share_server related test is skipped to avoid deleting share network as part of test. - One share network negative test is skipped to avoid creating a share with new share network. Change-Id: I272806b05c8b4d30451d0cf4b9dd3f366b8bf728 Closes-Bug: #1698429 (cherry picked from commit 29a52269aa0d70006e2f0537780e68369da619d0) --- .../tests/api/admin/test_share_servers.py | 3 +++ manila_tempest_tests/tests/api/base.py | 11 +++++++---- .../tests/api/test_share_networks_negative.py | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/manila_tempest_tests/tests/api/admin/test_share_servers.py b/manila_tempest_tests/tests/api/admin/test_share_servers.py index 0c784e9827..c387ed27f4 100644 --- a/manila_tempest_tests/tests/api/admin/test_share_servers.py +++ b/manila_tempest_tests/tests/api/admin/test_share_servers.py @@ -195,6 +195,9 @@ class ShareServersAdminTest(base.BaseSharesAdminTest): @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND) @ddt.data(True, False) + @testtools.skipIf(CONF.share.share_network_id != "", + "This test is not suitable for pre-existing " + "share_network.") def test_delete_share_server(self, delete_share_network): # Get network and subnet from existing share_network and reuse it # to be able to delete share_server after test ends. diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py index 260e85d3ca..96b2574a8f 100644 --- a/manila_tempest_tests/tests/api/base.py +++ b/manila_tempest_tests/tests/api/base.py @@ -406,7 +406,9 @@ class BaseSharesTest(test.BaseTestCase): cleanup_in_class=True, is_public=False, **kwargs): client = client or cls.shares_v2_client description = description or "Tempest's share" - share_network_id = share_network_id or client.share_network_id or None + share_network_id = (share_network_id or + CONF.share.share_network_id or + client.share_network_id or None) metadata = metadata or {} size = size or CONF.share.share_size kwargs.update({ @@ -885,9 +887,10 @@ class BaseSharesTest(test.BaseTestCase): elif res["type"] is "snapshot": client.delete_snapshot(res_id) client.wait_for_resource_deletion(snapshot_id=res_id) - elif res["type"] is "share_network": - client.delete_share_network(res_id) - client.wait_for_resource_deletion(sn_id=res_id) + elif (res["type"] is "share_network" and + res_id != CONF.share.share_network_id): + client.delete_share_network(res_id) + client.wait_for_resource_deletion(sn_id=res_id) elif res["type"] is "security_service": client.delete_security_service(res_id) client.wait_for_resource_deletion(ss_id=res_id) diff --git a/manila_tempest_tests/tests/api/test_share_networks_negative.py b/manila_tempest_tests/tests/api/test_share_networks_negative.py index 0ec9407eae..cc9581837a 100644 --- a/manila_tempest_tests/tests/api/test_share_networks_negative.py +++ b/manila_tempest_tests/tests/api/test_share_networks_negative.py @@ -111,6 +111,9 @@ class ShareNetworksNegativeTest(base.BaseSharesTest): @testtools.skipIf(not CONF.share.multitenancy_enabled, 'Can run only with drivers that do handle share servers ' 'creation. Skipping.') + @testtools.skipIf(CONF.share.share_network_id != "", + "This test is not suitable for pre-existing " + "share_network.") def test_try_delete_share_network_with_existing_shares(self): # Get valid network data for successful share creation share_network = self.shares_client.get_share_network(