]>
git.ipfire.org Git - thirdparty/lldpd.git/blob - tests/integration/test_interfaces.py
6 def test_simple_bridge(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
7 links(namespaces(3), namespaces(2)) # Another link to setup a bridge
9 links
.bridge('br42', 'eth1', 'eth3')
12 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
13 assert out
['lldp.eth0.port.descr'] == 'eth1'
14 assert out
['lldp.eth0.chassis.Bridge.enabled'] == 'on'
17 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
18 reason
="Dot1 not supported")
19 @pytest.mark
.parametrize('when', ['before', 'after'])
20 def test_bridge_with_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, when
):
21 links(namespaces(3), namespaces(2)) # Another link to setup a bridge
25 links
.bridge('br42', 'eth1', 'eth3')
26 links
.vlan('vlan100', 100, 'br42')
27 links
.vlan('vlan200', 200, 'br42')
28 links
.vlan('vlan300', 300, 'br42')
32 # IPv6 DAD may kick in
35 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
36 assert out
['lldp.eth0.port.descr'] == 'eth1'
37 assert out
['lldp.eth0.vlan'] == \
38 ['vlan100', 'vlan200', 'vlan300']
39 assert out
['lldp.eth0.vlan.vlan-id'] == \
43 @pytest.mark
.skipif('Dot3' not in pytest
.config
.lldpd
.features
,
44 reason
="Dot3 not supported")
45 @pytest.mark
.parametrize('when', ['before', 'after'])
46 def test_bond(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, when
):
47 links(namespaces(3), namespaces(2)) # Another link to setup a bond
51 idx
= links
.bond('bond42', 'eth3', 'eth1')
52 ipr
= pyroute2
.IPRoute()
53 # The bond has the MAC of eth3
54 assert ipr
.get_links(idx
)[0].get_attr('IFLA_ADDRESS') == \
59 # IPv6 DAD may kick in
62 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
63 assert out
['lldp.eth0.port.descr'] == 'eth1'
64 assert out
['lldp.eth0.port.aggregation'] == str(idx
)
65 # lldpd should be able to retrieve the right MAC
66 assert out
['lldp.eth0.port.mac'] == '00:00:00:00:00:02'
69 @pytest.mark
.skipif('Dot3' not in pytest
.config
.lldpd
.features
,
70 reason
="Dot3 not supported")
71 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
72 reason
="Dot1 not supported")
73 @pytest.mark
.parametrize('when', ['before', 'after'])
74 def test_bond_with_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, when
):
75 links(namespaces(3), namespaces(2)) # Another link to setup a bond
79 links
.bond('bond42', 'eth3', 'eth1')
80 links
.vlan('vlan300', 300, 'bond42')
81 links
.vlan('vlan301', 301, 'bond42')
82 links
.vlan('vlan302', 302, 'bond42')
83 links
.vlan('vlan303', 303, 'bond42')
87 # IPv6 DAD may kick in
90 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
91 assert out
['lldp.eth0.port.descr'] == 'eth1'
92 assert out
['lldp.eth0.vlan'] == \
93 ['vlan300', 'vlan301', 'vlan302', 'vlan303']
94 assert out
['lldp.eth0.vlan.vlan-id'] == \
95 ['300', '301', '302', '303']
98 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
99 reason
="Dot1 not supported")
100 @pytest.mark
.parametrize('when', ['before', 'after'])
101 def test_just_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, when
):
105 links
.vlan('vlan300', 300, 'eth1')
106 links
.vlan('vlan400', 400, 'eth1')
112 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
113 assert out
['lldp.eth0.port.descr'] == 'eth1'
114 assert out
['lldp.eth0.vlan'] == ['vlan300', 'vlan400']
115 assert out
['lldp.eth0.vlan.vlan-id'] == ['300', '400']
118 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
119 reason
="Dot1 not supported")
120 @pytest.mark
.parametrize('kind', ['plain', 'bridge', 'bond'])
121 def test_remove_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, kind
):
125 links
.bond(iface
, 'eth1')
126 elif kind
== 'bridge':
128 links
.bridge(iface
, 'eth1')
130 assert kind
== 'plain'
132 links
.vlan('vlan300', 300, iface
)
133 links
.vlan('vlan400', 400, iface
)
134 links
.vlan('vlan500', 500, iface
)
136 links
.remove('vlan300')
139 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
140 assert out
['lldp.eth0.port.descr'] == 'eth1'
141 assert out
['lldp.eth0.vlan'] == ['vlan400', 'vlan500']
142 assert out
['lldp.eth0.vlan.vlan-id'] == ['400', '500']
145 @pytest.mark
.skipif('Dot3' not in pytest
.config
.lldpd
.features
,
146 reason
="Dot3 not supported")
147 def test_unenslave_bond(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
149 links
.bond('bond42', 'eth1')
151 links
.remove('bond42')
155 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
156 assert out
['lldp.eth0.port.descr'] == 'eth1'
157 assert 'lldp.eth0.port.aggregation' not in out
160 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
161 reason
="Dot1 not supported")
162 def test_unenslave_bond_with_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
164 links
.bond('bond42', 'eth1')
165 links
.vlan('vlan300', 300, 'bond42')
166 links
.vlan('vlan400', 400, 'eth1')
168 links
.remove('bond42')
172 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
173 assert out
['lldp.eth0.port.descr'] == 'eth1'
174 assert out
['lldp.eth0.vlan'] == 'vlan400'
175 assert out
['lldp.eth0.vlan.vlan-id'] == '400'
178 def test_down_then_up(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
183 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
189 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
190 assert out
['lldp.eth0.port.descr'] == 'eth1'
193 def test_down_then_up_with_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
195 links
.vlan('vlan300', 300, 'eth1')
196 links
.vlan('vlan400', 400, 'eth1')
202 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
203 assert out
['lldp.eth0.port.descr'] == 'eth1'
204 assert out
['lldp.eth0.vlan'] == ['vlan300', 'vlan400']
205 assert out
['lldp.eth0.vlan.vlan-id'] == ['300', '400']
208 def test_new_interface(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
211 links(namespaces(1), namespaces(2))
214 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
215 assert out
['lldp.eth0.port.descr'] == 'eth1'
216 assert out
['lldp.eth2.port.descr'] == 'eth3'
217 assert out
['lldp.eth0.rid'] == out
['lldp.eth2.rid'] # Same chassis