From e0152b4e6d75b0d8e90c77e2731864a25e412a58 Mon Sep 17 00:00:00 2001 From: Lin Yang Date: Sun, 12 Jun 2016 18:16:40 +0800 Subject: [PATCH] Change to tempest stable API Previously several places in murano tempest test use unstable tempest api. In fact, it should use api from tempest.lib.* [1]. So fixed them to make them more robust and resilient to tempest changes. The unstable api removed here include: * tempest.clients * tempest.test [1] http://docs.openstack.org/developer/tempest/plugin.html#stable-tempest-apis-plugins-may-use Change-Id: I018b00cc026a707da6afe40a327b44e97c16db53 Related-Bug: #1589713 --- murano_tempest_tests/clients.py | 34 ++++++++++++++++--- .../tests/api/application_catalog/base.py | 18 +++++++--- .../application_catalog/test_categories.py | 11 +++--- .../test_categories_negative.py | 10 +++--- .../application_catalog/test_env_templates.py | 20 +++++------ .../test_env_templates_negative.py | 21 ++++++------ .../application_catalog/test_environments.py | 12 +++---- .../test_environments_negative.py | 15 ++++---- .../application_catalog/test_repository.py | 17 +++++----- .../test_repository_negative.py | 26 +++++++------- .../api/application_catalog/test_services.py | 10 +++--- .../test_services_negative.py | 29 ++++++++-------- .../api/application_catalog/test_sessions.py | 8 ++--- .../test_sessions_negative.py | 21 ++++++------ .../tests/api/service_broker/base.py | 16 ++++++--- .../test_service_broker_actions.py | 17 ++++++---- .../test_service_broker_negative.py | 6 ++-- 17 files changed, 169 insertions(+), 122 deletions(-) diff --git a/murano_tempest_tests/clients.py b/murano_tempest_tests/clients.py index 0c35cf353..b76c4bdfc 100644 --- a/murano_tempest_tests/clients.py +++ b/murano_tempest_tests/clients.py @@ -13,20 +13,22 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest import clients from tempest.common import credentials_factory as common_creds +from tempest import config +from tempest.lib import auth from murano_tempest_tests.services.application_catalog \ import application_catalog_client from murano_tempest_tests.services.service_broker import service_broker_client +CONF = config.CONF -class Manager(clients.Manager): + +class Manager(object): def __init__(self, credentials=common_creds.get_configured_admin_credentials( - 'identity_admin'), - service=None): - super(Manager, self).__init__(credentials, service) + 'identity_admin')): + self.auth_provider = get_auth_provider(credentials) self.service_broker_client = service_broker_client.ServiceBrokerClient( self.auth_provider) self.application_catalog_client = \ @@ -38,3 +40,25 @@ class AltManager(Manager): def __init__(self, service=None): super(AltManager, self).__init__( common_creds.get_configured_admin_credentials('alt_user'), service) + + +def get_auth_provider(credentials, scope='project'): + default_params = { + 'disable_ssl_certificate_validation': + CONF.identity.disable_ssl_certificate_validation, + 'ca_certs': CONF.identity.ca_certificates_file, + 'trace_requests': CONF.debug.trace_requests + } + + if isinstance(credentials, auth.KeystoneV3Credentials): + auth_provider_class, auth_url = \ + auth.KeystoneV3AuthProvider, CONF.identity.uri_v3 + else: + auth_provider_class, auth_url = \ + auth.KeystoneV2AuthProvider, CONF.identity.uri + + _auth_provider = auth_provider_class(credentials, auth_url, + scope=scope, + **default_params) + _auth_provider.set_auth() + return _auth_provider diff --git a/murano_tempest_tests/tests/api/application_catalog/base.py b/murano_tempest_tests/tests/api/application_catalog/base.py index 331b8d39b..c9f265fc8 100644 --- a/murano_tempest_tests/tests/api/application_catalog/base.py +++ b/murano_tempest_tests/tests/api/application_catalog/base.py @@ -16,7 +16,7 @@ from tempest.common import credentials_factory as common_creds from tempest.common import dynamic_creds from tempest import config -from tempest import test +from tempest.lib import base from murano_tempest_tests import clients from murano_tempest_tests import utils @@ -24,9 +24,19 @@ from murano_tempest_tests import utils CONF = config.CONF -class BaseApplicationCatalogTest(test.BaseTestCase): +class BaseApplicationCatalogTest(base.BaseTestCase): """Base test class for Murano Service Broker API tests.""" + @classmethod + def setUpClass(cls): + super(BaseApplicationCatalogTest, cls).setUpClass() + cls.resource_setup() + + @classmethod + def tearDownClass(cls): + cls.resource_cleanup() + super(BaseApplicationCatalogTest, cls).tearDownClass() + @classmethod def get_client_with_isolated_creds(cls, type_of_creds="admin"): @@ -39,7 +49,7 @@ class BaseApplicationCatalogTest(test.BaseTestCase): @classmethod def get_configured_isolated_creds(cls, type_of_creds='admin'): - identity_version = cls.get_identity_version() + identity_version = CONF.identity.auth_version if identity_version == 'v3': cls.admin_role = CONF.identity.admin_role else: @@ -72,7 +82,6 @@ class BaseApplicationCatalogTest(test.BaseTestCase): if not CONF.service_available.murano: skip_msg = "Murano is disabled" raise cls.skipException(skip_msg) - super(BaseApplicationCatalogTest, cls).resource_setup() if not hasattr(cls, "os"): creds = cls.get_configured_isolated_creds(type_of_creds='primary') cls.os = clients.Manager(credentials=creds) @@ -80,7 +89,6 @@ class BaseApplicationCatalogTest(test.BaseTestCase): @classmethod def resource_cleanup(cls): - super(BaseApplicationCatalogTest, cls).resource_cleanup() cls.clear_isolated_creds() @classmethod diff --git a/murano_tempest_tests/tests/api/application_catalog/test_categories.py b/murano_tempest_tests/tests/api/application_catalog/test_categories.py index 922084197..16ef91bcf 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_categories.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_categories.py @@ -13,8 +13,7 @@ # under the License. import os - -from tempest.test import attr +import testtools from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -41,12 +40,12 @@ class TestCategories(base.BaseApplicationCatalogIsolatedAdminTest): cls.application_catalog_client.delete_category(cls.category['id']) super(TestCategories, cls).resource_cleanup() - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_list_categories(self): categories_list = self.application_catalog_client.list_categories() self.assertIsInstance(categories_list, list) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_create_and_delete_category(self): name = utils.generate_name('create_and_delete_category') categories_list = self.application_catalog_client.list_categories() @@ -59,14 +58,14 @@ class TestCategories(base.BaseApplicationCatalogIsolatedAdminTest): categories_list = self.application_catalog_client.list_categories() self.assertNotIn(name, categories_list) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_category(self): category = self.application_catalog_client.get_category( self.category['id']) self.assertEqual(self.category['id'], category['id']) self.assertEqual(self.category['name'], category['name']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_add_package_to_new_category_and_remove_it_from_category(self): category = self.application_catalog_client.get_category( self.category['id']) diff --git a/murano_tempest_tests/tests/api/application_catalog/test_categories_negative.py b/murano_tempest_tests/tests/api/application_catalog/test_categories_negative.py index 681ead6f1..9122dde43 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_categories_negative.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_categories_negative.py @@ -13,9 +13,9 @@ # under the License. import os +import testtools from tempest.lib import exceptions -from tempest.test import attr from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -43,25 +43,25 @@ class TestCategoriesNegative(base.BaseApplicationCatalogIsolatedAdminTest): cls.application_catalog_client.delete_category(cls.category['id']) super(TestCategoriesNegative, cls).resource_cleanup() - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_category_by_incorrect_id(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.delete_category, utils.generate_uuid()) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_category_by_incorrect_id(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.get_category, utils.generate_uuid()) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_create_category_with_same_name(self): self.assertRaises(exceptions.Conflict, self.application_catalog_client.create_category, self.category['name']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_category_with_package(self): self.assertRaises(exceptions.Forbidden, self.application_catalog_client.delete_category, diff --git a/murano_tempest_tests/tests/api/application_catalog/test_env_templates.py b/murano_tempest_tests/tests/api/application_catalog/test_env_templates.py index 9ddf0af1c..1e3943246 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_env_templates.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_env_templates.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.test import attr +import testtools from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -21,13 +21,13 @@ from murano_tempest_tests import utils class TestEnvironmentTemplatesSanity(base.BaseApplicationCatalogTest): - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_list_empty_env_templates(self): templates_list = self.application_catalog_client.\ get_env_templates_list() self.assertIsInstance(templates_list, list) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_create_and_delete_env_template(self): name = utils.generate_name('create_and_delete_env_template') env_template = self.application_catalog_client.\ @@ -60,13 +60,13 @@ class TestEnvironmentTemplates(base.BaseApplicationCatalogTest): delete_env_template(cls.env_template['id']) super(TestEnvironmentTemplates, cls).resource_cleanup() - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_env_template(self): env_template = self.application_catalog_client.\ get_env_template(self.env_template['id']) self.assertEqual(self.env_template['name'], env_template['name']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_create_env_template_with_a_service(self): name = utils.generate_name('create_env_template_with_service') post_body = self._get_demo_app() @@ -79,7 +79,7 @@ class TestEnvironmentTemplates(base.BaseApplicationCatalogTest): self.assertIsInstance(list_services, list) self.assertIn(post_body, list_services) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_add_and_remove_service_in_env_templates(self): env_template_services = self.application_catalog_client.\ get_services_list_in_env_template(self.env_template['id']) @@ -98,7 +98,7 @@ class TestEnvironmentTemplates(base.BaseApplicationCatalogTest): get_services_list_in_env_template(self.env_template['id']) self.assertNotIn(service, services) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_create_public_env_template(self): name = utils.generate_name('create_public_env_template') env_template = self.application_catalog_client.\ @@ -110,7 +110,7 @@ class TestEnvironmentTemplates(base.BaseApplicationCatalogTest): get_env_template(env_template['id']) self.assertTrue(env_temp['is_public']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_clone_env_template(self): name = utils.generate_name('clone_env_template') cloned_template = self.alt_client.\ @@ -121,7 +121,7 @@ class TestEnvironmentTemplates(base.BaseApplicationCatalogTest): template = self.alt_client.get_env_template(cloned_template['id']) self.assertEqual(name, template['name']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_public_private_both_env_templates(self): name = utils.generate_name('get_public_private_both') public_env_template = self.application_catalog_client.\ @@ -174,7 +174,7 @@ class TestEnvironmentTemplates(base.BaseApplicationCatalogTest): self.assertNotIn(private_env_template, alt_env_templates) self.assertIn(private_alt_env_template, alt_env_templates) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_create_env_from_template(self): name = utils.generate_name('create_env_from_template') env_template = self.application_catalog_client.\ diff --git a/murano_tempest_tests/tests/api/application_catalog/test_env_templates_negative.py b/murano_tempest_tests/tests/api/application_catalog/test_env_templates_negative.py index e35b931b7..17139959e 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_env_templates_negative.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_env_templates_negative.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +import testtools + from tempest.lib import exceptions -from tempest.test import attr from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -40,25 +41,25 @@ class TestEnvironmentTemplatesNegative(base.BaseApplicationCatalogTest): cls.environment['id']) super(TestEnvironmentTemplatesNegative, cls).resource_cleanup() - @attr(type='negative') + @testtools.testcase.attr('negative') def test_clone_env_template_private(self): self.assertRaises(exceptions.Forbidden, self.alt_client.clone_env_template, self.env_template['id'], 'cloned_template') - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_environment_with_wrong_env_id(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.delete_env_template, None) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_create_environment_with_wrong_payload(self): self.assertRaises(exceptions.BadRequest, self.application_catalog_client.create_env_template, ' ') - @attr(type='negative') + @testtools.testcase.attr('negative') def test_double_delete_env_template(self): name = utils.generate_name('double_delete_env_template') env_template = self.application_catalog_client.\ @@ -69,7 +70,7 @@ class TestEnvironmentTemplatesNegative(base.BaseApplicationCatalogTest): self.application_catalog_client.delete_env_template, env_template['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_deleted_env_template(self): name = utils.generate_name('get_deleted_env_template') env_template = self.application_catalog_client.\ @@ -80,13 +81,13 @@ class TestEnvironmentTemplatesNegative(base.BaseApplicationCatalogTest): self.application_catalog_client.get_env_template, env_template['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_create_environment_template_with_same_name(self): self.assertRaises(exceptions.Conflict, self.application_catalog_client.create_env_template, self.name) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_create_env_from_template_witch_existing_name(self): self.assertRaises(exceptions.Conflict, self.application_catalog_client. @@ -111,13 +112,13 @@ class TestEnvTemplatesTenantIsolation(base.BaseApplicationCatalogTest): delete_env_template(cls.env_template['id']) super(TestEnvTemplatesTenantIsolation, cls).resource_cleanup() - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_env_template_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.get_env_template, self.env_template['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_env_template_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.delete_env_template, diff --git a/murano_tempest_tests/tests/api/application_catalog/test_environments.py b/murano_tempest_tests/tests/api/application_catalog/test_environments.py index 05b7bc62e..e0472bc76 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_environments.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_environments.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.test import attr +import testtools from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -33,13 +33,13 @@ class TestEnvironments(base.BaseApplicationCatalogTest): delete_environment(cls.environment['id']) super(TestEnvironments, cls).resource_cleanup() - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_list_environments(self): environments_list = self.application_catalog_client.\ get_environments_list() self.assertIsInstance(environments_list, list) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_create_and_delete_environment(self): environments_list = self.application_catalog_client.\ get_environments_list() @@ -56,7 +56,7 @@ class TestEnvironments(base.BaseApplicationCatalogTest): self.assertEqual(len(environments_list), len(upd_environments_list)) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_create_and_delete_environment_with_unicode_name(self): environments_list = self.application_catalog_client.\ get_environments_list() @@ -73,13 +73,13 @@ class TestEnvironments(base.BaseApplicationCatalogTest): self.assertEqual(len(environments_list), len(upd_environments_list)) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_environment(self): environment = self.application_catalog_client.\ get_environment(self.environment['id']) self.assertEqual(self.environment['name'], environment['name']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_update_environment(self): environment = self.application_catalog_client.\ update_environment(self.environment['id']) diff --git a/murano_tempest_tests/tests/api/application_catalog/test_environments_negative.py b/murano_tempest_tests/tests/api/application_catalog/test_environments_negative.py index 14fbd8cf4..7eed5a614 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_environments_negative.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_environments_negative.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +import testtools + from tempest.lib import exceptions -from tempest.test import attr from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -21,13 +22,13 @@ from murano_tempest_tests import utils class TestEnvironmentsNegative(base.BaseApplicationCatalogTest): - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_environment_with_wrong_env_id(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.delete_environment, utils.generate_uuid()) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_double_delete_environment(self): name = utils.generate_name('double_del_negavive') environment = self.application_catalog_client.\ @@ -37,7 +38,7 @@ class TestEnvironmentsNegative(base.BaseApplicationCatalogTest): self.application_catalog_client.delete_environment, environment['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_deleted_environment(self): name = utils.generate_name('double_del_negavive') environment = self.application_catalog_client.\ @@ -65,19 +66,19 @@ class TestEnvironmentNegativeTenantIsolation(base.BaseApplicationCatalogTest): delete_environment(cls.environment['id']) super(TestEnvironmentNegativeTenantIsolation, cls).resource_cleanup() - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_environment_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.get_environment, self.environment['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_update_environment_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.update_environment, self.environment['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_environment_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.delete_environment, diff --git a/murano_tempest_tests/tests/api/application_catalog/test_repository.py b/murano_tempest_tests/tests/api/application_catalog/test_repository.py index 389c90d80..44f39bed0 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_repository.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_repository.py @@ -13,8 +13,7 @@ # under the License. import os - -from tempest.test import attr +import testtools from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -22,12 +21,12 @@ from murano_tempest_tests import utils class TestRepositorySanity(base.BaseApplicationCatalogTest): - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_list_packages(self): package_list = self.application_catalog_client.get_list_packages() self.assertIsInstance(package_list, list) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_upload_and_delete_package(self): application_name = utils.generate_name('package_test_upload') abs_archive_path, dir_with_archive, archive_name = \ @@ -62,13 +61,13 @@ class TestRepository(base.BaseApplicationCatalogIsolatedAdminTest): os.remove(cls.abs_archive_path) cls.application_catalog_client.delete_package(cls.package['id']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_package(self): package = self.application_catalog_client.get_package( self.package['id']) self.assertEqual(self.package['tags'], package['tags']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_update_package(self): post_body = [ { @@ -155,14 +154,14 @@ class TestRepository(base.BaseApplicationCatalogIsolatedAdminTest): self.package['id'], post_body) self.assertEqual("New name", result['name']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_download_package(self): self.application_catalog_client.download_package(self.package['id']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_ui_definitions(self): self.application_catalog_client.get_ui_definition(self.package['id']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_logo(self): self.application_catalog_client.get_logo(self.package['id']) diff --git a/murano_tempest_tests/tests/api/application_catalog/test_repository_negative.py b/murano_tempest_tests/tests/api/application_catalog/test_repository_negative.py index fe87f7612..cd6c9fc54 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_repository_negative.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_repository_negative.py @@ -13,9 +13,9 @@ # under the License. import os +import testtools from tempest.lib import exceptions -from tempest.test import attr from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -23,7 +23,7 @@ from murano_tempest_tests import utils class TestRepositoryNegativeNotFound(base.BaseApplicationCatalogTest): - @attr(type='negative') + @testtools.testcase.attr('negative') def test_update_package_with_incorrect_id(self): post_body = [ @@ -38,31 +38,31 @@ class TestRepositoryNegativeNotFound(base.BaseApplicationCatalogTest): self.application_catalog_client.update_package, utils.generate_uuid(), post_body) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_package_with_incorrect_id(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.get_package, utils.generate_uuid()) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_package_with_incorrect_id(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.delete_package, utils.generate_uuid()) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_download_package_with_incorrect_id(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.download_package, utils.generate_uuid()) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_ui_definition_with_incorrect_id(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.get_ui_definition, utils.generate_uuid()) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_logo_with_incorrect_id(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.get_logo, @@ -92,7 +92,7 @@ class TestRepositoryNegativeForbidden(base.BaseApplicationCatalogTest): os.remove(cls.abs_archive_path) cls.application_catalog_client.delete_package(cls.package['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_update_package_from_another_tenant(self): post_body = [ { @@ -107,31 +107,31 @@ class TestRepositoryNegativeForbidden(base.BaseApplicationCatalogTest): self.package['id'], post_body) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_package_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.get_package, self.package['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_package_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.delete_package, self.package['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_download_package_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.download_package, self.package['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_ui_definition_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.get_ui_definition, self.package['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_logo_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.get_logo, diff --git a/murano_tempest_tests/tests/api/application_catalog/test_services.py b/murano_tempest_tests/tests/api/application_catalog/test_services.py index 72e9199b8..b46f7d650 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_services.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_services.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.test import attr +import testtools from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -33,7 +33,7 @@ class TestServices(base.BaseApplicationCatalogTest): delete_environment(cls.environment['id']) super(TestServices, cls).resource_cleanup() - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_services_list(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -43,7 +43,7 @@ class TestServices(base.BaseApplicationCatalogTest): get_services_list(self.environment['id'], session['id']) self.assertIsInstance(services_list, list) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_create_and_delete_demo_service(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -65,7 +65,7 @@ class TestServices(base.BaseApplicationCatalogTest): get_services_list(self.environment['id'], session['id']) self.assertEqual(len(services_list), len(services_list_)) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_service(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -85,7 +85,7 @@ class TestServices(base.BaseApplicationCatalogTest): session['id']) self.assertEqual(service, service_) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_services_without_sess_id(self): services = self.application_catalog_client.\ get_services_list(self.environment['id'], None) diff --git a/murano_tempest_tests/tests/api/application_catalog/test_services_negative.py b/murano_tempest_tests/tests/api/application_catalog/test_services_negative.py index d9d347ffb..623242305 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_services_negative.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_services_negative.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +import testtools + from tempest.lib import exceptions -from tempest.test import attr from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -34,7 +35,7 @@ class TestServicesNegative(base.BaseApplicationCatalogTest): delete_environment(cls.environment['id']) super(TestServicesNegative, cls).resource_cleanup() - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_services_list_without_env_id(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -45,7 +46,7 @@ class TestServicesNegative(base.BaseApplicationCatalogTest): None, session['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_services_list_after_delete_env(self): name = utils.generate_name("get_services_list_after_delete_env") environment = self.application_catalog_client.create_environment(name) @@ -57,7 +58,7 @@ class TestServicesNegative(base.BaseApplicationCatalogTest): environment['id'], session['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_services_list_after_delete_session(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -68,7 +69,7 @@ class TestServicesNegative(base.BaseApplicationCatalogTest): self.environment['id'], session['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_create_service_without_env_id(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -81,7 +82,7 @@ class TestServicesNegative(base.BaseApplicationCatalogTest): session['id'], post_body) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_create_service_without_sess_id(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -94,7 +95,7 @@ class TestServicesNegative(base.BaseApplicationCatalogTest): "", post_body) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_service_without_env_id(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -109,7 +110,7 @@ class TestServicesNegative(base.BaseApplicationCatalogTest): session['id'], service['?']['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_service_without_session_id(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -124,7 +125,7 @@ class TestServicesNegative(base.BaseApplicationCatalogTest): "", service['?']['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_double_delete_service(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -143,7 +144,7 @@ class TestServicesNegative(base.BaseApplicationCatalogTest): session['id'], service['?']['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_service_without_env_id(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -176,7 +177,7 @@ class TestServicesNegativeTenantIsolation(base.BaseApplicationCatalogTest): delete_environment(cls.environment['id']) super(TestServicesNegativeTenantIsolation, cls).resource_cleanup() - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_list_services_in_env_from_another_tenant(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -187,7 +188,7 @@ class TestServicesNegativeTenantIsolation(base.BaseApplicationCatalogTest): self.environment['id'], session['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_create_service_in_env_from_another_tenant(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -200,7 +201,7 @@ class TestServicesNegativeTenantIsolation(base.BaseApplicationCatalogTest): session['id'], post_body) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_service_in_env_from_another_tenant(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -215,7 +216,7 @@ class TestServicesNegativeTenantIsolation(base.BaseApplicationCatalogTest): session['id'], service['?']['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_service_in_env_from_another_tenant(self): session = self.application_catalog_client.\ create_session(self.environment['id']) diff --git a/murano_tempest_tests/tests/api/application_catalog/test_sessions.py b/murano_tempest_tests/tests/api/application_catalog/test_sessions.py index 4eed87b45..e36ccd0db 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_sessions.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_sessions.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.test import attr +import testtools from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -33,7 +33,7 @@ class TestSessions(base.BaseApplicationCatalogTest): delete_environment(cls.environment['id']) super(TestSessions, cls).resource_cleanup() - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_create_session(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -41,14 +41,14 @@ class TestSessions(base.BaseApplicationCatalogTest): self.environment['id'], session['id']) self.assertEqual(self.environment['id'], session['environment_id']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_delete_session(self): session = self.application_catalog_client.\ create_session(self.environment['id']) self.application_catalog_client.delete_session(self.environment['id'], session['id']) - @attr(type='smoke') + @testtools.testcase.attr('smoke') def test_get_session(self): session = self.application_catalog_client.\ create_session(self.environment['id']) diff --git a/murano_tempest_tests/tests/api/application_catalog/test_sessions_negative.py b/murano_tempest_tests/tests/api/application_catalog/test_sessions_negative.py index cfd1af6f5..04787282e 100644 --- a/murano_tempest_tests/tests/api/application_catalog/test_sessions_negative.py +++ b/murano_tempest_tests/tests/api/application_catalog/test_sessions_negative.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +import testtools + from tempest.lib import exceptions -from tempest.test import attr from murano_tempest_tests.tests.api.application_catalog import base from murano_tempest_tests import utils @@ -35,13 +36,13 @@ class TestSessionsNegative(base.BaseApplicationCatalogTest): delete_environment(cls.environment['id']) super(TestSessionsNegative, cls).resource_cleanup() - @attr(type='negative') + @testtools.testcase.attr('negative') def test_create_session_before_env(self): self.assertRaises(exceptions.NotFound, self.application_catalog_client.create_session, utils.generate_uuid()) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_session_without_env_id(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -51,7 +52,7 @@ class TestSessionsNegative(base.BaseApplicationCatalogTest): self.application_catalog_client.delete_session, None, session['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_session_without_env_id(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -61,7 +62,7 @@ class TestSessionsNegative(base.BaseApplicationCatalogTest): self.application_catalog_client.get_session, None, session['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_session_after_delete_env(self): name = utils.generate_name('get_session_after_delete_env') environment = self.application_catalog_client.create_environment(name) @@ -72,7 +73,7 @@ class TestSessionsNegative(base.BaseApplicationCatalogTest): self.application_catalog_client.get_session, environment['id'], session['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_double_delete_session(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -100,13 +101,13 @@ class TestSessionsNegativeTenantIsolation(base.BaseApplicationCatalogTest): delete_environment(cls.environment['id']) super(TestSessionsNegativeTenantIsolation, cls).resource_cleanup() - @attr(type='negative') + @testtools.testcase.attr('negative') def test_create_session_in_env_from_another_tenant(self): self.assertRaises(exceptions.Forbidden, self.alt_client.create_session, self.environment['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_delete_session_in_env_from_another_tenant(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -116,7 +117,7 @@ class TestSessionsNegativeTenantIsolation(base.BaseApplicationCatalogTest): self.alt_client.delete_session, self.environment['id'], session['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_get_session_in_env_from_another_tenant(self): session = self.application_catalog_client.\ create_session(self.environment['id']) @@ -126,7 +127,7 @@ class TestSessionsNegativeTenantIsolation(base.BaseApplicationCatalogTest): self.alt_client.get_session, self.environment['id'], session['id']) - @attr(type='negative') + @testtools.testcase.attr('negative') def test_deploy_session_in_env_from_another_tenant(self): session = self.application_catalog_client.\ create_session(self.environment['id']) diff --git a/murano_tempest_tests/tests/api/service_broker/base.py b/murano_tempest_tests/tests/api/service_broker/base.py index 51bdc427a..8fe7fd3c9 100644 --- a/murano_tempest_tests/tests/api/service_broker/base.py +++ b/murano_tempest_tests/tests/api/service_broker/base.py @@ -18,17 +18,27 @@ import time from tempest.common import dynamic_creds from tempest import config +from tempest.lib import base from tempest.lib import exceptions -from tempest import test from murano_tempest_tests import clients CONF = config.CONF -class BaseServiceBrokerTest(test.BaseTestCase): +class BaseServiceBrokerTest(base.BaseTestCase): """Base test class for Murano Service Broker API tests.""" + @classmethod + def setUpClass(cls): + super(BaseServiceBrokerTest, cls).setUpClass() + cls.resource_setup() + + @classmethod + def tearDownClass(cls): + cls.resource_cleanup() + super(BaseServiceBrokerTest, cls).tearDownClass() + @classmethod def get_client_with_isolated_creds(cls, name=None, type_of_creds="admin"): @@ -66,7 +76,6 @@ class BaseServiceBrokerTest(test.BaseTestCase): if not CONF.service_available.murano: skip_msg = "Murano is disabled" raise cls.skipException(skip_msg) - super(BaseServiceBrokerTest, cls).resource_setup() if not hasattr(cls, "os"): cls.username = CONF.identity.username cls.password = CONF.identity.password @@ -82,7 +91,6 @@ class BaseServiceBrokerTest(test.BaseTestCase): @classmethod def resource_cleanup(cls): - super(BaseServiceBrokerTest, cls).resource_cleanup() cls.clear_isolated_creds() @classmethod diff --git a/murano_tempest_tests/tests/api/service_broker/test_service_broker_actions.py b/murano_tempest_tests/tests/api/service_broker/test_service_broker_actions.py index 5598d8d29..900963abb 100644 --- a/murano_tempest_tests/tests/api/service_broker/test_service_broker_actions.py +++ b/murano_tempest_tests/tests/api/service_broker/test_service_broker_actions.py @@ -15,8 +15,7 @@ import json import os - -from tempest import test +import testtools from murano_tempest_tests.tests.api.service_broker import base from murano_tempest_tests import utils @@ -24,12 +23,13 @@ from murano_tempest_tests import utils class ServiceBrokerActionsTest(base.BaseServiceBrokerAdminTest): - @test.attr(type=["gate"]) + @testtools.testcase.attr('gate') def test_applications_listing(self): app_list = self.service_broker_client.get_applications_list() self.assertIsInstance(app_list, list) - @test.attr(type=["smoke", "gate"]) + @testtools.testcase.attr('smoke') + @testtools.testcase.attr('gate') def test_provision_and_deprovision(self): application_name = utils.generate_name('cfapi') abs_archive_path, dir_with_archive, archive_name = \ @@ -53,7 +53,8 @@ class ServiceBrokerActionsTest(base.BaseServiceBrokerAdminTest): self.addCleanup(self.perform_deprovision, instance_id) self.assertIsInstance(json.loads(service), dict) - @test.attr(type=["smoke", "gate"]) + @testtools.testcase.attr('smoke') + @testtools.testcase.attr('gate') def test_binding_instance(self): application_name = utils.generate_name('cfapi') abs_archive_path, dir_with_archive, archive_name = \ @@ -80,7 +81,8 @@ class ServiceBrokerActionsTest(base.BaseServiceBrokerAdminTest): self.assertIsInstance(binding, dict) self.assertEqual({'uri': 'localhost'}, binding) - @test.attr(type=["smoke", "gate"]) + @testtools.testcase.attr('smoke') + @testtools.testcase.attr('gate') def test_provision_with_incorrect_input(self): """Test provision with restricted items in object model @@ -117,7 +119,8 @@ class ServiceBrokerActionsTest(base.BaseServiceBrokerAdminTest): self.addCleanup(self.perform_deprovision, instance_id) self.assertIsInstance(json.loads(service), dict) - @test.attr(type=["smoke", "gate"]) + @testtools.testcase.attr('smoke') + @testtools.testcase.attr('gate') def test_double_provision_to_the_same_space(self): application_name = utils.generate_name('cfapi') abs_archive_path, dir_with_archive, archive_name = \ diff --git a/murano_tempest_tests/tests/api/service_broker/test_service_broker_negative.py b/murano_tempest_tests/tests/api/service_broker/test_service_broker_negative.py index 2b903caeb..92da1f976 100644 --- a/murano_tempest_tests/tests/api/service_broker/test_service_broker_negative.py +++ b/murano_tempest_tests/tests/api/service_broker/test_service_broker_negative.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +import testtools + from tempest.lib import exceptions -from tempest import test from murano_tempest_tests.tests.api.service_broker import base from murano_tempest_tests import utils @@ -22,7 +23,8 @@ from murano_tempest_tests import utils class ServiceBrokerNegativeTest(base.BaseServiceBrokerAdminTest): - @test.attr(type=['gate', 'negative']) + @testtools.testcase.attr('gate') + @testtools.testcase.attr('negative') def test_get_status_with_not_present_instance_id(self): not_present_instance_id = utils.generate_uuid() self.assertRaises(