diff options
author | umohnani8 <umohnani@redhat.com> | 2018-07-06 11:55:02 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-07-12 18:56:33 +0000 |
commit | 4f188aa191f1d28be19af64317bd8512f5c0cac0 (patch) | |
tree | ce729820a0ea0b22547ac9ef2dc62e99f15c7c3b /test/e2e/rmi_test.go | |
parent | a1f3d44497cbdc393063164b60a1875edf4e1548 (diff) | |
download | podman-4f188aa191f1d28be19af64317bd8512f5c0cac0.tar.gz podman-4f188aa191f1d28be19af64317bd8512f5c0cac0.tar.bz2 podman-4f188aa191f1d28be19af64317bd8512f5c0cac0.zip |
podman rmi should only untag image if parent of another
podman rmi was deleting an image even if it was a parent of
another image. This fix just untags the image instead.
This also fixes podman rmi to remove intermediate images of
an image when the image is removed.
Signed-off-by: umohnani8 <umohnani@redhat.com>
Closes: #1055
Approved by: mheon
Diffstat (limited to 'test/e2e/rmi_test.go')
-rw-r--r-- | test/e2e/rmi_test.go | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 399fcd0fc..2d096d7ba 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -103,4 +103,100 @@ var _ = Describe("Podman rmi", func() { resultForce.WaitWithDefaultTimeout() Expect(resultForce.ExitCode()).To(Equal(0)) }) + + It("podman rmi image that is a parent of another image", func() { + session := podmanTest.Podman([]string{"rmi", "-fa"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "--name", "c_test", ALPINE, "true"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"commit", "-q", "c_test", "test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"rm", "c_test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"rmi", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"images", "-q"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(1)) + + session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + untaggedImg := session.OutputToStringArray()[1] + + session = podmanTest.Podman([]string{"rmi", "-f", untaggedImg}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) + + It("podman rmi with cached images", func() { + session := podmanTest.Podman([]string{"rmi", "-fa"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + dockerfile := `FROM docker.io/library/alpine:latest + RUN mkdir hello + RUN touch test.txt + ENV foo=bar + ` + podmanTest.BuildImage(dockerfile, "test", "true") + + dockerfile = `FROM docker.io/library/alpine:latest + RUN mkdir hello + RUN touch test.txt + RUN mkdir blah + ENV foo=bar + ` + podmanTest.BuildImage(dockerfile, "test2", "true") + + session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + numOfImages := len(session.OutputToStringArray()) + + session = podmanTest.Podman([]string{"rmi", "test2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(numOfImages - len(session.OutputToStringArray())).To(Equal(2)) + + session = podmanTest.Podman([]string{"rmi", "test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(1)) + + podmanTest.BuildImage(dockerfile, "test3", "true") + + session = podmanTest.Podman([]string{"rmi", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"rmi", "test3"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToString())).To(Equal(0)) + }) }) |