Ensure HM updates work as expected

This patch ensures if only one parameter is provided the
rest are not modified (set to undefined)

Closes-Bug: #1997416
Change-Id: Ie47f19afdd041843fe47da739b09ee03a88c7b02
This commit is contained in:
Luis Tomas Bolivar 2022-11-22 12:33:14 +01:00
parent 71055bf302
commit 4ccc5970da
2 changed files with 24 additions and 5 deletions

View File

@ -2472,11 +2472,15 @@ class OvnProviderHelper():
LOG.debug("Could not find LB with pool id %s", pool_id)
return status
options = {
'interval': str(info['interval']),
'timeout': str(info['timeout']),
'success_count': str(info['success_count']),
'failure_count': str(info['failure_count'])}
options = {}
if info['interval']:
options['interval'] = str(info['interval'])
if info['timeout']:
options['timeout'] = str(info['timeout'])
if info['success_count']:
options['success_count'] = str(info['success_count'])
if info['failure_count']:
options['failure_count'] = str(info['failure_count'])
commands = []
commands.append(

View File

@ -3675,6 +3675,21 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
self.assertEqual(status['healthmonitors'][0]['operating_status'],
constants.ERROR)
@mock.patch.object(ovn_helper.OvnProviderHelper, '_find_ovn_lb_from_hm_id')
def test_hm_update_just_interval(self, folbfhi):
folbfhi.return_value = (self.ovn_hm, self.ovn_hm_lb)
self.health_monitor['interval'] = 3
self.helper.hm_update(self.health_monitor)
options = {
'interval': str(self.health_monitor['interval']),
'timeout': str(self.health_monitor['timeout']),
'success_count': str(self.health_monitor['success_count']),
'failure_count': str(self.health_monitor['failure_count'])}
self.helper.ovn_nbdb_api.db_set.assert_called_once_with(
'Load_Balancer_Health_Check',
self.ovn_hm.uuid,
('options', options))
def test_hm_delete(self):
self.helper.ovn_nbdb_api.db_list_rows.return_value.\
execute.return_value = [self.ovn_hm]