diff options
Diffstat (limited to 'test/system')
-rw-r--r-- | test/system/001-basic.bats | 64 | ||||
-rw-r--r-- | test/system/030-run.bats | 2 | ||||
-rw-r--r-- | test/system/090-events.bats | 54 | ||||
-rw-r--r-- | test/system/200-pod.bats | 2 | ||||
-rw-r--r-- | test/system/250-systemd.bats | 12 | ||||
-rw-r--r-- | test/system/255-auto-update.bats | 3 | ||||
-rw-r--r-- | test/system/330-corrupt-images.bats | 2 | ||||
-rw-r--r-- | test/system/710-kube.bats | 2 |
8 files changed, 122 insertions, 19 deletions
diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats index e3302bec3..378edc013 100644 --- a/test/system/001-basic.bats +++ b/test/system/001-basic.bats @@ -188,17 +188,77 @@ See 'podman version --help'" "podman version --remote" @test "podman --log-level recognizes log levels" { run_podman 1 --log-level=telepathic info is "$output" 'Log Level "telepathic" is not supported.*' + run_podman --log-level=trace info + if ! is_remote; then + # podman-remote does not do any trace logging + assert "$output" =~ " level=trace " "log-level=trace" + fi + assert "$output" =~ " level=debug " "log-level=trace includes debug" + 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 + 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 + 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 + assert "$output" !~ " level=" "log-level=warn shows no logs at all" + + # Force a warning (local podman only; podman-remote doesn't check versions) + if ! is_remote; then + run_podman --log-level=warn --storage-opt=mount_program=/bin/false info + assert "$output" =~ " level=warning msg=\"Failed to retrieve " \ + "log-level=warn" + + # confirm that default level is "warn", by invoking without --log-level + run_podman --storage-opt=mount_program=/bin/false info + assert "$output" =~ " level=warning msg=\"Failed to retrieve " \ + "default log level includes warning messages" + fi + run_podman --log-level=warning info + assert "$output" !~ " level=" "log-level=warning shows no logs at all" + run_podman --log-level=error info - run_podman --log-level=fatal info - run_podman --log-level=panic info + assert "$output" !~ " level=" "log-level=error shows no logs at all" + + # error, fatal, panic: + if is_remote; then + # podman-remote does not grok --runtime; all we can do is test parsing + for level in error fatal panic; do + run_podman --log-level=$level info + assert "$output" !~ " level=" \ + "log-level=$level shows no logs at all" + done + else + # local podman only + run_podman --log-level=error --storage-opt=mount_program=/bin/false --runtime=/bin/false info + assert "$output" =~ " level=error msg=\"Getting info on OCI runtime " \ + "log-level=error shows " + assert "$output" !~ " level=warn" \ + "log-level=error does not show warnings" + + run_podman --log-level=fatal --storage-opt=mount_program=/bin/false --runtime=/bin/false info + assert "$output" !~ " level=" "log-level=fatal shows no logs at all" + + run_podman --log-level=panic --storage-opt=mount_program=/bin/false --runtime=/bin/false info + assert "$output" !~ " level=" "log-level=panic shows no logs at all" + fi + # docker compat run_podman --debug info + assert "$output" =~ " level=debug " "podman --debug gives debug output" run_podman -D info + assert "$output" =~ " level=debug " "podman -D gives debug output" + run_podman 1 --debug --log-level=panic info is "$output" "Setting --log-level and --debug is not allowed" } diff --git a/test/system/030-run.bats b/test/system/030-run.bats index a3bfe5780..b1ce91d14 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -423,7 +423,7 @@ json-file | f # Invalid log-driver argument run_podman 125 run --log-driver=InvalidDriver $IMAGE true - is "$output" "Error: error running container create option: invalid log driver: invalid argument" \ + is "$output" "Error: running container create option: invalid log driver: invalid argument" \ "--log-driver InvalidDriver" } diff --git a/test/system/090-events.bats b/test/system/090-events.bats index cd1bf327b..90b9b3b9c 100644 --- a/test/system/090-events.bats +++ b/test/system/090-events.bats @@ -22,24 +22,25 @@ load helpers # Now filter just by container name, no label run_podman events --filter type=container --filter container=$cname --filter event=start --stream=false - is "$output" "$expect" "filtering just by label" + is "$output" "$expect" "filtering just by container" } @test "truncate events" { cname=test-$(random_string 30 | tr A-Z a-z) - labelname=$(random_string 10) - labelvalue=$(random_string 15) run_podman run -d --name=$cname --rm $IMAGE echo hi id="$output" - expect="$id" run_podman events --filter container=$cname --filter event=start --stream=false is "$output" ".* $id " "filtering by container name full id" - truncID=$(expr substr "$id" 1 12) + truncID=${id:0:12} run_podman events --filter container=$cname --filter event=start --stream=false --no-trunc=false is "$output" ".* $truncID " "filtering by container name trunc id" + + # --no-trunc does not affect --format; we always get the full ID + run_podman events --filter container=$cname --filter event=died --stream=false --format='{{.ID}}--{{.Image}}' --no-trunc=false + assert "$output" = "${id}--${IMAGE}" } @test "image events" { @@ -65,6 +66,7 @@ load helpers run_podman --events-backend=file untag $IMAGE $tag run_podman --events-backend=file tag $IMAGE $tag run_podman --events-backend=file rmi -f $imageID + run_podman --events-backend=file load -i $tarball run_podman --events-backend=file events --stream=false --filter type=image --since $t0 is "$output" ".*image push $imageID dir:$pushedDir @@ -74,9 +76,29 @@ load helpers .*image tag $imageID $tag .*image untag $imageID $tag:latest .*image tag $imageID $tag +.*image untag $imageID $IMAGE .*image untag $imageID $tag:latest .*image remove $imageID $imageID" \ "podman events" + + # With --format we can check the _exact_ output, not just substrings + local -a expect=("push--dir:$pushedDir" + "save--$tarball" + "loadfromarchive--$tarball" + "pull--docker-archive:$tarball" + "tag--$tag" + "untag--$tag:latest" + "tag--$tag" + "untag--$IMAGE" + "untag--$tag:latest" + "remove--$imageID" + "loadfromarchive--$tarball" + ) + run_podman --events-backend=file events --stream=false --filter type=image --since $t0 --format '{{.Status}}--{{.Name}}' + for i in $(seq 0 ${#expect[@]}); do + assert "${lines[$i]}" = "${expect[$i]}" "events, line $i" + done + assert "${#lines[@]}" = "${#expect[@]}" "Total lines of output" } function _events_disjunctive_filters() { @@ -110,7 +132,8 @@ function _events_disjunctive_filters() { is "$output" "hi" "Should support events-backend=file" run_podman 125 --events-backend=file logs --follow test - is "$output" "Error: using --follow with the journald --log-driver but without the journald --events-backend (file) is not supported" "Should fail with reasonable error message when events-backend and events-logger do not match" + is "$output" "Error: using --follow with the journald --log-driver but without the journald --events-backend (file) is not supported" \ + "Should fail with reasonable error message when events-backend and events-logger do not match" } @@ -135,7 +158,7 @@ function _populate_events_file() { local events_file=$1 truncate --size=0 $events_file for i in {0..99}; do - printf '{"Name":"busybox","Status":"pull","Time":"2022-04-06T11:26:42.7236679%02d+02:00","Type":"image","Attributes":null}\n' $i >> $events_file + printf '{"Name":"busybox","Status":"pull","Time":"2022-04-06T11:26:42.7236679%02d+02:00","Type":"image","Attributes":null}\n' $i >> $events_file done } @@ -147,7 +170,6 @@ function _populate_events_file() { # Config without a limit eventsFile=$PODMAN_TMPDIR/events.txt - _populate_events_file $eventsFile containersConf=$PODMAN_TMPDIR/containers.conf cat >$containersConf <<EOF [engine] @@ -155,6 +177,11 @@ events_logger="file" events_logfile_path="$eventsFile" EOF + # Check that a non existing event file does not cause a hang (#15688) + CONTAINERS_CONF=$containersConf run_podman events --stream=false + + _populate_events_file $eventsFile + # Create events *without* a limit and make sure that it has not been # rotated/truncated. contentBefore=$(head -n100 $eventsFile) @@ -191,7 +218,7 @@ EOF # Make sure that `podman events` can read the file, and that it returns the # same amount of events. We checked the contents before. CONTAINERS_CONF=$containersConf run_podman events --stream=false --since="2022-03-06T11:26:42.723667984+02:00" - is "$(wc -l <$eventsFile)" "$(wc -l <<<$output)" "all events are returned" + assert "${#lines[@]}" = 51 "Number of events returned" is "${lines[-2]}" ".* log-rotation $eventsFile" } @@ -213,3 +240,12 @@ EOF --format="{{.Attributes.$lname}}" assert "$output" = "$lvalue" "podman-events output includes container label" } + +@test "events - backend none should error" { + skip_if_remote "remote does not support --events-backend" + + run_podman 125 --events-backend none events + is "$output" "Error: cannot read events with the \"none\" backend" "correct error message" + run_podman 125 --events-backend none events --stream=false + is "$output" "Error: cannot read events with the \"none\" backend" "correct error message" +} diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index e3a9ec4c3..9bbd56fef 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -435,7 +435,7 @@ EOF run_podman pod rm $podID run_podman 125 pod create --exit-policy invalid - is "$output" "Error: .*error running pod create option: invalid pod exit policy: \"invalid\"" "invalid exit policy" + is "$output" "Error: .*running pod create option: invalid pod exit policy: \"invalid\"" "invalid exit policy" # Test exit-policy behaviour run_podman pod create --exit-policy continue diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index 3f6296b36..ddec3a492 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -34,9 +34,8 @@ function teardown() { # Helper to start a systemd service running a container function service_setup() { run_podman generate systemd \ - -e http_proxy -e HTTP_PROXY \ - -e https_proxy -e HTTPS_PROXY \ - -e no_proxy -e NO_PROXY \ + -e http_proxy -e https_proxy -e no_proxy \ + -e HTTP_PROXY -e HTTPS_PROXY -e NO_PROXY \ --new $cname echo "$output" > "$UNIT_FILE" run_podman rm $cname @@ -82,6 +81,13 @@ function service_cleanup() { skip "FIXME: 2022-09-01: requires conmon-2.1.4, ubuntu has 2.1.3" fi + # Warn when a custom restart policy is used without --new (see #15284) + run_podman create --restart=always $IMAGE + cid="$output" + run_podman generate systemd $cid + is "$output" ".*Container $cid has restart policy .*always.* which can lead to issues on shutdown.*" "generate systemd emits warning" + run_podman rm -f $cid + cname=$(random_string) # See #7407 for --pull=always. run_podman create --pull=always --name $cname --label "io.containers.autoupdate=registry" $IMAGE \ diff --git a/test/system/255-auto-update.bats b/test/system/255-auto-update.bats index a106914fe..76f6b02e8 100644 --- a/test/system/255-auto-update.bats +++ b/test/system/255-auto-update.bats @@ -115,6 +115,7 @@ function _confirm_update() { # Image has already been pulled, so this shouldn't take too long local timeout=5 while [[ $timeout -gt 0 ]]; do + sleep 1 run_podman '?' inspect --format "{{.Image}}" $cname if [[ $status != 0 ]]; then if [[ $output =~ (no such object|does not exist in database): ]]; then @@ -126,7 +127,7 @@ function _confirm_update() { elif [[ $output != $old_iid ]]; then return fi - sleep 1 + timeout=$((timeout - 1)) done die "Timed out waiting for $cname to update; old IID=$old_iid" diff --git a/test/system/330-corrupt-images.bats b/test/system/330-corrupt-images.bats index 7f2b81835..2f0fd753c 100644 --- a/test/system/330-corrupt-images.bats +++ b/test/system/330-corrupt-images.bats @@ -74,7 +74,7 @@ function _corrupt_image_test() { # Corruptify, and confirm that 'podman images' throws an error rm -v ${PODMAN_CORRUPT_TEST_WORKDIR}/root/*-images/$id/${rm_path} run_podman 125 images - is "$output" "Error: error retrieving label for image \"$id\": you may need to remove the image to resolve the error.*" + is "$output" "Error: retrieving label for image \"$id\": you may need to remove the image to resolve the error.*" # Run the requested command. Confirm it succeeds, with suitable warnings run_podman $* diff --git a/test/system/710-kube.bats b/test/system/710-kube.bats index c446ff65f..97a640e3f 100644 --- a/test/system/710-kube.bats +++ b/test/system/710-kube.bats @@ -91,7 +91,7 @@ status | = | null # Needs at least one container. Error is slightly different between # regular and remote podman: # regular: Error: pod ... only has... - # remote: Error: error generating YAML: pod ... only has... + # remote: Error: generating YAML: pod ... only has... run_podman 125 kube generate $pname assert "$output" =~ "Error: .* only has an infra container" |