From 4b0e452b0dc9d4db83bd2ea13450202d630849f9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 19 Sep 2014 06:43:20 -0400 Subject: [PATCH] Fix two functional tests within tempest_plugin Couple of functional tests within tempest plugin are generic driver specific, it verifies API actions of security-services, but for reproducing test cases tries create shares and share creation fails if enabled backend driver raises exception in case security-service has fake/improper data. Change-Id: Ib8915f1f7d52a6abc2f34cac4bba18a6ad7eaf46 Closes-Bug: #1371552 --- .../api/share/test_security_services.py | 21 ++++++++++++++++--- .../share/test_security_services_negative.py | 21 ++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/contrib/tempest/tempest/api/share/test_security_services.py b/contrib/tempest/tempest/api/share/test_security_services.py index f75351b42a..c3f8121076 100644 --- a/contrib/tempest/tempest/api/share/test_security_services.py +++ b/contrib/tempest/tempest/api/share/test_security_services.py @@ -13,9 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. +import six # noqa + from tempest.api.share import base +from tempest.openstack.common import log as logging from tempest import test +LOG = logging.getLogger(__name__) + class SecurityServicesTest(base.BaseSharesTest): @@ -76,9 +81,19 @@ class SecurityServicesTest(base.BaseSharesTest): fresh_sn["id"], ss["id"]) self.assertIn(int(resp["status"]), test.HTTP_SUCCESS) - resp, share = self.create_share(share_network_id=fresh_sn["id"], - cleanup_in_class=False) - self.assertIn(int(resp["status"]), test.HTTP_SUCCESS) + # Security service with fake data is used, so if we use backend driver + # that fails on wrong data, we expect error here. + # We require any share that uses our share-network. + try: + resp, share = self.create_share(share_network_id=fresh_sn["id"], + cleanup_in_class=False) + except Exception as e: + # we do wait for either 'error' or 'available' status because + # it is the only available statuses for proper deletion. + LOG.warning("Caught exception. It is expected in case backend " + "fails having security-service with improper data " + "that leads to share-server creation error. " + "%s" % six.text_type(e)) update_data = { "name": "name", diff --git a/contrib/tempest/tempest/api/share/test_security_services_negative.py b/contrib/tempest/tempest/api/share/test_security_services_negative.py index e0db0838ec..b669c0f51d 100644 --- a/contrib/tempest/tempest/api/share/test_security_services_negative.py +++ b/contrib/tempest/tempest/api/share/test_security_services_negative.py @@ -13,10 +13,15 @@ # License for the specific language governing permissions and limitations # under the License. +import six # noqa + from tempest.api.share import base from tempest import exceptions +from tempest.openstack.common import log as logging from tempest import test +LOG = logging.getLogger(__name__) + class SecurityServicesNegativeTest(base.BaseSharesTest): @@ -82,9 +87,19 @@ class SecurityServicesNegativeTest(base.BaseSharesTest): fresh_sn["id"], ss["id"]) self.assertIn(int(resp["status"]), test.HTTP_SUCCESS) - resp, share = self.create_share(share_network_id=fresh_sn["id"], - cleanup_in_class=False) - self.assertIn(int(resp["status"]), test.HTTP_SUCCESS) + # Security service with fake data is used, so if we use backend driver + # that fails on wrong data, we expect error here. + # We require any share that uses our share-network. + try: + resp, share = self.create_share(share_network_id=fresh_sn["id"], + cleanup_in_class=False) + except Exception as e: + # we do wait for either 'error' or 'available' status because + # it is the only available statuses for proper deletion. + LOG.warning("Caught exception. It is expected in case backend " + "fails having security-service with improper data " + "that leads to share-server creation error. " + "%s" % six.text_type(e)) self.assertRaises(exceptions.Unauthorized, self.shares_client.update_security_service,