diff --git a/test/system/505-networking-pasta.bats b/test/system/505-networking-pasta.bats index fb9c517bf8..0f5da11636 100644 --- a/test/system/505-networking-pasta.bats +++ b/test/system/505-networking-pasta.bats @@ -800,6 +800,7 @@ EOF @test "pasta/bridge and host.containers.internal" { skip_if_no_ipv4 "IPv4 not routable on the host" pasta_ip="$(default_addr 4)" + host_ips=$(ip -4 -j addr | jq -r '.[] | select(.ifname != "lo") | .addr_info[].local') for network in "pasta" "bridge"; do # special exit code logic needed here, it is possible that there is no host.containers.internal @@ -808,17 +809,17 @@ EOF run_podman '?' run --rm --network=$network $IMAGE grep host.containers.internal /etc/hosts if [ "$status" -eq 0 ]; then assert "$output" !~ "$pasta_ip" "pasta host ip must not be assigned ($network)" - assert "$(hostname -I)" =~ "$(cut -f1 <<<$output)" "ip is one of the host ips ($network)" + assert "$host_ips" =~ "$(cut -f1 <<<$output)" "ip is one of the host ips ($network)" elif [ "$status" -eq 1 ]; then # if only pasta ip then we cannot have a host.containers.internal entry # make sure this fact is actually the case - assert "$pasta_ip" == "$(hostname -I | tr -d '[:space:]')" "pasta ip must the only one one the host ($network)" + assert "$pasta_ip" == "$host_ips" "pasta ip must the only one one the host ($network)" else die "unexpected exit code '$status' from grep or podman ($network)" fi done - host_ip=$(hostname -I | cut -f 1 -d " ") + first_host_ip=$(head -n 1 <<<"$host_ips") run_podman run --rm --network=pasta:-a,169.254.0.2,-g,169.254.0.1,-n,24 $IMAGE grep host.containers.internal /etc/hosts - assert "$output" =~ "^$host_ip" "uses host first ip" + assert "$output" =~ "^$first_host_ip" "uses host first ip" }