summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiro Tomaska <mtomaska@redhat.com>2023-02-27 20:58:53 -0600
committerMiro Tomaska <mtomaska@redhat.com>2023-03-06 18:25:04 +0000
commitee781c277b3aa47eb8f891568fb4b1b8359c2f38 (patch)
treec22498b5767d85610bbd244705a749f7443b1280
parent69eb752cb158a33ba6965deb86a11c546dcf2171 (diff)
downloadneutron-ee781c277b3aa47eb8f891568fb4b1b8359c2f38.tar.gz
Reintroduce agent bridge resync test19.6.0
It appears we have changed the test_agent_resync_on_non_existing_bridgetest main purpose in change 709544[1]. The test is no longer testing on what is describing it will test, i.e. resync on bridge change. Testing resync on a bridge change is still important. I feel like what the test is testing is already covered in _test_agent_events set of tests. [1] https://review.opendev.org/c/openstack/neutron/+/709544 Change-Id: I8f164c12db7c4c1aa54ba07feede3586e6a19381 (cherry picked from commit 75e83602247360cf10b7b9aa4e53a0135b491cae)
-rw-r--r--neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py35
1 files changed, 20 insertions, 15 deletions
diff --git a/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py b/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py
index 80ecaa7b04..2ce06ec550 100644
--- a/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py
+++ b/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py
@@ -143,7 +143,7 @@ class TestMetadataAgent(base.TestOVNFunctionalBase):
external_ids={
ovn_const.OVN_CIDRS_EXT_ID_KEY: '192.168.122.123/24'}))
- def _create_logical_switch_port(self, type_=None):
+ def _create_logical_switch_port(self, type_=None, addresses=None):
lswitch_name = 'ovn-' + uuidutils.generate_uuid()
lswitchport_name = 'ovn-port-' + uuidutils.generate_uuid()
# It may take some time to ovn-northd to translate from OVN NB DB to
@@ -153,6 +153,8 @@ class TestMetadataAgent(base.TestOVNFunctionalBase):
self.handler.watch_event(pb_event)
lswitch_port_columns = {}
+ if addresses:
+ lswitch_port_columns['addresses'] = addresses
if type_:
lswitch_port_columns['type'] = type_
@@ -167,30 +169,33 @@ class TestMetadataAgent(base.TestOVNFunctionalBase):
return lswitchport_name, lswitch_name
- @mock.patch.object(agent.PortBindingChassisCreatedEvent, 'run')
- def test_agent_resync_on_non_existing_bridge(self, mock_pbinding):
+ def test_agent_resync_on_non_existing_bridge(self):
+ BR_NEW = 'br-new'
+ self._mock_get_ovn_br.return_value = BR_NEW
+ self.agent.ovs_idl.list_br.return_value.execute.return_value = [BR_NEW]
# The agent has initialized with br-int and above list_br doesn't
# return it, hence the agent should trigger reconfiguration and store
# new br-new value to its attribute.
self.assertEqual(self.OVN_BRIDGE, self.agent.ovn_bridge)
- lswitchport_name, _ = self._create_logical_switch_port()
+ # NOTE: The IP address is specifically picked such that it fits the
+ # metadata port external_ids: { neutron:cidrs }. This is because agent
+ # will only trigger if the logical port is part of a neutron subnet
+ lswitchport_name, _ = self._create_logical_switch_port(
+ addresses='AA:AA:AA:AA:AA:AB 192.168.122.125'
+ )
# Trigger PortBindingChassisCreatedEvent
self.sb_api.lsp_bind(lswitchport_name, self.chassis_name).execute(
check_error=True, log_errors=True)
- exc = Exception('PortBindingChassisCreatedEvent was not called')
- def check_mock_pbinding():
- if mock_pbinding.call_count < 1:
- return False
- args = mock_pbinding.call_args[0]
- self.assertEqual('update', args[0])
- self.assertEqual(lswitchport_name, args[1].logical_port)
- self.assertEqual(self.chassis_name, args[1].chassis[0].name)
- return True
-
- n_utils.wait_until_true(check_mock_pbinding, timeout=10, exception=exc)
+ exc = Exception("Agent bridge hasn't changed from %s to %s "
+ "in 10 seconds after Port_Binding event" %
+ (self.agent.ovn_bridge, BR_NEW))
+ n_utils.wait_until_true(
+ lambda: BR_NEW == self.agent.ovn_bridge,
+ timeout=10,
+ exception=exc)
def _test_agent_events(self, delete, type_=None):
m_pb_created = mock.patch.object(