summaryrefslogtreecommitdiff
path: root/test/system/080-pause.bats
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-04 15:03:40 +0200
committerGitHub <noreply@github.com>2020-06-04 15:03:40 +0200
commit650ed437a8abac4d0a67b1b6e17239cb1eea2477 (patch)
tree88ecafe4ea602b787ff3eff7ed36211f68ca0719 /test/system/080-pause.bats
parentc133e55afc7d5c44a65c4021bf206b65073422a5 (diff)
parent2d5a2a7640d0f320d391a2fcc6a4bd0eb03b9f9f (diff)
downloadpodman-650ed437a8abac4d0a67b1b6e17239cb1eea2477.tar.gz
podman-650ed437a8abac4d0a67b1b6e17239cb1eea2477.tar.bz2
podman-650ed437a8abac4d0a67b1b6e17239cb1eea2477.zip
Merge pull request #6489 from edsantiago/bats
BATS and APIv2: more tests and tweaks
Diffstat (limited to 'test/system/080-pause.bats')
-rw-r--r--test/system/080-pause.bats58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/system/080-pause.bats b/test/system/080-pause.bats
new file mode 100644
index 000000000..4ec0906f4
--- /dev/null
+++ b/test/system/080-pause.bats
@@ -0,0 +1,58 @@
+#!/usr/bin/env bats -*- bats -*-
+#
+# tests for podman pause/unpause functionality
+#
+
+load helpers
+
+@test "podman pause/unpause" {
+ skip_if_rootless "pause does not work rootless"
+
+ cname=$(random_string 10)
+ run_podman run -d --name $cname $IMAGE \
+ sh -c 'while :;do date +%s;sleep 1;done'
+ cid="$output"
+ # Wait for first time value
+ wait_for_output '[0-9]\{10,\}' $cid
+
+ # Pause container, sleep a bit, unpause, sleep again to give process
+ # time to write a new post-restart time value. Pause by CID, unpause
+ # by name, just to exercise code paths. While paused, check 'ps'
+ # and 'inspect', then check again after restarting.
+ run_podman pause $cid
+ run_podman inspect --format '{{.State.Status}}' $cid
+ is "$output" "paused" "podman inspect .State.Status"
+ sleep 3
+ run_podman ps -a --format '{{.ID}} {{.Names}} {{.Status}}'
+ is "$output" "${cid:0:12} $cname paused" "podman ps on paused container"
+ run_podman unpause $cname
+ run_podman ps -a --format '{{.ID}} {{.Names}} {{.Status}}'
+ is "$output" "${cid:0:12} $cname Up .*" "podman ps on resumed container"
+ sleep 1
+
+ # Get full logs, and iterate through them computing delta_t between entries
+ run_podman logs $cid
+ i=1
+ max_delta=0
+ while [ $i -lt ${#lines[*]} ]; do
+ this_delta=$(( ${lines[$i]} - ${lines[$(($i - 1))]} ))
+ if [ $this_delta -gt $max_delta ]; then
+ max_delta=$this_delta
+ fi
+ i=$(( $i + 1 ))
+ done
+
+ # There should be a 3-4 second gap, *maybe* 5. Never 1 or 2, that
+ # would imply that the container never paused.
+ is "$max_delta" "[3456]" "delta t between paused and restarted"
+
+ run_podman rm -f $cname
+
+ # Pause/unpause on nonexistent name or id - these should all fail
+ run_podman 125 pause $cid
+ run_podman 125 pause $cname
+ run_podman 125 unpause $cid
+ run_podman 125 unpause $cname
+}
+
+# vim: filetype=sh