]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
LBaaS plugin returns unnecessary information for PING and TCP health monitors
authorAvishay Balderman <avishayb@radware.com>
Wed, 23 Jan 2013 09:49:32 +0000 (01:49 -0800)
committerAvishay Balderman <avishayb@radware.com>
Wed, 23 Jan 2013 14:00:27 +0000 (06:00 -0800)
Fixes Bug #1100749

Change-Id: Id1e22621b398786f3d6b670f53b6e23e7fb89786

quantum/db/loadbalancer/loadbalancer_db.py
quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py

index 356df7b2c4dee54b6ad25b5272dc861d97bc67af..4e731473c7eb07b56cd3a4685825f00b7d53625c 100644 (file)
@@ -603,11 +603,14 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase):
                'delay': health_monitor['delay'],
                'timeout': health_monitor['timeout'],
                'max_retries': health_monitor['max_retries'],
-               'http_method': health_monitor['http_method'],
-               'url_path': health_monitor['url_path'],
-               'expected_codes': health_monitor['expected_codes'],
                'admin_state_up': health_monitor['admin_state_up'],
                'status': health_monitor['status']}
+        # no point to add the values below to
+        # the result if the 'type' is not HTTP/S
+        if res['type'] in ['HTTP', 'HTTPS']:
+            for attr in ['url_path', 'http_method', 'expected_codes']:
+                res[attr] = health_monitor[attr]
+
         return self._fields(res, fields)
 
     def create_health_monitor(self, context, health_monitor):
index e97b8e4b389d0baaf62f6f27cb70801fc351c042..4c5ebf0587290a9d1724e6c060cf357804dd5323 100644 (file)
@@ -366,12 +366,24 @@ class LoadBalancerPluginDbTestCase(unittest2.TestCase):
                                           admin_status_up,
                                           **kwargs)
         health_monitor = self.deserialize(fmt, res)
+        the_health_monitor = health_monitor['health_monitor']
         if res.status_int >= 400:
             raise webob.exc.HTTPClientError(code=res.status_int)
+        # make sure:
+        # 1. When the type is HTTP/S we have HTTP related attributes in
+        #    the result
+        # 2. When the type is not HTTP/S we do not have HTTP related
+        #    attributes in the result
+        http_related_attributes = ('http_method', 'url_path', 'expected_codes')
+        if type in ['HTTP', 'HTTPS']:
+            for arg in http_related_attributes:
+                self.assertIsNotNone(the_health_monitor.get(arg))
+        else:
+            for arg in http_related_attributes:
+                self.assertIsNone(the_health_monitor.get(arg))
         yield health_monitor
         if not no_delete:
-            self._delete('health_monitors',
-                         health_monitor['health_monitor']['id'])
+            self._delete('health_monitors', the_health_monitor['id'])
 
 
 class TestLoadBalancer(LoadBalancerPluginDbTestCase):