From 8e3cd57eca2614179a7713f096b24995753b99b4 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Tue, 8 Oct 2024 12:25:50 +0200 Subject: [PATCH] [Fullstack] Add active waiting for one HA agent to be active for router It may happen that therer will be no communication between keepalived services running in each of the fake hosts for the router and because of that all of the agents hosting router will set themselves as 'active'. Lets add active wait for 15 seconds for the L3 ha agents to set just one of them as 'active' for the HA router. This will allow to make sure if the communication issue is temporary and caused e.g. by the overloaded node or it is permanent (and further debugging will be needed to understand root cause of the issue). Related-Bug: #2083609 Change-Id: I25d39a63ce9351235f98d22c2b3534452963cb85 (cherry picked from commit 634cb25d524cde5eaca4d5fc67746d3c7022287c) --- neutron/tests/fullstack/test_l3_agent.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/neutron/tests/fullstack/test_l3_agent.py b/neutron/tests/fullstack/test_l3_agent.py index c896cdadcea..6c5f1c9b876 100644 --- a/neutron/tests/fullstack/test_l3_agent.py +++ b/neutron/tests/fullstack/test_l3_agent.py @@ -486,12 +486,21 @@ class TestHAL3Agent(TestL3Agent): 'active', ) + def is_one_host_active_for_router(): + active_hosts = get_active_hosts() + return len(active_hosts) == 1 + + try: + common_utils.wait_until_true( + is_one_host_active_for_router, timeout=15) + except common_utils.WaitTimeout: + pass + + # Test one last time: active_hosts = get_active_hosts() - - # Only one host should be active - self.assertEqual(len(active_hosts), 1, - 'More than one active HA routers') - + if len(active_hosts) != 1: + self.fail('Number of active hosts for router: %s', + len(active_hosts)) active_host = active_hosts[0] backup_host = next( h for h in self.environment.hosts if h != active_host)