From 2ec1acbf6cf8f4c2e3fed6493e4e048ccc666b66 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Tue, 30 Jan 2018 10:45:01 -0500 Subject: [PATCH] Add test for remote nested stacks Add a scenario test with remote nested stacks: Local Remote Root stack ----------------> Intermediate stack - Base stack Change-Id: If68f721181f502b3eb364dec13c8ef388d61f57d Story: #1739447 Task: 22217 --- .../templates/remote_nested_base.yaml | 29 ++++++++++++++ .../templates/remote_nested_intermediate.yaml | 27 +++++++++++++ .../templates/remote_nested_root.yaml | 35 +++++++++++++++++ .../scenario/test_remote_deeply_nested.py | 39 +++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 heat_tempest_plugin/tests/scenario/templates/remote_nested_base.yaml create mode 100644 heat_tempest_plugin/tests/scenario/templates/remote_nested_intermediate.yaml create mode 100644 heat_tempest_plugin/tests/scenario/templates/remote_nested_root.yaml create mode 100644 heat_tempest_plugin/tests/scenario/test_remote_deeply_nested.py 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_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)