Skip to content

Commit

Permalink
Merge pull request #23908 from edsantiago/safename-505
Browse files Browse the repository at this point in the history
CI: make 505-pasta parallel safe
  • Loading branch information
openshift-merge-bot[bot] authored Sep 13, 2024
2 parents 03bae4a + 22ec8ea commit 421a80b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
20 changes: 20 additions & 0 deletions test/system/500-networking.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 20 additions & 23 deletions test/system/505-networking-pasta.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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}"
Expand All @@ -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 #####################################################################
Expand Down Expand Up @@ -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 ####################################################################
Expand Down Expand Up @@ -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"
Expand Down

1 comment on commit 421a80b

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.