Merge "Add test for basic resources as heat define test"
This commit is contained in:
commit
816d20c527
|
@ -0,0 +1,110 @@
|
|||
heat_template_version: 2014-10-16
|
||||
|
||||
description: >
|
||||
This HOT template that just defines a single server.
|
||||
Contains just base features to verify base heat support.
|
||||
|
||||
parameters:
|
||||
key_name:
|
||||
type: string
|
||||
default: key-01
|
||||
description: Name of an existing key pair to use for the server
|
||||
flavor:
|
||||
type: string
|
||||
description: Flavor for the server to be created
|
||||
default: m1.small
|
||||
constraints:
|
||||
- custom_constraint: nova.flavor
|
||||
image:
|
||||
type: string
|
||||
description: Image ID or image name to use for the server
|
||||
constraints:
|
||||
- custom_constraint: glance.image
|
||||
vol_size:
|
||||
type: number
|
||||
description: The size of the Cinder volume
|
||||
default: 1
|
||||
private_net_name:
|
||||
type: string
|
||||
default: private-net-01
|
||||
description: Name of private network to be created
|
||||
private_net_cidr:
|
||||
type: string
|
||||
default: 192.168.101.0/24
|
||||
description: Private network address (CIDR notation)
|
||||
private_net_gateway:
|
||||
type: string
|
||||
default: 192.168.101.1
|
||||
description: Private network gateway address
|
||||
private_net_pool_start:
|
||||
type: string
|
||||
default: 192.168.101.2
|
||||
description: Start of private network IP address allocation pool
|
||||
private_net_pool_end:
|
||||
type: string
|
||||
default: 192.168.101.127
|
||||
description: End of private network IP address allocation pool
|
||||
echo_foo:
|
||||
default: fooooo
|
||||
type: string
|
||||
|
||||
resources:
|
||||
private_net:
|
||||
type: OS::Neutron::Net
|
||||
properties:
|
||||
name: { get_param: private_net_name }
|
||||
|
||||
private_subnet:
|
||||
type: OS::Neutron::Subnet
|
||||
properties:
|
||||
network_id: { get_resource: private_net }
|
||||
cidr: { get_param: private_net_cidr }
|
||||
gateway_ip: { get_param: private_net_gateway }
|
||||
allocation_pools:
|
||||
- start: { get_param: private_net_pool_start }
|
||||
end: { get_param: private_net_pool_end }
|
||||
|
||||
server_port:
|
||||
type: OS::Neutron::Port
|
||||
properties:
|
||||
network_id: { get_resource: private_net }
|
||||
fixed_ips:
|
||||
- subnet_id: { get_resource: private_subnet }
|
||||
|
||||
key:
|
||||
type: OS::Nova::KeyPair
|
||||
properties:
|
||||
name: { get_param: key_name }
|
||||
|
||||
server:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
key_name: { get_resource: key }
|
||||
image: { get_param: image }
|
||||
flavor: { get_param: flavor }
|
||||
networks:
|
||||
- port: { get_resource: server_port }
|
||||
user_data:
|
||||
str_replace:
|
||||
template: |
|
||||
#!/bin/bash
|
||||
echo echo_foo
|
||||
params:
|
||||
echo_foo: { get_param: echo_foo }
|
||||
|
||||
vol:
|
||||
type: OS::Cinder::Volume
|
||||
properties:
|
||||
size: { get_param: vol_size }
|
||||
|
||||
vol_att:
|
||||
type: OS::Cinder::VolumeAttachment
|
||||
properties:
|
||||
instance_uuid: { get_resource: server }
|
||||
volume_id: { get_resource: vol }
|
||||
mountpoint: /dev/vdb
|
||||
|
||||
outputs:
|
||||
server_networks:
|
||||
description: The networks of the deployed server
|
||||
value: { get_attr: [server, networks] }
|
|
@ -0,0 +1,73 @@
|
|||
# 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.
|
||||
|
||||
from heat_integrationtests.common import test
|
||||
from heat_integrationtests.scenario import scenario_base
|
||||
from heatclient.common import template_utils
|
||||
|
||||
|
||||
class BasicResourcesTest(scenario_base.ScenarioTestsBase):
|
||||
|
||||
def setUp(self):
|
||||
super(BasicResourcesTest, self).setUp()
|
||||
if not self.conf.image_ref:
|
||||
raise self.skipException("No image configured to test")
|
||||
if not self.conf.instance_type:
|
||||
raise self.skipException("No flavor configured to test")
|
||||
|
||||
def check_stack(self):
|
||||
sid = self.stack_identifier
|
||||
# Check that stack were created
|
||||
self._wait_for_stack_status(sid, '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)
|
||||
self.assertEqual(server.id, server_id)
|
||||
|
||||
stack = self.client.stacks.get(sid)
|
||||
|
||||
server_networks = self._stack_output(stack, 'server_networks')
|
||||
self.assertIn(self.private_net_name, server_networks)
|
||||
|
||||
def test_base_resources_integration(self):
|
||||
"""Define test for base resources interation from core porjects
|
||||
|
||||
The alternative scenario is the following:
|
||||
1. Create a stack with basic resources from core projects.
|
||||
2. Check that all stack resources are created successfully.
|
||||
3. Wait for deployment.
|
||||
4. Check that stack was created.
|
||||
5. Check stack outputs.
|
||||
"""
|
||||
|
||||
self.private_net_name = test.rand_name('heat-net')
|
||||
parameters = {
|
||||
'key_name': test.rand_name('heat-key'),
|
||||
'flavor': self.conf.instance_type,
|
||||
'image': self.conf.image_ref,
|
||||
'vol_size': self.conf.volume_size,
|
||||
'private_net_name': self.private_net_name
|
||||
}
|
||||
|
||||
env_files, env = template_utils.process_environment_and_files(
|
||||
self.conf.boot_config_env)
|
||||
|
||||
# Launch stack
|
||||
self.stack_identifier = self.launch_stack(
|
||||
template_name='test_base_resources.yaml',
|
||||
parameters=parameters,
|
||||
expected_status=None,
|
||||
environment=env
|
||||
)
|
||||
|
||||
# Check stack
|
||||
self.check_stack()
|
Loading…
Reference in New Issue