Merge "Add functional test for multi-cloud"
diff --git a/heat_tempest_plugin/common/test.py b/heat_tempest_plugin/common/test.py
index cbf4abb..008ac87 100644
--- a/heat_tempest_plugin/common/test.py
+++ b/heat_tempest_plugin/common/test.py
@@ -109,19 +109,57 @@
return decorator
+def requires_service_type(service_type):
+ '''Decorator for tests requiring a specific service being available.
+
+ The decorated test will be skipped when a service is not available.
+ '''
+ def decorator(test_method):
+ conf = getattr(config.CONF, 'heat_plugin', None)
+ if not conf or conf.auth_url is None:
+ return test_method
+
+ manager = clients.ClientManager(conf)
+ try:
+ manager.identity_client.get_endpoint_url(
+ service_type, conf.region, conf.endpoint_type)
+ except kc_exceptions.EndpointNotFound:
+ skipper = testtools.skip(
+ "%s service not available, skipping test." % service_type)
+ return skipper(test_method)
+ else:
+ return test_method
+ return decorator
+
+
+def _check_require(group, feature, test_method):
+ features_group = getattr(config.CONF, group, None)
+ if not features_group:
+ return test_method
+ feature_enabled = features_group.get(feature, True)
+ skipper = testtools.skipUnless(feature_enabled,
+ "%s - Feature not enabled." % feature)
+ return skipper(test_method)
+
+
def requires_feature(feature):
'''Decorator for tests requring specific feature.
The decorated test will be skipped when a specific feature is disabled.
'''
def decorator(test_method):
- features_group = getattr(config.CONF, 'heat_features_enabled', None)
- if not features_group:
- return test_method
- feature_enabled = config.CONF.heat_features_enabled.get(feature, False)
- skipper = testtools.skipUnless(feature_enabled,
- "%s - Feature not enabled." % feature)
- return skipper(test_method)
+ return _check_require('heat_features_enabled', feature, test_method)
+ return decorator
+
+
+def requires_service_feature(service, feature):
+ '''Decorator for tests requring specific service feature enabled in tempest.
+
+ The decorated test will be skipped when a specific feature is disabled.
+ '''
+ def decorator(test_method):
+ group = service + '_feature_enabled'
+ return _check_require(group, feature, test_method)
return decorator
@@ -246,15 +284,6 @@
return False
return True
- def is_service_available(self, service_type):
- try:
- self.identity_client.get_endpoint_url(
- service_type, self.conf.region, self.conf.endpoint_type)
- except kc_exceptions.EndpointNotFound:
- return False
- else:
- return True
-
@staticmethod
def _stack_output(stack, output_key, validate_errors=True):
"""Return a stack output value for a given key."""
diff --git a/heat_tempest_plugin/config.py b/heat_tempest_plugin/config.py
index 910caaf..c30981c 100644
--- a/heat_tempest_plugin/config.py
+++ b/heat_tempest_plugin/config.py
@@ -16,9 +16,12 @@
title="Available OpenStack Services")
ServiceAvailableGroup = [
- cfg.BoolOpt("heat_plugin",
+ cfg.BoolOpt("heat",
default=True,
- help="Whether or not heat is expected to be available"),
+ help="Whether or not heat is expected to be available",
+ deprecated_opts=[cfg.DeprecatedOpt(
+ 'heat_plugin',
+ group='service_available')]),
]
heat_group = cfg.OptGroup(name="heat_plugin",
diff --git a/heat_tempest_plugin/tests/functional/test_event_sinks.py b/heat_tempest_plugin/tests/functional/test_event_sinks.py
index 7cb1d7b..dd1accc 100644
--- a/heat_tempest_plugin/tests/functional/test_event_sinks.py
+++ b/heat_tempest_plugin/tests/functional/test_event_sinks.py
@@ -19,6 +19,7 @@
from heat_tempest_plugin.tests.functional import functional_base
+@test.requires_service_type('messaging')
class ZaqarEventSinkTest(functional_base.FunctionalTestsBase):
template = '''
heat_template_version: "2013-05-23"
diff --git a/heat_tempest_plugin/tests/functional/test_external_ref.py b/heat_tempest_plugin/tests/functional/test_external_ref.py
index d6a73ac..1667908 100644
--- a/heat_tempest_plugin/tests/functional/test_external_ref.py
+++ b/heat_tempest_plugin/tests/functional/test_external_ref.py
@@ -34,25 +34,26 @@
value: {get_resource: test1}
'''
- @decorators.idempotent_id('45449bad-18ba-4148-82e6-a6bc1e9a9b04')
- def test_create_with_external_ref(self):
- stack_name = self._stack_rand_name()
- stack_identifier = self.stack_create(
- stack_name=stack_name,
- template=self.TEMPLATE_WITH_EX_REF,
+ def _stack_create(self, template):
+ self.stack_name = self._stack_rand_name()
+ self.stack_identifier = self.stack_create(
+ stack_name=self.stack_name,
+ template=template,
files={},
disable_rollback=True,
parameters={},
- environment={}
+ environment={},
+ expected_status='CREATE_COMPLETE'
)
- stack = self.client.stacks.get(stack_identifier)
-
- self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
expected_resources = {'test1': 'OS::Heat::TestResource'}
self.assertEqual(expected_resources,
- self.list_resources(stack_identifier))
- stack = self.client.stacks.get(stack_identifier)
+ self.list_resources(self.stack_identifier))
+
+ @decorators.idempotent_id('45449bad-18ba-4148-82e6-a6bc1e9a9b04')
+ def test_create_with_external_ref(self):
+ self._stack_create(self.TEMPLATE_WITH_EX_REF)
+ stack = self.client.stacks.get(self.stack_identifier)
self.assertEqual(
[{'description': 'No description given',
'output_key': 'str',
@@ -60,28 +61,41 @@
@decorators.idempotent_id('fb16477c-e981-4ef9-a83b-c0acc162343a')
def test_update_with_external_ref(self):
- stack_name = self._stack_rand_name()
- stack_identifier = self.stack_create(
- stack_name=stack_name,
- template=self.TEMPLATE,
- files={},
- disable_rollback=True,
- parameters={},
- environment={}
- )
- stack = self.client.stacks.get(stack_identifier)
+ self._stack_create(self.TEMPLATE)
- self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
- expected_resources = {'test1': 'OS::Heat::TestResource'}
- self.assertEqual(expected_resources,
- self.list_resources(stack_identifier))
- stack = self.client.stacks.get(stack_identifier)
+ stack = self.client.stacks.get(self.stack_identifier)
self.assertEqual([], stack.outputs)
- stack_name = stack_identifier.split('/')[0]
- kwargs = {'stack_id': stack_identifier, 'stack_name': stack_name,
+ stack_name = self.stack_identifier.split('/')[0]
+ kwargs = {'stack_id': self.stack_identifier, 'stack_name': stack_name,
'template': self.TEMPLATE_WITH_EX_REF, 'files': {},
'disable_rollback': True, 'parameters': {}, 'environment': {}
}
self.client.stacks.update(**kwargs)
- self._wait_for_stack_status(stack_identifier, 'UPDATE_FAILED')
+ self._wait_for_stack_status(self.stack_identifier, 'UPDATE_FAILED')
+
+ @decorators.idempotent_id('0ac301c2-b377-49b8-82e2-2458634bc8cf')
+ def test_update_stack_contain_external_ref(self):
+ self._stack_create(self.TEMPLATE_WITH_EX_REF)
+
+ stack = self.client.stacks.get(self.stack_identifier)
+ self.assertEqual(
+ [{'description': 'No description given',
+ 'output_key': 'str',
+ 'output_value': 'foobar'}], stack.outputs)
+
+ # Update Stack without change external_id
+
+ new_stack_name = self._stack_rand_name()
+ kwargs = {'stack_id': self.stack_identifier,
+ 'stack_name': new_stack_name,
+ 'template': self.TEMPLATE_WITH_EX_REF, 'files': {},
+ 'disable_rollback': True, 'parameters': {}, 'environment': {}
+ }
+ self.client.stacks.update(**kwargs)
+
+ self._wait_for_stack_status(self.stack_identifier, 'UPDATE_COMPLETE')
+
+ expected_resources = {'test1': 'OS::Heat::TestResource'}
+ self.assertEqual(expected_resources,
+ self.list_resources(self.stack_identifier))
diff --git a/heat_tempest_plugin/tests/functional/test_software_config.py b/heat_tempest_plugin/tests/functional/test_software_config.py
index f034096..ada67f2 100644
--- a/heat_tempest_plugin/tests/functional/test_software_config.py
+++ b/heat_tempest_plugin/tests/functional/test_software_config.py
@@ -183,6 +183,7 @@
verify=self.verify_cert)
+@test.requires_service_type('messaging')
class ZaqarSignalTransportTest(functional_base.FunctionalTestsBase):
server_template = '''
heat_template_version: "2013-05-23"
diff --git a/heat_tempest_plugin/tests/functional/test_waitcondition.py b/heat_tempest_plugin/tests/functional/test_waitcondition.py
index c21b33b..3bffd76 100644
--- a/heat_tempest_plugin/tests/functional/test_waitcondition.py
+++ b/heat_tempest_plugin/tests/functional/test_waitcondition.py
@@ -16,9 +16,11 @@
from tempest.lib import decorators
from zaqarclient.queues.v2 import client as zaqarclient
+from heat_tempest_plugin.common import test
from heat_tempest_plugin.tests.functional import functional_base
+@test.requires_service_type('messaging')
class ZaqarWaitConditionTest(functional_base.FunctionalTestsBase):
template = '''
heat_template_version: "2013-05-23"
diff --git a/heat_tempest_plugin/tests/scenario/templates/remote_nested_base.yaml b/heat_tempest_plugin/tests/scenario/templates/remote_nested_base.yaml
new file mode 100644
index 0000000..fc1441f
--- /dev/null
+++ b/heat_tempest_plugin/tests/scenario/templates/remote_nested_base.yaml
@@ -0,0 +1,29 @@
+heat_template_version: 2015-10-15
+description: |
+ The base stack (containing an actual resource) for the remote deeply-nested
+ stack test.
+
+parameters:
+ name:
+ type: string
+ description: Name of the router
+ constraints:
+ - allowed_pattern: "[a-z][a-z0-9-]{1,}"
+ network_name:
+ type: string
+ description: The network to connect to
+ constraints:
+ - custom_constraint: neutron.network
+
+resources:
+ router:
+ type: OS::Neutron::Router
+ properties:
+ name:
+ list_join: ['-', [{ get_param: name }, 'router']]
+ external_gateway_info:
+ network: {get_param: network_name}
+
+outputs:
+ router:
+ value: {get_resource: router}
diff --git a/heat_tempest_plugin/tests/scenario/templates/remote_nested_intermediate.yaml b/heat_tempest_plugin/tests/scenario/templates/remote_nested_intermediate.yaml
new file mode 100644
index 0000000..6fc7082
--- /dev/null
+++ b/heat_tempest_plugin/tests/scenario/templates/remote_nested_intermediate.yaml
@@ -0,0 +1,27 @@
+heat_template_version: 2015-10-15
+description: |
+ The intermediate stack (containing a local nested stack) to be instantiated
+ remotely in the remote deeply-nested stack test.
+
+parameters:
+ name:
+ type: string
+ description: Name of the router
+ constraints:
+ - allowed_pattern: "[a-z][a-z0-9-]{1,}"
+ network_name:
+ type: string
+ description: The public network to connect to
+ constraints:
+ - custom_constraint: neutron.network
+
+resources:
+ network_stack_as_custom_type:
+ type: remote_nested_base.yaml
+ properties:
+ name: {get_param: name}
+ network_name: {get_param: network_name}
+
+outputs:
+ router:
+ value: {get_attr: [network_stack_as_custom_type, router]}
diff --git a/heat_tempest_plugin/tests/scenario/templates/remote_nested_root.yaml b/heat_tempest_plugin/tests/scenario/templates/remote_nested_root.yaml
new file mode 100644
index 0000000..39bb8cb
--- /dev/null
+++ b/heat_tempest_plugin/tests/scenario/templates/remote_nested_root.yaml
@@ -0,0 +1,35 @@
+heat_template_version: 2015-10-15
+description: |
+ The root stack (containing a remote stack) for the deeply-nested remote
+ stack test.
+
+parameters:
+ name:
+ type: string
+ description: Name of the router
+ constraints:
+ - allowed_pattern: "[a-z][a-z0-9-]{1,}"
+ network_name:
+ type: string
+ description: The public network to connect to
+ constraints:
+ - custom_constraint: neutron.network
+ region:
+ type: string
+ description: The region in which to create the remote stack
+ default: RegionOne
+
+resources:
+ network_stack:
+ type: OS::Heat::Stack
+ properties:
+ template: {get_file: remote_nested_intermediate.yaml}
+ context:
+ region_name: {get_param: region}
+ parameters:
+ name: {get_param: name}
+ network_name: {get_param: network_name}
+
+outputs:
+ router:
+ value: {get_attr: [network_stack, outputs, router]}
diff --git a/heat_tempest_plugin/tests/scenario/test_aodh_alarm.py b/heat_tempest_plugin/tests/scenario/test_aodh_alarm.py
index 4e25158..dafca12 100644
--- a/heat_tempest_plugin/tests/scenario/test_aodh_alarm.py
+++ b/heat_tempest_plugin/tests/scenario/test_aodh_alarm.py
@@ -51,9 +51,9 @@
stack_identifier = self.stack_create(template=self.template,
parameters=parameters)
- measures = [{'timestamp': test.isotime(datetime.datetime.now()),
+ measures = [{'timestamp': test.isotime(datetime.datetime.utcnow()),
'value': 100}, {'timestamp': test.isotime(
- datetime.datetime.now() + datetime.timedelta(
+ datetime.datetime.utcnow() + datetime.timedelta(
minutes=1)), 'value': 100}]
# send measures(should cause the alarm to fire)
self.metric_client.metric.add_measures(metric['id'], measures)
diff --git a/heat_tempest_plugin/tests/scenario/test_remote_deeply_nested.py b/heat_tempest_plugin/tests/scenario/test_remote_deeply_nested.py
new file mode 100644
index 0000000..d020e63
--- /dev/null
+++ b/heat_tempest_plugin/tests/scenario/test_remote_deeply_nested.py
@@ -0,0 +1,39 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import six
+import uuid
+
+from heat_tempest_plugin.tests.scenario import scenario_base
+from tempest.lib import decorators
+
+
+class RemoteDeeplyNestedStackTest(scenario_base.ScenarioTestsBase):
+ @decorators.idempotent_id('2ed94cae-da14-4060-a6b3-526e7a8cbbe4')
+ def test_remote_nested(self):
+ parameters = {
+ 'name': 'remote-nested',
+ 'network_name': 'public',
+ }
+
+ stack_id = self.launch_stack(
+ template_name='remote_nested_root.yaml',
+ parameters={'region': self.conf.region},
+ environment={'parameters': parameters}
+ )
+
+ stack = self.client.stacks.get(stack_id)
+ router_id = self._stack_output(stack, 'router')
+ self.assertIsInstance(router_id, six.string_types)
+ uuid.UUID(router_id)
+
+ self._stack_delete(stack_id)
diff --git a/heat_tempest_plugin/tests/scenario/test_volumes.py b/heat_tempest_plugin/tests/scenario/test_volumes.py
index 57d0936..7dfa8bf 100644
--- a/heat_tempest_plugin/tests/scenario/test_volumes.py
+++ b/heat_tempest_plugin/tests/scenario/test_volumes.py
@@ -17,11 +17,13 @@
from tempest.lib import decorators
from heat_tempest_plugin.common import exceptions
+from heat_tempest_plugin.common import test
from heat_tempest_plugin.tests.scenario import scenario_base
LOG = logging.getLogger(__name__)
+@test.requires_service_feature('volume', 'backup')
class VolumeBackupRestoreIntegrationTest(scenario_base.ScenarioTestsBase):
"""Class is responsible for testing of volume backup."""
diff --git a/tox.ini b/tox.ini
index 7b8aeec..549457a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -12,6 +12,7 @@
testr run {posargs}
[testenv:pep8]
+basepython = python3
setenv =
PYTHONPATH = .
commands =
@@ -25,12 +26,14 @@
check-uuid --fix --package heat_tempest_plugin
[testenv:docs]
+basepython = python3
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
sphinxcontrib-httpdomain
commands = python setup.py build_sphinx
[testenv:venv]
+basepython = python3
commands = {posargs}
[flake8]