summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/prune_test.go158
-rw-r--r--test/e2e/volume_prune_test.go1
2 files changed, 156 insertions, 3 deletions
diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go
index 466a4f739..a09b6f37a 100644
--- a/test/e2e/prune_test.go
+++ b/test/e2e/prune_test.go
@@ -148,7 +148,6 @@ var _ = Describe("Podman prune", func() {
It("podman system image prune unused images", func() {
SkipIfRemote()
- Skip(v2fail)
podmanTest.RestoreAllArtifacts()
podmanTest.BuildImage(pruneImage, "alpine_bash:latest", "true")
prune := podmanTest.PodmanNoCache([]string{"system", "prune", "-a", "--force"})
@@ -162,7 +161,6 @@ var _ = Describe("Podman prune", func() {
})
It("podman system prune pods", func() {
- Skip(v2fail)
session := podmanTest.Podman([]string{"pod", "create"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@@ -193,4 +191,160 @@ var _ = Describe("Podman prune", func() {
Expect(pods.ExitCode()).To(Equal(0))
Expect(len(pods.OutputToStringArray())).To(Equal(2))
})
+
+ It("podman system prune - pod,container stopped", func() {
+ session := podmanTest.Podman([]string{"pod", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Start and stop a pod to get it in exited state.
+ session = podmanTest.Podman([]string{"pod", "start", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"pod", "stop", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Create a container. This container should be pruned.
+ create := podmanTest.Podman([]string{"create", "--name", "test", BB})
+ create.WaitWithDefaultTimeout()
+ Expect(create.ExitCode()).To(Equal(0))
+
+ prune := podmanTest.Podman([]string{"system", "prune", "-f"})
+ prune.WaitWithDefaultTimeout()
+ Expect(prune.ExitCode()).To(Equal(0))
+
+ pods := podmanTest.Podman([]string{"pod", "ps"})
+ pods.WaitWithDefaultTimeout()
+ Expect(pods.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfPods()).To(Equal(0))
+
+ Expect(podmanTest.NumberOfContainers()).To(Equal(0))
+ })
+
+ It("podman system prune with running, exited pod and volume prune set true", func() {
+
+ // Start and stop a pod to get it in exited state.
+ session := podmanTest.Podman([]string{"pod", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"pod", "start", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"pod", "stop", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Start a pod and leave it running
+ session = podmanTest.Podman([]string{"pod", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"pod", "start", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Number of pod should be 2. One exited one running.
+ Expect(podmanTest.NumberOfPods()).To(Equal(2))
+
+ // Create a container. This container should be pruned.
+ _, ec, _ := podmanTest.RunLsContainer("test1")
+ Expect(ec).To(Equal(0))
+
+ // Number of containers should be three now.
+ // Two as pods infra container and one newly created.
+ Expect(podmanTest.NumberOfContainers()).To(Equal(3))
+
+ // image list current count should not be pruned if all flag isnt enabled
+ session = podmanTest.Podman([]string{"images"})
+ session.WaitWithDefaultTimeout()
+ numberOfImages := len(session.OutputToStringArray())
+
+ // Adding unused volume should be pruned
+ session = podmanTest.Podman([]string{"volume", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"create", "-v", "myvol:/myvol", ALPINE, "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(3))
+
+ session = podmanTest.Podman([]string{"system", "prune", "--force", "--volumes"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Volumes should be pruned.
+ session = podmanTest.Podman([]string{"volume", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(0))
+
+ // One Pod should not be pruned as it was running
+ Expect(podmanTest.NumberOfPods()).To(Equal(1))
+
+ // Running pods infra container should not be pruned.
+ Expect(podmanTest.NumberOfContainers()).To(Equal(1))
+
+ // Image should not be pruned and number should be same.
+ images := podmanTest.Podman([]string{"images"})
+ images.WaitWithDefaultTimeout()
+ Expect(len(images.OutputToStringArray())).To(Equal(numberOfImages))
+ })
+
+ It("podman system prune - with dangling images true", func() {
+ session := podmanTest.Podman([]string{"pod", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Start and stop a pod to get it in exited state.
+ session = podmanTest.Podman([]string{"pod", "start", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"pod", "stop", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Create a container. This container should be pruned.
+ create := podmanTest.Podman([]string{"create", "--name", "test", BB})
+ create.WaitWithDefaultTimeout()
+ Expect(create.ExitCode()).To(Equal(0))
+
+ // Adding images should be pruned
+ podmanTest.BuildImage(pruneImage, "alpine_bash:latest", "true")
+
+ // Adding unused volume should not be pruned as volumes not set
+ session = podmanTest.Podman([]string{"volume", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ prune := podmanTest.Podman([]string{"system", "prune", "-f", "-a"})
+ prune.WaitWithDefaultTimeout()
+ Expect(prune.ExitCode()).To(Equal(0))
+
+ pods := podmanTest.Podman([]string{"pod", "ps"})
+ pods.WaitWithDefaultTimeout()
+ Expect(pods.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfPods()).To(Equal(0))
+
+ Expect(podmanTest.NumberOfContainers()).To(Equal(0))
+
+ // Volumes should not be pruned
+ session = podmanTest.Podman([]string{"volume", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(2))
+
+ images := podmanTest.PodmanNoCache([]string{"images", "-aq"})
+ images.WaitWithDefaultTimeout()
+ // all images are unused, so they all should be deleted!
+ Expect(len(images.OutputToStringArray())).To(Equal(0))
+ })
})
diff --git a/test/e2e/volume_prune_test.go b/test/e2e/volume_prune_test.go
index b9ea90568..3049646b0 100644
--- a/test/e2e/volume_prune_test.go
+++ b/test/e2e/volume_prune_test.go
@@ -65,7 +65,6 @@ var _ = Describe("Podman volume prune", func() {
})
It("podman system prune --volume", func() {
- Skip(v2fail)
session := podmanTest.Podman([]string{"volume", "create"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))