summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e/create_test.go14
-rw-r--r--test/e2e/inspect_test.go40
-rw-r--r--test/e2e/logs_test.go32
3 files changed, 70 insertions, 16 deletions
diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go
index 822e470f2..52ce0b46a 100644
--- a/test/e2e/create_test.go
+++ b/test/e2e/create_test.go
@@ -401,6 +401,20 @@ var _ = Describe("Podman create", func() {
Expect(session.ExitCode()).To(Not(Equal(0)))
})
+ It("podman create with --restart-policy unless-stopped", func() {
+ ctrName := "testctr"
+ unlessStopped := "unless-stopped"
+ session := podmanTest.Podman([]string{"create", "-t", "--restart", unlessStopped, "--name", ctrName, ALPINE, "/bin/sh"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"inspect", ctrName})
+ inspect.WaitWithDefaultTimeout()
+ data := inspect.InspectContainerToJSON()
+ Expect(len(data)).To(Equal(1))
+ Expect(data[0].HostConfig.RestartPolicy.Name).To(Equal(unlessStopped))
+ })
+
It("podman create with -m 1000000 sets swap to 2000000", func() {
numMem := 1000000
ctrName := "testCtr"
diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go
index 62f69f1c1..2fad38a36 100644
--- a/test/e2e/inspect_test.go
+++ b/test/e2e/inspect_test.go
@@ -223,4 +223,44 @@ var _ = Describe("Podman inspect", func() {
Expect(baseJSON[0].ID).To(Equal(ctrJSON[0].ID))
})
+
+ It("podman inspect always produces a valid array", func() {
+ baseInspect := podmanTest.Podman([]string{"inspect", "doesNotExist"})
+ baseInspect.WaitWithDefaultTimeout()
+ Expect(baseInspect.ExitCode()).To(Not(Equal(0)))
+ emptyJSON := baseInspect.InspectContainerToJSON()
+ Expect(len(emptyJSON)).To(Equal(0))
+ })
+
+ It("podman inspect one container with not exist returns 1-length valid array", func() {
+ ctrName := "testCtr"
+ create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "sh"})
+ create.WaitWithDefaultTimeout()
+ Expect(create.ExitCode()).To(Equal(0))
+
+ baseInspect := podmanTest.Podman([]string{"inspect", ctrName, "doesNotExist"})
+ baseInspect.WaitWithDefaultTimeout()
+ Expect(baseInspect.ExitCode()).To(Not(Equal(0)))
+ baseJSON := baseInspect.InspectContainerToJSON()
+ Expect(len(baseJSON)).To(Equal(1))
+ Expect(baseJSON[0].Name).To(Equal(ctrName))
+ })
+
+ It("podman inspect container + image with same name gives container", func() {
+ ctrName := "testcontainer"
+ create := podmanTest.PodmanNoCache([]string{"create", "--name", ctrName, ALPINE, "sh"})
+ create.WaitWithDefaultTimeout()
+ Expect(create.ExitCode()).To(Equal(0))
+
+ tag := podmanTest.PodmanNoCache([]string{"tag", ALPINE, ctrName + ":latest"})
+ tag.WaitWithDefaultTimeout()
+ Expect(tag.ExitCode()).To(Equal(0))
+
+ baseInspect := podmanTest.Podman([]string{"inspect", ctrName})
+ baseInspect.WaitWithDefaultTimeout()
+ Expect(baseInspect.ExitCode()).To(Equal(0))
+ baseJSON := baseInspect.InspectContainerToJSON()
+ Expect(len(baseJSON)).To(Equal(1))
+ Expect(baseJSON[0].Name).To(Equal(ctrName))
+ })
})
diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go
index f19147662..a4a59acb2 100644
--- a/test/e2e/logs_test.go
+++ b/test/e2e/logs_test.go
@@ -283,22 +283,22 @@ var _ = Describe("Podman logs", func() {
results.WaitWithDefaultTimeout()
Expect(results).To(Exit(0))
- // Verify that the cleanup process worked correctly and we can recreate a container with the same name
- logc = podmanTest.Podman([]string{"run", "--rm", "--name", containerName, "-dt", ALPINE, "true"})
- logc.WaitWithDefaultTimeout()
- Expect(logc).To(Exit(0))
- })
-
- It("follow output stopped container", func() {
- containerName := "logs-f"
-
- logc := podmanTest.Podman([]string{"run", "--name", containerName, "-d", ALPINE})
- logc.WaitWithDefaultTimeout()
- Expect(logc).To(Exit(0))
-
- results := podmanTest.Podman([]string{"logs", "-f", containerName})
- results.WaitWithDefaultTimeout()
- Expect(results).To(Exit(0))
+ // TODO: we should actually check for two podman lines,
+ // but as of 2020-06-17 there's a race condition in which
+ // 'logs -f' may not catch all output from a container
+ Expect(results.OutputToString()).To(ContainSubstring("podman"))
+
+ // Container should now be terminatING or terminatED, but we
+ // have no guarantee of which: 'logs -f' does not necessarily
+ // wait for cleanup. Run 'inspect' and accept either state.
+ inspect := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.State.Status}}", containerName})
+ inspect.WaitWithDefaultTimeout()
+ if inspect.ExitCode() == 0 {
+ Expect(inspect.OutputToString()).To(Equal("exited"))
+ // TODO: add 2-second wait loop to confirm cleanup
+ } else {
+ Expect(inspect.ErrorToString()).To(ContainSubstring("no such container"))
+ }
})
It("podman logs with log-driver=none errors", func() {