From 6b021dd4ba58bccce443044b985af879429f1784 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 31 May 2024 16:42:11 +0200 Subject: [PATCH 01/12] test/system: speed up user namespace preserved root ownership We don't have two loop twice for the stat call we can just stat both dirs at once. This means we only have to create half of the containers so the test is twice as fast. Signed-off-by: Paul Holzinger --- test/system/030-run.bats | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 5ff1fb29ba..9049a74fad 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -308,12 +308,10 @@ echo $rand | 0 | $rand for user in "--user=0" "--user=100"; do for keepid in "" ${keep}; do opts="$priv $user $keepid" - - for dir in /etc /usr;do - run_podman run --rm $opts $IMAGE stat -c '%u:%g:%n' $dir - remove_same_dev_warning # grumble - is "$output" "0:0:$dir" "run $opts ($dir)" - done + run_podman run --rm $opts $IMAGE stat -c '%u:%g:%n' $dir /etc /usr + remove_same_dev_warning # grumble + is "${lines[0]}" "0:0:/etc" "run $opts /etc" + is "${lines[1]}" "0:0:/usr" "run $opts /usr" done done done From c466377013fd5462ccf417c6155fcd3ea8e21818 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 31 May 2024 16:47:55 +0200 Subject: [PATCH 02/12] test/system: speed up quadlet - basic Another case of contianer does not exit with SIGTERM so we waste 10s. Now because our contianer reacts to sigterm and exits 0 the systemd unit status changed to inactive from failed. Signed-off-by: Paul Holzinger --- test/system/252-quadlet.bats | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/system/252-quadlet.bats b/test/system/252-quadlet.bats index bf1f7450e7..5365cbae8f 100644 --- a/test/system/252-quadlet.bats +++ b/test/system/252-quadlet.bats @@ -150,7 +150,9 @@ function remove_secret() { cat > $quadlet_file < Date: Fri, 31 May 2024 17:23:54 +0200 Subject: [PATCH 03/12] test/system: remove obsolete debug in net connect/disconnect test Issue #11825 was fixed a long time ago. Also we no longer test cni/dnsname so there is really no point in having this. Speeds up the test by 1 second. Signed-off-by: Paul Holzinger --- test/system/500-networking.bats | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index 6d260172d0..a8bec57139 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -552,14 +552,6 @@ load helpers.network run_podman network connect $netname $background_cid 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 run_podman network connect $netname2 $cid is "$output" "" "Output should be empty (no errors)" From 471e001c7f8cd375b09db39c1705c12fa36dff05 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 3 Jun 2024 14:17:34 +0200 Subject: [PATCH 04/12] test/system: speed up podman --log-level recognizes log levels Use podman version over podman info because info has to query a lot of internal state, e.g. contianer and image count, so it is slower than a simple info. This speeds the test up by about 600ms locally. Signed-off-by: Paul Holzinger --- test/system/001-basic.bats | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats index 7b4cc58b3e..7c10296290 100644 --- a/test/system/001-basic.bats +++ b/test/system/001-basic.bats @@ -195,10 +195,10 @@ See 'podman version --help'" "podman version --remote" } @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.*' - run_podman --log-level=trace info + run_podman --log-level=trace version if ! is_remote; then # podman-remote does not do any trace logging 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=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=debug " "log-level=debug" assert "$output" =~ " level=info " "log-level=debug includes info" 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=debug " "log-level=info does not show debug" 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" - run_podman --log-level=warning info + run_podman --log-level=warning version 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" # docker compat - run_podman --debug info + run_podman --debug version 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" - 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" } From 8d3f65b026ca643da4f8d5db87b0c1f5f5cd6207 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 3 Jun 2024 14:49:03 +0200 Subject: [PATCH 05/12] test/system: speed up podman build - workdir, cmd, env, label Overall just combine several container runs into one. Every RUN instruction will run a new container which is quite expensive so chain the commands together. The same for podman run's. I could have combined a bit more but I think this leaves it still readable. This speeds up the test about 4s locally from 8s before. Signed-off-by: Paul Holzinger --- test/system/070-build.bats | 56 ++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/test/system/070-build.bats b/test/system/070-build.bats index 6f77feb79e..73fc8f4ceb 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -360,11 +360,11 @@ LABEL $label_name=$label_value WORKDIR $workdir # Test for #7094 - chowning of invalid symlinks -RUN mkdir -p /a/b/c -RUN ln -s /no/such/nonesuch /a/b/c/badsymlink -RUN ln -s /bin/mydefaultcmd /a/b/c/goodsymlink -RUN 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 +RUN mkdir -p /a/b/c && \ + ln -s /no/such/nonesuch /a/b/c/badsymlink && \ + ln -s /bin/mydefaultcmd /a/b/c/goodsymlink && \ + touch /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 # 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 http_proxy http-proxy-in-image ENV ftp_proxy ftp-proxy-in-image + ADD mycmd /bin/mydefaultcmd -RUN chmod 755 /bin/mydefaultcmd -RUN chown 2:3 /bin/mydefaultcmd - -RUN $CAT_SECRET - -RUN echo explicit-build-arg=\$arg_explicit -RUN echo implicit-build-arg=\$arg_implicit +RUN chmod 755 /bin/mydefaultcmd && \ + chown 2:3 /bin/mydefaultcmd && \ + $CAT_SECRET && \ + echo explicit-build-arg=\$arg_explicit && \ + echo implicit-build-arg=\$arg_implicit && \ + cat /etc/resolv.conf CMD ["/bin/mydefaultcmd","$s_echo"] -RUN cat /etc/resolv.conf EOF # 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-file2 \ 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[1]}" "https-proxy-in-env-file" "env-file sets proxy var" @@ -469,8 +469,7 @@ EOF fi # test that workdir is set for command-line commands also - run_podman run --rm build_test pwd - is "$output" "$workdir" "pwd command in container" + is "${lines[3]}" "$workdir" "pwd command in container" # Determine buildah version, so we can confirm it gets into Labels # Multiple --format options confirm command-line override (last one wins) @@ -494,10 +493,8 @@ Cmd[0] | /bin/mydefaultcmd Cmd[1] | $s_echo WorkingDir | $workdir 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 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, # be they dangling or valid, would barf with # Error: chown /_data/symlink: ENOENT - run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/badsymlink - is "$output" "1:2:'/a/b/c/badsymlink' -> '/no/such/nonesuch'" \ + run_podman run --rm build_test \ + 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" - - 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'" \ + is "${lines[1]}" "1:2:'/a/b/c/goodsymlink' -> '/bin/mydefaultcmd'" \ "good symlink to existing file is chowned and preserved" - - run_podman run --rm build_test stat -c'%u:%g' /bin/mydefaultcmd - 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" + is "${lines[2]}" "2:3:/bin/mydefaultcmd" "target of symlink is not chowned" + is "${lines[3]}" "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 # confirm that 'image tree' works as expected From 8852614792f463f07833b91679611ffc7ff1ad21 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 3 Jun 2024 15:23:31 +0200 Subject: [PATCH 06/12] test/system: speed up podman cp dir from host to container It makes the test a bit uglier but I cannot see a good way to sped this up otherwise. I chnaged the created test to only start/stop the contianer once instead of every test case iteration. This makes it about 2s faster locally. Signed-off-by: Paul Holzinger --- test/system/065-cp.bats | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/system/065-cp.bats b/test/system/065-cp.bats index 0a2b155374..191cc885b5 100644 --- a/test/system/065-cp.bats +++ b/test/system/065-cp.bats @@ -360,20 +360,26 @@ load helpers while read src dest dest_fullname description; do run_podman cp $srcdir/$src destrunning:$dest 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") run_podman rm -t 0 -f destrunning # CREATED container + run_podman create --name destcreated --workdir=/srv $cpimage sleep infinity while read src dest dest_fullname description; do - run_podman create --name destcreated --workdir=/srv $cpimage sleep infinity run_podman cp $srcdir/$src destcreated:$dest - run_podman start destcreated - 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 + # tests checks are done below 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 125 cp $srcdir destnotdir:/etc/os-release is "$output" "Error: destination must be a directory when copying a directory" "cannot copy directory to file" From 7f3bb2d2389e77dd4ee6a0aaea31c0e491fc1ed1 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 3 Jun 2024 15:30:06 +0200 Subject: [PATCH 07/12] test/system: speed up podman parallel build should not race It is not clear at all why the count of 30 was choosen, this seems a lot and of course takes quite a while. The test takes over 16s in CI. To speed it up reduce the count to 10. I think this should still be good enough to ensure there are no races IMO. Signed-off-by: Paul Holzinger --- test/system/070-build.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/070-build.bats b/test/system/070-build.bats index 73fc8f4ceb..8926ac0fdd 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -246,7 +246,7 @@ FROM $IMAGE RUN echo hi EOF - local count=30 + local count=10 for i in $(seq --format '%02g' 1 $count); do timeout --foreground -v --kill=10 60 \ $PODMAN build -t i$i $PODMAN_TMPDIR &> $PODMAN_TMPDIR/log.$i & From 609146fb758abaa400bcd186cabd7562dab003c2 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 3 Jun 2024 15:36:31 +0200 Subject: [PATCH 08/12] test/system: speed up quadlet - pod simple Another case of contianer does not exit with SIGTERM so we waste 10s. Now because our contianer reacts to sigterm and exits 0 the systemd unit status changed to inactive from failed. And most importantly add Notify=yes because the socat call always failed as the default is to not leak the notify socket into the container. Signed-off-by: Paul Holzinger --- test/system/252-quadlet.bats | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/system/252-quadlet.bats b/test/system/252-quadlet.bats index 5365cbae8f..7821172169 100644 --- a/test/system/252-quadlet.bats +++ b/test/system/252-quadlet.bats @@ -1435,8 +1435,11 @@ EOF cat > $quadlet_container_file < Date: Mon, 3 Jun 2024 16:38:53 +0200 Subject: [PATCH 09/12] test/system: speed up podman network reload First, as root don't wait 5s for the timeout, 1s is enough. Also switch to use the curl --max-time option instead, that way we know we do not kill curl before it had the chance to do anything possibly. Second, combine podman inspect commands into one. This makes the test faster by over one second as we safe a bunch of podman commands. Signed-off-by: Paul Holzinger --- test/system/500-networking.bats | 58 +++++++++++++++++---------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index a8bec57139..79a396392b 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -308,10 +308,10 @@ load helpers.network $IMAGE /bin/busybox-extras httpd -f -p 80 cid=$output - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" - ip1="$output" - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" - mac1="$output" + run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}} +{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" + ip1="${lines[0]}" + mac1="${lines[1]}" # Verify http contents: curl from localhost run curl -s -S $SERVER/index.txt @@ -326,9 +326,9 @@ load helpers.network fi run iptables -t nat -F "$chain" - # check that we cannot curl (timeout after 5 sec) - run timeout 5 curl -s $SERVER/index.txt - assert $status -eq 124 "curl did not time out" + # check that we cannot curl (timeout after 1 sec) + run curl --max-time 1 -s $SERVER/index.txt + assert $status -eq 28 "curl did not time out" fi # reload the network to recreate the iptables rules @@ -336,10 +336,10 @@ load helpers.network is "$output" "$cid" "Output does match container ID" # check that we still have the same mac and ip - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" - is "$output" "$ip1" "IP address changed after podman network reload" - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" - is "$output" "$mac1" "MAC address changed after podman network reload" + run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}} +{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" + is "${lines[0]}" "$ip1" "IP address changed after podman network reload" + is "${lines[1]}" "$mac1" "MAC address changed after podman network reload" # check that we can still curl run curl -s $SERVER/index.txt @@ -353,13 +353,13 @@ load helpers.network # connect the container to the second network run_podman network connect $netname2 $cid - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").IPAddress}}" - ip2="$output" - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").GlobalIPv6Address}}" - is "$output" "fd.*:.*" "IPv6 address should start with fd..." - ipv6="$output" - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").MacAddress}}" - mac2="$output" + run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").IPAddress}} +{{(index .NetworkSettings.Networks \"$netname2\").GlobalIPv6Address}} +{{(index .NetworkSettings.Networks \"$netname2\").MacAddress}}" + ip2="${lines[0]}" + is "${lines[1]}" "fd.*:.*" "IPv6 address should start with fd..." + ipv6="${lines[1]}" + mac2="${lines[2]}" # make sure --all is working and that this # cmd also works if the iptables still exists @@ -367,16 +367,18 @@ load helpers.network is "$output" "$cid" "Output does match container ID" # check that both network keep there ip and mac - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" - is "$output" "$ip1" "IP address changed after podman network reload ($netname)" - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" - is "$output" "$mac1" "MAC address changed after podman network reload ($netname)" - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").IPAddress}}" - 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)" - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").MacAddress}}" - is "$output" "$mac2" "MAC address changed after podman network reload ($netname2)" + run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}} +{{(index .NetworkSettings.Networks \"$netname\").MacAddress}} +{{(index .NetworkSettings.Networks \"$netname2\").IPAddress}} +{{(index .NetworkSettings.Networks \"$netname2\").GlobalIPv6Address}} +{{(index .NetworkSettings.Networks \"$netname2\").MacAddress}} +" + + is "${lines[0]}" "$ip1" "IP address changed after podman network reload ($netname)" + is "${lines[1]}" "$mac1" "MAC address changed after podman network reload ($netname)" + 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 run curl -s -S $SERVER/index.txt From 8fa1ffbbec60e462073dd3aa6bf09cf910cdb3e2 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 3 Jun 2024 18:00:25 +0200 Subject: [PATCH 10/12] test/system: speed up podman network connect/disconnect Combine multiple inspect --format into one, it is not much but is makes it faster by a few 100 ms. Signed-off-by: Paul Holzinger --- test/system/500-networking.bats | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index 79a396392b..3d0697364f 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -480,7 +480,7 @@ load helpers.network run_podman network create $netname2 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. run_podman run -d --network $netname $IMAGE top background_cid=$output @@ -500,14 +500,14 @@ load helpers.network run curl --retry 2 --retry-connrefused -s $SERVER/index.txt is "$output" "$random_1" "curl $SERVER/index.txt" - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" - ip="$output" - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" - mac="$output" + run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}} +{{(index .NetworkSettings.Networks \"$netname\").MacAddress}} +{{(index .NetworkSettings.Networks \"$netname\").Aliases}}" + ip="${lines[0]}" + mac="${lines[1]}" # check network alias for container short id - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").Aliases}}" - is "$output" "[${cid:0:12} $hostname]" "short container id and hostname in network aliases" + is "${lines[2]}" "[${cid:0:12} $hostname]" "short container id and hostname in network aliases" # check /etc/hosts for our entry run_podman exec $cid cat /etc/hosts @@ -535,13 +535,12 @@ load helpers.network # check that we have a new ip and mac # if the ip is still the same this whole test turns into a nop - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" - new_ip="$output" + run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}} +{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" + new_ip="${lines[0]}" assert "$new_ip" != "$ip" \ "IP address did not change after podman network disconnect/connect" - - run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}" - assert "$output" != "$mac" \ + assert "${lines[1]}" != "$mac" \ "MAC address did not change after podman network disconnect/connect" # check /etc/hosts for the new entry From 350dfabf66636f376f174ca879e0857069d1d672 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 3 Jun 2024 19:05:36 +0200 Subject: [PATCH 11/12] test/system: speed up podman ps --external The buildah buil kill trick is bad as we have to sleep and wait to aboid flakes which takes time. Instead it is possible to redo this build part manually with buildah commands. It is not trival and harder to understand but it safes 2-3s so I think it is worth it. Signed-off-by: Paul Holzinger --- test/system/040-ps.bats | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/test/system/040-ps.bats b/test/system/040-ps.bats index 5259299ecc..3d829ffcf0 100644 --- a/test/system/040-ps.bats +++ b/test/system/040-ps.bats @@ -142,25 +142,38 @@ load helpers run_podman ps --external is "${#lines[@]}" "1" "setup check: no storage containers at start of test" - # Force a buildah timeout; this leaves a buildah container behind - local t0=$SECONDS - PODMAN_TIMEOUT=5 run_podman 124 build -t thiswillneverexist - < Date: Thu, 23 May 2024 05:37:23 -0600 Subject: [PATCH 12/12] run bats -T, to profile timing hogs Signed-off-by: Ed Santiago Signed-off-by: Paul Holzinger --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 82bd446270..7030cf90b4 100644 --- a/Makefile +++ b/Makefile @@ -665,7 +665,7 @@ localmachine: localsystem: # Wipe existing config, database, and cache: start with clean slate. $(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 remotesystem: @@ -690,7 +690,7 @@ remotesystem: echo "Error: ./bin/podman system service did not come up on $$SOCK_FILE" >&2;\ exit 1;\ 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=$$?;\ kill %1;\ rm -f $$SOCK_FILE;\