test/system: fix up many tests that do not cleanup

All tests should cleanup themselves and not leak stuff.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2024-06-05 15:16:02 +02:00
parent e9c6cd1559
commit a2352fa3ea
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
22 changed files with 81 additions and 29 deletions

View File

@ -37,10 +37,7 @@ echo $rand | 0 | $rand
# a way to do so. # a way to do so.
eval set "$cmd" eval set "$cmd"
# FIXME: The </dev/null is a hack, necessary because as of 2019-09 run_podman $expected_rc run --rm $IMAGE "$@"
# podman-remote has a bug in which it silently slurps up stdin,
# including the output of parse_table (i.e. tests to be run).
run_podman $expected_rc run $IMAGE "$@"
is "$output" "$expected_output" "podman run $cmd - output" is "$output" "$expected_output" "podman run $cmd - output"
tests_run=$(expr $tests_run + 1) tests_run=$(expr $tests_run + 1)
@ -1504,6 +1501,8 @@ search | $IMAGE |
# This should be safe because stop is guaranteed to call cleanup? # This should be safe because stop is guaranteed to call cleanup?
run_podman inspect --format "{{ .State.Status }}" testctr run_podman inspect --format "{{ .State.Status }}" testctr
is "$output" "exited" "container has successfully transitioned to exited state after stop" is "$output" "exited" "container has successfully transitioned to exited state after stop"
run_podman rm -f -t0 testctr
} }
# vim: filetype=sh # vim: filetype=sh

View File

