Fix exception about loadbalancer_stats
Octavia send loadbalancer statistics through rabbit with type loadbalancer_stats but neutron_lbaas does not support this type. Closes-Bug: #1636380 Change-Id: Ib50c8aad8ce4a8393d69f9c271a8cfb7bedac086
This commit is contained in:
parent
c17d39e1b0
commit
4a5af03452
|
@ -61,9 +61,12 @@ class LoadBalancerBaseDriver(object):
|
|||
self.plugin = plugin
|
||||
|
||||
def handle_streamed_event(self, container):
|
||||
# TODO(crc32): update_stats will be implemented here in the future
|
||||
if container.info_type not in LoadBalancerBaseDriver.model_map:
|
||||
if container.info_type == constants.LISTENER_STATS_EVENT:
|
||||
if container.info_type == constants.LOADBALANCER_STATS_EVENT:
|
||||
context = ncontext.get_admin_context()
|
||||
self.plugin.db.update_loadbalancer_stats(
|
||||
context, container.info_id, container.info_payload)
|
||||
elif container.info_type == constants.LISTENER_STATS_EVENT:
|
||||
return
|
||||
else:
|
||||
exc = exceptions.ModelMapException(
|
||||
|
|
|
@ -167,6 +167,7 @@ MIN_CONNECT_VALUE = -1
|
|||
LISTENER_EVENT = 'listener'
|
||||
LISTENER_STATS_EVENT = 'listener_stats'
|
||||
LOADBALANCER_EVENT = 'loadbalancer'
|
||||
LOADBALANCER_STATS_EVENT = 'loadbalancer_stats'
|
||||
MEMBER_EVENT = 'member'
|
||||
OPERATING_STATUS = 'operating_status'
|
||||
POOL_EVENT = 'pool'
|
||||
|
|
|
@ -138,6 +138,21 @@ class TestOctaviaMessagingConsumer(test_octavia_driver.BaseOctaviaDriverTest):
|
|||
self.assertRaises(exceptions.ModelMapException,
|
||||
self.consumer.endpoints[0].update_info, {}, cnt)
|
||||
|
||||
def test_update_loadbalancer_stats(self):
|
||||
self.set_db_mocks()
|
||||
stats = {
|
||||
'bytes_in': 1,
|
||||
'bytes_out': 2,
|
||||
'active_connections': 3,
|
||||
'total_connections': 4,
|
||||
'request_errors': 5,
|
||||
}
|
||||
cnt = InfoContainer(constants.LOADBALANCER_STATS_EVENT, 'lb_id',
|
||||
stats).to_dict()
|
||||
self.consumer.endpoints[0].update_info({}, cnt)
|
||||
self.driver.plugin.db.update_loadbalancer_stats.assert_called_with(
|
||||
mock.ANY, 'lb_id', stats)
|
||||
|
||||
def test_updatedb_ignores_listener_stats(self):
|
||||
self.set_db_mocks()
|
||||
cnt = InfoContainer('listener_stats', 'id', self.payload).to_dict()
|
||||
|
|
Loading…
Reference in New Issue