Skip to content

Commit cbcfa69

Browse files
mnederloffernandoroyosanchez
authored andcommitted
[OVN] Fix virtual parent match for PortBindingUpdateVirtualPortsEvent
As mentioned in change [1], the condition should be a `is None` as per inline comment. [1] https://review.opendev.org/c/openstack/neutron/+/896883 (NOTE: This patch retrieves a test that was skipped in a previous backport.) Related-Bug: #2038413 Change-Id: I3666cf0509747863ca2a416c8bfc065582573734 (cherry picked from commit 170d99f)
1 parent ebd52b0 commit cbcfa69

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def match_fn(self, event, row, old):
572572
# which means we need to update the host_id information
573573
return True
574574

575-
if getattr(old, 'options', None) is not None:
575+
if getattr(old, 'options', None) is None:
576576
# The "old.options" dictionary is not being modified,
577577
# thus the virtual parents didn't change.
578578
return False

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from ovsdbapp.backend.ovs_idl import event
2929
from ovsdbapp.backend.ovs_idl import idlutils
3030
import tenacity
31-
import testtools
3231

3332
from neutron.common.ovn import constants as ovn_const
3433
from neutron.common import utils as n_utils
@@ -360,7 +359,6 @@ def is_port_virtual_parents(port_id, vparents):
360359

361360
@mock.patch.object(mech_driver.OVNMechanismDriver,
362361
'update_virtual_port_host')
363-
@testtools.skip('will be recovery by following patch in chain 2038413')
364362
def test_virtual_port_host_update(self, mock_update_vip_host):
365363
# NOTE: because we can't simulate traffic from a port, this check is
366364
# not done in this test. This test checks the VIP host is unset when

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,65 @@ def test_event_matches(self):
392392
'type': '_fake_'}))
393393

394394

395+
class TestPortBindingUpdateVirtualPortsEvent(base.BaseTestCase):
396+
def setUp(self):
397+
super().setUp()
398+
self.event = ovsdb_monitor.PortBindingUpdateVirtualPortsEvent(None)
399+
400+
self.pbtable = fakes.FakeOvsdbTable.create_one_ovsdb_table(
401+
attrs={'name': 'Port_Binding'})
402+
self.ovsdb_row = fakes.FakeOvsdbRow.create_one_ovsdb_row
403+
404+
self.row = self.ovsdb_row(
405+
attrs={'_table': self.pbtable,
406+
'chassis': 'newchassis',
407+
'options': {
408+
'virtual-parents': 'uuid1,uuid2'}})
409+
410+
def test_delete_event_matches(self):
411+
# Delete event (only type virtual).
412+
self.assertFalse(self.event.match_fn(
413+
self.event.ROW_DELETE,
414+
self.ovsdb_row(attrs={'_table': self.pbtable, 'type': '_fake_'}),
415+
None))
416+
self.assertTrue(self.event.match_fn(
417+
self.event.ROW_DELETE,
418+
self.ovsdb_row(attrs={'_table': self.pbtable, 'type': 'virtual'}),
419+
None))
420+
421+
def test_event_no_match_no_options(self):
422+
# Unrelated portbind change (no options in old, so no virtual parents)
423+
self.assertFalse(self.event.match_fn(
424+
self.event.ROW_UPDATE, self.row,
425+
self.ovsdb_row(attrs={'_table': self.pbtable,
426+
'name': 'somename'})))
427+
428+
def test_event_no_match_other_options_change(self):
429+
# Non-virtual parent change, no chassis has changed
430+
old = self.ovsdb_row(attrs={'_table': self.pbtable,
431+
'options': {
432+
'virtual-parents': 'uuid1,uuid2',
433+
'other-opt': '_fake_'}})
434+
435+
self.assertFalse(self.event.match_fn(self.event.ROW_UPDATE,
436+
self.row, old))
437+
438+
def test_event_match_chassis_change(self):
439+
# Port binding change (chassis changed, and marked in old)
440+
self.assertTrue(self.event.match_fn(
441+
self.event.ROW_UPDATE, self.row,
442+
self.ovsdb_row(attrs={'_table': self.pbtable,
443+
'chassis': 'fakechassis'})))
444+
445+
def test_event_match_virtual_parent_change(self):
446+
# Virtual parent change
447+
old = self.ovsdb_row(attrs={'_table': self.pbtable,
448+
'options': {
449+
'virtual-parents': 'uuid1,uuid3'}})
450+
self.assertTrue(self.event.match_fn(self.event.ROW_UPDATE,
451+
self.row, old))
452+
453+
395454
class TestOvnNbIdlNotifyHandler(test_mech_driver.OVNMechanismDriverTestCase):
396455

397456
def setUp(self):

0 commit comments

Comments
 (0)