From 1298f19773574963b9ce5ba7ca3b1637d1a07ef6 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 23 Dec 2019 05:43:08 -0700 Subject: more BATS tests - run: --name (includes 'podman container exists' tests) - run: --pull (always, never, missing) - build: new test for ADD URL (#4420) - exec: new test for issue #4785 (pipe getting lost) - diff: new test - selinux (mostly copied from docker-autotest) Plus a bug fix: the wait_for_output() helper would continue checking, eventually timing out, even if the container had already exited (probably because of an error). Fix: as part of the loop, run 'podman inspect' and bail out if container is not running. Include exit code and logs. Signed-off-by: Ed Santiago --- test/system/030-run.bats | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'test/system/030-run.bats') diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 7cbb60501..f1e9776c1 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -85,4 +85,55 @@ echo $rand | 0 | $rand run_podman 1 run --rm $IMAGE sh -c /bin/false } +@test "podman run --name" { + randomname=$(random_string 30) + + # Assume that 4 seconds gives us enough time for 3 quick tests (or at + # least for the 'ps'; the 'container exists' should pass even in the + # unlikely case that the container exits before we get to them) + run_podman run -d --name $randomname $IMAGE sleep 4 + cid=$output + + run_podman ps --format '{{.Names}}--{{.ID}}' + is "$output" "$randomname--${cid:0:12}" + + run_podman container exists $randomname + run_podman container exists $cid + + # Done with live-container tests; now let's test after container finishes + run_podman wait $cid + + # Container still exists even after stopping: + run_podman container exists $randomname + run_podman container exists $cid + + # ...but not after being removed: + run_podman rm $cid + run_podman 1 container exists $randomname + run_podman 1 container exists $cid +} + +@test "podman run --pull" { + skip_if_remote "podman-remote does not emit 'Trying to pull' msgs" + + run_podman run --pull=missing $IMAGE true + is "$output" "" "--pull=missing [present]: no output" + + run_podman run --pull=never $IMAGE true + is "$output" "" "--pull=never [present]: no output" + + # Now test with busybox, which we don't have present + run_podman 125 run --pull=never busybox true + is "$output" "Error: unable to find a name and tag match for busybox in repotags: no such image" "--pull=never [busybox/missing]: error" + + run_podman run --pull=missing busybox true + is "$output" "Trying to pull .*" "--pull=missing [busybox/missing]: fetches" + + run_podman run --pull=always busybox true + is "$output" "Trying to pull .*" "--pull=always [busybox/present]: fetches" + + run_podman rm -a + run_podman rmi busybox +} + # vim: filetype=sh -- cgit v1.2.3-54-g00ecf