[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 170d99f2d5)
This commit is contained in:
Michel Nederlof 2024-06-10 12:18:46 +02:00 committed by Fernando Royo
parent ebd52b0df3
commit cbcfa692fc
3 changed files with 60 additions and 3 deletions

View File

@ -572,7 +572,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

@ -28,7 +28,6 @@ from oslo_utils import uuidutils
from ovsdbapp.backend.ovs_idl import event
from ovsdbapp.backend.ovs_idl import idlutils
import tenacity
import testtools
from neutron.common.ovn import constants as ovn_const
from neutron.common import utils as n_utils
@ -360,7 +359,6 @@ class TestNBDbMonitor(base.TestOVNFunctionalBase):
@mock.patch.object(mech_driver.OVNMechanismDriver,
'update_virtual_port_host')
@testtools.skip('will be recovery by following patch in chain 2038413')
def test_virtual_port_host_update(self, mock_update_vip_host):
# NOTE: because we can't simulate traffic from a port, this check is
# not done in this test. This test checks the VIP host is unset when

View File

@ -392,6 +392,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):