Split templates and tests in scenario tests
- Added subdirectory "templates" for storing all templates used in scenario tests. - Added parameter sub_dir for method _load_template. - Inline template was moved in templates directory from test_neutron_autoscaling. Change-Id: I1acaf1ccc1466cf7ffc2e004eff486f49f4b5928
This commit is contained in:
parent
9a4a9f48fb
commit
b6afc2b831
@ -179,9 +179,10 @@ class HeatIntegrationTest(testscenarios.WithScenarios,
|
||||
LOG.debug('Console output for %s', server.id)
|
||||
LOG.debug(server.get_console_output())
|
||||
|
||||
def _load_template(self, base_file, file_name):
|
||||
def _load_template(self, base_file, file_name, sub_dir=None):
|
||||
sub_dir = sub_dir or ''
|
||||
filepath = os.path.join(os.path.dirname(os.path.realpath(base_file)),
|
||||
file_name)
|
||||
sub_dir, file_name)
|
||||
with open(filepath) as f:
|
||||
return f.read()
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
heat_template_version: 2014-10-16
|
||||
|
||||
description: Auto-scaling Test
|
||||
|
||||
parameters:
|
||||
image_id:
|
||||
type: string
|
||||
label: Image ID
|
||||
description: Image ID from configurations
|
||||
capacity:
|
||||
type: string
|
||||
label: Capacity
|
||||
description: Auto-scaling group desired capacity
|
||||
fixed_subnet_name:
|
||||
type: string
|
||||
label: fixed subnetwork ID
|
||||
description: subnetwork ID used for autoscaling
|
||||
instance_type:
|
||||
type: string
|
||||
label: instance_type
|
||||
description: type of instance to launch
|
||||
|
||||
resources:
|
||||
test_pool:
|
||||
type: OS::Neutron::Pool
|
||||
properties:
|
||||
description: Test Pool
|
||||
lb_method: ROUND_ROBIN
|
||||
name: test_pool
|
||||
protocol: HTTP
|
||||
subnet: { get_param: fixed_subnet_name }
|
||||
vip: {
|
||||
"description": "Test VIP",
|
||||
"protocol_port": 80,
|
||||
"name": "test_vip"
|
||||
}
|
||||
load_balancer:
|
||||
type: OS::Neutron::LoadBalancer
|
||||
properties:
|
||||
protocol_port: 80
|
||||
pool_id: { get_resource: test_pool }
|
||||
launch_config:
|
||||
type: AWS::AutoScaling::LaunchConfiguration
|
||||
properties:
|
||||
ImageId: { get_param: image_id }
|
||||
InstanceType: { get_param: instance_type }
|
||||
server_group:
|
||||
type: AWS::AutoScaling::AutoScalingGroup
|
||||
properties:
|
||||
AvailabilityZones : ["nova"]
|
||||
LaunchConfigurationName : { get_resource : launch_config }
|
||||
MinSize : 1
|
||||
MaxSize : 5
|
||||
DesiredCapacity: { get_param: capacity }
|
||||
LoadBalancerNames : [ { get_resource : load_balancer } ]
|
@ -12,64 +12,6 @@
|
||||
|
||||
from heat_integrationtests.common import test
|
||||
|
||||
test_template = '''
|
||||
heat_template_version: 2014-10-16
|
||||
|
||||
description: Auto-scaling Test
|
||||
|
||||
parameters:
|
||||
image_id:
|
||||
type: string
|
||||
label: Image ID
|
||||
description: Image ID from configurations
|
||||
capacity:
|
||||
type: string
|
||||
label: Capacity
|
||||
description: Auto-scaling group desired capacity
|
||||
fixed_subnet_name:
|
||||
type: string
|
||||
label: fixed subnetwork ID
|
||||
description: subnetwork ID used for autoscaling
|
||||
instance_type:
|
||||
type: string
|
||||
label: instance_type
|
||||
description: type of instance to launch
|
||||
|
||||
resources:
|
||||
test_pool:
|
||||
type: OS::Neutron::Pool
|
||||
properties:
|
||||
description: Test Pool
|
||||
lb_method: ROUND_ROBIN
|
||||
name: test_pool
|
||||
protocol: HTTP
|
||||
subnet: { get_param: fixed_subnet_name }
|
||||
vip: {
|
||||
"description": "Test VIP",
|
||||
"protocol_port": 80,
|
||||
"name": "test_vip"
|
||||
}
|
||||
load_balancer:
|
||||
type: OS::Neutron::LoadBalancer
|
||||
properties:
|
||||
protocol_port: 80
|
||||
pool_id: { get_resource: test_pool }
|
||||
launch_config:
|
||||
type: AWS::AutoScaling::LaunchConfiguration
|
||||
properties:
|
||||
ImageId: { get_param: image_id }
|
||||
InstanceType: { get_param: instance_type }
|
||||
server_group:
|
||||
type: AWS::AutoScaling::AutoScalingGroup
|
||||
properties:
|
||||
AvailabilityZones : ["nova"]
|
||||
LaunchConfigurationName : { get_resource : launch_config }
|
||||
MinSize : 1
|
||||
MaxSize : 5
|
||||
DesiredCapacity: { get_param: capacity }
|
||||
LoadBalancerNames : [ { get_resource : load_balancer } ]
|
||||
'''
|
||||
|
||||
|
||||
class NeutronAutoscalingTest(test.HeatIntegrationTest):
|
||||
"""
|
||||
@ -106,8 +48,11 @@ class NeutronAutoscalingTest(test.HeatIntegrationTest):
|
||||
"fixed_subnet_name": self.conf.fixed_subnet_name,
|
||||
}}
|
||||
|
||||
template = self._load_template(__file__,
|
||||
'test_neutron_autoscaling.yaml',
|
||||
'templates')
|
||||
# Create stack
|
||||
stack_id = self.stack_create(template=test_template,
|
||||
stack_id = self.stack_create(template=template,
|
||||
environment=env)
|
||||
|
||||
members = self.network_client.list_members()
|
||||
@ -116,7 +61,7 @@ class NeutronAutoscalingTest(test.HeatIntegrationTest):
|
||||
# Increase desired capacity and update the stack
|
||||
env["parameters"]["capacity"] = "2"
|
||||
self.update_stack(stack_id,
|
||||
template=test_template,
|
||||
template=template,
|
||||
environment=env)
|
||||
|
||||
upd_members = self.network_client.list_members()
|
||||
|
@ -27,6 +27,7 @@ class CfnInitIntegrationTest(test.HeatIntegrationTest):
|
||||
raise self.skipException("No image configured to test")
|
||||
self.client = self.orchestration_client
|
||||
self.template_name = 'test_server_cfn_init.yaml'
|
||||
self.sub_dir = 'templates'
|
||||
|
||||
def assign_keypair(self):
|
||||
self.stack_name = self._stack_rand_name()
|
||||
@ -48,7 +49,8 @@ class CfnInitIntegrationTest(test.HeatIntegrationTest):
|
||||
}
|
||||
|
||||
# create the stack
|
||||
self.template = self._load_template(__file__, self.template_name)
|
||||
self.template = self._load_template(__file__, self.template_name,
|
||||
self.sub_dir)
|
||||
self.client.stacks.create(
|
||||
stack_name=self.stack_name,
|
||||
template=self.template,
|
||||
|
@ -56,7 +56,7 @@ class VolumeBackupRestoreIntegrationTest(test.HeatIntegrationTest):
|
||||
# TODO(shardy): refactor this into a generic base-class helper
|
||||
net = self._get_default_network()
|
||||
stack_name = self._stack_rand_name()
|
||||
template = self._load_template(__file__, template_name)
|
||||
template = self._load_template(__file__, template_name, 'templates')
|
||||
parameters = {'key_name': self.keypair_name,
|
||||
'instance_type': self.conf.instance_type,
|
||||
'image_id': self.conf.minimal_image_ref,
|
||||
|
Loading…
Reference in New Issue
Block a user