From: Oleg Bondarev Date: Thu, 13 Jun 2013 12:28:38 +0000 (+0400) Subject: Fix haproxy plugin_driver.update_health_monitor() signature X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a1b8a10c569ae460a3abd86019d86c759ab6ab20;p=openstack-build%2Fneutron-build.git Fix haproxy plugin_driver.update_health_monitor() signature - add old_health_monitor parameter to the method - the method signature in abstract lbaas driver was also changed to accept pool_id rather than an assoc object as driver only needs pool_id Fixes bug 1190577 Change-Id: Ie199f46e089a16214ed649a3169e985a726e5d99 --- diff --git a/quantum/services/loadbalancer/drivers/abstract_driver.py b/quantum/services/loadbalancer/drivers/abstract_driver.py index 411230103..eaec09ac2 100644 --- a/quantum/services/loadbalancer/drivers/abstract_driver.py +++ b/quantum/services/loadbalancer/drivers/abstract_driver.py @@ -117,7 +117,7 @@ class LoadBalancerAbstractDriver(object): def update_health_monitor(self, context, old_health_monitor, health_monitor, - pool_association): + pool_id): pass @abc.abstractmethod diff --git a/quantum/services/loadbalancer/drivers/haproxy/plugin_driver.py b/quantum/services/loadbalancer/drivers/haproxy/plugin_driver.py index 76426cbbd..3a8f19cfd 100644 --- a/quantum/services/loadbalancer/drivers/haproxy/plugin_driver.py +++ b/quantum/services/loadbalancer/drivers/haproxy/plugin_driver.py @@ -271,8 +271,9 @@ class HaproxyOnHostPluginDriver(abstract_driver.LoadBalancerAbstractDriver): self.plugin._delete_db_member(context, member['id']) self.agent_rpc.modify_pool(context, member['pool_id']) - def update_health_monitor(self, context, healthmon, pool_id): - # healthmon is unused here because agent will fetch what is necessary + def update_health_monitor(self, context, old_health_monitor, + health_monitor, pool_id): + # monitors are unused here because agent will fetch what is necessary self.agent_rpc.modify_pool(context, pool_id) def delete_health_monitor(self, context, healthmon_id, pool_id): diff --git a/quantum/services/loadbalancer/plugin.py b/quantum/services/loadbalancer/plugin.py index 1f67d62fe..1db138d83 100644 --- a/quantum/services/loadbalancer/plugin.py +++ b/quantum/services/loadbalancer/plugin.py @@ -166,7 +166,8 @@ class LoadBalancerPlugin(loadbalancer_db.LoadBalancerPluginDb): loadbalancer_db.PoolMonitorAssociation ).filter_by(monitor_id=hm['id']) for assoc in qry: - self.driver.update_health_monitor(context, old_hm, hm, assoc) + self.driver.update_health_monitor(context, old_hm, + hm, assoc['pool_id']) return hm def _delete_db_pool_health_monitor(self, context, hm_id, pool_id): diff --git a/quantum/tests/unit/services/loadbalancer/drivers/haproxy/test_plugin_driver.py b/quantum/tests/unit/services/loadbalancer/drivers/haproxy/test_plugin_driver.py index 8129f4d86..3852af6e0 100644 --- a/quantum/tests/unit/services/loadbalancer/drivers/haproxy/test_plugin_driver.py +++ b/quantum/tests/unit/services/loadbalancer/drivers/haproxy/test_plugin_driver.py @@ -321,3 +321,41 @@ class TestLoadBalancerPluginNotificationWrapper(TestLoadBalancerPluginBase): mock.ANY, vip['vip']['pool_id'] ) + + def test_update_health_monitor_associated_with_pool(self): + with self.health_monitor(type='HTTP') as monitor: + with self.pool() as pool: + data = { + 'health_monitor': { + 'id': monitor['health_monitor']['id'], + 'tenant_id': self._tenant_id + } + } + req = self.new_create_request( + 'pools', + data, + fmt=self.fmt, + id=pool['pool']['id'], + subresource='health_monitors') + res = req.get_response(self.ext_api) + self.assertEqual(res.status_int, 201) + self.mock_api.modify_pool.assert_called_once_with( + mock.ANY, + pool['pool']['id'] + ) + + self.mock_api.reset_mock() + data = {'health_monitor': {'delay': 20, + 'timeout': 20, + 'max_retries': 2, + 'admin_state_up': False}} + req = self.new_update_request("health_monitors", + data, + monitor['health_monitor']['id']) + req.get_response(self.ext_api) + self.mock_api.modify_pool.assert_called_once_with( + mock.ANY, + pool['pool']['id'] + ) + + # TODO(obondarev): improve plugin_driver test coverage (bug 1191007)