Skip to content

Commit a29a1b3

Browse files
committed
tests for ipv4.dhcp.routes
Signed-off-by: Gwendolyn <[email protected]>
1 parent 8f375f8 commit a29a1b3

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

test/main.sh

+1
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ if [ "${1:-"all"}" != "cluster" ]; then
318318
run_test test_server_config "server configuration"
319319
run_test test_filemanip "file manipulations"
320320
run_test test_network "network management"
321+
run_test test_network_dhcp_routes "network dhcp routes"
321322
run_test test_network_acl "network ACL management"
322323
run_test test_network_forward "network address forwards"
323324
run_test test_network_zone "network DNS zones"

test/suites/network_dhcp_routes.sh

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
test_network_dhcp_routes() {
2+
ensure_import_testimage
3+
ensure_has_localhost_remote "${INCUS_ADDR}"
4+
5+
# bridge network
6+
incus network create inct$$
7+
incus network set inct$$ ipv4.address 10.13.37.1/24
8+
incus network set inct$$ ipv4.dhcp.routes 1.2.0.0/16,10.13.37.5,2.3.0.0/16,10.13.37.7
9+
10+
incus launch testimage nettest -n inct$$
11+
12+
cat > "${TEST_DIR}"/udhcpc.sh <<EOL
13+
#!/bin/sh
14+
[ "\$1" = "bound" ] && echo "STATICROUTES: \$staticroutes"
15+
EOL
16+
17+
incus file push "${TEST_DIR}/udhcpc.sh" nettest/udhcpc.sh
18+
incus exec nettest -- chmod a+rx /udhcpc.sh
19+
20+
staticroutes_output=$(incus exec nettest -- udhcpc -s /udhcpc.sh 2>/dev/null | grep STATICROUTES)
21+
22+
echo "$staticroutes_output" | grep -q "1.2.0.0/16 10.13.37.5"
23+
echo "$staticroutes_output" | grep -q "2.3.0.0/16 10.13.37.7"
24+
25+
incus delete nettest -f
26+
27+
if [ -n "${INCUS_OFFLINE:-}" ]; then
28+
echo "==> SKIP: Skipping OCI tests as running offline"
29+
else
30+
ensure_has_localhost_remote "${INCUS_ADDR}"
31+
32+
incus remote add docker https://docker.io --protocol=oci
33+
incus launch docker:alpine nettest --network=inct$$
34+
35+
incus exec nettest -- ip route list | grep -q "1.2.0.0/16 via 10.13.37.5"
36+
incus exec nettest -- ip route list | grep -q "2.3.0.0/16 via 10.13.37.7"
37+
38+
incus delete -f nettest
39+
incus remote remove docker
40+
fi
41+
42+
incus network delete inct$$
43+
44+
45+
# ovn network
46+
if incus network create inct$$ -t ovn network=none; then
47+
incus network set inct$$ ipv4.address 10.13.37.1/24
48+
incus network set inct$$ ipv4.dhcp.routes 1.2.0.0/16,10.13.37.5,2.3.0.0/16,10.13.37.7
49+
50+
incus launch testimage nettest -n inct$$
51+
52+
incus exec nettest -- ip route list | grep -q "1.2.0.0/16 via 10.13.37.5"
53+
incus exec nettest -- ip route list | grep -q "2.3.0.0/16 via 10.13.37.7"
54+
55+
incus delete nettest -f
56+
incus network delete inct$$
57+
else
58+
echo "==> SKIP: Skipping OVN tests"
59+
fi
60+
}

0 commit comments

Comments
 (0)