Use common wait_until_ha_router_has_state method everywhere

In the L3 functional tests framework module there is already helper
method called wait_until_ha_router_has_state which should be used to
wait for desired HA router's state.
This method has proper debug logging added so debugging issues in CI is
easier when it's used.
It is also decorated with unstable_test decorator to skip tests when
router will fail to transition to desired state (see related bug for
details).

In some tests this method wasn't used so we couldn't benefit from the
logging and unstable_test decorator there. Now it should be unifed and
used everywhere in the same way.

Related-Bug: #1956958
Change-Id: I9d79b123bb20ded327208d84a14d4f8d2e505087
(cherry picked from commit e39011c733)
This commit is contained in:
Slawek Kaplonski 2022-07-04 11:09:23 +02:00 committed by yatin
parent 5cb3428d77
commit 6ef9d235d2
1 changed files with 6 additions and 10 deletions

View File

@ -213,7 +213,7 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
n, len([line for line in out.strip().split('\n') if line]))
if ha:
common_utils.wait_until_true(lambda: router.ha_state == 'primary')
self.wait_until_ha_router_has_state(router, 'primary')
with self.assert_max_execution_time(100):
assert_num_of_conntrack_rules(0)
@ -334,7 +334,7 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
router.process()
if enable_ha:
common_utils.wait_until_true(lambda: router.ha_state == 'primary')
self.wait_until_ha_router_has_state(router, 'primary')
# Keepalived notifies of a state transition when it starts,
# not when it ends. Thus, we have to wait until keepalived finishes
@ -669,29 +669,25 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
check_external_device=True):
try:
common_utils.wait_until_true(
lambda: router1.ha_state == 'primary')
self.wait_until_ha_router_has_state(router1, 'primary')
if check_external_device:
common_utils.wait_until_true(
lambda: self._check_external_device(router1))
primary_router = router1
backup_router = router2
except common_utils.WaitTimeout:
common_utils.wait_until_true(
lambda: router2.ha_state == 'primary')
self.wait_until_ha_router_has_state(router2, 'primary')
if check_external_device:
common_utils.wait_until_true(
lambda: self._check_external_device(router2))
primary_router = router2
backup_router = router1
common_utils.wait_until_true(
lambda: primary_router.ha_state == 'primary')
self.wait_until_ha_router_has_state(primary_router, 'primary')
if check_external_device:
common_utils.wait_until_true(
lambda: self._check_external_device(primary_router))
common_utils.wait_until_true(
lambda: backup_router.ha_state == 'backup')
self.wait_until_ha_router_has_state(backup_router, 'backup')
LOG.debug("Found primary router %s and backup router %s",
primary_router.router_id, backup_router.router_id)