Skip to content

Commit 1fda7ab

Browse files
committed
Check the Chassis_Private nb_cfg_timestamp with current value
In ``test_agent_updated_at_use_nb_cfg_timestamp`` now the test checks the local cache agent "updated_at" value with the current SB "Chassis_Private.nb_cfg_timestamp" value, read from the DB each time the value is tested. Closes-Bug: #1974149 Change-Id: Ibd9ebfbd628d98a6a5de2b4fe47a9cbc65500c84 (cherry picked from commit 1b51ad2)
1 parent 820b25a commit 1fda7ab

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,19 +456,30 @@ def test_agent_change_controller(self):
456456
type(neutron_agent.AgentCache()[self.chassis_name]))
457457

458458
def test_agent_updated_at_use_nb_cfg_timestamp(self):
459+
def check_agent_ts():
460+
agent = neutron_agent.AgentCache()[self.chassis_name]
461+
chassis_ts = self.sb_api.db_get(
462+
'Chassis_Private', self.chassis_name,
463+
'nb_cfg_timestamp').execute(check_error=True)
464+
updated_at = datetime.datetime.fromtimestamp(
465+
int(chassis_ts / 1000), datetime.timezone.utc)
466+
return agent.updated_at == updated_at
467+
459468
if not self.sb_api.is_table_present('Chassis_Private'):
460469
self.skipTest('Ovn sb not support Chassis_Private')
461470
timestamp = timeutils.utcnow_ts()
462471
nb_cfg_timestamp = timestamp * 1000
463-
updated_at = datetime.datetime.fromtimestamp(
464-
timestamp, datetime.timezone.utc)
465472
self.sb_api.db_set('Chassis_Private', self.chassis_name, (
466473
'nb_cfg_timestamp', nb_cfg_timestamp)).execute(check_error=True)
467-
n_utils.wait_until_true(lambda:
468-
neutron_agent.AgentCache()[self.chassis_name].
469-
chassis_private.nb_cfg_timestamp == nb_cfg_timestamp)
470-
agent = neutron_agent.AgentCache()[self.chassis_name]
471-
self.assertEqual(updated_at, agent.updated_at)
474+
try:
475+
n_utils.wait_until_true(check_agent_ts, timeout=5)
476+
except n_utils.WaitTimeout:
477+
agent = neutron_agent.AgentCache()[self.chassis_name]
478+
chassis_ts = self.sb_api.db_get(
479+
'Chassis_Private', self.chassis_name,
480+
'nb_cfg_timestamp').execute(check_error=True)
481+
self.fail('Chassis timestamp: %s, agent updated_at: %s' %
482+
(chassis_ts, str(agent.updated_at)))
472483

473484

474485
class TestOvnIdlProbeInterval(base.TestOVNFunctionalBase):

0 commit comments

Comments
 (0)