diff options
author | Jakub Libosvar <libosvar@redhat.com> | 2021-04-22 15:26:12 +0000 |
---|---|---|
committer | Jakub Libosvar <libosvar@redhat.com> | 2021-04-22 15:28:21 +0000 |
commit | 1a3fa2206db3c9485db84ade3d5cc179bc1c22ce (patch) | |
tree | 4622d3d66fa9d501f76cd6758e971cd1840cdf44 /neutron | |
parent | 32e938e698f260af6896f6179a5ffc0838677124 (diff) | |
download | neutron-1a3fa2206db3c9485db84ade3d5cc179bc1c22ce.tar.gz |
ovn: Add functional tests for get_network_port_bindings_by_ip
The change I708904b982d243359f2eeda809beae0321f1a7db lacked tests for
unbounds port with the same IP. This patch adds simple test that creates
2 LSPs on the same LS with the same IP and one is unbound. Such setup
should return only the bound port.
Related-bug: #1922934
Change-Id: I71659a1c846852f9cb9bedba23c946438357b079
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
Diffstat (limited to 'neutron')
-rw-r--r-- | neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py index f587c1b56f..5f29b2e9f5 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py @@ -129,7 +129,7 @@ class TestSbApi(BaseOvnIdlTest): check_error=True) self.assertEqual(nets, self.api.get_chassis_metadata_networks(name)) - def test_get_network_port_bindings_by_ip(self): + def _create_bound_port_with_ip(self): chassis, switch, port, binding = self._add_switch_port( self.data['chassis'][0]['name']) mac = 'de:ad:be:ef:4d:ad' @@ -142,9 +142,27 @@ class TestSbApi(BaseOvnIdlTest): port.name, [mac_ip]).execute(check_error=True) self.assertTrue(pb_update_event.wait()) self.api.lsp_bind(port.name, chassis.name).execute(check_error=True) + + return binding, ipaddr, switch + + def test_get_network_port_bindings_by_ip(self): + binding, ipaddr, _ = self._create_bound_port_with_ip() + result = self.api.get_network_port_bindings_by_ip( + str(binding.datapath.uuid), ipaddr) + self.assertIn(binding, result) + + def test_get_network_port_bindings_by_ip_with_unbound_port(self): + binding, ipaddr, switch = self._create_bound_port_with_ip() + unbound_port_name = utils.get_rand_device_name(prefix="port") + mac_ip = "de:ad:be:ef:4d:ab %s" % ipaddr + with self.nbapi.transaction(check_error=True) as txn: + txn.add( + self.nbapi.lsp_add(switch.name, unbound_port_name, type=type)) + txn.add(self.nbapi.lsp_set_addresses(unbound_port_name, [mac_ip])) result = self.api.get_network_port_bindings_by_ip( str(binding.datapath.uuid), ipaddr) self.assertIn(binding, result) + self.assertEqual(1, len(result)) def test_get_ports_on_chassis(self): chassis, switch, port, binding = self._add_switch_port( |