From 1e6b38807ee63de095ddbd4a321cb1d4b93b8d86 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 21 Aug 2022 11:37:20 +0900 Subject: [PATCH] Execute volume tests only when cinder is available This change makes sure that the scenario tests which require cinder are skipped when the [service_available] cinder option is False. Change-Id: I94c48ecd28acadda39abf4ef794434a72e9a7002 --- heat_tempest_plugin/common/test.py | 18 +++++++++++++++++- .../tests/scenario/test_base_resources.py | 1 + .../tests/scenario/test_volumes.py | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/heat_tempest_plugin/common/test.py b/heat_tempest_plugin/common/test.py index e5ed9d0..1dd2137 100644 --- a/heat_tempest_plugin/common/test.py +++ b/heat_tempest_plugin/common/test.py @@ -109,6 +109,22 @@ def requires_resource_type(resource_type): return decorator +def requires_service(service): + '''Decorator for tests requiring a specific service being available. + + The decorated test will be skipped when a service is not available. This + based on the [service_available] options implemented in tempest + ''' + def decorator(test_method): + if not getattr(config.CONF.service_available, service, True): + skipper = testtools.skip( + "%s service not available, skipping test." % service) + return skipper(test_method) + else: + return test_method + return decorator + + def requires_service_type(service_type): '''Decorator for tests requiring a specific service being available. @@ -125,7 +141,7 @@ def requires_service_type(service_type): service_type, conf.region, conf.endpoint_type) except kc_exceptions.EndpointNotFound: skipper = testtools.skip( - "%s service not available, skipping test." % service_type) + "%s service type not available, skipping test." % service_type) return skipper(test_method) else: return test_method diff --git a/heat_tempest_plugin/tests/scenario/test_base_resources.py b/heat_tempest_plugin/tests/scenario/test_base_resources.py index ddd8564..a84df93 100644 --- a/heat_tempest_plugin/tests/scenario/test_base_resources.py +++ b/heat_tempest_plugin/tests/scenario/test_base_resources.py @@ -17,6 +17,7 @@ from heat_tempest_plugin.common import test from heat_tempest_plugin.tests.scenario import scenario_base +@test.requires_service('cinder') class BasicResourcesTest(scenario_base.ScenarioTestsBase): def setUp(self): diff --git a/heat_tempest_plugin/tests/scenario/test_volumes.py b/heat_tempest_plugin/tests/scenario/test_volumes.py index 3a179a9..d99ed62 100644 --- a/heat_tempest_plugin/tests/scenario/test_volumes.py +++ b/heat_tempest_plugin/tests/scenario/test_volumes.py @@ -25,6 +25,7 @@ LOG = logging.getLogger(__name__) @test.requires_service_feature('volume', 'backup') +@test.requires_service('cinder') class VolumeBackupRestoreIntegrationTest(scenario_base.ScenarioTestsBase): """Class is responsible for testing of volume backup."""