Skip to content

Commit

Permalink
Merge pull request #8325 from edsantiago/bats
Browse files Browse the repository at this point in the history
system tests: various
  • Loading branch information
openshift-merge-robot authored Nov 15, 2020
2 parents 4eb9c28 + a4c2471 commit 9fa09a8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
12 changes: 10 additions & 2 deletions test/system/010-images.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
load helpers

@test "podman images - basic output" {
run_podman images -a
headings="REPOSITORY *TAG *IMAGE ID *CREATED *SIZE"

is "${lines[0]}" "REPOSITORY *TAG *IMAGE ID *CREATED *SIZE" "header line"
run_podman images -a
is "${lines[0]}" "$headings" "header line"
is "${lines[1]}" "$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME *$PODMAN_TEST_IMAGE_TAG *[0-9a-f]\+" "podman images output"

# 'podman images' should emit headings even if there are no images
# (but --root only works locally)
if ! is_remote; then
run_podman --root ${PODMAN_TMPDIR}/nothing-here-move-along images
is "$output" "$headings" "'podman images' emits headings even w/o images"
fi
}

@test "podman images - custom formats" {
Expand Down
57 changes: 57 additions & 0 deletions test/system/070-build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,63 @@ EOF
run_podman rmi -f build_test
}

# #8092 - podman build should not gobble stdin (Fixes: #8066)
@test "podman build - does not gobble stdin that does not belong to it" {
random1=random1-$(random_string 12)
random2=random2-$(random_string 15)
random3=random3-$(random_string 12)

tmpdir=$PODMAN_TMPDIR/build-test
mkdir -p $tmpdir
cat >$tmpdir/Containerfile <<EOF
FROM $IMAGE
RUN echo x${random2}y
EOF

# This is a little rococo, bear with me please. #8092 fixed a bug
# in which 'podman build' would slurp up any input in the pipeline.
# Not a problem in a contrived example such as the one below, but
# definitely a problem when running commands in a pipeline to bash:
# all commands after 'podman build' would silently be ignored.
# In the test below, prior to #8092, the 'sed' would not get
# any input, and we would never see $random3 in the output.
# And, we use 'sed' to massage $random3 juuuuust on the remote
# chance that podman itself could pass stdin through.
results=$(echo $random3 | (
echo $random1
run_podman build -t build_test $tmpdir
sed -e 's/^/a/' -e 's/$/z/'
))

# First simple test: confirm that we see the piped-in string, as
# massaged by sed. This fails in 287edd4e2, the commit before #8092.
# We do this before the thorough test (below) because, should it
# fail, the diagnostic is much clearer and easier to understand.
is "$results" ".*a${random3}z" "stdin remains after podman-build"

# More thorough test: verify all the required strings in order.
# This is unlikely to fail, but it costs us nothing and could
# catch a regression somewhere else.
# FIXME: podman-remote output differs from local: #8342 (spurious ^M)
# FIXME: podman-remote output differs from local: #8343 (extra SHA output)
remote_extra=""
if is_remote; then remote_extra=".*";fi
expect="${random1}
.*
STEP 1: FROM $IMAGE
STEP 2: RUN echo x${random2}y
x${random2}y${remote_extra}
STEP 3: COMMIT build_test${remote_extra}
--> [0-9a-f]\{11\}
[0-9a-f]\{64\}
a${random3}z"

is "$results" "$expect" "Full output from 'podman build' pipeline"

run_podman rmi -f build_test
}


function teardown() {
# A timeout or other error in 'build' can leave behind stale images
# that podman can't even see and which will cascade into subsequent
Expand Down
3 changes: 2 additions & 1 deletion test/system/160-volumes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ EOF
myvol=myvol$(random_string)
rand=$(random_string)

run_podman run --rm -v $myvol:/myvol:z $IMAGE \
# Duplicate "-v" confirms #8307, fix for double-lock on same volume
run_podman run --rm -v $myvol:/myvol:z -v $myvol:/myvol2:z $IMAGE \
sh -c "echo $rand >/myvol/myfile"
run_podman volume ls -q
is "$output" "$myvol" "autocreated named container persists"
Expand Down

0 comments on commit 9fa09a8

Please sign in to comment.