diff options
author | Paul Holzinger <pholzing@redhat.com> | 2024-06-25 13:18:42 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2024-06-25 13:20:54 +0200 |
commit | 205226998c5dffc56c4a82100355ddabc56ed62f (patch) | |
tree | 6bd5ba5b3ff63fe2bb8270f4f3228b1f1f17e0c7 /test | |
parent | b6ad729a7f6e907a4bcc46a9151aef8f41898962 (diff) |
test: add macvlan metric test
Make sure macvlan supports the metric option, the code did so for a
while but there never was a metric test added here and it didn't work in
podman[1]. So make sure we test it works and do not regress.
[1] https://github.com/containers/common/issues/2051
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/300-macvlan.bats | 14 | ||||
-rw-r--r-- | test/testfiles/metric-macvlan.json | 37 |
2 files changed, 51 insertions, 0 deletions
diff --git a/test/300-macvlan.bats b/test/300-macvlan.bats index c062a7f..eaea724 100644 --- a/test/300-macvlan.bats +++ b/test/300-macvlan.bats @@ -375,3 +375,17 @@ EOF run_in_container_netns ip -o link show assert "${#lines[@]}" == 2 "only two interfaces (lo, eth0) in the netns, the tmp macvlan interface should be gone" } + +@test "macvlan route metric from config" { + run_netavark --file ${TESTSDIR}/testfiles/metric-macvlan.json setup $(get_container_netns_path) + + run_in_container_netns ip -j route list match 0.0.0.0 + default_route="$output" + assert_json "$default_route" '.[0].dst' == "default" "Default route was selected" + assert_json "$default_route" '.[0].metric' == "200" "Route metric set from config" + + run_in_container_netns ip -j -6 route list match ::0 + default_route_v6="$output" + assert_json "$default_route_v6" '.[0].dst' == "default" "Default route was selected" + assert_json "$default_route_v6" '.[0].metric' == "200" "v6 route metric matches v4" +} diff --git a/test/testfiles/metric-macvlan.json b/test/testfiles/metric-macvlan.json new file mode 100644 index 0000000..5f21efe --- /dev/null +++ b/test/testfiles/metric-macvlan.json @@ -0,0 +1,37 @@ +{ + "container_id": "bc14fe7cd3633e7be338522002bb0c3ccb18150da7a6c733735ffdf8ff7e85d1", + "container_name": "metrictest", + "networks": { + "metric": { + "interface_name": "eth1", + "static_ips": [ + "10.89.0.2", + "fde0::2" + ] + } + }, + "network_info": { + "metric": { + "dns_enabled": false, + "driver": "macvlan", + "id": "7ba44a9a709f8093621eae1a1db2ccafc2471bae19cdf9dd2ea7cf3773b9211c", + "internal": false, + "ipv6_enabled": true, + "name": "metric", + "network_interface": "dummy0", + "subnets": [ + { + "gateway": "10.89.0.1", + "subnet": "10.89.0.0/24" + }, + { + "subnet": "fde0::/64", + "gateway": "fde0::1" + } + ], + "options": { + "metric": "200" + } + } + } +} |