Skip to content

Commit 6ef9d23

Browse files
slawqokarelyatin
authored andcommitted
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 e39011c)
1 parent 5cb3428 commit 6ef9d23

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

neutron/tests/functional/agent/l3/framework.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def assert_num_of_conntrack_rules(n):
213213
n, len([line for line in out.strip().split('\n') if line]))
214214

215215
if ha:
216-
common_utils.wait_until_true(lambda: router.ha_state == 'primary')
216+
self.wait_until_ha_router_has_state(router, 'primary')
217217

218218
with self.assert_max_execution_time(100):
219219
assert_num_of_conntrack_rules(0)
@@ -334,7 +334,7 @@ def _router_lifecycle(self, enable_ha, ip_version=constants.IP_VERSION_4,
334334
router.process()
335335

336336
if enable_ha:
337-
common_utils.wait_until_true(lambda: router.ha_state == 'primary')
337+
self.wait_until_ha_router_has_state(router, 'primary')
338338

339339
# Keepalived notifies of a state transition when it starts,
340340
# not when it ends. Thus, we have to wait until keepalived finishes
@@ -669,29 +669,25 @@ def _get_primary_and_backup_routers(self, router1, router2,
669669
check_external_device=True):
670670

671671
try:
672-
common_utils.wait_until_true(
673-
lambda: router1.ha_state == 'primary')
672+
self.wait_until_ha_router_has_state(router1, 'primary')
674673
if check_external_device:
675674
common_utils.wait_until_true(
676675
lambda: self._check_external_device(router1))
677676
primary_router = router1
678677
backup_router = router2
679678
except common_utils.WaitTimeout:
680-
common_utils.wait_until_true(
681-
lambda: router2.ha_state == 'primary')
679+
self.wait_until_ha_router_has_state(router2, 'primary')
682680
if check_external_device:
683681
common_utils.wait_until_true(
684682
lambda: self._check_external_device(router2))
685683
primary_router = router2
686684
backup_router = router1
687685

688-
common_utils.wait_until_true(
689-
lambda: primary_router.ha_state == 'primary')
686+
self.wait_until_ha_router_has_state(primary_router, 'primary')
690687
if check_external_device:
691688
common_utils.wait_until_true(
692689
lambda: self._check_external_device(primary_router))
693-
common_utils.wait_until_true(
694-
lambda: backup_router.ha_state == 'backup')
690+
self.wait_until_ha_router_has_state(backup_router, 'backup')
695691

696692
LOG.debug("Found primary router %s and backup router %s",
697693
primary_router.router_id, backup_router.router_id)

0 commit comments

Comments
 (0)