summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/compose/test-compose31
-rw-r--r--test/system/037-runlabel.bats32
-rw-r--r--test/system/050-stop.bats1
3 files changed, 51 insertions, 13 deletions
diff --git a/test/compose/test-compose b/test/compose/test-compose
index abb957b43..c4c484190 100755
--- a/test/compose/test-compose
+++ b/test/compose/test-compose
@@ -136,8 +136,11 @@ function _show_ok() {
local expect=$3
local actual=$4
printf "${red}not ok $count $testname${reset}\n"
- printf "${red}# expected: %s${reset}\n" "$expect"
- printf "${red}# actual: ${bold}%s${reset}\n" "$actual"
+ # Not all errors include actual/expect
+ if [[ -n "$expect" || -n "$actual" ]]; then
+ printf "${red}# expected: %s${reset}\n" "$expect"
+ printf "${red}# actual: ${bold}%s${reset}\n" "$actual"
+ fi
echo "not ok $count $testname" >>$LOG
echo " expected: $expect" >>$LOG
@@ -164,20 +167,22 @@ function test_port() {
local expect="$3" # what to expect from curl output
# -s -S means "silent, but show errors"
- local actual=$(curl --retry 3 --retry-all-errors -s -S http://127.0.0.1:$port/)
+ local actual
+ actual=$(curl --retry 3 --retry-all-errors -s -S http://127.0.0.1:$port/)
local curl_rc=$?
- # FIXME 2021-04-13: test is flaking, curl succeeds but returns empty result.
- # Could it be that the container is not actually ready? Wait, and retry.
- if [[ $curl_rc -eq 0 && -z "$actual" ]]; then
- sleep 1
- echo "# Retrying curl:"
- actual=$(curl --retry 3 --retry-all-errors -s -S http://127.0.0.1:$port/)
- curl_rc=$?
- fi
-
if [ $curl_rc -ne 0 ]; then
- _show_ok 0 "$testname - curl failed with status $curl_rc"
+ _show_ok 0 "$testname - curl (port $port) failed with status $curl_rc"
+ # FIXME: is this useful? What else can we do to diagnose?
+ echo "# docker-compose logs:"
+ docker-compose logs
+ echo "# podman ps -a:"
+ $PODMAN_BIN --root $WORKDIR/root --runroot $WORKDIR/runroot ps -a
+ if type -p ss; then
+ echo "# ss -tulpn:"
+ ss -tulpn
+ fi
+ return
fi
case "$op" in
diff --git a/test/system/037-runlabel.bats b/test/system/037-runlabel.bats
new file mode 100644
index 000000000..8e18f40d3
--- /dev/null
+++ b/test/system/037-runlabel.bats
@@ -0,0 +1,32 @@
+#!/usr/bin/env bats
+
+load helpers
+
+@test "podman container runlabel test" {
+ skip_if_remote "container runlabel is not supported for remote"
+ tmpdir=$PODMAN_TMPDIR/runlabel-test
+ mkdir -p $tmpdir
+ containerfile=$tmpdir/Containerfile
+ rand1=$(random_string 30)
+ rand2=$(random_string 30)
+ rand3=$(random_string 30)
+ cat >$containerfile <<EOF
+FROM $IMAGE
+LABEL INSTALL /usr/bin/podman run -t -i --rm \\\${OPT1} --privileged -v /:/host --net=host --ipc=host --pid=host -e HOST=/host -e NAME=\\\${NAME} -e IMAGE=\\\${IMAGE} -e CONFDIR=/etc/\\\${NAME} -e LOGDIR=/var/log/\\\${NAME} -e DATADIR=/var/lib/\\\${NAME} \\\${IMAGE} \\\${OPT2} /bin/install.sh \\\${OPT3}
+EOF
+
+ run_podman build -t runlabel_image $tmpdir
+
+ run_podman container runlabel --opt1=${rand1} --opt2=${rand2} --opt3=${rand3} --name test1 --display install runlabel_image
+ is "$output" "command: ${PODMAN} run -t -i --rm ${rand1} --privileged -v /:/host --net=host --ipc=host --pid=host -e HOST=/host -e NAME=test1 -e IMAGE=localhost/runlabel_image:latest -e CONFDIR=/etc/test1 -e LOGDIR=/var/log/test1 -e DATADIR=/var/lib/test1 localhost/runlabel_image:latest ${rand2} /bin/install.sh ${rand3}" "generating runlabel install command"
+
+ run_podman container runlabel --opt3=${rand3} --display install runlabel_image
+ is "$output" "command: ${PODMAN} run -t -i --rm --privileged -v /:/host --net=host --ipc=host --pid=host -e HOST=/host -e NAME=runlabel_image -e IMAGE=localhost/runlabel_image:latest -e CONFDIR=/etc/runlabel_image -e LOGDIR=/var/log/runlabel_image -e DATADIR=/var/lib/runlabel_image localhost/runlabel_image:latest /bin/install.sh ${rand3}" "generating runlabel without name and --opt1, --opt2"
+
+ run_podman 125 container runlabel --opt1=${rand1} --opt2=${rand2} --opt3=${rand3} --name test1 --display run runlabel_image
+ is "$output" "Error: cannot find the value of label: run in image: runlabel_image" "generating runlabel run command"
+
+ run_podman rmi -f runlabel_image
+}
+
+# vim: filetype=sh
diff --git a/test/system/050-stop.bats b/test/system/050-stop.bats
index 0652a97e4..a9495e350 100644
--- a/test/system/050-stop.bats
+++ b/test/system/050-stop.bats
@@ -132,6 +132,7 @@ load helpers
is "$output" "stopping" "Status of container should be 'stopping'"
run_podman kill stopme
+ run_podman wait stopme
# Exit code should be 137 as it was killed
run_podman inspect --format '{{.State.ExitCode}}' stopme