Browse Source

Merge "functional: Wait for port binding update"

changes/74/686974/1
Zuul 1 month ago
parent
commit
aa8a0cb5d5

+ 23
- 0
networking_ovn/tests/functional/resources/ovsdb/events.py View File

@@ -16,6 +16,7 @@ import collections
import threading

from ovsdbapp.backend.ovs_idl import event
from ovsdbapp.tests.functional.schema.ovn_southbound import event as test_event


class WaitForCrLrpPortBindingEvent(event.RowEvent):
@@ -40,3 +41,25 @@ class WaitForCrLrpPortBindingEvent(event.RowEvent):
self.timeout)
del self.logical_port_events[logical_port_name]
return wait_val


class WaitForCreatePortBindingEvent(test_event.WaitForPortBindingEvent):
event_name = 'WaitForCreatePortBindingEvent'

def run(self, event, row, old):
self.row = row
super(WaitForCreatePortBindingEvent, self).run(event, row, old)


class WaitForUpdatePortBindingEvent(test_event.WaitForPortBindingEvent):
event_name = 'WaitForUpdatePortBindingEvent'

def __init__(self, port, mac, timeout=5):
# Call the super of the superclass to avoid passing CREATE event type
# to the superclass.
super(test_event.WaitForPortBindingEvent, self).__init__(
(self.ROW_UPDATE,),
'Port_Binding',
(('logical_port', '=', port),
('mac', '=', mac)),
timeout=timeout)

+ 8
- 9
networking_ovn/tests/functional/test_impl_idl.py View File

@@ -16,16 +16,10 @@ import uuid

from ovsdbapp import event as ovsdb_event
from ovsdbapp.tests.functional import base
from ovsdbapp.tests.functional.schema.ovn_southbound import event
from ovsdbapp.tests import utils

from networking_ovn.ovsdb import impl_idl_ovn as impl


class WaitForPortBindingEvent(event.WaitForPortBindingEvent):
def run(self, event, row, old):
self.row = row
super(WaitForPortBindingEvent, self).run(event, row, old)
from networking_ovn.tests.functional.resources.ovsdb import events


class TestSbApi(base.FunctionalTestCase):
@@ -92,7 +86,7 @@ class TestSbApi(base.FunctionalTestCase):
sname, pname = (utils.get_rand_device_name(prefix=p)
for p in ('switch', 'port'))
chassis = self.api.lookup('Chassis', chassis_name)
row_event = WaitForPortBindingEvent(pname)
row_event = events.WaitForCreatePortBindingEvent(pname)
self.handler.watch_event(row_event)
with self.nbapi.transaction(check_error=True) as txn:
switch = txn.add(self.nbapi.ls_add(sname))
@@ -124,8 +118,13 @@ class TestSbApi(base.FunctionalTestCase):
self.data['chassis'][0]['name'])
mac = 'de:ad:be:ef:4d:ad'
ipaddr = '192.0.2.1'
mac_ip = '%s %s' % (mac, ipaddr)
pb_update_event = events.WaitForUpdatePortBindingEvent(
port.name, mac=[mac_ip])
self.handler.watch_event(pb_update_event)
self.nbapi.lsp_set_addresses(
port.name, ['%s %s' % (mac, ipaddr)]).execute(check_error=True)
port.name, [mac_ip]).execute(check_error=True)
self.assertTrue(pb_update_event.wait())
self.api.lsp_bind(port.name, chassis.name).execute(check_error=True)
result = self.api.get_network_port_bindings_by_ip(
str(binding.datapath.uuid), ipaddr)

Loading…
Cancel
Save