Don't hard code subnet

Replace hard coded private-subnet with configurable heat subnet for
lbaasv2 functional test.

Change-Id: Ie1a3d9ce02da30dcfa67b9de76900807de8212df
This commit is contained in:
Anant Patil 2016-06-07 15:18:35 +05:30
parent 051999e47f
commit 4c54183621

View File

@ -21,12 +21,15 @@ class LoadBalancerv2Test(functional_base.FunctionalTestsBase):
create_template = ''' create_template = '''
heat_template_version: 2016-04-08 heat_template_version: 2016-04-08
parameters:
subnet:
type: string
resources: resources:
loadbalancer: loadbalancer:
type: OS::Neutron::LBaaS::LoadBalancer type: OS::Neutron::LBaaS::LoadBalancer
properties: properties:
description: aLoadBalancer description: aLoadBalancer
vip_subnet: private-subnet vip_subnet: { get_param: subnet }
listener: listener:
type: OS::Neutron::LBaaS::Listener type: OS::Neutron::LBaaS::Listener
properties: properties:
@ -48,7 +51,7 @@ resources:
address: 1.1.1.1 address: 1.1.1.1
pool: { get_resource: pool } pool: { get_resource: pool }
protocol_port: 1111 protocol_port: 1111
subnet: private-subnet subnet: { get_param: subnet }
weight: 255 weight: 255
# pm2 # pm2
healthmonitor: healthmonitor:
@ -79,7 +82,7 @@ outputs:
address: 2.2.2.2 address: 2.2.2.2
pool: { get_resource: pool } pool: { get_resource: pool }
protocol_port: 2222 protocol_port: 2222
subnet: private-subnet subnet: { get_param: subnet }
weight: 222 weight: 222
''' '''
@ -89,7 +92,11 @@ outputs:
self.skipTest('LBaasv2 extension not available, skipping') self.skipTest('LBaasv2 extension not available, skipping')
def test_create_update_loadbalancer(self): def test_create_update_loadbalancer(self):
stack_identifier = self.stack_create(template=self.create_template) parameters = {
'subnet': self.conf.fixed_subnet_name,
}
stack_identifier = self.stack_create(template=self.create_template,
parameters=parameters)
stack = self.client.stacks.get(stack_identifier) stack = self.client.stacks.get(stack_identifier)
output = self._stack_output(stack, 'loadbalancer') output = self._stack_output(stack, 'loadbalancer')
self.assertEqual('ONLINE', output['operating_status']) self.assertEqual('ONLINE', output['operating_status'])
@ -101,7 +108,8 @@ outputs:
template = template.replace('aLoadBalancer', 'updatedLoadBalancer') template = template.replace('aLoadBalancer', 'updatedLoadBalancer')
template = template.replace('aPool', 'updatedPool') template = template.replace('aPool', 'updatedPool')
template = template.replace('aListener', 'updatedListener') template = template.replace('aListener', 'updatedListener')
self.update_stack(stack_identifier, template=template) self.update_stack(stack_identifier, template=template,
parameters=parameters)
stack = self.client.stacks.get(stack_identifier) stack = self.client.stacks.get(stack_identifier)
output = self._stack_output(stack, 'loadbalancer') output = self._stack_output(stack, 'loadbalancer')
@ -121,7 +129,11 @@ outputs:
self.assertEqual('updatedListener', output['description']) self.assertEqual('updatedListener', output['description'])
def test_add_delete_poolmember(self): def test_add_delete_poolmember(self):
stack_identifier = self.stack_create(template=self.create_template) parameters = {
'subnet': self.conf.fixed_subnet_name,
}
stack_identifier = self.stack_create(template=self.create_template,
parameters=parameters)
stack = self.client.stacks.get(stack_identifier) stack = self.client.stacks.get(stack_identifier)
output = self._stack_output(stack, 'loadbalancer') output = self._stack_output(stack, 'loadbalancer')
self.assertEqual('ONLINE', output['operating_status']) self.assertEqual('ONLINE', output['operating_status'])
@ -129,14 +141,16 @@ outputs:
self.assertEqual(1, len(output['members'])) self.assertEqual(1, len(output['members']))
# add pool member # add pool member
template = self.create_template.replace('# pm2', self.add_member) template = self.create_template.replace('# pm2', self.add_member)
self.update_stack(stack_identifier, template=template) self.update_stack(stack_identifier, template=template,
parameters=parameters)
stack = self.client.stacks.get(stack_identifier) stack = self.client.stacks.get(stack_identifier)
output = self._stack_output(stack, 'loadbalancer') output = self._stack_output(stack, 'loadbalancer')
self.assertEqual('ONLINE', output['operating_status']) self.assertEqual('ONLINE', output['operating_status'])
output = self._stack_output(stack, 'pool') output = self._stack_output(stack, 'pool')
self.assertEqual(2, len(output['members'])) self.assertEqual(2, len(output['members']))
# delete pool member # delete pool member
self.update_stack(stack_identifier, template=self.create_template) self.update_stack(stack_identifier, template=self.create_template,
parameters=parameters)
stack = self.client.stacks.get(stack_identifier) stack = self.client.stacks.get(stack_identifier)
output = self._stack_output(stack, 'loadbalancer') output = self._stack_output(stack, 'loadbalancer')
self.assertEqual('ONLINE', output['operating_status']) self.assertEqual('ONLINE', output['operating_status'])