Merge "Fix compile_amphora_details when using UDP listeners" into stable/xena

This commit is contained in:
Zuul 2022-06-06 23:30:39 +00:00 committed by Gerrit Code Review
commit 74cd04d171
2 changed files with 10 additions and 5 deletions

View File

@ -112,7 +112,7 @@ class AmphoraInfo(object):
def _count_lvs_listener_processes(self, lvs_driver, listener_list): def _count_lvs_listener_processes(self, lvs_driver, listener_list):
num = 0 num = 0
for listener_id in listener_list: for listener_id in listener_list:
if lvs_driver.is_listener_running(listener_id): if util.is_lvs_listener_running(listener_id):
# optional check if it's still running # optional check if it's still running
num += 1 num += 1
return num return num

View File

@ -182,6 +182,8 @@ class TestAmphoraInfo(base.TestCase):
self.assertEqual(expected_dict, actual.json) self.assertEqual(expected_dict, actual.json)
api_server.VERSION = original_version api_server.VERSION = original_version
@mock.patch('octavia.amphorae.backends.agent.api_server.util.'
'is_lvs_listener_running')
@mock.patch('octavia.amphorae.backends.agent.api_server.util.' @mock.patch('octavia.amphorae.backends.agent.api_server.util.'
'get_lvs_listeners', 'get_lvs_listeners',
return_value=[FAKE_LISTENER_ID_3, FAKE_LISTENER_ID_4]) return_value=[FAKE_LISTENER_ID_3, FAKE_LISTENER_ID_4])
@ -205,7 +207,8 @@ class TestAmphoraInfo(base.TestCase):
m_pkg_version, m_load, m_pkg_version, m_load,
m_get_nets, m_get_nets,
m_os, m_cpu, mget_mem, m_os, m_cpu, mget_mem,
mock_get_lb, mget_lvs_listener): mock_get_lb, mget_lvs_listener,
mock_is_lvs_listener_running):
mget_mem.return_value = {'SwapCached': 0, 'Buffers': 344792, mget_mem.return_value = {'SwapCached': 0, 'Buffers': 344792,
'MemTotal': 21692784, 'Cached': 4271856, 'MemTotal': 21692784, 'Cached': 4271856,
'Slab': 534384, 'MemFree': 12685624, 'Slab': 534384, 'MemFree': 12685624,
@ -227,7 +230,7 @@ class TestAmphoraInfo(base.TestCase):
m_count.return_value = 5 m_count.return_value = 5
self.lvs_driver.get_subscribed_amp_compile_info.return_value = [ self.lvs_driver.get_subscribed_amp_compile_info.return_value = [
'keepalived', 'ipvsadm'] 'keepalived', 'ipvsadm']
self.lvs_driver.is_listener_running.side_effect = [True, False] mock_is_lvs_listener_running.side_effect = [True, False]
mock_get_lb.return_value = [self.LB_ID_1] mock_get_lb.return_value = [self.LB_ID_1]
original_version = api_server.VERSION original_version = api_server.VERSION
api_server.VERSION = self.API_VERSION api_server.VERSION = self.API_VERSION
@ -282,8 +285,10 @@ class TestAmphoraInfo(base.TestCase):
[uuidutils.generate_uuid(), uuidutils.generate_uuid()]) [uuidutils.generate_uuid(), uuidutils.generate_uuid()])
self.assertEqual(1, result) self.assertEqual(1, result)
def test__count_lvs_listener_processes(self): @mock.patch('octavia.amphorae.backends.agent.api_server.util.'
self.lvs_driver.is_listener_running.side_effect = [True, False, True] 'is_lvs_listener_running')
def test__count_lvs_listener_processes(self, mock_is_lvs_listener_running):
mock_is_lvs_listener_running.side_effect = [True, False, True]
expected = 2 expected = 2
actual = self.amp_info._count_lvs_listener_processes( actual = self.amp_info._count_lvs_listener_processes(
self.lvs_driver, [self.FAKE_LISTENER_ID_1, self.lvs_driver, [self.FAKE_LISTENER_ID_1,