@ -143,6 +143,8 @@ function _log_test_restarted() {
expected=$(mktemp -p ${PODMAN_TMPDIR} expectedXXXXXXXX) expected=$(mktemp -p ${PODMAN_TMPDIR} expectedXXXXXXXX)
seq 1 20 > $expected seq 1 20 > $expected
diff -u ${expected} ${logfile} diff -u ${expected} ${logfile}
run_podman rm -f -t0 logtest
} }
@test "podman logs restarted - k8s-file" { @test "podman logs restarted - k8s-file" {
@ -165,6 +167,7 @@ function _log_test_restarted() {
run_podman --events-backend=file logs test run_podman --events-backend=file logs test
run_podman 125 --events-backend=file logs --follow test run_podman 125 --events-backend=file logs --follow test
is "$output" "Error: using --follow with the journald --log-driver but without the journald --events-backend (file) is not supported" "journald logger requires journald eventer" is "$output" "Error: using --follow with the journald --log-driver but without the journald --events-backend (file) is not supported" "journald logger requires journald eventer"
run_podman rm test
} }
function _log_test_since() { function _log_test_since() {

View File

@ -68,6 +68,8 @@ load helpers
# Nothing on match # Nothing on match
run_podman start --filter restart-policy=none --all run_podman start --filter restart-policy=none --all
is "$output" "" is "$output" ""
run_podman rm -f $c1 $c2 $c3
} }
@test "podman start --filter invalid-restart-policy - return error" { @test "podman start --filter invalid-restart-policy - return error" {
@ -76,6 +78,7 @@ load helpers
run_podman 125 start --filter restart-policy=fakepolicy $cid run_podman 125 start --filter restart-policy=fakepolicy $cid
is "$output" "Error: fakepolicy invalid restart policy" \ is "$output" "Error: fakepolicy invalid restart policy" \
"CID of restart-policy=<not-exists> container" "CID of restart-policy=<not-exists> container"
run_podman rm -f $cid
} }
@test "podman start --all --filter" { @test "podman start --all --filter" {
@ -87,6 +90,8 @@ load helpers
run_podman wait $cid_exited_0 $cid_exited_1 run_podman wait $cid_exited_0 $cid_exited_1
run_podman start --all --filter exited=0 run_podman start --all --filter exited=0
is "$output" "$cid_exited_0" is "$output" "$cid_exited_0"
run_podman rm -f $cid_exited_0 $cid_exited_1
} }
@test "podman start print IDs or raw input" { @test "podman start print IDs or raw input" {

View File

@ -39,9 +39,13 @@ load helpers
@test "podman stop --all" { @test "podman stop --all" {
# Start three containers, create (without running) a fourth # Start three containers, create (without running) a fourth
run_podman run -d --name c1 $IMAGE sleep 20 run_podman run -d --name c1 $IMAGE sleep 20
cid1="$output"
run_podman run -d --name c2 $IMAGE sleep 40 run_podman run -d --name c2 $IMAGE sleep 40
cid2="$output"
run_podman run -d --name c3 $IMAGE sleep 60 run_podman run -d --name c3 $IMAGE sleep 60
cid3="$output"
run_podman create --name c4 $IMAGE sleep 80 run_podman create --name c4 $IMAGE sleep 80
cid4="$output"
# podman ps (without -a) should show the three running containers # podman ps (without -a) should show the three running containers
run_podman ps --sort names --format '{{.Names}}--{{.Status}}' run_podman ps --sort names --format '{{.Names}}--{{.Status}}'
@ -71,6 +75,8 @@ load helpers
is "${lines[1]}" "c2--Exited.*" "ps -a, second stopped container" is "${lines[1]}" "c2--Exited.*" "ps -a, second stopped container"
is "${lines[2]}" "c3--Exited.*" "ps -a, third stopped container" is "${lines[2]}" "c3--Exited.*" "ps -a, third stopped container"
is "${lines[3]}" "c4--Created.*" "ps -a, created container (unaffected)" is "${lines[3]}" "c4--Created.*" "ps -a, created container (unaffected)"
run_podman rm $cid1 $cid2 $cid3 $cid4
} }
@test "podman stop print IDs or raw input" { @test "podman stop print IDs or raw input" {
@ -194,6 +200,8 @@ load helpers
# Exit code should be 137 as it was killed # Exit code should be 137 as it was killed
run_podman inspect --format '{{.State.ExitCode}}' stopme run_podman inspect --format '{{.State.ExitCode}}' stopme
is "$output" "137" "Exit code of killed container" is "$output" "137" "Exit code of killed container"
run_podman rm stopme
} }
@test "podman stop -t 1 Generate warning" { @test "podman stop -t 1 Generate warning" {

View File

@ -283,11 +283,12 @@ EOF
is "$output" ".*$v1a" "podman images --inspect should include $v1a" is "$output" ".*$v1a" "podman images --inspect should include $v1a"
is "$output" ".*$v1b" "podman images --inspect should include $v1b" is "$output" ".*$v1b" "podman images --inspect should include $v1b"
run_podman create --rm --mount type=glob,src=${PODMAN_TMPDIR}/v1\*,ro $IMAGE ls $vol1a $vol1b run_podman create --mount type=glob,src=${PODMAN_TMPDIR}/v1\*,ro $IMAGE ls $vol1a $vol1b
cid=$output cid=$output
run_podman container inspect $output run_podman container inspect $cid
is "$output" ".*$vol1a" "podman images --inspect should include $vol1a" is "$output" ".*$vol1a" "podman images --inspect should include $vol1a"
is "$output" ".*$vol1b" "podman images --inspect should include $vol1b" is "$output" ".*$vol1b" "podman images --inspect should include $vol1b"
run_podman rm $cid
run_podman 125 run --rm --mount type=bind,source=${PODMAN_TMPDIR}/v2\*,ro=false $IMAGE touch $vol2 run_podman 125 run --rm --mount type=bind,source=${PODMAN_TMPDIR}/v2\*,ro=false $IMAGE touch $vol2
is "$output" "Error: must set volume destination" "Bind mounts require destination" is "$output" "Error: must set volume destination" "Bind mounts require destination"

View File

@ -1134,6 +1134,7 @@ EOF
run_podman run --rm --volumes-from test_ctr $IMAGE echo $rand_content run_podman run --rm --volumes-from test_ctr $IMAGE echo $rand_content
is "$output" "$rand_content" "No error should be thrown about volume in use" is "$output" "$rand_content" "No error should be thrown about volume in use"
run_podman rm -f -v -t0 test_ctr
run_podman rmi -f build_test run_podman rmi -f build_test
} }

View File

@ -217,6 +217,8 @@ load helpers
run_podman inspect --format "{{len .ExecIDs}}" $cid run_podman inspect --format "{{len .ExecIDs}}" $cid
assert "$output" = "0" ".ExecIDs must be empty" assert "$output" = "0" ".ExecIDs must be empty"
run_podman rm -f -t0 $cid
} }
# 'exec --preserve-fd' passes a list of additional file descriptors into the container # 'exec --preserve-fd' passes a list of additional file descriptors into the container
@ -239,6 +241,8 @@ load helpers
assert "${lines[0]}" !~ [123][0-9] "/proc/self/fd must not contain 10-39" assert "${lines[0]}" !~ [123][0-9] "/proc/self/fd must not contain 10-39"
assert "${lines[1]}" = "fd9" "cat from fd 9" assert "${lines[1]}" = "fd9" "cat from fd 9"
assert "${lines[2]}" = "$content" "cat from fd 40" assert "${lines[2]}" = "$content" "cat from fd 40"
run_podman rm -f -t0 $cid
} }
# vim: filetype=sh # vim: filetype=sh

