Merge pull request #22886 from Luap99/fast-system-test-3

test/system: make some tests faster part 3
This commit is contained in:
openshift-merge-bot[bot] 2024-06-05 13:19:00 +00:00 committed by GitHub
commit 42ffa4db43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 130 additions and 119 deletions

View File

@ -665,7 +665,7 @@ localmachine:
localsystem: localsystem:
# Wipe existing config, database, and cache: start with clean slate. # Wipe existing config, database, and cache: start with clean slate.
$(RM) -rf ${HOME}/.local/share/containers ${HOME}/.config/containers $(RM) -rf ${HOME}/.local/share/containers ${HOME}/.config/containers
if timeout -v 1 true; then PODMAN=$(CURDIR)/bin/podman QUADLET=$(CURDIR)/bin/quadlet bats test/system/; else echo "Skipping $@: 'timeout -v' unavailable'"; fi if timeout -v 1 true; then PODMAN=$(CURDIR)/bin/podman QUADLET=$(CURDIR)/bin/quadlet bats -T test/system/; else echo "Skipping $@: 'timeout -v' unavailable'"; fi
.PHONY: remotesystem .PHONY: remotesystem
remotesystem: remotesystem:
@ -690,7 +690,7 @@ remotesystem:
echo "Error: ./bin/podman system service did not come up on $$SOCK_FILE" >&2;\ echo "Error: ./bin/podman system service did not come up on $$SOCK_FILE" >&2;\
exit 1;\ exit 1;\
fi;\ fi;\
env PODMAN="$(CURDIR)/bin/podman-remote --url $$PODMAN_SOCKET" bats test/system/ ;\ env PODMAN="$(CURDIR)/bin/podman-remote --url $$PODMAN_SOCKET" bats -T test/system/ ;\
rc=$$?;\ rc=$$?;\
kill %1;\ kill %1;\
rm -f $$SOCK_FILE;\ rm -f $$SOCK_FILE;\

View File

@ -195,10 +195,10 @@ See 'podman version --help'" "podman version --remote"
} }
@test "podman --log-level recognizes log levels" { @test "podman --log-level recognizes log levels" {
run_podman 1 --log-level=telepathic info run_podman 1 --log-level=telepathic version
is "$output" 'Log Level "telepathic" is not supported.*' is "$output" 'Log Level "telepathic" is not supported.*'
run_podman --log-level=trace info run_podman --log-level=trace version
if ! is_remote; then if ! is_remote; then
# podman-remote does not do any trace logging # podman-remote does not do any trace logging
assert "$output" =~ " level=trace " "log-level=trace" assert "$output" =~ " level=trace " "log-level=trace"
@ -207,33 +207,33 @@ See 'podman version --help'" "podman version --remote"
assert "$output" =~ " level=info " "log-level=trace includes info" assert "$output" =~ " level=info " "log-level=trace includes info"
assert "$output" !~ " level=warn" "log-level=trace does not show warn" assert "$output" !~ " level=warn" "log-level=trace does not show warn"
run_podman --log-level=debug info run_podman --log-level=debug version
assert "$output" !~ " level=trace " "log-level=debug does not show trace" assert "$output" !~ " level=trace " "log-level=debug does not show trace"
assert "$output" =~ " level=debug " "log-level=debug" assert "$output" =~ " level=debug " "log-level=debug"
assert "$output" =~ " level=info " "log-level=debug includes info" assert "$output" =~ " level=info " "log-level=debug includes info"
assert "$output" !~ " level=warn" "log-level=debug does not show warn" assert "$output" !~ " level=warn" "log-level=debug does not show warn"
run_podman --log-level=info info run_podman --log-level=info version
assert "$output" !~ " level=trace " "log-level=info does not show trace" assert "$output" !~ " level=trace " "log-level=info does not show trace"
assert "$output" !~ " level=debug " "log-level=info does not show debug" assert "$output" !~ " level=debug " "log-level=info does not show debug"
assert "$output" =~ " level=info " "log-level=info" assert "$output" =~ " level=info " "log-level=info"
run_podman --log-level=warn info run_podman --log-level=warn version
assert "$output" !~ " level=" "log-level=warn shows no logs at all" assert "$output" !~ " level=" "log-level=warn shows no logs at all"
run_podman --log-level=warning info run_podman --log-level=warning version
assert "$output" !~ " level=" "log-level=warning shows no logs at all" assert "$output" !~ " level=" "log-level=warning shows no logs at all"
run_podman --log-level=error info run_podman --log-level=error version
assert "$output" !~ " level=" "log-level=error shows no logs at all" assert "$output" !~ " level=" "log-level=error shows no logs at all"
# docker compat # docker compat
run_podman --debug info run_podman --debug version
assert "$output" =~ " level=debug " "podman --debug gives debug output" assert "$output" =~ " level=debug " "podman --debug gives debug output"
run_podman -D info run_podman -D version
assert "$output" =~ " level=debug " "podman -D gives debug output" assert "$output" =~ " level=debug " "podman -D gives debug output"
run_podman 1 --debug --log-level=panic info run_podman 1 --debug --log-level=panic version
is "$output" "Setting --log-level and --debug is not allowed" is "$output" "Setting --log-level and --debug is not allowed"
} }

