Merge "Fix race condition in tests with swift key"
diff --git a/functional/test_create_update_neutron_subnet.py b/functional/test_create_update_neutron_subnet.py
index 6dad7f2..ceb74a9 100644
--- a/functional/test_create_update_neutron_subnet.py
+++ b/functional/test_create_update_neutron_subnet.py
@@ -24,10 +24,13 @@
properties:
network: { get_resource: net }
cidr: 11.11.11.0/24
+ gateway_ip: 11.11.11.5
allocation_pools: [{start: 11.11.11.10, end: 11.11.11.250}]
outputs:
alloc_pools:
value: {get_attr: [subnet, allocation_pools]}
+ gateway_ip:
+ value: {get_attr: [subnet, gateway_ip]}
'''
@@ -36,14 +39,14 @@
def setUp(self):
super(UpdateSubnetTest, self).setUp()
- def get_alloc_pools(self, stack_identifier):
+ def get_outputs(self, stack_identifier, output_key):
stack = self.client.stacks.get(stack_identifier)
- alloc_pools = self._stack_output(stack, 'alloc_pools')
- return alloc_pools
+ output = self._stack_output(stack, output_key)
+ return output
def test_update_allocation_pools(self):
stack_identifier = self.stack_create(template=test_template)
- alloc_pools = self.get_alloc_pools(stack_identifier)
+ alloc_pools = self.get_outputs(stack_identifier, 'alloc_pools')
self.assertEqual([{'start': '11.11.11.10', 'end': '11.11.11.250'}],
alloc_pools)
@@ -52,14 +55,14 @@
'allocation_pools: [{start: 11.11.11.10, end: 11.11.11.250}]',
'allocation_pools: [{start: 11.11.11.10, end: 11.11.11.100}]')
self.update_stack(stack_identifier, templ_other_pool)
- new_alloc_pools = self.get_alloc_pools(stack_identifier)
+ new_alloc_pools = self.get_outputs(stack_identifier, 'alloc_pools')
# the new pools should be the new range
self.assertEqual([{'start': '11.11.11.10', 'end': '11.11.11.100'}],
new_alloc_pools)
def test_update_allocation_pools_to_empty(self):
stack_identifier = self.stack_create(template=test_template)
- alloc_pools = self.get_alloc_pools(stack_identifier)
+ alloc_pools = self.get_outputs(stack_identifier, 'alloc_pools')
self.assertEqual([{'start': '11.11.11.10', 'end': '11.11.11.250'}],
alloc_pools)
@@ -68,13 +71,13 @@
'allocation_pools: [{start: 11.11.11.10, end: 11.11.11.250}]',
'allocation_pools: []')
self.update_stack(stack_identifier, templ_empty_pools)
- new_alloc_pools = self.get_alloc_pools(stack_identifier)
+ new_alloc_pools = self.get_outputs(stack_identifier, 'alloc_pools')
# new_alloc_pools should be []
self.assertEqual([], new_alloc_pools)
def test_update_to_no_allocation_pools(self):
stack_identifier = self.stack_create(template=test_template)
- alloc_pools = self.get_alloc_pools(stack_identifier)
+ alloc_pools = self.get_outputs(stack_identifier, 'alloc_pools')
self.assertEqual([{'start': '11.11.11.10', 'end': '11.11.11.250'}],
alloc_pools)
@@ -83,6 +86,45 @@
'allocation_pools: [{start: 11.11.11.10, end: 11.11.11.250}]',
'')
self.update_stack(stack_identifier, templ_no_pools)
- last_alloc_pools = self.get_alloc_pools(stack_identifier)
+ last_alloc_pools = self.get_outputs(stack_identifier, 'alloc_pools')
# last_alloc_pools should be []
self.assertEqual([], last_alloc_pools)
+
+ def test_update_gateway_ip(self):
+ stack_identifier = self.stack_create(template=test_template)
+ gw_ip = self.get_outputs(stack_identifier, 'gateway_ip')
+ self.assertEqual('11.11.11.5', gw_ip)
+
+ # Update gateway_ip
+ templ_other_gw_ip = test_template.replace(
+ 'gateway_ip: 11.11.11.5', 'gateway_ip: 11.11.11.9')
+ self.update_stack(stack_identifier, templ_other_gw_ip)
+ new_gw_ip = self.get_outputs(stack_identifier, 'gateway_ip')
+ # the gateway_ip should be the new one
+ self.assertEqual('11.11.11.9', new_gw_ip)
+
+ def test_update_gateway_ip_to_empty(self):
+ stack_identifier = self.stack_create(template=test_template)
+ gw_ip = self.get_outputs(stack_identifier, 'gateway_ip')
+ self.assertEqual('11.11.11.5', gw_ip)
+
+ # Update gateway_ip to null(resolve to '')
+ templ_empty_gw_ip = test_template.replace(
+ 'gateway_ip: 11.11.11.5', 'gateway_ip: null')
+ self.update_stack(stack_identifier, templ_empty_gw_ip)
+ new_gw_ip = self.get_outputs(stack_identifier, 'gateway_ip')
+ # new gateway_ip should be None
+ self.assertIsNone(new_gw_ip)
+
+ def test_update_to_no_gateway_ip(self):
+ stack_identifier = self.stack_create(template=test_template)
+ gw_ip = self.get_outputs(stack_identifier, 'gateway_ip')
+ self.assertEqual('11.11.11.5', gw_ip)
+
+ # Remove the gateway from template
+ templ_no_gw_ip = test_template.replace(
+ 'gateway_ip: 11.11.11.5', '')
+ self.update_stack(stack_identifier, templ_no_gw_ip)
+ new_gw_ip = self.get_outputs(stack_identifier, 'gateway_ip')
+ # new gateway_ip should be None
+ self.assertIsNone(new_gw_ip)