View File

@ -134,7 +134,7 @@ function _events_disjunctive_filters() {
run_podman 125 --events-backend=file logs --follow test run_podman 125 --events-backend=file logs --follow test
is "$output" "Error: using --follow with the journald --log-driver but without the journald --events-backend (file) is not supported" \ is "$output" "Error: using --follow with the journald --log-driver but without the journald --events-backend (file) is not supported" \
"Should fail with reasonable error message when events-backend and events-logger do not match" "Should fail with reasonable error message when events-backend and events-logger do not match"
run_podman rm test
} }
@test "events with disjunctive filters - default" { @test "events with disjunctive filters - default" {
@ -358,6 +358,8 @@ EOF
--stream=false --stream=false
assert "$output" != ".*ConmonPidFile.*" assert "$output" != ".*ConmonPidFile.*"
assert "$output" != ".*EffectiveCaps.*" assert "$output" != ".*EffectiveCaps.*"
run_podman rm $cname
} }
@test "events - container inspect data - journald" { @test "events - container inspect data - journald" {

View File

@ -135,6 +135,7 @@ load helpers
run_podman 125 start $random_name run_podman 125 start $random_name
# FIXME(#14873): while older Podmans return 0 on wait, Docker does not. # FIXME(#14873): while older Podmans return 0 on wait, Docker does not.
run_podman wait $random_name run_podman wait $random_name
run_podman rm $random_name
} }
@test "podman kill - no restart" { @test "podman kill - no restart" {
@ -149,6 +150,7 @@ load helpers
is "$output" "42" "container exits with 42 on receiving SIGTERM" is "$output" "42" "container exits with 42 on receiving SIGTERM"
run_podman container inspect --format "{{.State.StoppedByUser}}" $ctr run_podman container inspect --format "{{.State.StoppedByUser}}" $ctr
is "$output" "true" "container is marked to be stopped by a user" is "$output" "true" "container is marked to be stopped by a user"
run_podman rm $ctr
} }
# vim: filetype=sh # vim: filetype=sh

View File

@ -508,6 +508,7 @@ spec:
is "$output" "stop" "custom exit policy" is "$output" "stop" "custom exit policy"
_ensure_pod_state $name-pod Exited _ensure_pod_state $name-pod Exited
run_podman pod rm $name-pod run_podman pod rm $name-pod
run_podman network rm podman-default-kube-network
} }
@test "pod resource limits" { @test "pod resource limits" {

View File

@ -275,6 +275,7 @@ LISTEN_FDNAMES=listen_fdnames" | sort)
run_podman create --name $cname $IMAGE top run_podman create --name $cname $IMAGE top
run_podman 125 generate systemd --new=false --template -n $cname run_podman 125 generate systemd --new=false --template -n $cname
is "$output" ".*--template cannot be set" "Error message should be '--template requires --new'" is "$output" ".*--template cannot be set" "Error message should be '--template requires --new'"
run_podman rm $cname
} }
@test "podman --cgroup=cgroupfs doesn't show systemd warning" { @test "podman --cgroup=cgroupfs doesn't show systemd warning" {
@ -287,6 +288,7 @@ LISTEN_FDNAMES=listen_fdnames" | sort)
container_uuid=$output container_uuid=$output
run_podman inspect test --format '{{ .ID }}' run_podman inspect test --format '{{ .ID }}'
is "${container_uuid}" "${output:0:32}" "UUID should be first 32 chars of Container id" is "${container_uuid}" "${output:0:32}" "UUID should be first 32 chars of Container id"
run_podman rm test
} }
@test "podman --systemd fails on cgroup v1 with a private cgroupns" { @test "podman --systemd fails on cgroup v1 with a private cgroupns" {
@ -480,6 +482,7 @@ $name stderr" "logs work with passthrough"
run_podman 1 container exists $service_container run_podman 1 container exists $service_container
run_podman 1 pod exists test_pod run_podman 1 pod exists test_pod
run_podman rmi $(pause_image) run_podman rmi $(pause_image)
run_podman network rm podman-default-kube-network
rm -f $UNIT_DIR/$unit_name rm -f $UNIT_DIR/$unit_name
} }
@ -492,5 +495,6 @@ $name stderr" "logs work with passthrough"
is "$output" ".*[DEPRECATED] command:" is "$output" ".*[DEPRECATED] command:"
run_podman generate --help run_podman generate --help
is "$output" ".*\[DEPRECATED\] Generate systemd units" is "$output" ".*\[DEPRECATED\] Generate systemd units"
run_podman rm test
} }
# vim: filetype=sh # vim: filetype=sh

