mirror of
https://github.com/containers/netavark.git
synced 2026-02-05 06:45:56 +01:00
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>
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
37
test/testfiles/metric-macvlan.json
Normal file
37
test/testfiles/metric-macvlan.json
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user