aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-04-27 16:47:32 -0400
committerGitHub <noreply@github.com>2021-04-27 16:47:32 -0400
commitf613a2a8d5778cf088f4d18b69c86b082264a882 (patch)
treebf07f589419a0d25d23125eaeb27f04103b49ca1 /test
parentdbc13f3dac4fa4095ae5db86085e5711a701eb7b (diff)
parent3538815c5b2b4c97304e3ea940cee414b0004d2f (diff)
downloadpodman-f613a2a8d5778cf088f4d18b69c86b082264a882.tar.gz
podman-f613a2a8d5778cf088f4d18b69c86b082264a882.tar.bz2
podman-f613a2a8d5778cf088f4d18b69c86b082264a882.zip
Merge pull request #10119 from rhatdan/timeout
Add podman run --timeout option
Diffstat (limited to 'test')
-rw-r--r--test/e2e/generate_systemd_test.go2
-rw-r--r--test/system/030-run.bats23
2 files changed, 24 insertions, 1 deletions
diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go
index 3a1da5d8c..75d778f10 100644
--- a/test/e2e/generate_systemd_test.go
+++ b/test/e2e/generate_systemd_test.go
@@ -242,7 +242,7 @@ var _ = Describe("Podman generate systemd", func() {
n.WaitWithDefaultTimeout()
Expect(n.ExitCode()).To(Equal(0))
- session := podmanTest.Podman([]string{"generate", "systemd", "--timeout", "42", "--name", "--new", "foo"})
+ session := podmanTest.Podman([]string{"generate", "systemd", "--time", "42", "--name", "--new", "foo"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
diff --git a/test/system/030-run.bats b/test/system/030-run.bats
index b2999a9e7..c007a1557 100644
--- a/test/system/030-run.bats
+++ b/test/system/030-run.bats
@@ -668,4 +668,27 @@ json-file | f
is "$output" ".*HOME=/.*"
}
+@test "podman run --timeout - basic test" {
+ cid=timeouttest
+ t0=$SECONDS
+ run_podman 255 run --name $cid --timeout 10 $IMAGE sleep 60
+ t1=$SECONDS
+ # Confirm that container is stopped. Podman-remote unfortunately
+ # cannot tell the difference between "stopped" and "exited", and
+ # spits them out interchangeably, so we need to recognize either.
+ run_podman inspect --format '{{.State.Status}} {{.State.ExitCode}}' $cid
+ is "$output" "\\(stopped\|exited\\) \-1" \
+ "Status and exit code of stopped container"
+
+ # This operation should take
+ # exactly 10 seconds. Give it some leeway.
+ delta_t=$(( $t1 - $t0 ))
+ [ $delta_t -gt 8 ] ||\
+ die "podman stop: ran too quickly! ($delta_t seconds; expected >= 10)"
+ [ $delta_t -le 14 ] ||\
+ die "podman stop: took too long ($delta_t seconds; expected ~10)"
+
+ run_podman rm $cid
+}
+
# vim: filetype=sh