diff options
author | Steve Baker <sbaker@redhat.com> | 2016-06-30 00:56:13 +0000 |
---|---|---|
committer | Steve Baker <sbaker@redhat.com> | 2016-08-04 02:04:50 +0000 |
commit | e9030c744fb5e05ef67afedf783b00910e91cd76 (patch) | |
tree | 1c156805aed149aa3970c141e0ddf778c4c479e2 /heat_integrationtests | |
parent | 86a037e3f2924742ab07d1c504144291ada5e477 (diff) | |
download | heat-e9030c744fb5e05ef67afedf783b00910e91cd76.tar.gz |
Add scenario test_server_signal
This is similar to test_server_cfn_init with the following
differences:
- Use heat instead of AWS resources
- Use HOT template format
- Create and configure a neutron network which the server will be
booted into
The last difference will allow the tempest test
tempest.api.orchestration.stacks.test_neutron_resources to be deleted.
This tempest test is more appropriate as a scenario test, so it
wouldn't even be considered for defcore and really doesn't belong in
tempest.
Change-Id: Id4f76be2114fb07b3c608d7d0ec0f76f43ad1d21
Diffstat (limited to 'heat_integrationtests')
-rw-r--r-- | heat_integrationtests/scenario/templates/test_server_signal.yaml | 104 | ||||
-rw-r--r-- | heat_integrationtests/scenario/test_server_signal.py | 74 |
2 files changed, 178 insertions, 0 deletions
diff --git a/heat_integrationtests/scenario/templates/test_server_signal.yaml b/heat_integrationtests/scenario/templates/test_server_signal.yaml new file mode 100644 index 000000000..dfb1155e9 --- /dev/null +++ b/heat_integrationtests/scenario/templates/test_server_signal.yaml @@ -0,0 +1,104 @@ +heat_template_version: 2013-05-23 +description: | + Template which uses a wait condition to confirm that a minimal + signalling works in a created network +parameters: + key_name: + type: string + flavor: + type: string + image: + type: string + subnet_cidr: + type: string + default: 10.100.0.0/16 + timeout: + type: number + public_net: + type: string + default: public + private_net: + type: string + default: heat-net + dns_servers: + type: comma_delimited_list + default: ["8.8.8.8", "8.8.4.4"] +resources: + sg: + type: OS::Neutron::SecurityGroup + properties: + name: the_sg + description: Ping and SSH + rules: + - protocol: icmp + - protocol: tcp + port_range_min: 22 + port_range_max: 22 + + floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network: {get_param: public_net} + + network: + type: OS::Neutron::Net + + subnet: + type: OS::Neutron::Subnet + properties: + network: {get_resource: network} + ip_version: 4 + cidr: {get_param: subnet_cidr} + dns_nameservers: {get_param: dns_servers} + + router: + type: OS::Neutron::Router + properties: + external_gateway_info: + network: {get_param: public_net} + + router_interface: + type: OS::Neutron::RouterInterface + properties: + router: {get_resource: router} + subnet: {get_resource: subnet} + + wait_handle: + type: OS::Heat::WaitConditionHandle + + server: + type: OS::Nova::Server + properties: + image: {get_param: image} + flavor: {get_param: flavor} + key_name: {get_param: key_name} + networks: + - subnet: {get_resource: subnet} + security_groups: + - {get_resource: sg} + user_data_format: RAW + user_data: + str_replace: + template: | + #!/bin/sh + wc_notify --data-binary '{"status": "SUCCESS", "data": "test complete"}' + params: + wc_notify: { get_attr: ['wait_handle', 'curl_cli'] } + + server_floating_ip_assoc: + type: OS::Neutron::FloatingIPAssociation + properties: + floatingip_id: {get_resource: floating_ip} + port_id: {get_attr: [server, addresses, {get_resource: network}, 0, port]} + + wait_condition: + type: OS::Heat::WaitCondition + properties: + handle: {get_resource: wait_handle} + timeout: {get_param: timeout} + +outputs: + server_ip: + value: {get_attr: [floating_ip, floating_ip_address]} + wc_data: + value: {get_attr: [wait_condition, data]} diff --git a/heat_integrationtests/scenario/test_server_signal.py b/heat_integrationtests/scenario/test_server_signal.py new file mode 100644 index 000000000..de42f02b1 --- /dev/null +++ b/heat_integrationtests/scenario/test_server_signal.py @@ -0,0 +1,74 @@ +# +# 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 json + +from heat_integrationtests.common import exceptions +from heat_integrationtests.scenario import scenario_base + + +class ServerSignalIntegrationTest(scenario_base.ScenarioTestsBase): + """Test a server in a created network can signal to heat.""" + + def test_server_signal(self): + """Check a server in a created network can signal to heat.""" + parameters = { + 'key_name': self.keypair_name, + 'flavor': self.conf.instance_type, + 'image': self.conf.image_ref, + 'timeout': self.conf.build_timeout, + } + + # Launch stack + sid = self.launch_stack( + template_name="test_server_signal.yaml", + parameters=parameters, + expected_status=None + ) + + # Check status of all resources + for res in ('sg', 'floating_ip', 'network', 'router', 'subnet', + 'router_interface', 'wait_handle', 'server', + 'server_floating_ip_assoc'): + self._wait_for_resource_status( + sid, res, 'CREATE_COMPLETE') + + server_resource = self.client.resources.get(sid, 'server') + server_id = server_resource.physical_resource_id + server = self.compute_client.servers.get(server_id) + + try: + self._wait_for_resource_status( + sid, 'wait_condition', 'CREATE_COMPLETE') + except (exceptions.StackResourceBuildErrorException, + exceptions.TimeoutException): + raise + finally: + # attempt to log the server console regardless of WaitCondition + # going to complete. This allows successful and failed cloud-init + # logs to be compared + self._log_console_output(servers=[server]) + + stack = self.client.stacks.get(sid) + + wc_data = json.loads( + self._stack_output(stack, 'wc_data')) + self.assertEqual({'1': 'test complete'}, wc_data) + + server_ip = self._stack_output(stack, 'server_ip') + + # Check that created server is reachable + if not self._ping_ip_address(server_ip): + self._log_console_output(servers=[server]) + self.fail( + "Timed out waiting for %s to become reachable" % server_ip) |