Merge "Correct update to zero numbers of health monitors"

This commit is contained in:
Jenkins 2014-04-08 08:51:04 +00:00 committed by Gerrit Code Review
commit cd57d1cf2e
2 changed files with 53 additions and 4 deletions

View File

@ -382,8 +382,8 @@ class Pool(neutron.NeutronResource):
def handle_update(self, json_snippet, tmpl_diff, prop_diff): def handle_update(self, json_snippet, tmpl_diff, prop_diff):
if prop_diff: if prop_diff:
client = self.neutron() client = self.neutron()
monitors = set(prop_diff.pop(self.MONITORS, [])) if self.MONITORS in prop_diff:
if monitors: monitors = set(prop_diff.pop(self.MONITORS))
old_monitors = set(self.properties[self.MONITORS]) old_monitors = set(self.properties[self.MONITORS])
for monitor in old_monitors - monitors: for monitor in old_monitors - monitors:
client.disassociate_health_monitor(self.resource_id, client.disassociate_health_monitor(self.resource_id,

View File

@ -990,8 +990,7 @@ class PoolUpdateHealthMonitorsTest(HeatTestCase):
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
utils.setup_dummy_db() utils.setup_dummy_db()
@utils.stack_delete_after def _create_pool_with_health_monitors(self):
def test_update_pool_with_references_to_health_monitors(self):
clients.OpenStackClients.keystone().MultipleTimes().AndReturn( clients.OpenStackClients.keystone().MultipleTimes().AndReturn(
fakes.FakeKeystoneClient()) fakes.FakeKeystoneClient())
neutronclient.Client.create_health_monitor({ neutronclient.Client.create_health_monitor({
@ -1026,6 +1025,10 @@ class PoolUpdateHealthMonitorsTest(HeatTestCase):
neutronclient.Client.show_vip('xyz').AndReturn( neutronclient.Client.show_vip('xyz').AndReturn(
{'vip': {'status': 'ACTIVE'}}) {'vip': {'status': 'ACTIVE'}})
@utils.stack_delete_after
def test_update_pool_with_references_to_health_monitors(self):
self._create_pool_with_health_monitors()
neutronclient.Client.disassociate_health_monitor( neutronclient.Client.disassociate_health_monitor(
'5678', mox.IsA(unicode)) '5678', mox.IsA(unicode))
@ -1043,3 +1046,49 @@ class PoolUpdateHealthMonitorsTest(HeatTestCase):
self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE), self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE),
self.stack.state) self.stack.state)
self.m.VerifyAll() self.m.VerifyAll()
@utils.stack_delete_after
def test_update_pool_with_empty_list_of_health_monitors(self):
self._create_pool_with_health_monitors()
neutronclient.Client.disassociate_health_monitor(
'5678', '5555').InAnyOrder()
neutronclient.Client.disassociate_health_monitor(
'5678', '6666').InAnyOrder()
self.m.ReplayAll()
snippet = template_format.parse(pool_with_health_monitors_template)
self.stack = utils.parse_stack(snippet)
self.stack.create()
self.assertEqual((self.stack.CREATE, self.stack.COMPLETE),
self.stack.state)
snippet['Resources']['pool']['Properties']['monitors'] = []
updated_stack = utils.parse_stack(snippet)
self.stack.update(updated_stack)
self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE),
self.stack.state)
self.m.VerifyAll()
@utils.stack_delete_after
def test_update_pool_without_health_monitors(self):
self._create_pool_with_health_monitors()
neutronclient.Client.disassociate_health_monitor(
'5678', '5555').InAnyOrder()
neutronclient.Client.disassociate_health_monitor(
'5678', '6666').InAnyOrder()
self.m.ReplayAll()
snippet = template_format.parse(pool_with_health_monitors_template)
self.stack = utils.parse_stack(snippet)
self.stack.create()
self.assertEqual((self.stack.CREATE, self.stack.COMPLETE),
self.stack.state)
snippet['Resources']['pool']['Properties'].pop('monitors')
updated_stack = utils.parse_stack(snippet)
self.stack.update(updated_stack)
self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE),
self.stack.state)
self.m.VerifyAll()