diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index b37c2fda25f9..9bfaf05aa44c 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -1095,4 +1095,24 @@ function wait_for_restart_count() { run_podman network rm $netname } +# 2024-07-23 moved from 505 pasta tests because it can't run in parallel +# CANNOT BE PARALLELIZED +@test "Podman unshare --rootless-netns with Pasta" { + skip_if_remote "unshare is local-only" + skip_if_not_rootless "pasta networking only available in rootless mode" + skip_if_no_pasta "pasta not found; this test requires pasta" + + pasta_iface=$(default_ifname 4) + assert "$pasta_iface" != "" "pasta_iface is set" + + # First let's force a setup error by making pasta be "false". + ln -s /usr/bin/false $PODMAN_TMPDIR/pasta + CONTAINERS_HELPER_BINARY_DIR="$PODMAN_TMPDIR" run_podman 125 unshare --rootless-netns ip addr + assert "$output" =~ "pasta failed with exit code 1" + + # Now this should recover from the previous error and setup the netns correctly. + run_podman unshare --rootless-netns ip addr + is "$output" ".*${pasta_iface}.*" +} + # vim: filetype=sh diff --git a/test/system/505-networking-pasta.bats b/test/system/505-networking-pasta.bats index 9f0af92c34c7..f32e3e427d18 100644 --- a/test/system/505-networking-pasta.bats +++ b/test/system/505-networking-pasta.bats @@ -10,6 +10,9 @@ load helpers load helpers.network +# All tests in this file must be able to run in parallel +# bats file_tags=ci:parallel + function setup() { basic_setup skip_if_not_rootless "pasta networking only available in rootless mode" @@ -156,7 +159,7 @@ function pasta_test_do() { local seq="$(echo ${port} | tr '-' ' ')" local xseq="$(echo ${xport} | tr '-' ' ')" else - local port=$(random_free_port "" ${address} ${proto}) + local port=$(random_free_port "" ${addr} ${proto}) local xport="$((port + delta))" local seq="${port} ${port}" local xseq="${xport} ${xport}" @@ -336,7 +339,7 @@ function pasta_test_do() { @test "podman puts pasta IP in /etc/hosts" { skip_if_no_ipv4 "IPv4 not routable on the host" - pname="p$(random_string 30)" + pname="p-$(safename)" ip="$(default_addr 4)" run_podman pod create --net=pasta --name "${pname}" @@ -345,7 +348,6 @@ function pasta_test_do() { assert "$(echo ${output} | cut -f1 -d' ')" = "${ip}" "Correct /etc/hosts entry missing" run_podman pod rm "${pname}" - run_podman rmi $(pause_image) } ### Routes ##################################################################### @@ -766,8 +768,21 @@ function pasta_test_do() { local pidfile="${PODMAN_TMPDIR}/pasta.pid" run_podman run --rm "--net=pasta:--pid,${pidfile}" $IMAGE true - sleep 1 - ! ps -p $(cat "${pidfile}") && rm "${pidfile}" + + # Allow time for process to vanish, in case there's high load + local pid=$(< $pidfile) + local timeout=5 + while [[ $timeout -gt 0 ]]; do + if ! ps -p $pid; then + return + fi + + # Still alive. Wait and retry + sleep 1 + timeout=$((timeout - 1)) + done + + die "Timed out waiting for pid $pid to terminate" } ### Options #################################################################### @@ -801,24 +816,6 @@ EOF assert "$output" =~ "$mac2" "mac address from cli is set on custom interface" } -### Rootless unshare testing - -@test "Podman unshare --rootless-netns with Pasta" { - skip_if_remote "unshare is local-only" - - pasta_iface=$(default_ifname 4) - assert "$pasta_iface" != "" "pasta_iface is set" - - # First let's force a setup error by making pasta be "false". - ln -s /usr/bin/false $PODMAN_TMPDIR/pasta - CONTAINERS_HELPER_BINARY_DIR="$PODMAN_TMPDIR" run_podman 125 unshare --rootless-netns ip addr - assert "$output" =~ "pasta failed with exit code 1" - - # Now this should recover from the previous error and setup the netns correctly. - run_podman unshare --rootless-netns ip addr - is "$output" ".*${pasta_iface}.*" -} - # https://github.com/containers/podman/issues/22653 @test "pasta/bridge and host.containers.internal" { skip_if_no_ipv4 "IPv4 not routable on the host"