[OVN] Add the default condition check in `PortBindingChassisEvent
`
The event ``PortBindingChassisEvent`` should be executed only if the initialization condition "type=ovn_const.OVN_CHASSIS_REDIRECT" is met. This condition was skipped since [1], where the ``match_fn`` was overriden. [1]https://review.opendev.org/q/I3b7c5d73d2b0d20fb06527ade30af8939b249d75 Closes-Bug: #2037717 Change-Id: I01fa481456c0a675b5857d9796b8323493e4fbc1
This commit is contained in:
@@ -426,11 +426,13 @@ class PortBindingChassisEvent(row_event.RowEvent):
|
||||
self.l3_plugin = directory.get_plugin(constants.L3)
|
||||
table = 'Port_Binding'
|
||||
events = (self.ROW_UPDATE,)
|
||||
super(PortBindingChassisEvent, self).__init__(
|
||||
events, table, (('type', '=', ovn_const.OVN_CHASSIS_REDIRECT),))
|
||||
super().__init__(events, table, None)
|
||||
self.event_name = 'PortBindingChassisEvent'
|
||||
|
||||
def match_fn(self, event, row, old):
|
||||
if row.type != ovn_const.OVN_CHASSIS_REDIRECT:
|
||||
return False
|
||||
|
||||
if len(old._data) == 1 and 'external_ids' in old._data:
|
||||
# NOTE: since [1], the NB logical_router_port.external_ids are
|
||||
# copied into the SB port_binding.external_ids. If only the
|
||||
|
@@ -673,3 +673,45 @@ class TestOvnIdlConnections(base.TestOVNFunctionalBase):
|
||||
**kwargs)
|
||||
self.assertEqual(set(idlutils.parse_connection(conns)),
|
||||
set(idl._session.remotes))
|
||||
|
||||
|
||||
class TestPortBindingChassisEvent(base.TestOVNFunctionalBase,
|
||||
test_l3.L3NatTestCaseMixin):
|
||||
|
||||
def setUp(self, **kwargs):
|
||||
super().setUp(**kwargs)
|
||||
self.chassis = self.add_fake_chassis('ovs-host1')
|
||||
self.l3_plugin = directory.get_plugin(plugin_constants.L3)
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
self.net = self._make_network(
|
||||
self.fmt, 'ext_net', True, as_admin=True, **kwargs)
|
||||
self._make_subnet(self.fmt, self.net, '20.0.10.1', '20.0.10.0/24')
|
||||
port_res = self._create_port(self.fmt, self.net['network']['id'])
|
||||
self.port = self.deserialize(self.fmt, port_res)['port']
|
||||
|
||||
self.ext_api = test_extensions.setup_extensions_middleware(
|
||||
test_l3.L3TestExtensionManager())
|
||||
self.pb_event_match = mock.patch.object(
|
||||
self.sb_api.idl._portbinding_event, 'match_fn').start()
|
||||
|
||||
def _check_pb_type(self, _type):
|
||||
def check_pb_type(_type):
|
||||
if len(self.pb_event_match.call_args_list) < 1:
|
||||
return False
|
||||
|
||||
pb_row = self.pb_event_match.call_args_list[0].args[1]
|
||||
return _type == pb_row.type
|
||||
|
||||
n_utils.wait_until_true(lambda: check_pb_type(_type), timeout=5)
|
||||
|
||||
def test_pb_type_patch(self):
|
||||
router = self._make_router(self.fmt, self._tenant_id)
|
||||
self._add_external_gateway_to_router(router['router']['id'],
|
||||
self.net['network']['id'])
|
||||
self._check_pb_type('patch')
|
||||
|
||||
def test_pb_type_empty(self):
|
||||
self.sb_api.lsp_bind(self.port['id'], self.chassis,
|
||||
may_exist=True).execute(check_error=True)
|
||||
self._check_pb_type('')
|
||||
|
Reference in New Issue
Block a user