blob: 4567e43df6da6e971a9bd7529e7480206b7cb672 [file] [log] [blame]
Steve Bakerc2f84ee2016-06-30 00:56:13 +00001#
2# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
13
14import json
15
16from heat_integrationtests.common import exceptions
17from heat_integrationtests.scenario import scenario_base
18
19
20class ServerSignalIntegrationTest(scenario_base.ScenarioTestsBase):
21 """Test a server in a created network can signal to heat."""
22
23 def test_server_signal(self):
24 """Check a server in a created network can signal to heat."""
25 parameters = {
26 'key_name': self.keypair_name,
rabic333f762016-09-29 08:34:03 +053027 'flavor': self.conf.minimal_instance_type,
28 'image': self.conf.minimal_image_ref,
Steve Bakerc2f84ee2016-06-30 00:56:13 +000029 'timeout': self.conf.build_timeout,
30 }
31
32 # Launch stack
33 sid = self.launch_stack(
34 template_name="test_server_signal.yaml",
35 parameters=parameters,
36 expected_status=None
37 )
38
39 # Check status of all resources
40 for res in ('sg', 'floating_ip', 'network', 'router', 'subnet',
41 'router_interface', 'wait_handle', 'server',
42 'server_floating_ip_assoc'):
43 self._wait_for_resource_status(
44 sid, res, 'CREATE_COMPLETE')
45
46 server_resource = self.client.resources.get(sid, 'server')
47 server_id = server_resource.physical_resource_id
48 server = self.compute_client.servers.get(server_id)
49
50 try:
51 self._wait_for_resource_status(
52 sid, 'wait_condition', 'CREATE_COMPLETE')
53 except (exceptions.StackResourceBuildErrorException,
54 exceptions.TimeoutException):
55 raise
56 finally:
57 # attempt to log the server console regardless of WaitCondition
58 # going to complete. This allows successful and failed cloud-init
59 # logs to be compared
60 self._log_console_output(servers=[server])
61
62 stack = self.client.stacks.get(sid)
63
64 wc_data = json.loads(
65 self._stack_output(stack, 'wc_data'))
66 self.assertEqual({'1': 'test complete'}, wc_data)
67
68 server_ip = self._stack_output(stack, 'server_ip')
69
70 # Check that created server is reachable
71 if not self._ping_ip_address(server_ip):
72 self._log_console_output(servers=[server])
73 self.fail(
74 "Timed out waiting for %s to become reachable" % server_ip)