Skip to content

Commit 8e246f9

Browse files
committed
Disable DHCP server on tested devices in DHCP client integration tests
When testing the 'dnsmasq' device as a DHCP client, the DHCP client flag is removed from the interface (because the device is by default a DHCP server), resulting in validation failure. The plugin introduced in this commit removes the 'dhcp.server' flag from nodes in the 'dhcp_clients' group to ensure the DHCP clients are never also DHCP servers, causing the DHCP feature check to fail on dnsmasq DHCP clients.
1 parent 1882cbd commit 8e246f9

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

tests/integration/dhcp/01-ipv4-client.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
---
2+
message: |
3+
Use this topology to test the DHCPv4 client on your device. Use 'netlab
4+
validate' to check whether your devices requested DHCP leases from the DHCP
5+
server.
6+
7+
If your client suppors configurable 'router option' requests to generate
8+
a default route, check that C1 has a default route but C2 does not.
9+
10+
plugin: [ no_dhcp_server ]
11+
12+
groups:
13+
dhcp_clients:
14+
members: [ c1, c2 ]
15+
216
nodes:
317
c1:
418
c2:
@@ -31,11 +45,3 @@ validate:
3145
valid:
3246
eos: len(vrfs.default.ipv4ActiveLeases) == 2
3347
dnsmasq: stdout.rstrip() == '2'
34-
35-
message: |
36-
Use this topology to test the DHCPv4 client on your device. Use 'netlab
37-
validate' to check whether your devices requested DHCP leases from the DHCP
38-
server.
39-
40-
If your client suppors configurable 'router option' requests to generate
41-
a default route, check that C1 has a default route but C2 does not.

tests/integration/dhcp/02-ipv6-client.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
---
2+
message: |
3+
Use this topology to test the DHCPv6 client on your device. Use 'netlab
4+
validate' to check whether your devices requested DHCPv6 leases from the
5+
DHCPv6 server.
6+
7+
plugin: [ no_dhcp_server ]
8+
9+
groups:
10+
dhcp_clients:
11+
members: [ c1, c2 ]
12+
113
addressing.lan:
214
ipv4: false
315
ipv6: 2001:db8:cafe::/48
@@ -33,8 +45,3 @@ validate:
3345
valid:
3446
eos: vrfs.default.ipv6ActiveLeases
3547
dnsmasq: stdout.rstrip() == '2'
36-
37-
message: |
38-
Use this topology to test the DHCPv6 client on your device. Use 'netlab
39-
validate' to check whether your devices requested DHCPv6 leases from the
40-
DHCPv6 server.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
A plugin that removes dhcp.server flag from DHCP clients -- needed to make
3+
dnsmasq fail the DHCP client test at "create the lab" phase
4+
"""
5+
6+
from box import Box
7+
8+
9+
def pre_link_transform(topology: Box) -> None:
10+
clients = topology.get('groups.dhcp_clients.members',[])
11+
for c_node in clients:
12+
c_data = topology.nodes[c_node]
13+
c_data.pop('dhcp.server',True)

0 commit comments

Comments
 (0)