]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix haproxy plugin_driver.update_health_monitor() signature
authorOleg Bondarev <obondarev@mirantis.com>
Thu, 13 Jun 2013 12:28:38 +0000 (16:28 +0400)
committerGerrit Code Review <review@openstack.org>
Fri, 21 Jun 2013 04:35:16 +0000 (04:35 +0000)
- 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

quantum/services/loadbalancer/drivers/abstract_driver.py
quantum/services/loadbalancer/drivers/haproxy/plugin_driver.py
quantum/services/loadbalancer/plugin.py
quantum/tests/unit/services/loadbalancer/drivers/haproxy/test_plugin_driver.py

index 4112301033843dded8ade0c0f93fde783e345b9a..eaec09ac26c6ec8f9852cabb366885a901e02e00 100644 (file)
@@ -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
index 76426cbbd8f07ff9d8efa0c03014029ded91ff3f..3a8f19cfde330b314afb8c1ad118b9ef30d6dfa1 100644 (file)
@@ -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):
index 1f67d62febb9d3831161c3d4cee31df954bc8242..1db138d83f6cf1b1426de282cafd97b8ea8f6938 100644 (file)
@@ -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):
index 8129f4d86b40f5c909615dfc42eafd9497be7b0a..3852af6e0060865fce8c0879e80a374df922f69c 100644 (file)
@@ -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)