View File

@ -308,12 +308,10 @@ echo $rand | 0 | $rand
for user in "--user=0" "--user=100"; do for user in "--user=0" "--user=100"; do
for keepid in "" ${keep}; do for keepid in "" ${keep}; do
opts="$priv $user $keepid" opts="$priv $user $keepid"
run_podman run --rm $opts $IMAGE stat -c '%u:%g:%n' $dir /etc /usr
for dir in /etc /usr;do
run_podman run --rm $opts $IMAGE stat -c '%u:%g:%n' $dir
remove_same_dev_warning # grumble remove_same_dev_warning # grumble
is "$output" "0:0:$dir" "run $opts ($dir)" is "${lines[0]}" "0:0:/etc" "run $opts /etc"
done is "${lines[1]}" "0:0:/usr" "run $opts /usr"
done done
done done
done done

View File

@ -142,25 +142,38 @@ load helpers
run_podman ps --external run_podman ps --external
is "${#lines[@]}" "1" "setup check: no storage containers at start of test" is "${#lines[@]}" "1" "setup check: no storage containers at start of test"
# Force a buildah timeout; this leaves a buildah container behind # Ok this here is basically a way to reproduce a "leaked" podman build buildah
local t0=$SECONDS # container without having to kill any process and usage of sleep.
PODMAN_TIMEOUT=5 run_podman 124 build -t thiswillneverexist - <<EOF run buildah from $IMAGE
FROM $IMAGE assert "$status" -eq 0 "buildah from successfully"
RUN touch /intermediate.image.to.be.pruned buildah_cid="$output"
RUN sleep 30
EOF # Commit new image so we have something to prune.
local t1=$SECONDS run buildah commit $buildah_cid
local delta_t=$((t1 - t0)) assert "$status" -eq 0 "buildah commit successfully"
assert $delta_t -le 10 \ buildah_image_id="${lines[-1]}"
"podman build did not get killed within 10 seconds"
# Create new buildah container with new image so that one can be pruned directly.
run buildah from "$buildah_image_id"
assert "$status" -eq 0 "buildah from new buildah image successfully"
# We have to mount the container to trigger the "container .* is mounted" check below.
local unshare=
if is_rootless; then
# rootless needs unshare for mounting
unshare="buildah unshare"
fi
run $unshare buildah mount "$buildah_cid"
assert "$status" -eq 0 "buildah mount container successfully"
run_podman ps -a run_podman ps -a
is "${#lines[@]}" "1" "podman ps -a does not see buildah containers" is "${#lines[@]}" "1" "podman ps -a does not see buildah containers"
run_podman ps --external run_podman ps --external
is "${#lines[@]}" "3" "podman ps -a --external sees buildah containers" is "${#lines[@]}" "3" "podman ps -a --external sees buildah containers"
# output can include "second ago" or "seconds ago" depending on the timing so match both
is "${lines[1]}" \ is "${lines[1]}" \
"[0-9a-f]\{12\} \+$IMAGE *buildah .* seconds ago .* Storage .* ${PODMAN_TEST_IMAGE_NAME}-working-container" \ "[0-9a-f]\{12\} \+$IMAGE *buildah .* seconds\? ago .* Storage .* ${PODMAN_TEST_IMAGE_NAME}-working-container" \
"podman ps --external" "podman ps --external"
# 'rm -a' should be a NOP # 'rm -a' should be a NOP

