Merge pull request #2842 from cevich/improve_podman_pod_rm

Improve podman pod rm -a test
This commit is contained in:
OpenShift Merge Robot 2019-04-03 10:36:38 -07:00 committed by GitHub
commit e662cb1f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 8 deletions

View File

@ -3,6 +3,7 @@
package integration package integration
import ( import (
"fmt"
"os" "os"
. "github.com/containers/libpod/test/utils" . "github.com/containers/libpod/test/utils"
@ -95,28 +96,41 @@ var _ = Describe("Podman pod rm", func() {
}) })
It("podman pod rm -a doesn't remove a running container", func() { It("podman pod rm -a doesn't remove a running container", func() {
fmt.Printf("To start, there are %d pods\n", podmanTest.NumberOfPods())
_, ec, podid1 := podmanTest.CreatePod("") _, ec, podid1 := podmanTest.CreatePod("")
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("") _, ec, _ = podmanTest.CreatePod("")
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
fmt.Printf("Started %d pods\n", podmanTest.NumberOfPods())
session := podmanTest.RunTopContainerInPod("", podid1) session := podmanTest.RunTopContainerInPod("", podid1)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
podmanTest.WaitForContainer()
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
fmt.Printf("Started container running in one pod")
num_pods := podmanTest.NumberOfPods()
Expect(num_pods).To(Equal(2))
ps := podmanTest.Podman([]string{"pod", "ps"})
ps.WaitWithDefaultTimeout()
fmt.Printf("Current %d pod(s):\n%s\n", num_pods, ps.OutputToString())
fmt.Printf("Removing all empty pods\n")
result := podmanTest.Podman([]string{"pod", "rm", "-a"}) result := podmanTest.Podman([]string{"pod", "rm", "-a"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Not(Equal(0))) Expect(result.ExitCode()).To(Not(Equal(0)))
foundExpectedError, _ := result.ErrorGrepString("contains containers and cannot be removed")
Expect(foundExpectedError).To(Equal(true))
result = podmanTest.Podman([]string{"ps", "-q"}) num_pods = podmanTest.NumberOfPods()
result.WaitWithDefaultTimeout() ps = podmanTest.Podman([]string{"pod", "ps"})
Expect(len(result.OutputToStringArray())).To(Equal(1)) ps.WaitWithDefaultTimeout()
fmt.Printf("Final %d pod(s):\n%s\n", num_pods, ps.OutputToString())
// one pod should have been deleted Expect(num_pods).To(Equal(1))
result = podmanTest.Podman([]string{"pod", "ps", "-q"}) // Confirm top container still running inside remaining pod
result.WaitWithDefaultTimeout() Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
Expect(len(result.OutputToStringArray())).To(Equal(1))
}) })
It("podman pod rm -fa removes everything", func() { It("podman pod rm -fa removes everything", func() {