From 69362215b2fbaf7617c989ef2538d01ad8130db2 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 20 Nov 2019 11:33:51 +0100 Subject: [PATCH] tests: add a test with different MTU interfaces See #365. --- tests/integration/fixtures/network.py | 10 +++++++--- tests/integration/test_basic.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/integration/fixtures/network.py b/tests/integration/fixtures/network.py index f867ea5a..c4be4802 100644 --- a/tests/integration/fixtures/network.py +++ b/tests/integration/fixtures/network.py @@ -27,10 +27,10 @@ class LinksFactory(object): self.ns = Namespace('net') self.count = 0 - def __call__(self, *args): - return self.veth(*args) + def __call__(self, *args, **kwargs): + return self.veth(*args, **kwargs) - def veth(self, ns1, ns2, sleep=0): + def veth(self, ns1, ns2, sleep=0, mtu=1500): """Create a veth pair between two namespaces.""" with self.ns: # First, create a link @@ -50,6 +50,10 @@ class LinksFactory(object): ipr.link('set', index=idx[1], address=int_to_mac(self.count + 2)) + # Set MTU + ipr.link('set', index=idx[0], mtu=mtu) + ipr.link('set', index=idx[1], mtu=mtu) + # Then, move each to the target namespace ipr.link('set', index=idx[0], net_ns_fd=ns1.fd('net')) ipr.link('set', index=idx[1], net_ns_fd=ns2.fd('net')) diff --git a/tests/integration/test_basic.py b/tests/integration/test_basic.py index 89d98756..cb4b91d6 100644 --- a/tests/integration/test_basic.py +++ b/tests/integration/test_basic.py @@ -73,6 +73,7 @@ def test_one_interface(lldpd1, lldpd, lldpcli, namespaces): "lldp.eth0.port.descr": "eth0", "lldp.eth0.ttl.ttl": "120"} + @pytest.mark.parametrize("interfaces", (5, 10, 20)) def test_several_interfaces(lldpd, lldpcli, links, namespaces, interfaces): for i in range(2, interfaces + 1): @@ -89,6 +90,19 @@ def test_several_interfaces(lldpd, lldpcli, links, namespaces, interfaces): '00:00:00:00:00:{num:02x}'.format(num=(i - 2)*2 + 1) +def test_different_mtu(lldpd, lldpcli, links, namespaces): + links(namespaces(1), namespaces(2), mtu=1500) + links(namespaces(1), namespaces(2), mtu=9000) + with namespaces(1): + lldpd() + with namespaces(2): + lldpd() + with namespaces(1): + out = lldpcli("-f", "keyvalue", "show", "interfaces") + assert out['lldp.eth0.chassis.mac'] == '00:00:00:00:00:01' + assert out['lldp.eth2.chassis.mac'] == '00:00:00:00:00:01' + + def test_overrided_description(lldpd1, lldpd, lldpcli, namespaces): with namespaces(2): lldpd("-S", "Modified description") -- 2.39.2