Fix health monitor information retrieval in API response
Closes bug: #2038367 Behavior: In the response body of the LB API when creating a new load balancer, the information about the health monitor is always null, even though it has been configured. Reproduce: Using the Octavia API to create a new LB with all components. You cannot see any information about the health monitor that will be returned. Proposed Fix: Modify the assignment to use `data_model.health_monitor` instead of `pool.healthmonitor`. Change-Id: Ia914ad89b6fdf3606c3d4bff0a4c425348c15e0c
This commit is contained in:
parent
860d2f6aad
commit
7261730dff
@ -106,7 +106,7 @@ class PoolResponse(BasePoolType):
|
||||
if cls._full_response():
|
||||
del pool.loadbalancers
|
||||
member_model = member.MemberFullResponse
|
||||
if pool.healthmonitor:
|
||||
if data_model.health_monitor:
|
||||
pool.healthmonitor = (
|
||||
health_monitor.HealthMonitorFullResponse
|
||||
.from_data_model(data_model.health_monitor))
|
||||
|
@ -17,8 +17,12 @@ from wsme import exc
|
||||
from wsme.rest import json as wsme_json
|
||||
from wsme import types as wsme_types
|
||||
|
||||
from octavia.api.common import types
|
||||
from octavia.api.v2.types import health_monitor as health_monitor_type
|
||||
from octavia.api.v2.types import member as member_type
|
||||
from octavia.api.v2.types import pool as pool_type
|
||||
from octavia.common import constants
|
||||
from octavia.common import data_models
|
||||
from octavia.tests.unit.api.common import base
|
||||
|
||||
|
||||
@ -224,3 +228,70 @@ class TestSessionPersistencePUT(base.BaseTypesTest, TestSessionPersistence):
|
||||
body = {"cookie_name": "cookie\nmonster"}
|
||||
self.assertRaises(exc.InvalidInput, wsme_json.fromjson, self._type,
|
||||
body)
|
||||
|
||||
|
||||
class TestPoolResponse(base.BaseTypesTest):
|
||||
|
||||
_type = pool_type.PoolResponse
|
||||
|
||||
def test_pool_response_with_health_monitor(self):
|
||||
health_monitor_id = uuidutils.generate_uuid()
|
||||
health_monitor_model = data_models.HealthMonitor(id=health_monitor_id)
|
||||
pool_model = data_models.Pool(health_monitor=health_monitor_model)
|
||||
pool = self._type.from_data_model(data_model=pool_model)
|
||||
self.assertEqual(pool.healthmonitor_id, health_monitor_id)
|
||||
|
||||
def test_pool_response_with_members(self):
|
||||
member_id = uuidutils.generate_uuid()
|
||||
members = [data_models.Member(id=member_id)]
|
||||
pool_model = data_models.Pool(members=members)
|
||||
pool = self._type.from_data_model(data_model=pool_model)
|
||||
self.assertIsInstance(pool.members[0], types.IdOnlyType)
|
||||
self.assertEqual(pool.members[0].id, member_id)
|
||||
|
||||
def test_pool_response_with_load_balancer(self):
|
||||
load_balancer_id = uuidutils.generate_uuid()
|
||||
load_balancer = data_models.LoadBalancer(id=load_balancer_id)
|
||||
pool_model = data_models.Pool(load_balancer=load_balancer)
|
||||
pool = self._type.from_data_model(data_model=pool_model)
|
||||
self.assertIsInstance(pool.loadbalancers[0], types.IdOnlyType)
|
||||
self.assertEqual(pool.loadbalancers[0].id, load_balancer_id)
|
||||
|
||||
def test_pool_response_with_session_persistence(self):
|
||||
session_persistence = data_models.SessionPersistence(
|
||||
cookie_name="test"
|
||||
)
|
||||
pool_model = data_models.Pool(session_persistence=session_persistence)
|
||||
pool = self._type.from_data_model(data_model=pool_model)
|
||||
self.assertEqual(pool.session_persistence.cookie_name, "test")
|
||||
|
||||
def test_pool_response_without_children(self):
|
||||
pool = self._type.from_data_model(data_model=data_models.Pool())
|
||||
self.assertEqual(len(pool.loadbalancers), 0)
|
||||
self.assertIsNone(pool.session_persistence)
|
||||
self.assertEqual(len(pool.members), 0)
|
||||
self.assertEqual(len(pool.listeners), 0)
|
||||
self.assertEqual(pool.healthmonitor_id, wsme_types.Unset)
|
||||
|
||||
|
||||
class TestPoolFullResponse(base.BaseTypesTest):
|
||||
|
||||
_type = pool_type.PoolFullResponse
|
||||
|
||||
def test_pool_full_response_with_health_monitor(self):
|
||||
health_monitor_model = data_models.HealthMonitor()
|
||||
pool_model = data_models.Pool(health_monitor=health_monitor_model)
|
||||
pool = self._type.from_data_model(data_model=pool_model)
|
||||
self.assertIsInstance(
|
||||
pool.healthmonitor, health_monitor_type.HealthMonitorFullResponse
|
||||
)
|
||||
|
||||
def test_pool_full_response_with_members(self):
|
||||
members = [data_models.Member()]
|
||||
pool_model = data_models.Pool(members=members)
|
||||
pool = self._type.from_data_model(data_model=pool_model)
|
||||
self.assertIsInstance(pool.members[0], member_type.MemberFullResponse)
|
||||
|
||||
def test_pool_full_response_without_children(self):
|
||||
pool = self._type.from_data_model(data_model=data_models.Pool())
|
||||
self.assertIsNone(pool.healthmonitor)
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Bug fix: The response body of the LB API, when creating a new load
|
||||
balancer, now correctly includes information about the health monitor.
|
||||
Previously, this information was consistently null, despite configuring
|
||||
a health monitor.
|
Loading…
x
Reference in New Issue
Block a user