Merge "[OVN] Fix virtual parent match for PortBindingUpdateVirtualPortsEvent" into stable/2023.1

This commit is contained in:
Zuul 2024-06-14 12:32:59 +00:00 committed by Gerrit Code Review
commit 675eba6d2c
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 # which means we need to update the host_id information
return True 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, # The "old.options" dictionary is not being modified,
# thus the virtual parents didn't change. # thus the virtual parents didn't change.
return False 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 event
from ovsdbapp.backend.ovs_idl import idlutils from ovsdbapp.backend.ovs_idl import idlutils
import tenacity import tenacity
import testtools
from neutron.common.ovn import constants as ovn_const from neutron.common.ovn import constants as ovn_const
from neutron.common import utils as n_utils from neutron.common import utils as n_utils
@ -360,7 +359,6 @@ class TestNBDbMonitor(base.TestOVNFunctionalBase):
@mock.patch.object(mech_driver.OVNMechanismDriver, @mock.patch.object(mech_driver.OVNMechanismDriver,
'update_virtual_port_host') '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): def test_virtual_port_host_update(self, mock_update_vip_host):
# NOTE: because we can't simulate traffic from a port, this check is # 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 # 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_'})) '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): class TestOvnNbIdlNotifyHandler(test_mech_driver.OVNMechanismDriverTestCase):
def setUp(self): def setUp(self):