View File

@ -324,6 +324,7 @@ EOF
is "$output" "with space" is "$output" "with space"
service_cleanup $QUADLET_SERVICE_NAME inactive service_cleanup $QUADLET_SERVICE_NAME inactive
run_podman volume rm $volume_name
} }
# A quadlet container depends on a quadlet volume # A quadlet container depends on a quadlet volume
@ -450,6 +451,7 @@ EOF
is "$output" "with space" is "$output" "with space"
service_cleanup $QUADLET_SERVICE_NAME inactive service_cleanup $QUADLET_SERVICE_NAME inactive
run_podman network rm $network_name
} }
# A quadlet container depends on a quadlet network # A quadlet container depends on a quadlet network
@ -591,6 +593,7 @@ EOF
service_cleanup $QUADLET_SERVICE_NAME inactive service_cleanup $QUADLET_SERVICE_NAME inactive
run_podman rmi $(pause_image) run_podman rmi $(pause_image)
run_podman network rm podman-default-kube-network
} }
@test "quadlet kube - named network dependency" { @test "quadlet kube - named network dependency" {
@ -960,6 +963,7 @@ EOF
done < <(parse_table "$exit_tests") done < <(parse_table "$exit_tests")
run_podman rmi $(pause_image) run_podman rmi $(pause_image)
run_podman network rm podman-default-kube-network
} }
@test "quadlet kube - Working Directory" { @test "quadlet kube - Working Directory" {
@ -1020,6 +1024,7 @@ EOF
service_cleanup $QUADLET_SERVICE_NAME inactive service_cleanup $QUADLET_SERVICE_NAME inactive
run_podman rmi $(pause_image) run_podman rmi $(pause_image)
run_podman network rm podman-default-kube-network
} }
@test "quadlet - image files" { @test "quadlet - image files" {
@ -1251,6 +1256,7 @@ EOF
service_cleanup $pod_service inactive service_cleanup $pod_service inactive
run_podman volume rm $quadlet_kube_volume_name run_podman volume rm $quadlet_kube_volume_name
run_podman rmi --ignore $(pause_image) run_podman rmi --ignore $(pause_image)
run_podman network rm podman-default-kube-network
} }
@test "quadlet - kube down force" { @test "quadlet - kube down force" {
@ -1330,6 +1336,7 @@ EOF
# Volume should not exist # Volume should not exist
run_podman 1 volume exists ${quadlet_kube_volume_name} run_podman 1 volume exists ${quadlet_kube_volume_name}
run_podman rmi --ignore $(pause_image) run_podman rmi --ignore $(pause_image)
run_podman network rm podman-default-kube-network
} }
@test "quadlet - image tag" { @test "quadlet - image tag" {
@ -1417,6 +1424,7 @@ EOF
service_cleanup $container_service failed service_cleanup $container_service failed
run_podman image rm --ignore $image_for_test run_podman image rm --ignore $image_for_test
run_podman rmi --ignore $(pause_image) run_podman rmi --ignore $(pause_image)
run_podman volume rm $volume_name
} }
@test "quadlet - pod simple" { @test "quadlet - pod simple" {
@ -1546,5 +1554,6 @@ EOF
service_cleanup $QUADLET_SERVICE_NAME inactive service_cleanup $QUADLET_SERVICE_NAME inactive
run_podman rmi $untagged_image:latest $built_image $(pause_image) run_podman rmi $untagged_image:latest $built_image $(pause_image)
run_podman network rm podman-default-kube-network
} }
# vim: filetype=sh # vim: filetype=sh

View File

