Test does the following: 1. Creates an instances with LoadBalancer 2. Increased desired capacity 3. Check that LB resources has been increased Test replaces test_neutron_autoscaling unittest. Part of blueprint decouple-nested. Change-Id: I3b4924bfe3e427ffc77b23e0a3b6b08accfa39eb
124 lines
4.1 KiB
Python
124 lines
4.1 KiB
Python
# 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
|
|
|
|
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):
|
|
""""
|
|
The class is responsible for testing of neutron resources autoscaling.
|
|
"""
|
|
|
|
def setUp(self):
|
|
super(NeutronAutoscalingTest, self).setUp()
|
|
self.client = self.orchestration_client
|
|
if not self.conf.minimal_image_ref:
|
|
raise self.skipException("No minimal image configured to test")
|
|
if not self.conf.instance_type:
|
|
raise self.skipException("No flavor configured to test")
|
|
if not self.conf.fixed_subnet_name:
|
|
raise self.skipException("No sub-network configured to test")
|
|
|
|
def test_neutron_autoscaling(self):
|
|
"""
|
|
Check autoscaling of load balancer members in heat.
|
|
|
|
The alternative scenario is the following:
|
|
1. Initialize environment variables.
|
|
2. Create a stack with a load balancer.
|
|
3. Check that the load balancer created
|
|
one load balancer member for stack.
|
|
4. Update stack definition: increase desired capacity of stack.
|
|
5. Check that number of members in load balancer was increased.
|
|
"""
|
|
|
|
# Init env variables
|
|
env = {'parameters': {"image_id": self.conf.minimal_image_ref,
|
|
"capacity": "1",
|
|
"instance_type": self.conf.instance_type,
|
|
"fixed_subnet_name":
|
|
self.conf.fixed_subnet_name,
|
|
}}
|
|
|
|
# Create stack
|
|
stack_id = self.stack_create(template=test_template,
|
|
environment=env)
|
|
|
|
members = self.network_client.list_members()
|
|
self.assertEqual(1, len(members["members"]))
|
|
|
|
# Increase desired capacity and update the stack
|
|
env["parameters"]["capacity"] = "2"
|
|
self.update_stack(stack_id,
|
|
template=test_template,
|
|
environment=env)
|
|
|
|
upd_members = self.network_client.list_members()
|
|
self.assertEqual(2, len(upd_members["members"])) |