Skip to content

Commit 963d19c

Browse files
committed
System test cleanup
- cp test: clean up stray image - build test: add workaround for containers#9567 (ultra-slow ubuntu). We're seeing CI flakes (timeouts) due to ubuntu 2004 being absurdly slow. Workaround: double our timeout on one specific test when ubuntu + remote. - build test: clean up new copy-from test (from containers#9275). The test was copy-pasted from buildah system tests, without really adapting for podman environment (e.g. it was using images that we don't use here, and would cause pulls, which will cause flakes). Rewrite test so it references only $IMAGE, remove some confusing/unnecessary stuff, selectively run parts of it even when rootless or remote, and add a test to confirm that copy-from succeeded. - load test: add error-message test to new load-invalid (containers#9672). Basically, make sure the command fails for the right reason. - play test (kube): use $IMAGE, not alpine; and add pause-image cleanup to teardown() - apiv2 mounts test: add a maintainability comment in a tricky section of code; and tighten up the mount point test. Signed-off-by: Ed Santiago <[email protected]>
1 parent e7dc592 commit 963d19c

File tree

5 files changed

+78
-20
lines changed

5 files changed

+78
-20
lines changed

test/apiv2/44-mounts.at

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ podman pull $IMAGE &>/dev/null
66
tmpfs_name="/mytmpfs"
77
t POST containers/create?name=hostconfig_test \
88
Image=$IMAGE \
9-
Cmd='["df"]' \
9+
Cmd='["df","-P","'$tmpfs_name'"]' \
1010
HostConfig='{"Binds":["/tmp/doesnotexist:/test1"]' \
1111
TmpFs="{\"$tmpfs_name\":\"rw\"}}" \
1212
201 \
@@ -22,5 +22,10 @@ t POST containers/${cid}/start 204
2222
t POST containers/${cid}/wait 200
2323
t GET containers/${cid}/logs?stdout=true 200
2424

25-
like "$(<$WORKDIR/curl.result.out)" ".* ${tmpfs_name}" \
25+
# /logs returns application/octet-stream, which our test helper saves in
26+
# an outfile rather than returning in $output. That's why we can't test
27+
# this directly in the /logs test above; instead, we rely on knowing the
28+
# path to the stored results. The 'tr' is needed because there may be
29+
# null bytes in the outfile.
30+
like "$(tr -d \\0 <$WORKDIR/curl.result.out)" ".* ${tmpfs_name}" \
2631
"'df' output includes tmpfs name"

test/system/065-cp.bats

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ load helpers
370370
is "${lines[0]}" "${randomcontent[0]}" "eval symlink - created container"
371371
is "${lines[1]}" "${randomcontent[1]}" "eval symlink - created container"
372372
run_podman rm -f cpcontainer
373+
run_podman rmi $cpimage
373374
}
374375

375376

test/system/070-build.bats

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,21 @@ EOF
241241
build_arg_implicit+="=$arg_implicit_value"
242242
fi
243243

244+
# FIXME FIXME FIXME: 2021-03-15: workaround for #9567 (slow ubuntu 2004):
245+
# we're seeing lots of timeouts in CI. Until/unless #9567 gets fixed,
246+
# let's get CI passing by extending the timeout when remote on ubuntu
247+
local localtimeout=${PODMAN_TIMEOUT}
248+
if is_remote; then
249+
if grep -qi ubuntu /etc/os-release; then
250+
localtimeout=$(( 2 * $localtimeout ))
251+
fi
252+
fi
253+
244254
# cd to the dir, so we test relative paths (important for podman-remote)
245255
cd $PODMAN_TMPDIR
246256
export arg_explicit="THIS SHOULD BE OVERRIDDEN BY COMMAND LINE!"
247257
export arg_implicit=${arg_implicit_value}
248-
run_podman ${MOUNTS_CONF} build \
258+
PODMAN_TIMEOUT=$localtimeout run_podman ${MOUNTS_CONF} build \
249259
--build-arg arg_explicit=${arg_explicit_value} \
250260
$build_arg_implicit \
251261
--dns-search $nosuchdomain \
@@ -594,43 +604,68 @@ EOF
594604
run_podman rmi -a --force
595605
}
596606

