mirror of
https://github.com/containers/podman.git
synced 2025-11-29 01:28:22 +08:00
e2e: ExitCleanly(): low-hanging fruit, part 1
Continuing work on RUN-1907: huge set of files, but not as intimidating as it looks. Commit 1 of 2: mindless replace of Exit(0) with ExitCleanly() Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@@ -23,17 +23,17 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman start single container by id", func() {
|
||||
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
cid := session.OutputToString()
|
||||
session = podmanTest.Podman([]string{"start", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
})
|
||||
|
||||
It("podman start --rm removed on failure", func() {
|
||||
session := podmanTest.Podman([]string{"create", "--name=test", "--rm", ALPINE, "foo"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
session = podmanTest.Podman([]string{"start", "test"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(125))
|
||||
@@ -45,7 +45,7 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman start --rm --attach removed on failure", func() {
|
||||
session := podmanTest.Podman([]string{"create", "--rm", ALPINE, "foo"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
cid := session.OutputToString()
|
||||
session = podmanTest.Podman([]string{"start", "--attach", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
@@ -58,23 +58,23 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman container start single container by id", func() {
|
||||
session := podmanTest.Podman([]string{"container", "create", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
cid := session.OutputToString()
|
||||
session = podmanTest.Podman([]string{"container", "start", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToString()).To(Equal(cid))
|
||||
})
|
||||
|
||||
It("podman container start single container by short id", func() {
|
||||
session := podmanTest.Podman([]string{"container", "create", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
cid := session.OutputToString()
|
||||
shortID := cid[0:10]
|
||||
session = podmanTest.Podman([]string{"container", "start", shortID})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToString()).To(Equal(shortID))
|
||||
})
|
||||
|
||||
@@ -82,17 +82,17 @@ var _ = Describe("Podman start", func() {
|
||||
name := "foobar99"
|
||||
session := podmanTest.Podman([]string{"create", "--name", name, ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
session = podmanTest.Podman([]string{"start", name})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToString()).To(Equal(name))
|
||||
})
|
||||
|
||||
It("podman start single container with attach and test the signal", func() {
|
||||
session := podmanTest.Podman([]string{"create", "--entrypoint", "sh", ALPINE, "-c", "exit 1"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
cid := session.OutputToString()
|
||||
session = podmanTest.Podman([]string{"start", "--attach", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
@@ -109,7 +109,7 @@ var _ = Describe("Podman start", func() {
|
||||
cid2 := session2.OutputToString()
|
||||
session = podmanTest.Podman([]string{"start", cid1, cid2})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
})
|
||||
|
||||
It("podman start multiple containers with bogus", func() {
|
||||
@@ -124,10 +124,10 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman multiple containers -- attach should fail", func() {
|
||||
session := podmanTest.Podman([]string{"create", "--name", "foobar1", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
session = podmanTest.Podman([]string{"create", "--name", "foobar2", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
session = podmanTest.Podman([]string{"start", "-a", "foobar1", "foobar2"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(125))
|
||||
@@ -136,7 +136,7 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman failed to start with --rm should delete the container", func() {
|
||||
session := podmanTest.Podman([]string{"create", "--name", "test1", "--rm", ALPINE, "foo"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
start := podmanTest.Podman([]string{"start", "test1"})
|
||||
start.WaitWithDefaultTimeout()
|
||||
@@ -151,7 +151,7 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman failed to start without --rm should NOT delete the container", func() {
|
||||
session := podmanTest.Podman([]string{"create", ALPINE, "foo"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
start := podmanTest.Podman([]string{"start", session.OutputToString()})
|
||||
start.WaitWithDefaultTimeout()
|
||||
@@ -163,7 +163,7 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman start --sig-proxy should not work without --attach", func() {
|
||||
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
session = podmanTest.Podman([]string{"start", "-l", "--sig-proxy"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
@@ -175,12 +175,12 @@ var _ = Describe("Podman start", func() {
|
||||
pidfile := tempdir + "pidfile"
|
||||
session := podmanTest.Podman([]string{"create", "--pidfile", pidfile, ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
cid := session.OutputToString()
|
||||
|
||||
session = podmanTest.Podman([]string{"start", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
readFirstLine := func(path string) string {
|
||||
content, err := os.ReadFile(path)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -194,48 +194,48 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman start container --filter", func() {
|
||||
session1 := podmanTest.Podman([]string{"container", "create", ALPINE})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(0))
|
||||
Expect(session1).Should(ExitCleanly())
|
||||
cid1 := session1.OutputToString()
|
||||
|
||||
session1 = podmanTest.Podman([]string{"container", "create", ALPINE})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(0))
|
||||
Expect(session1).Should(ExitCleanly())
|
||||
cid2 := session1.OutputToString()
|
||||
|
||||
session1 = podmanTest.Podman([]string{"container", "create", ALPINE})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(0))
|
||||
Expect(session1).Should(ExitCleanly())
|
||||
cid3 := session1.OutputToString()
|
||||
shortCid3 := cid3[0:5]
|
||||
|
||||
session1 = podmanTest.Podman([]string{"container", "create", "--label", "test=with,comma", ALPINE})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(0))
|
||||
Expect(session1).Should(ExitCleanly())
|
||||
cid4 := session1.OutputToString()
|
||||
|
||||
session1 = podmanTest.Podman([]string{"start", cid1, "-f", "status=running"})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(0))
|
||||
Expect(session1).Should(ExitCleanly())
|
||||
Expect(session1.OutputToString()).To(BeEmpty())
|
||||
|
||||
session1 = podmanTest.Podman([]string{"start", "--all", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(0))
|
||||
Expect(session1).Should(ExitCleanly())
|
||||
Expect(session1.OutputToString()).To(BeEmpty())
|
||||
|
||||
session1 = podmanTest.Podman([]string{"start", "--all", "--filter", fmt.Sprintf("id=%s", shortCid3)})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(0))
|
||||
Expect(session1).Should(ExitCleanly())
|
||||
Expect(session1.OutputToString()).To(BeEquivalentTo(cid3))
|
||||
|
||||
session1 = podmanTest.Podman([]string{"start", "--all", "--filter", "label=test=with,comma"})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(0))
|
||||
Expect(session1).Should(ExitCleanly())
|
||||
Expect(session1.OutputToString()).To(BeEquivalentTo(cid4))
|
||||
|
||||
session1 = podmanTest.Podman([]string{"start", "-f", fmt.Sprintf("id=%s", cid2)})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(0))
|
||||
Expect(session1).Should(ExitCleanly())
|
||||
Expect(session1.OutputToString()).To(BeEquivalentTo(cid2))
|
||||
})
|
||||
|
||||
@@ -244,27 +244,27 @@ var _ = Describe("Podman start", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
session := podmanTest.Podman([]string{"create", "--userns", "keep-id", "--user", "bin:bin", "--volume", fmt.Sprintf("%s:%s:ro", home, home), ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
cid := session.OutputToString()
|
||||
|
||||
session = podmanTest.Podman([]string{"start", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
session = podmanTest.Podman([]string{"inspect", cid, "--format", "{{.Config.Env}}"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
env := session.OutputToString()
|
||||
Expect(env).To(ContainSubstring("HOME"))
|
||||
Expect(env).ToNot(ContainSubstring(fmt.Sprintf("HOME=%s", home)))
|
||||
|
||||
session = podmanTest.Podman([]string{"restart", "-t", "-1", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
session = podmanTest.Podman([]string{"inspect", cid, "--format", "{{.Config.Env}}"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
env = session.OutputToString()
|
||||
Expect(env).To(ContainSubstring("HOME"))
|
||||
Expect(env).ToNot(ContainSubstring(fmt.Sprintf("HOME=%s", home)))
|
||||
@@ -273,26 +273,26 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman start container sets HOME to home of execUser", func() {
|
||||
session := podmanTest.Podman([]string{"create", "--userns", "keep-id", "--user", "bin:bin", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
cid := session.OutputToString()
|
||||
|
||||
session = podmanTest.Podman([]string{"start", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
session = podmanTest.Podman([]string{"inspect", cid, "--format", "{{.Config.Env}}"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
env := session.OutputToString()
|
||||
Expect(env).To(ContainSubstring("HOME=/bin"))
|
||||
|
||||
session = podmanTest.Podman([]string{"restart", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
session = podmanTest.Podman([]string{"inspect", cid, "--format", "{{.Config.Env}}"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
env = session.OutputToString()
|
||||
Expect(env).To(ContainSubstring("HOME=/bin"))
|
||||
})
|
||||
@@ -300,26 +300,26 @@ var _ = Describe("Podman start", func() {
|
||||
It("podman start container retains the HOME env if present", func() {
|
||||
session := podmanTest.Podman([]string{"create", "--userns", "keep-id", "--user", "bin:bin", "--env=HOME=/env/is/respected", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
cid := session.OutputToString()
|
||||
|
||||
session = podmanTest.Podman([]string{"start", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
session = podmanTest.Podman([]string{"inspect", cid, "--format", "{{.Config.Env}}"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
env := session.OutputToString()
|
||||
Expect(env).To(ContainSubstring("HOME=/env/is/respected"))
|
||||
|
||||
session = podmanTest.Podman([]string{"restart", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
session = podmanTest.Podman([]string{"inspect", cid, "--format", "{{.Config.Env}}"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
env = session.OutputToString()
|
||||
Expect(env).To(ContainSubstring("HOME=/env/is/respected"))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user