From 598e0376c6497929a5abc1aa7c7ea1dada5de589 Mon Sep 17 00:00:00 2001 From: Maciej Jozefczyk Date: Mon, 29 Jun 2020 10:55:14 +0000 Subject: [PATCH] [OVN] Wait for WaitForDataPathBindingCreateEvent event in functional tests There is a bug in OVN functional tests, where it looks for datapath binding of just created network. In rare conditions datapath binding entry could not be in place in time, because it is a ovn-northd responsibility to create it and we don't lock this process in neutron api. Change-Id: Ice115623491ad5b50397a0338f0a7780dc05d24c Closes-Bug: #1884986 --- .../ovn/mech_driver/ovsdb/test_ovsdb_monitor.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py index 4f1296faaf1..8f333488bd7 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py @@ -39,6 +39,17 @@ class WaitForMACBindingDeleteEvent(event.WaitEvent): events, table, conditions, timeout=15) +class WaitForDataPathBindingCreateEvent(event.WaitEvent): + event_name = 'WaitForDataPathBindingCreateEvent' + + def __init__(self, net_name): + table = 'Datapath_Binding' + events = (self.ROW_CREATE,) + conditions = (('external_ids', '=', {'name2': net_name}),) + super(WaitForDataPathBindingCreateEvent, self).__init__( + events, table, conditions, timeout=15) + + class DistributedLockTestEvent(event.WaitEvent): ONETIME = False COUNTER = 0 @@ -125,10 +136,12 @@ class TestNBDbMonitor(base.TestOVNFunctionalBase): * Delete the FIP. * Check that the MAC_Binding entry gets deleted. """ - self._make_network(self.fmt, 'network1', True) + net_name = 'network1' + self._make_network(self.fmt, net_name, True) + row_event = WaitForDataPathBindingCreateEvent(net_name) dp = self.sb_api.db_find( 'Datapath_Binding', - ('external_ids', '=', {'name2': 'network1'})).execute() + ('external_ids', '=', {'name2': net_name})).execute() macb_id = self.sb_api.db_create('MAC_Binding', datapath=dp[0]['_uuid'], ip='100.0.0.21').execute() port = self.create_port()