[FT] Wait for the manager to be created

This patch introduces a `WaitEvent` to check that the expected
`Manager` register is created before checking it (again).

Closes-Bug: #2131024
Signed-off-by: Rodolfo Alonso Hernandez <ralonsoh@redhat.com>
Change-Id: I64a82952a0895d7ffd8d3e886c4615d62bbe4b20
This commit is contained in:
Rodolfo Alonso Hernandez
2025-11-11 12:37:57 +00:00
parent d738cff717
commit 2b63ab6877

View File

@@ -14,6 +14,7 @@
# under the License.
from neutron_lib import constants as const
from ovsdbapp.backend.ovs_idl import event
from neutron.agent.common import ovs_lib
from neutron.agent.ovsdb.native import helpers
@@ -22,6 +23,16 @@ from neutron.tests.common import net_helpers
from neutron.tests.functional import base
class WaitOvsManagerEvent(event.WaitEvent):
event_name = 'WaitOvsManagerEvent'
def __init__(self, manager_target):
table = 'Manager'
events = (self.ROW_CREATE,)
conditions = (('target', '=', manager_target),)
super().__init__(events, table, conditions, timeout=10)
class EnableConnectionUriTestCase(base.BaseSudoTestCase):
def test_add_manager_appends(self):
@@ -39,10 +50,15 @@ class EnableConnectionUriTestCase(base.BaseSudoTestCase):
manager_connections.append('ptcp:%s:127.0.0.1' % _port)
for index, conn_uri in enumerate(ovsdb_cfg_connections):
target_event = WaitOvsManagerEvent(manager_connections[index])
ovs.ovsdb.idl.notify_handler.watch_event(target_event)
helpers.enable_connection_uri(conn_uri)
manager_removal.append(ovs.ovsdb.remove_manager(
manager_connections[index]))
self.addCleanup(manager_removal[index].execute)
target_event.wait()
# This check is redundant, the ``target_event`` ensures the
# ``Manager`` register with the expected targer is created.
self.assertIn(manager_connections[index],
ovs.ovsdb.get_manager().execute())