@ -564,6 +564,7 @@ EOF
# Clean up # Clean up
systemctl stop $service_name systemctl stop $service_name
run_podman rmi -f $(pause_image) $local_image $newID $oldID run_podman rmi -f $(pause_image) $local_image $newID $oldID
run_podman network rm podman-default-kube-network
rm -f $UNIT_DIR/$unit_name rm -f $UNIT_DIR/$unit_name
} }

View File

@ -318,6 +318,7 @@ READY=1" "sdnotify sent MAINPID and READY"
# Clean up pod and pause image # Clean up pod and pause image
run_podman play kube --down $PODMAN_TMPDIR/test.yaml run_podman play kube --down $PODMAN_TMPDIR/test.yaml
run_podman rmi $(pause_image) run_podman rmi $(pause_image)
run_podman network rm podman-default-kube-network
} }
@test "sdnotify : play kube - with policies" { @test "sdnotify : play kube - with policies" {
@ -427,6 +428,7 @@ READY=1" "sdnotify sent MAINPID and READY"
# Clean up pod and pause image # Clean up pod and pause image
run_podman play kube --down $yaml_source run_podman play kube --down $yaml_source
run_podman rmi $(pause_image) run_podman rmi $(pause_image)
run_podman network rm podman-default-kube-network
} }
function generate_exit_code_yaml { function generate_exit_code_yaml {
@ -517,6 +519,7 @@ none | false | false | 0
is "$output" "Error: unsupported exit-code propagation \"bogus\"" "error on unsupported exit-code propagation" is "$output" "Error: unsupported exit-code propagation \"bogus\"" "error on unsupported exit-code propagation"
run_podman rmi $(pause_image) run_podman rmi $(pause_image)
run_podman network rm podman-default-kube-network
} }
@test "podman pull - EXTEND_TIMEOUT_USEC" { @test "podman pull - EXTEND_TIMEOUT_USEC" {

View File

@ -155,6 +155,8 @@ device-write-iops = /dev/zero:4000 | - | -
# Restart should ensure that the container comes back up and recreates the file # Restart should ensure that the container comes back up and recreates the file
wait_for_file ${PODMAN_TMPDIR}/alive wait_for_file ${PODMAN_TMPDIR}/alive
run_podman rm -f -t0 testctr
} }
# vim: filetype=sh # vim: filetype=sh

View File

@ -345,7 +345,7 @@ EOF
run id -Z run id -Z
user=$(secon -u $output) user=$(secon -u $output)
role=$(secon -r $output) role=$(secon -r $output)
CONTAINERS_CONF_OVERRIDE=$overrideConf run_podman run $IMAGE cat /proc/self/attr/current CONTAINERS_CONF_OVERRIDE=$overrideConf run_podman run --rm $IMAGE cat /proc/self/attr/current
level=$(secon -l $output) level=$(secon -l $output)
id -Z id -Z
is "$output" "$user:$role:container_t:$level" "Confined label Correctly" is "$output" "$user:$role:container_t:$level" "Confined label Correctly"

View File

@ -118,7 +118,7 @@ function teardown() {
run tty <$PODMAN_TEST_PTY run tty <$PODMAN_TEST_PTY
expected_tty="$output" expected_tty="$output"
run_podman run -v/dev:/dev --log-driver=passthrough-tty $IMAGE tty <$PODMAN_TEST_PTY run_podman run --rm -v/dev:/dev --log-driver=passthrough-tty $IMAGE tty <$PODMAN_TEST_PTY
is "$output" "$expected_tty" "passthrough-tty: tty matches" is "$output" "$expected_tty" "passthrough-tty: tty matches"
} }

View File

