Merge "Split templates and tests in scenario tests"
diff --git a/common/test.py b/common/test.py
index b4c3c81..be9cdce 100644
--- a/common/test.py
+++ b/common/test.py
@@ -114,9 +114,10 @@
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()
diff --git a/scenario/templates/test_neutron_autoscaling.yaml b/scenario/templates/test_neutron_autoscaling.yaml
new file mode 100644
index 0000000..59aad2c
--- /dev/null
+++ b/scenario/templates/test_neutron_autoscaling.yaml
@@ -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 } ]
diff --git a/scenario/test_server_cfn_init.yaml b/scenario/templates/test_server_cfn_init.yaml
similarity index 100%
rename from scenario/test_server_cfn_init.yaml
rename to scenario/templates/test_server_cfn_init.yaml
diff --git a/scenario/test_volumes_create_from_backup.yaml b/scenario/templates/test_volumes_create_from_backup.yaml
similarity index 100%
rename from scenario/test_volumes_create_from_backup.yaml
rename to scenario/templates/test_volumes_create_from_backup.yaml
diff --git a/scenario/test_volumes_delete_snapshot.yaml b/scenario/templates/test_volumes_delete_snapshot.yaml
similarity index 100%
rename from scenario/test_volumes_delete_snapshot.yaml
rename to scenario/templates/test_volumes_delete_snapshot.yaml
diff --git a/scenario/test_neutron_autoscaling.py b/scenario/test_neutron_autoscaling.py
index be01328..0e3c404 100644
--- a/scenario/test_neutron_autoscaling.py
+++ b/scenario/test_neutron_autoscaling.py
@@ -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 @@
"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 @@
# 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()
diff --git a/scenario/test_server_cfn_init.py b/scenario/test_server_cfn_init.py
index 64b2a35..630e2e9 100644
--- a/scenario/test_server_cfn_init.py
+++ b/scenario/test_server_cfn_init.py
@@ -27,6 +27,7 @@
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 @@
}
# 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,
diff --git a/scenario/test_volumes.py b/scenario/test_volumes.py
index 841a091..9953648 100644
--- a/scenario/test_volumes.py
+++ b/scenario/test_volumes.py
@@ -56,7 +56,7 @@
# 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,