View File

@ -360,20 +360,26 @@ load helpers
while read src dest dest_fullname description; do while read src dest dest_fullname description; do
run_podman cp $srcdir/$src destrunning:$dest run_podman cp $srcdir/$src destrunning:$dest
run_podman exec destrunning cat $dest_fullname/hostfile0 $dest_fullname/hostfile1 run_podman exec destrunning cat $dest_fullname/hostfile0 $dest_fullname/hostfile1
is "$(echo $output)" "${randomcontent[*]}" "$description (cp -> ctr:$dest - RUNNING)" is "${lines[*]}" "${randomcontent[*]}" "$description (cp -> ctr:$dest - RUNNING)"
done < <(parse_table "$tests") done < <(parse_table "$tests")
run_podman rm -t 0 -f destrunning run_podman rm -t 0 -f destrunning
# CREATED container # CREATED container
while read src dest dest_fullname description; do
run_podman create --name destcreated --workdir=/srv $cpimage sleep infinity run_podman create --name destcreated --workdir=/srv $cpimage sleep infinity
while read src dest dest_fullname description; do
run_podman cp $srcdir/$src destcreated:$dest run_podman cp $srcdir/$src destcreated:$dest
run_podman start destcreated # tests checks are done below
run_podman exec destcreated cat $dest_fullname/hostfile0 $dest_fullname/hostfile1
is "$(echo $output)" "${randomcontent[*]}" "$description (cp -> ctr:$dest - CREATED)"
run_podman rm -t 0 -f destcreated
done < <(parse_table "$tests") done < <(parse_table "$tests")
# Now do the test checks, it is a bit ugly that we do this over two loops but this
# makes the test faster as we do not have to start/stop the container on every iteration.
run_podman start destcreated
while read src dest dest_fullname description; do
run_podman exec destcreated cat $dest_fullname/hostfile0 $dest_fullname/hostfile1
is "${lines[*]}" "${randomcontent[*]}" "$description (cp -> ctr:$dest - CREATED)"
done < <(parse_table "$tests")
run_podman rm -t 0 -f destcreated
run_podman create --name destnotdir --workdir=/srv $cpimage sleep infinity run_podman create --name destnotdir --workdir=/srv $cpimage sleep infinity
run_podman 125 cp $srcdir destnotdir:/etc/os-release run_podman 125 cp $srcdir destnotdir:/etc/os-release
is "$output" "Error: destination must be a directory when copying a directory" "cannot copy directory to file" is "$output" "Error: destination must be a directory when copying a directory" "cannot copy directory to file"

View File