@ -722,6 +722,8 @@ nameserver 8.8.8.8" "nameserver order is correct"
run_podman run --network host --dns 1.1.1.1 --rm $IMAGE cat /etc/resolv.conf run_podman run --network host --dns 1.1.1.1 --rm $IMAGE cat /etc/resolv.conf
assert "$output" =~ ".*nameserver 1\.1\.1\.1.*" \ assert "$output" =~ ".*nameserver 1\.1\.1\.1.*" \
"resolv.conf contains 1.1.1.1 nameserver" "resolv.conf contains 1.1.1.1 nameserver"
run_podman network rm -f $netname
} }
@test "podman run port forward range" { @test "podman run port forward range" {

View File

@ -230,7 +230,7 @@ function pasta_test_do() {
done done
# and server, # and server,
run_podman run --net=pasta"${pasta_spec}" -p "${podman_spec}" "${IMAGE}" \ run_podman run --rm --net=pasta"${pasta_spec}" -p "${podman_spec}" "${IMAGE}" \
sh -c 'for port in $(seq '"${xseq}"'); do '\ sh -c 'for port in $(seq '"${xseq}"'); do '\
' socat -u '"${bind}"' '"${recv}"' & '\ ' socat -u '"${bind}"' '"${recv}"' & '\
' done; wait' ' done; wait'
@ -244,7 +244,7 @@ function pasta_test_do() {
@test "IPv4 default address assignment" { @test "IPv4 default address assignment" {
skip_if_no_ipv4 "IPv4 not routable on the host" skip_if_no_ipv4 "IPv4 not routable on the host"
run_podman run --net=pasta $IMAGE ip -j -4 address show run_podman run --rm --net=pasta $IMAGE ip -j -4 address show
local container_address="$(ipv4_get_addr_global "${output}")" local container_address="$(ipv4_get_addr_global "${output}")"
local host_address="$(default_addr 4)" local host_address="$(default_addr 4)"
@ -256,7 +256,7 @@ function pasta_test_do() {
@test "IPv4 address assignment" { @test "IPv4 address assignment" {
skip_if_no_ipv4 "IPv4 not routable on the host" skip_if_no_ipv4 "IPv4 not routable on the host"
run_podman run --net=pasta:-a,192.0.2.1 $IMAGE ip -j -4 address show run_podman run --rm --net=pasta:-a,192.0.2.1 $IMAGE ip -j -4 address show
local container_address="$(ipv4_get_addr_global "${output}")" local container_address="$(ipv4_get_addr_global "${output}")"
@ -268,7 +268,7 @@ function pasta_test_do() {
skip_if_no_ipv4 "IPv4 not routable on the host" skip_if_no_ipv4 "IPv4 not routable on the host"
skip_if_no_ipv6 "IPv6 not routable on the host" skip_if_no_ipv6 "IPv6 not routable on the host"
run_podman run --net=pasta:-6 $IMAGE ip -j -4 address show run_podman run --rm --net=pasta:-6 $IMAGE ip -j -4 address show
local container_address="$(ipv4_get_addr_global "${output}")" local container_address="$(ipv4_get_addr_global "${output}")"
@ -279,7 +279,7 @@ function pasta_test_do() {
@test "IPv6 default address assignment" { @test "IPv6 default address assignment" {
skip_if_no_ipv6 "IPv6 not routable on the host" skip_if_no_ipv6 "IPv6 not routable on the host"
run_podman run --net=pasta $IMAGE ip -j -6 address show run_podman run --rm --net=pasta $IMAGE ip -j -6 address show
local container_address="$(ipv6_get_addr_global "${output}")" local container_address="$(ipv6_get_addr_global "${output}")"
local host_address="$(default_addr 6)" local host_address="$(default_addr 6)"
@ -291,7 +291,7 @@ function pasta_test_do() {
@test "IPv6 address assignment" { @test "IPv6 address assignment" {
skip_if_no_ipv6 "IPv6 not routable on the host" skip_if_no_ipv6 "IPv6 not routable on the host"
run_podman run --net=pasta:-a,2001:db8::1 $IMAGE ip -j -6 address show run_podman run --rm --net=pasta:-a,2001:db8::1 $IMAGE ip -j -6 address show
local container_address="$(ipv6_get_addr_global "${output}")" local container_address="$(ipv6_get_addr_global "${output}")"
@ -303,7 +303,7 @@ function pasta_test_do() {
skip_if_no_ipv6 "IPv6 not routable on the host" skip_if_no_ipv6 "IPv6 not routable on the host"
skip_if_no_ipv4 "IPv4 not routable on the host" skip_if_no_ipv4 "IPv4 not routable on the host"
run_podman run --net=pasta:-4 $IMAGE ip -j -6 address show run_podman run --rm --net=pasta:-4 $IMAGE ip -j -6 address show
local container_address="$(ipv6_get_addr_global "${output}")" local container_address="$(ipv6_get_addr_global "${output}")"
@ -331,7 +331,7 @@ function pasta_test_do() {
@test "IPv4 default route" { @test "IPv4 default route" {
skip_if_no_ipv4 "IPv4 not routable on the host" skip_if_no_ipv4 "IPv4 not routable on the host"
run_podman run --net=pasta $IMAGE ip -j -4 route show run_podman run --rm --net=pasta $IMAGE ip -j -4 route show
local container_route="$(ipv4_get_route_default "${output}")" local container_route="$(ipv4_get_route_default "${output}")"
local host_route="$(ipv4_get_route_default)" local host_route="$(ipv4_get_route_default)"
@ -343,7 +343,7 @@ function pasta_test_do() {
@test "IPv4 default route assignment" { @test "IPv4 default route assignment" {
skip_if_no_ipv4 "IPv4 not routable on the host" skip_if_no_ipv4 "IPv4 not routable on the host"
run_podman run --net=pasta:-a,192.0.2.2,-g,192.0.2.1 $IMAGE \ run_podman run --rm --net=pasta:-a,192.0.2.2,-g,192.0.2.1 $IMAGE \
ip -j -4 route show ip -j -4 route show
local container_route="$(ipv4_get_route_default "${output}")" local container_route="$(ipv4_get_route_default "${output}")"
@ -355,7 +355,7 @@ function pasta_test_do() {
@test "IPv6 default route" { @test "IPv6 default route" {
skip_if_no_ipv6 "IPv6 not routable on the host" skip_if_no_ipv6 "IPv6 not routable on the host"
run_podman run --net=pasta $IMAGE ip -j -6 route show run_podman run --rm --net=pasta $IMAGE ip -j -6 route show
local container_route="$(ipv6_get_route_default "${output}")" local container_route="$(ipv6_get_route_default "${output}")"
local host_route="$(ipv6_get_route_default)" local host_route="$(ipv6_get_route_default)"
@ -367,7 +367,7 @@ function pasta_test_do() {
@test "IPv6 default route assignment" { @test "IPv6 default route assignment" {
skip_if_no_ipv6 "IPv6 not routable on the host" skip_if_no_ipv6 "IPv6 not routable on the host"
run_podman run --net=pasta:-a,2001:db8::2,-g,2001:db8::1 $IMAGE \ run_podman run --rm --net=pasta:-a,2001:db8::2,-g,2001:db8::1 $IMAGE \
ip -j -6 route show ip -j -6 route show
local container_route="$(ipv6_get_route_default "${output}")" local container_route="$(ipv6_get_route_default "${output}")"
@ -379,7 +379,7 @@ function pasta_test_do() {
### Interfaces ################################################################# ### Interfaces #################################################################
@test "Default MTU" { @test "Default MTU" {
run_podman run --net=pasta $IMAGE ip -j link show run_podman run --rm --net=pasta $IMAGE ip -j link show
container_tap_mtu="$(ether_get_mtu "${output}")" container_tap_mtu="$(ether_get_mtu "${output}")"
@ -388,7 +388,7 @@ function pasta_test_do() {
} }
@test "MTU assignment" { @test "MTU assignment" {
run_podman run --net=pasta:-m,1280 $IMAGE ip -j link show run_podman run --rm --net=pasta:-m,1280 $IMAGE ip -j link show
container_tap_mtu="$(ether_get_mtu "${output}")" container_tap_mtu="$(ether_get_mtu "${output}")"
@ -397,7 +397,7 @@ function pasta_test_do() {
} }
@test "Loopback interface state" { @test "Loopback interface state" {
run_podman run --net=pasta $IMAGE ip -j link show run_podman run --rm --net=pasta $IMAGE ip -j link show
local jq_expr='.[] | select(.link_type == "loopback").flags | '\ local jq_expr='.[] | select(.link_type == "loopback").flags | '\
' contains(["UP"])' ' contains(["UP"])'
@ -413,7 +413,7 @@ function pasta_test_do() {
@test "External resolver, IPv4" { @test "External resolver, IPv4" {
skip_if_no_ipv4 "IPv4 not routable on the host" skip_if_no_ipv4 "IPv4 not routable on the host"
run_podman '?' run --net=pasta $IMAGE nslookup 127.0.0.1 run_podman '?' run --rm --net=pasta $IMAGE nslookup 127.0.0.1
assert "$output" =~ "1.0.0.127.in-addr.arpa" \ assert "$output" =~ "1.0.0.127.in-addr.arpa" \
"127.0.0.1 not resolved" "127.0.0.1 not resolved"
@ -422,7 +422,7 @@ function pasta_test_do() {
@test "External resolver, IPv6" { @test "External resolver, IPv6" {
skip_if_no_ipv6 "IPv6 not routable on the host" skip_if_no_ipv6 "IPv6 not routable on the host"
run_podman run --net=pasta $IMAGE nslookup ::1 || : run_podman '?' run --rm --net=pasta $IMAGE nslookup ::1
assert "$output" =~ "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" \ assert "$output" =~ "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" \
"::1 not resolved" "::1 not resolved"
@ -743,7 +743,7 @@ function pasta_test_do() {
@test "pasta(1) quits when the namespace is gone" { @test "pasta(1) quits when the namespace is gone" {
local pidfile="${PODMAN_TMPDIR}/pasta.pid" local pidfile="${PODMAN_TMPDIR}/pasta.pid"
run_podman run "--net=pasta:--pid,${pidfile}" $IMAGE true run_podman run --rm "--net=pasta:--pid,${pidfile}" $IMAGE true
sleep 1 sleep 1
! ps -p $(cat "${pidfile}") && rm "${pidfile}" ! ps -p $(cat "${pidfile}") && rm "${pidfile}"
} }
@ -752,7 +752,7 @@ function pasta_test_do() {
@test "Unsupported protocol in port forwarding" { @test "Unsupported protocol in port forwarding" {
local port=$(random_free_port "" "" tcp) local port=$(random_free_port "" "" tcp)
run_podman 126 run --net=pasta -p "${port}:${port}/sctp" $IMAGE true run_podman 126 run --rm --net=pasta -p "${port}:${port}/sctp" $IMAGE true
is "$output" "Error: .*can't forward protocol: sctp" is "$output" "Error: .*can't forward protocol: sctp"
} }
@ -769,12 +769,13 @@ EOF
# 2023-06-29 DO NOT INCLUDE "--net=pasta" on this line! # 2023-06-29 DO NOT INCLUDE "--net=pasta" on this line!
# This tests containers.conf:default_rootless_network_cmd (pr #19032) # This tests containers.conf:default_rootless_network_cmd (pr #19032)
CONTAINERS_CONF_OVERRIDE=$containersconf run_podman run $IMAGE ip link show myname CONTAINERS_CONF_OVERRIDE=$containersconf run_podman run --rm $IMAGE ip link show myname
assert "$output" =~ "$mac" "mac address is set on custom interface" assert "$output" =~ "$mac" "mac address is set on custom interface"
# now, again but this time overwrite a option on the cli. # now, again but this time overwrite a option on the cli.
mac2="aa:bb:cc:dd:ee:ff" mac2="aa:bb:cc:dd:ee:ff"
CONTAINERS_CONF_OVERRIDE=$containersconf run_podman run --net=pasta:--ns-mac-addr,"$mac2" $IMAGE ip link show myname CONTAINERS_CONF_OVERRIDE=$containersconf run_podman run --rm \
--net=pasta:--ns-mac-addr,"$mac2" $IMAGE ip link show myname
assert "$output" =~ "$mac2" "mac address from cli is set on custom interface" assert "$output" =~ "$mac2" "mac address from cli is set on custom interface"
} }

View File

@ -228,6 +228,8 @@ function teardown() {
run_podman logs $cid run_podman logs $cid
trim=$(sed -z -e 's/[\r\n]\+//g' <<<"$output") trim=$(sed -z -e 's/[\r\n]\+//g' <<<"$output")
is "$trim" "READY123123" "File lock restored" is "$trim" "READY123123" "File lock restored"
run_podman rm $cid
} }
@test "podman checkpoint/restore ip and mac handling" { @test "podman checkpoint/restore ip and mac handling" {

View File

@ -17,6 +17,7 @@ function teardown() {
run_podman rmi $id run_podman rmi $id
fi fi
done <<<"$output" done <<<"$output"
run_podman network rm -f podman-default-kube-network
basic_teardown basic_teardown
} }

View File

@ -88,6 +88,7 @@ status | = | null
run_podman pod rm -a run_podman pod rm -a
run_podman rm -a run_podman rm -a
run_podman rmi $(pause_image) run_podman rmi $(pause_image)
run_podman network rm podman-default-kube-network
} }
@test "podman kube generate - pod" { @test "podman kube generate - pod" {