607+
# Caveat lector: this test was mostly copy-pasted from buildah in #9275.
608+
# It's not entirely clear what it's testing, or if the 'mount' section is
609+
# necessary.
597610
@test "build with copy-from referencing the base image" {
598-
skip_if_rootless "cannot mount as rootless"
599-
target=busybox-derived
600-
target_mt=busybox-mt-derived
611+
target=derived
612+
target_mt=derived-mt
601613
tmpdir=$PODMAN_TMPDIR/build-test
602614
mkdir -p $tmpdir
615+
603616
containerfile1=$tmpdir/Containerfile1
604-
cat >$containerfile1 <<EOF
605-
FROM quay.io/libpod/busybox AS build
606-
RUN rm -f /bin/paste
617+
cat >$containerfile1 <<EOF
618+
FROM $IMAGE AS build
619+
RUN rm -f /etc/issue
607620
USER 1001
608-
COPY --from=quay.io/libpod/busybox /bin/paste /test/
621+
COPY --from=$IMAGE /etc/issue /test/
609622
EOF
623+
610624
containerfile2=$tmpdir/Containerfile2
611-
cat >$containerfile2 <<EOF
612-
FROM quay.io/libpod/busybox AS test
613-
RUN rm -f /bin/nl
625+
cat >$containerfile2 <<EOF
626+
FROM $IMAGE AS test
627+
RUN rm -f /etc/alpine-release
614628
FROM quay.io/libpod/alpine AS final
615-
COPY --from=quay.io/libpod/busybox /bin/nl /test/
629+
COPY --from=$IMAGE /etc/alpine-release /test/
616630
EOF
617-
run_podman build -t ${target} -f ${containerfile1} ${tmpdir}
618-
run_podman build --jobs 4 -t ${target} -f ${containerfile1} ${tmpdir}
619631

620-
run_podman build -t ${target} -f ${containerfile2} ${tmpdir}
632+
# Before the build, $IMAGE's base image should not be present
633+
local base_image=quay.io/libpod/alpine:latest
634+
run_podman 1 image exists $base_image
635+
636+
run_podman build --jobs 1 -t ${target} -f ${containerfile2} ${tmpdir}
621637
run_podman build --no-cache --jobs 4 -t ${target_mt} -f ${containerfile2} ${tmpdir}
622638

639+
# After the build, the base image should exist
640+
run_podman image exists $base_image
641+
623642
# (can only test locally; podman-remote has no image mount command)
624-
if ! is_remote; then
643+
# (can also only test as root; mounting under rootless podman is too hard)
644+
# We perform the test as a conditional, not a 'skip', because there's
645+
# value in testing the above 'build' commands even remote & rootless.
646+
if ! is_remote && ! is_rootless; then
625647
run_podman image mount ${target}
626648
root_single_job=$output
627649

628650
run_podman image mount ${target_mt}
629651
root_multi_job=$output
630652

631653
# Check that both the version with --jobs 1 and --jobs=N have the same number of files
632-
test $(find $root_single_job -type f | wc -l) = $(find $root_multi_job -type f | wc -l)
654+
nfiles_single=$(find $root_single_job -type f | wc -l)
655+
nfiles_multi=$(find $root_multi_job -type f | wc -l)
656+
run_podman image umount ${target_mt}
657+
run_podman image umount ${target}
658+
659+
is "$nfiles_single" "$nfiles_multi" \
660+
"Number of files (--jobs=1) == (--jobs=4)"
661+
662+
# Make sure the number is reasonable
663+
test "$nfiles_single" -gt 50
633664
fi
665+
666+
# Clean up
667+
run_podman rmi ${target_mt} ${target} ${base_image}
668+
run_podman image prune -f
634669
}
635670

636671
@test "podman build --logfile test" {

test/system/120-load.bats

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ verify_iid_and_name() {
3131
invalid=$PODMAN_TMPDIR/invalid
3232
echo "I am an invalid file and should cause a podman-load error" > $invalid
3333
run_podman 125 load -i $invalid
34+
# podman and podman-remote emit different messages; this is a common string
35+
is "$output" ".*error pulling image: unable to pull .*" \
36+
"load -i INVALID fails with expected diagnostic"
3437
}
3538

3639
@test "podman save to pipe and load" {

test/system/700-play.bats

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55

66
load helpers
77

8+
# This is a long ugly way to clean up pods and remove the pause image
9+
function teardown() {
10+
run_podman pod rm -f -a
11+
run_podman rm -f -a
12+
run_podman image list --format '{{.ID}} {{.Repository}}'
13+
while read id name; do
14+
if [[ "$name" =~ /pause ]]; then
15+
run_podman rmi $id
16+
fi
17+
done <<<"$output"
18+
19+
basic_teardown
20+
}
21+
822
testYaml="
923
apiVersion: v1
1024
kind: Pod
@@ -24,7 +38,7 @@ spec:
2438
value: xterm
2539
- name: container
2640
value: podman
27-
image: quay.io/libpod/alpine:latest
41+
image: $IMAGE
2842
name: test
2943
resources: {}
3044
securityContext:

0 commit comments

Comments
 (0)