]>
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')
34 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
35 assert out
['lldp.eth0.port.descr'] == 'eth1'
36 assert out
['lldp.eth0.vlan'] == \
37 ['vlan100', 'vlan200', 'vlan300']
38 assert out
['lldp.eth0.vlan.vlan-id'] == \
42 @pytest.mark
.skipif('Dot3' not in pytest
.config
.lldpd
.features
,
43 reason
="Dot3 not supported")
44 @pytest.mark
.parametrize('when', ['before', 'after'])
45 def test_bond(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, when
):
46 links(namespaces(3), namespaces(2)) # Another link to setup a bond
50 idx
= links
.bond('bond42', 'eth3', 'eth1')
51 ipr
= pyroute2
.IPRoute()
52 # The bond has the MAC of eth3
53 assert ipr
.get_links(idx
)[0].get_attr('IFLA_ADDRESS') == \
60 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
61 assert out
['lldp.eth0.port.descr'] == 'eth1'
62 assert out
['lldp.eth0.port.aggregation'] == str(idx
)
63 # lldpd should be able to retrieve the right MAC
64 assert out
['lldp.eth0.port.mac'] == '00:00:00:00:00:02'
67 @pytest.mark
.skipif('Dot3' not in pytest
.config
.lldpd
.features
,
68 reason
="Dot3 not supported")
69 @pytest.mark
.parametrize('when', ['before', 'after'])
70 def test_team(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, when
):
71 links(namespaces(3), namespaces(2)) # Another link to setup a bond
75 idx
= links
.team('team42', 'eth3', 'eth1')
81 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
82 assert out
['lldp.eth0.port.descr'] == 'eth1'
83 assert out
['lldp.eth0.port.aggregation'] == str(idx
)
84 # Unfortunately, we cannot get the right MAC currently... So,
85 # this bit will succeed by chance.
86 assert out
['lldp.eth0.port.mac'] == '00:00:00:00:00:02'
89 @pytest.mark
.skipif('Dot3' not in pytest
.config
.lldpd
.features
,
90 reason
="Dot3 not supported")
91 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
92 reason
="Dot1 not supported")
93 @pytest.mark
.parametrize('when', ['before', 'after'])
94 def test_bond_with_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, when
):
95 links(namespaces(3), namespaces(2)) # Another link to setup a bond
99 links
.bond('bond42', 'eth3', 'eth1')
100 links
.vlan('vlan300', 300, 'bond42')
101 links
.vlan('vlan301', 301, 'bond42')
102 links
.vlan('vlan302', 302, 'bond42')
103 links
.vlan('vlan303', 303, 'bond42')
109 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
110 assert out
['lldp.eth0.port.descr'] == 'eth1'
111 assert out
['lldp.eth0.vlan'] == \
112 ['vlan300', 'vlan301', 'vlan302', 'vlan303']
113 assert out
['lldp.eth0.vlan.vlan-id'] == \
114 ['300', '301', '302', '303']
117 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
118 reason
="Dot1 not supported")
119 @pytest.mark
.parametrize('when', ['before', 'after'])
120 def test_just_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, when
):
124 links
.vlan('vlan300', 300, 'eth1')
125 links
.vlan('vlan400', 400, 'eth1')
131 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
132 assert out
['lldp.eth0.port.descr'] == 'eth1'
133 assert out
['lldp.eth0.vlan'] == ['vlan300', 'vlan400']
134 assert out
['lldp.eth0.vlan.vlan-id'] == ['300', '400']
137 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
138 reason
="Dot1 not supported")
139 @pytest.mark
.parametrize('kind', ['plain', 'bridge', 'bond'])
140 def test_remove_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
, kind
):
144 links
.bond(iface
, 'eth1')
145 elif kind
== 'bridge':
147 links
.bridge(iface
, 'eth1')
149 assert kind
== 'plain'
151 links
.vlan('vlan300', 300, iface
)
152 links
.vlan('vlan400', 400, iface
)
153 links
.vlan('vlan500', 500, iface
)
155 links
.remove('vlan300')
158 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
159 assert out
['lldp.eth0.port.descr'] == 'eth1'
160 assert out
['lldp.eth0.vlan'] == ['vlan400', 'vlan500']
161 assert out
['lldp.eth0.vlan.vlan-id'] == ['400', '500']
164 @pytest.mark
.skipif('Dot3' not in pytest
.config
.lldpd
.features
,
165 reason
="Dot3 not supported")
166 def test_unenslave_bond(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
168 links
.bond('bond42', 'eth1')
170 links
.remove('bond42')
174 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
175 assert out
['lldp.eth0.port.descr'] == 'eth1'
176 assert 'lldp.eth0.port.aggregation' not in out
179 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
180 reason
="Dot1 not supported")
181 def test_unenslave_bond_with_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
183 links
.bond('bond42', 'eth1')
184 links
.vlan('vlan300', 300, 'bond42')
185 links
.vlan('vlan400', 400, 'eth1')
187 links
.remove('bond42')
191 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
192 assert out
['lldp.eth0.port.descr'] == 'eth1'
193 assert out
['lldp.eth0.vlan'] == 'vlan400'
194 assert out
['lldp.eth0.vlan.vlan-id'] == '400'
197 def test_down_then_up(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
202 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
208 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
209 assert out
['lldp.eth0.port.descr'] == 'eth1'
212 @pytest.mark
.skipif('Dot1' not in pytest
.config
.lldpd
.features
,
213 reason
="Dot1 not supported")
214 def test_down_then_up_with_vlan(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
216 links
.vlan('vlan300', 300, 'eth1')
217 links
.vlan('vlan400', 400, 'eth1')
223 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
224 assert out
['lldp.eth0.port.descr'] == 'eth1'
225 assert out
['lldp.eth0.vlan'] == ['vlan300', 'vlan400']
226 assert out
['lldp.eth0.vlan.vlan-id'] == ['300', '400']
229 def test_new_interface(lldpd1
, lldpd
, lldpcli
, namespaces
, links
):
232 links(namespaces(1), namespaces(2), 4)
235 out
= lldpcli("-f", "keyvalue", "show", "neighbors", "details")
236 assert out
['lldp.eth0.port.descr'] == 'eth1'
237 assert out
['lldp.eth2.port.descr'] == 'eth3'
238 assert out
['lldp.eth0.rid'] == out
['lldp.eth2.rid'] # Same chassis