@ -246,7 +246,7 @@ FROM $IMAGE
RUN echo hi RUN echo hi
EOF EOF
local count=30 local count=10
for i in $(seq --format '%02g' 1 $count); do for i in $(seq --format '%02g' 1 $count); do
timeout --foreground -v --kill=10 60 \ timeout --foreground -v --kill=10 60 \
$PODMAN build -t i$i $PODMAN_TMPDIR &> $PODMAN_TMPDIR/log.$i & $PODMAN build -t i$i $PODMAN_TMPDIR &> $PODMAN_TMPDIR/log.$i &
@ -360,11 +360,11 @@ LABEL $label_name=$label_value
WORKDIR $workdir WORKDIR $workdir
# Test for #7094 - chowning of invalid symlinks # Test for #7094 - chowning of invalid symlinks
RUN mkdir -p /a/b/c RUN mkdir -p /a/b/c && \
RUN ln -s /no/such/nonesuch /a/b/c/badsymlink ln -s /no/such/nonesuch /a/b/c/badsymlink && \
RUN ln -s /bin/mydefaultcmd /a/b/c/goodsymlink ln -s /bin/mydefaultcmd /a/b/c/goodsymlink && \
RUN touch /a/b/c/myfile touch /a/b/c/myfile && \
RUN chown -h 1:2 /a/b/c/badsymlink /a/b/c/goodsymlink && chown -h 4:5 /a/b/c/myfile chown -h 1:2 /a/b/c/badsymlink /a/b/c/goodsymlink && chown -h 4:5 /a/b/c/myfile
VOLUME /a/b/c VOLUME /a/b/c
# Test for environment passing and override # Test for environment passing and override
@ -374,17 +374,16 @@ ENV MYENV3 this-should-be-overridden-by-env-file
ENV MYENV4 this-should-be-overridden-by-cmdline ENV MYENV4 this-should-be-overridden-by-cmdline
ENV http_proxy http-proxy-in-image ENV http_proxy http-proxy-in-image
ENV ftp_proxy ftp-proxy-in-image ENV ftp_proxy ftp-proxy-in-image
ADD mycmd /bin/mydefaultcmd ADD mycmd /bin/mydefaultcmd
RUN chmod 755 /bin/mydefaultcmd RUN chmod 755 /bin/mydefaultcmd && \
RUN chown 2:3 /bin/mydefaultcmd chown 2:3 /bin/mydefaultcmd && \
$CAT_SECRET && \
RUN $CAT_SECRET echo explicit-build-arg=\$arg_explicit && \
echo implicit-build-arg=\$arg_implicit && \
RUN echo explicit-build-arg=\$arg_explicit cat /etc/resolv.conf
RUN echo implicit-build-arg=\$arg_implicit
CMD ["/bin/mydefaultcmd","$s_echo"] CMD ["/bin/mydefaultcmd","$s_echo"]
RUN cat /etc/resolv.conf
EOF EOF
# The goal is to test that a missing value will be inherited from # The goal is to test that a missing value will be inherited from
@ -458,7 +457,8 @@ EOF
--env-file=$PODMAN_TMPDIR/env-file1 \ --env-file=$PODMAN_TMPDIR/env-file1 \
--env-file=$PODMAN_TMPDIR/env-file2 \ --env-file=$PODMAN_TMPDIR/env-file2 \
build_test \ build_test \
printenv http_proxy https_proxy ftp_proxy sh -c "printenv http_proxy https_proxy ftp_proxy &&
pwd"
is "${lines[0]}" "http-proxy-in-env-file" "env-file overrides env" is "${lines[0]}" "http-proxy-in-env-file" "env-file overrides env"
is "${lines[1]}" "https-proxy-in-env-file" "env-file sets proxy var" is "${lines[1]}" "https-proxy-in-env-file" "env-file sets proxy var"
@ -469,8 +469,7 @@ EOF
fi fi
# test that workdir is set for command-line commands also # test that workdir is set for command-line commands also
run_podman run --rm build_test pwd is "${lines[3]}" "$workdir" "pwd command in container"
is "$output" "$workdir" "pwd command in container"
# Determine buildah version, so we can confirm it gets into Labels # Determine buildah version, so we can confirm it gets into Labels
# Multiple --format options confirm command-line override (last one wins) # Multiple --format options confirm command-line override (last one wins)
@ -494,10 +493,8 @@ Cmd[0] | /bin/mydefaultcmd
Cmd[1] | $s_echo Cmd[1] | $s_echo
WorkingDir | $workdir WorkingDir | $workdir
Labels.$label_name | $label_value Labels.$label_name | $label_value
Labels.\"io.buildah.version\" | $buildah_version
" "
# FIXME: 2021-02-24: Fixed in buildah #3036; re-enable this once podman
# vendors in a newer buildah!
# Labels.\"io.buildah.version\" | $buildah_version
parse_table "$tests" | while read field expect; do parse_table "$tests" | while read field expect; do
actual=$(jq -r ".[0].Config.$field" <<<"$output") actual=$(jq -r ".[0].Config.$field" <<<"$output")
@ -509,19 +506,18 @@ Labels.$label_name | $label_value
# get here because any 'podman run' on a volume that had symlinks, # get here because any 'podman run' on a volume that had symlinks,
# be they dangling or valid, would barf with # be they dangling or valid, would barf with
# Error: chown <mountpath>/_data/symlink: ENOENT # Error: chown <mountpath>/_data/symlink: ENOENT
run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/badsymlink run_podman run --rm build_test \
is "$output" "1:2:'/a/b/c/badsymlink' -> '/no/such/nonesuch'" \ stat -c'%u:%g:%N' /a/b/c/badsymlink \
/a/b/c/goodsymlink \
/bin/mydefaultcmd \
/a/b/c/myfile
is "${lines[0]}" "1:2:'/a/b/c/badsymlink' -> '/no/such/nonesuch'" \
"bad symlink to nonexistent file is chowned and preserved" "bad symlink to nonexistent file is chowned and preserved"
is "${lines[1]}" "1:2:'/a/b/c/goodsymlink' -> '/bin/mydefaultcmd'" \
run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/goodsymlink
is "$output" "1:2:'/a/b/c/goodsymlink' -> '/bin/mydefaultcmd'" \
"good symlink to existing file is chowned and preserved" "good symlink to existing file is chowned and preserved"
is "${lines[2]}" "2:3:/bin/mydefaultcmd" "target of symlink is not chowned"
run_podman run --rm build_test stat -c'%u:%g' /bin/mydefaultcmd is "${lines[3]}" "4:5:/a/b/c/myfile" "file in volume is chowned"
is "$output" "2:3" "target of symlink is not chowned"
run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/myfile
is "$output" "4:5:/a/b/c/myfile" "file in volume is chowned"
# Hey, as long as we have an image with lots of layers, let's # Hey, as long as we have an image with lots of layers, let's
# confirm that 'image tree' works as expected # confirm that 'image tree' works as expected

