Skip to content

Commit 33adbc8

Browse files
committed
[FT] Wait for the FIP Port_Binding event before checking MAC removal
In the test ``test_floatingip_mac_bindings``, when a FIP is created, the FIP address "MAC_Binding" register should be removed. This patch is adding an active wait for the FIP address "Port_Binding" before checking the "MAC_Binding" removal. This patch is also increasing the timeout to check the "MAC_Binding" removal, from 15 to 30 seconds. This excesive delay could be caused because of how the event ``run`` method is handled. Once the eventlet removal is finished, we should revert this timeout increase. Conflicts: neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py Closes-Bug: #2115242 Signed-off-by: Rodolfo Alonso Hernandez <[email protected]> Change-Id: Ia153b48aaec72e6a073b313ef2aea8efac6dbbae (cherry picked from commit 5034b07)
1 parent c3be83f commit 33adbc8

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ def __init__(self, chassis_name):
6969
super().__init__(events, 'Chassis_Private', conditions, timeout=15)
7070

7171

72+
class WaitForPortBindingFIPEvent(event.WaitEvent):
73+
event_name = 'WaitForPortBindingFIPEvent'
74+
75+
def __init__(self, fip):
76+
events = (self.ROW_UPDATE, )
77+
self._fip = fip
78+
super().__init__(events, 'Port_Binding', {}, timeout=15)
79+
80+
def match_fn(self, event, row, old=None):
81+
try:
82+
return (row.external_ids[ovn_const.OVN_PORT_FIP_EXT_ID_KEY] ==
83+
self._fip)
84+
except (AttributeError, KeyError):
85+
return False
86+
87+
7288
class DistributedLockTestEvent(event.WaitEvent):
7389
ONETIME = False
7490
COUNTER = 0
@@ -219,10 +235,15 @@ def test_floatingip_mac_bindings(self):
219235
port = self.create_port()
220236

221237
# Ensure that the MAC_Binding entry gets deleted after creating a FIP
238+
fip_event = WaitForPortBindingFIPEvent('100.0.0.21')
239+
self.mech_driver.sb_ovn.idl.notify_handler.watch_event(fip_event)
222240
fip = self._create_fip(port, '100.0.0.21')
241+
self.assertTrue(fip_event.wait())
242+
# TODO(ralonsoh): restore the timeout=15 value (or even lower) once
243+
# the eventlet removal finishes.
223244
n_utils.wait_until_true(
224245
lambda: not self._check_mac_binding_exists(macb_id),
225-
timeout=15, sleep=1)
246+
timeout=30, sleep=1)
226247

227248
# Now that the FIP is created, add a new MAC_Binding entry with the
228249
# same IP address
@@ -231,9 +252,11 @@ def test_floatingip_mac_bindings(self):
231252

232253
# Ensure that the MAC_Binding entry gets deleted after deleting the FIP
233254
self.l3_plugin.delete_floatingip(self.context, fip['id'])
255+
# TODO(ralonsoh): restore the timeout=15 value (or even lower) once
256+
# the eventlet removal finishes.
234257
n_utils.wait_until_true(
235258
lambda: not self._check_mac_binding_exists(macb_id),
236-
timeout=15, sleep=1)
259+
timeout=30, sleep=1)
237260

238261
def _test_port_binding_and_status(self, port_id, action, status):
239262
# This function binds or unbinds port to chassis and

0 commit comments

Comments
 (0)