[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

Related-Bug: #2038413
Change-Id: I3666cf0509747863ca2a416c8bfc065582573734
(cherry picked from commit 170d99f2d5)
This commit is contained in:
Michel Nederlof 2024-06-10 12:18:46 +02:00 committed by Fernando Royo
parent 0d8cc09c4a
commit 1098929a54
2 changed files with 60 additions and 1 deletions

View File

@ -568,7 +568,7 @@ class PortBindingUpdateVirtualPortsEvent(row_event.RowEvent):
# which means we need to update the host_id information
return True
if getattr(old, 'options', None) is not None:
if getattr(old, 'options', None) is None:
# The "old.options" dictionary is not being modified,
# thus the virtual parents didn't change.
return False

View File

@ -329,6 +329,65 @@ class TestPortBindingChassisUpdateEvent(base.BaseTestCase):
'type': '_fake_'}))
class TestPortBindingUpdateVirtualPortsEvent(base.BaseTestCase):
def setUp(self):
super().setUp()
self.event = ovsdb_monitor.PortBindingUpdateVirtualPortsEvent(None)
self.pbtable = fakes.FakeOvsdbTable.create_one_ovsdb_table(
attrs={'name': 'Port_Binding'})
self.ovsdb_row = fakes.FakeOvsdbRow.create_one_ovsdb_row
self.row = self.ovsdb_row(
attrs={'_table': self.pbtable,
'chassis': 'newchassis',
'options': {
'virtual-parents': 'uuid1,uuid2'}})
def test_delete_event_matches(self):
# Delete event (only type virtual).
self.assertFalse(self.event.match_fn(
self.event.ROW_DELETE,
self.ovsdb_row(attrs={'_table': self.pbtable, 'type': '_fake_'}),
None))
self.assertTrue(self.event.match_fn(
self.event.ROW_DELETE,
self.ovsdb_row(attrs={'_table': self.pbtable, 'type': 'virtual'}),
None))
def test_event_no_match_no_options(self):
# Unrelated portbind change (no options in old, so no virtual parents)
self.assertFalse(self.event.match_fn(
self.event.ROW_UPDATE, self.row,
self.ovsdb_row(attrs={'_table': self.pbtable,
'name': 'somename'})))
def test_event_no_match_other_options_change(self):
# Non-virtual parent change, no chassis has changed
old = self.ovsdb_row(attrs={'_table': self.pbtable,
'options': {
'virtual-parents': 'uuid1,uuid2',
'other-opt': '_fake_'}})
self.assertFalse(self.event.match_fn(self.event.ROW_UPDATE,
self.row, old))
def test_event_match_chassis_change(self):
# Port binding change (chassis changed, and marked in old)
self.assertTrue(self.event.match_fn(
self.event.ROW_UPDATE, self.row,
self.ovsdb_row(attrs={'_table': self.pbtable,
'chassis': 'fakechassis'})))
def test_event_match_virtual_parent_change(self):
# Virtual parent change
old = self.ovsdb_row(attrs={'_table': self.pbtable,
'options': {
'virtual-parents': 'uuid1,uuid3'}})
self.assertTrue(self.event.match_fn(self.event.ROW_UPDATE,
self.row, old))
class TestOvnNbIdlNotifyHandler(test_mech_driver.OVNMechanismDriverTestCase):
def setUp(self):