blob: 80194a0b6e8062eaba2359e0601f683427ca1ec1 [file] [log] [blame]
ricolinc756e712017-04-06 22:50:10 +08001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13from heat_integrationtests.common import test
14from heat_integrationtests.scenario import scenario_base
15from heatclient.common import template_utils
16
17
18class BasicResourcesTest(scenario_base.ScenarioTestsBase):
19
20 def setUp(self):
21 super(BasicResourcesTest, self).setUp()
22 if not self.conf.image_ref:
23 raise self.skipException("No image configured to test")
24 if not self.conf.instance_type:
25 raise self.skipException("No flavor configured to test")
26
27 def check_stack(self):
28 sid = self.stack_identifier
29 # Check that stack were created
30 self._wait_for_stack_status(sid, 'CREATE_COMPLETE')
31 server_resource = self.client.resources.get(sid, 'server')
32 server_id = server_resource.physical_resource_id
33 server = self.compute_client.servers.get(server_id)
34 self.assertEqual(server.id, server_id)
35
36 stack = self.client.stacks.get(sid)
37
38 server_networks = self._stack_output(stack, 'server_networks')
39 self.assertIn(self.private_net_name, server_networks)
40
41 def test_base_resources_integration(self):
42 """Define test for base resources interation from core porjects
43
44 The alternative scenario is the following:
45 1. Create a stack with basic resources from core projects.
46 2. Check that all stack resources are created successfully.
47 3. Wait for deployment.
48 4. Check that stack was created.
49 5. Check stack outputs.
50 """
51
52 self.private_net_name = test.rand_name('heat-net')
53 parameters = {
54 'key_name': test.rand_name('heat-key'),
55 'flavor': self.conf.instance_type,
56 'image': self.conf.image_ref,
57 'vol_size': self.conf.volume_size,
58 'private_net_name': self.private_net_name
59 }
60
61 env_files, env = template_utils.process_environment_and_files(
62 self.conf.boot_config_env)
63
64 # Launch stack
65 self.stack_identifier = self.launch_stack(
66 template_name='test_base_resources.yaml',
67 parameters=parameters,
68 expected_status=None,
69 environment=env
70 )
71
72 # Check stack
73 self.check_stack()