View File

@ -150,7 +150,9 @@ function remove_secret() {
cat > $quadlet_file <<EOF cat > $quadlet_file <<EOF
[Container] [Container]
Image=$IMAGE Image=$IMAGE
Exec=sh -c "echo STARTED CONTAINER; echo "READY=1" | socat -u STDIN unix-sendto:\$NOTIFY_SOCKET; sleep inf" # Note it is important that the trap is before the ready message,
# otherwise the signal handler may not registered in time before we do systemctl stop.
Exec=sh -c "echo STARTED CONTAINER; trap 'exit' SIGTERM; echo "READY=1" | socat -u STDIN unix-sendto:\$NOTIFY_SOCKET; while :; do sleep 0.1; done"
Notify=yes Notify=yes
LogDriver=passthrough LogDriver=passthrough
Network=none Network=none
@ -180,7 +182,7 @@ EOF
run_podman container inspect --format "{{.State.Status}}" $QUADLET_CONTAINER_NAME run_podman container inspect --format "{{.State.Status}}" $QUADLET_CONTAINER_NAME
is "$output" "running" "container should be started by systemd and hence be running" is "$output" "running" "container should be started by systemd and hence be running"
service_cleanup $QUADLET_SERVICE_NAME failed service_cleanup $QUADLET_SERVICE_NAME inactive
} }
@test "quadlet conflict names" { @test "quadlet conflict names" {
@ -1433,8 +1435,11 @@ EOF
cat > $quadlet_container_file <<EOF cat > $quadlet_container_file <<EOF
[Container] [Container]
Image=$IMAGE Image=$IMAGE
Exec=sh -c "echo STARTED CONTAINER; echo "READY=1" | socat -u STDIN unix-sendto:\$NOTIFY_SOCKET; sleep inf" # Note it is important that the trap is before the ready message,
# otherwise the signal handler may not registered in time before we do systemctl stop.
Exec=sh -c "echo STARTED CONTAINER; trap 'exit' SIGTERM; echo "READY=1" | socat -u STDIN unix-sendto:\$NOTIFY_SOCKET; while :; do sleep 0.1; done"
Pod=$quadlet_pod_unit Pod=$quadlet_pod_unit
Notify=yes
EOF EOF
# Use the same directory for all quadlet files to make sure later steps access previous ones # Use the same directory for all quadlet files to make sure later steps access previous ones
@ -1467,7 +1472,7 @@ EOF
# The service of the container should be active # The service of the container should be active
run systemctl show --property=ActiveState "$container_service" run systemctl show --property=ActiveState "$container_service"
assert "ActiveState=failed" \ assert "ActiveState=inactive" \
"quadlet - pod base: container service ActiveState" "quadlet - pod base: container service ActiveState"
# Container should not exist # Container should not exist

View File

@ -308,10 +308,10 @@ load helpers.network
$IMAGE /bin/busybox-extras httpd -f -p 80 $IMAGE /bin/busybox-extras httpd -f -p 80
cid=$output cid=$output
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}
ip1="$output" {{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" ip1="${lines[0]}"
mac1="$output" mac1="${lines[1]}"
# Verify http contents: curl from localhost # Verify http contents: curl from localhost
run curl -s -S $SERVER/index.txt run curl -s -S $SERVER/index.txt
@ -326,9 +326,9 @@ load helpers.network
fi fi
run iptables -t nat -F "$chain" run iptables -t nat -F "$chain"
# check that we cannot curl (timeout after 5 sec) # check that we cannot curl (timeout after 1 sec)
run timeout 5 curl -s $SERVER/index.txt run curl --max-time 1 -s $SERVER/index.txt
assert $status -eq 124 "curl did not time out" assert $status -eq 28 "curl did not time out"
fi fi
# reload the network to recreate the iptables rules # reload the network to recreate the iptables rules
@ -336,10 +336,10 @@ load helpers.network
is "$output" "$cid" "Output does match container ID" is "$output" "$cid" "Output does match container ID"
# check that we still have the same mac and ip # check that we still have the same mac and ip
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}
is "$output" "$ip1" "IP address changed after podman network reload" {{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" is "${lines[0]}" "$ip1" "IP address changed after podman network reload"
is "$output" "$mac1" "MAC address changed after podman network reload" is "${lines[1]}" "$mac1" "MAC address changed after podman network reload"
# check that we can still curl # check that we can still curl
run curl -s $SERVER/index.txt run curl -s $SERVER/index.txt
@ -353,13 +353,13 @@ load helpers.network
# connect the container to the second network # connect the container to the second network
run_podman network connect $netname2 $cid run_podman network connect $netname2 $cid
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").IPAddress}}" run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").IPAddress}}
ip2="$output" {{(index .NetworkSettings.Networks \"$netname2\").GlobalIPv6Address}}
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").GlobalIPv6Address}}" {{(index .NetworkSettings.Networks \"$netname2\").MacAddress}}"
is "$output" "fd.*:.*" "IPv6 address should start with fd..." ip2="${lines[0]}"
ipv6="$output" is "${lines[1]}" "fd.*:.*" "IPv6 address should start with fd..."
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").MacAddress}}" ipv6="${lines[1]}"
mac2="$output" mac2="${lines[2]}"
# make sure --all is working and that this # make sure --all is working and that this
# cmd also works if the iptables still exists # cmd also works if the iptables still exists
@ -367,16 +367,18 @@ load helpers.network
is "$output" "$cid" "Output does match container ID" is "$output" "$cid" "Output does match container ID"
# check that both network keep there ip and mac # check that both network keep there ip and mac
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}
is "$output" "$ip1" "IP address changed after podman network reload ($netname)" {{(index .NetworkSettings.Networks \"$netname\").MacAddress}}
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" {{(index .NetworkSettings.Networks \"$netname2\").IPAddress}}
is "$output" "$mac1" "MAC address changed after podman network reload ($netname)" {{(index .NetworkSettings.Networks \"$netname2\").GlobalIPv6Address}}
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").IPAddress}}" {{(index .NetworkSettings.Networks \"$netname2\").MacAddress}}
is "$output" "$ip2" "IP address changed after podman network reload ($netname2)" "
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").GlobalIPv6Address}}"
is "$output" "$ipv6" "IPv6 address changed after podman network reload ($netname2)" is "${lines[0]}" "$ip1" "IP address changed after podman network reload ($netname)"
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").MacAddress}}" is "${lines[1]}" "$mac1" "MAC address changed after podman network reload ($netname)"
is "$output" "$mac2" "MAC address changed after podman network reload ($netname2)" is "${lines[2]}" "$ip2" "IP address changed after podman network reload ($netname2)"
is "${lines[3]}" "$ipv6" "IPv6 address changed after podman network reload ($netname2)"
is "${lines[4]}" "$mac2" "MAC address changed after podman network reload ($netname2)"
# check that we can still curl # check that we can still curl
run curl -s -S $SERVER/index.txt run curl -s -S $SERVER/index.txt
@ -478,7 +480,7 @@ load helpers.network
run_podman network create $netname2 run_podman network create $netname2
is "$output" "$netname2" "output of 'network create'" is "$output" "$netname2" "output of 'network create'"
# First, run a container in background to ensure that the rootless cni ns # First, run a container in background to ensure that the rootless netns
# is not destroyed after network disconnect. # is not destroyed after network disconnect.
run_podman run -d --network $netname $IMAGE top run_podman run -d --network $netname $IMAGE top
background_cid=$output background_cid=$output
@ -498,14 +500,14 @@ load helpers.network
run curl --retry 2 --retry-connrefused -s $SERVER/index.txt run curl --retry 2 --retry-connrefused -s $SERVER/index.txt
is "$output" "$random_1" "curl $SERVER/index.txt" is "$output" "$random_1" "curl $SERVER/index.txt"
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}
ip="$output" {{(index .NetworkSettings.Networks \"$netname\").MacAddress}}
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" {{(index .NetworkSettings.Networks \"$netname\").Aliases}}"
mac="$output" ip="${lines[0]}"
mac="${lines[1]}"
# check network alias for container short id # check network alias for container short id
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").Aliases}}" is "${lines[2]}" "[${cid:0:12} $hostname]" "short container id and hostname in network aliases"
is "$output" "[${cid:0:12} $hostname]" "short container id and hostname in network aliases"
# check /etc/hosts for our entry # check /etc/hosts for our entry
run_podman exec $cid cat /etc/hosts run_podman exec $cid cat /etc/hosts
@ -533,13 +535,12 @@ load helpers.network
# check that we have a new ip and mac # check that we have a new ip and mac
# if the ip is still the same this whole test turns into a nop # if the ip is still the same this whole test turns into a nop
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}
new_ip="$output" {{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
new_ip="${lines[0]}"
assert "$new_ip" != "$ip" \ assert "$new_ip" != "$ip" \
"IP address did not change after podman network disconnect/connect" "IP address did not change after podman network disconnect/connect"
assert "${lines[1]}" != "$mac" \
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
assert "$output" != "$mac" \
"MAC address did not change after podman network disconnect/connect" "MAC address did not change after podman network disconnect/connect"
# check /etc/hosts for the new entry # check /etc/hosts for the new entry
@ -552,14 +553,6 @@ load helpers.network
run_podman network connect $netname $background_cid run_podman network connect $netname $background_cid
is "$output" "" "(re)connect of container with no open ports" is "$output" "" "(re)connect of container with no open ports"
# FIXME FIXME FIXME: #11825: bodhi tests are failing, remote+rootless only,
# with "dnsmasq: failed to create inotify". This error has never occurred
# in CI, and Ed has been unable to reproduce it on 1minutetip. This next
# line is a suggestion from Paul Holzinger for trying to shed light on
# the system context before the failure. This output will be invisible
# if the test passes.
for foo in /proc/\*/fd/*; do readlink -f $foo; done |grep '^/proc/.*inotify' |cut -d/ -f3 | xargs -I '{}' -- ps --no-headers -o '%p %U %a' -p '{}' |uniq -c |sort -n
# connect a second network # connect a second network
run_podman network connect $netname2 $cid run_podman network connect $netname2 $cid
is "$output" "" "Output should be empty (no errors)" is "$output" "" "Output should be empty (no errors)"