diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-05-03 23:14:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 23:14:12 +0200 |
commit | 4aa90145bf611a7bc08ddff7e061a630154e8b40 (patch) | |
tree | 01dc345c05b6ef2c5416eb169f0388c3afb4feb1 /test/e2e | |
parent | 2658e870d21dc03096740f17fa869463136d3fae (diff) | |
parent | d3286952e6f99b3c1f8ba177d8caddc9544adea4 (diff) | |
download | podman-4aa90145bf611a7bc08ddff7e061a630154e8b40.tar.gz podman-4aa90145bf611a7bc08ddff7e061a630154e8b40.tar.bz2 podman-4aa90145bf611a7bc08ddff7e061a630154e8b40.zip |
Merge pull request #2826 from mheon/restart_policy
Add restart policy for containers
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/run_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index fe95db016..030722b47 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "strings" + "time" . "github.com/containers/libpod/test/utils" "github.com/mrunalp/fileutils" @@ -720,4 +721,48 @@ USER mail` Expect(session.ExitCode()).To(Equal(1)) os.Unsetenv("http_proxy") }) + + It("podman run with restart-policy always restarts containers", func() { + podmanTest.RestoreArtifact(fedoraMinimal) + + testDir := filepath.Join(podmanTest.RunRoot, "restart-test") + err := os.Mkdir(testDir, 0755) + Expect(err).To(BeNil()) + + aliveFile := filepath.Join(testDir, "running") + file, err := os.Create(aliveFile) + Expect(err).To(BeNil()) + file.Close() + + session := podmanTest.Podman([]string{"run", "-dt", "--restart", "always", "-v", fmt.Sprintf("%s:/tmp/runroot:Z", testDir), fedoraMinimal, "bash", "-c", "date +%N > /tmp/runroot/ran && while test -r /tmp/runroot/running; do sleep 0.1s; done"}) + + found := false + testFile := filepath.Join(testDir, "ran") + for i := 0; i < 10; i++ { + time.Sleep(1 * time.Second) + if _, err := os.Stat(testFile); err == nil { + found = true + err = os.Remove(testFile) + Expect(err).To(BeNil()) + break + } + } + Expect(found).To(BeTrue()) + + err = os.Remove(aliveFile) + Expect(err).To(BeNil()) + + session.WaitWithDefaultTimeout() + + // 10 seconds to restart the container + found = false + for i := 0; i < 10; i++ { + time.Sleep(1 * time.Second) + if _, err := os.Stat(testFile); err == nil { + found = true + break + } + } + Expect(found).To(BeTrue()) + }) }) |