github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/e2e/pod_prune_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"os"
     5  
     6  	. "github.com/containers/podman/v3/test/utils"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  	. "github.com/onsi/gomega/gexec"
    10  )
    11  
    12  var _ = Describe("Podman pod prune", func() {
    13  	var (
    14  		tempdir    string
    15  		err        error
    16  		podmanTest *PodmanTestIntegration
    17  	)
    18  
    19  	BeforeEach(func() {
    20  		tempdir, err = CreateTempDirInTempDir()
    21  		if err != nil {
    22  			os.Exit(1)
    23  		}
    24  		podmanTest = PodmanTestCreate(tempdir)
    25  		podmanTest.Setup()
    26  		podmanTest.SeedImages()
    27  	})
    28  
    29  	AfterEach(func() {
    30  		podmanTest.Cleanup()
    31  		f := CurrentGinkgoTestDescription()
    32  		processTestResult(f)
    33  
    34  	})
    35  
    36  	It("podman pod prune empty pod", func() {
    37  		_, ec, _ := podmanTest.CreatePod(nil)
    38  		Expect(ec).To(Equal(0))
    39  
    40  		result := podmanTest.Podman([]string{"pod", "prune", "--force"})
    41  		result.WaitWithDefaultTimeout()
    42  		Expect(result).Should(Exit(0))
    43  	})
    44  
    45  	It("podman pod prune doesn't remove a pod with a running container", func() {
    46  		_, ec, podid := podmanTest.CreatePod(nil)
    47  		Expect(ec).To(Equal(0))
    48  
    49  		ec2 := podmanTest.RunTopContainerInPod("", podid)
    50  		ec2.WaitWithDefaultTimeout()
    51  		Expect(ec2).Should(Exit(0))
    52  
    53  		result := podmanTest.Podman([]string{"pod", "prune", "-f"})
    54  		result.WaitWithDefaultTimeout()
    55  		Expect(result).Should(Exit(0))
    56  
    57  		result = podmanTest.Podman([]string{"ps", "-qa"})
    58  		result.WaitWithDefaultTimeout()
    59  		Expect(len(result.OutputToStringArray())).To(Equal(1))
    60  	})
    61  
    62  	It("podman pod prune removes a pod with a stopped container", func() {
    63  		_, ec, podid := podmanTest.CreatePod(nil)
    64  		Expect(ec).To(Equal(0))
    65  
    66  		_, ec2, _ := podmanTest.RunLsContainerInPod("", podid)
    67  		Expect(ec2).To(Equal(0))
    68  
    69  		result := podmanTest.Podman([]string{"pod", "prune", "-f"})
    70  		result.WaitWithDefaultTimeout()
    71  		Expect(result).Should(Exit(0))
    72  
    73  		result = podmanTest.Podman([]string{"ps", "-qa"})
    74  		result.WaitWithDefaultTimeout()
    75  		Expect(len(result.OutputToStringArray())).To(Equal(0))
    76  	})
    77  })