github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/e2e/run_cleanup_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"os"
     5  
     6  	. "github.com/hanks177/podman/v4/test/utils"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  	. "github.com/onsi/gomega/gexec"
    10  )
    11  
    12  var _ = Describe("Podman run exit", 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  		err = podmanTest.RestoreArtifact(ALPINE)
    27  		Expect(err).ToNot(HaveOccurred())
    28  	})
    29  
    30  	AfterEach(func() {
    31  		podmanTest.Cleanup()
    32  		f := CurrentGinkgoTestDescription()
    33  		processTestResult(f)
    34  
    35  	})
    36  
    37  	It("podman run -d mount cleanup test", func() {
    38  		SkipIfRemote("podman-remote does not support mount")
    39  		SkipIfRootless("TODO rootless podman mount requires podman unshare first")
    40  
    41  		result := podmanTest.Podman([]string{"run", "-dt", ALPINE, "top"})
    42  		result.WaitWithDefaultTimeout()
    43  		cid := result.OutputToString()
    44  		Expect(result).Should(Exit(0))
    45  
    46  		mount := SystemExec("mount", nil)
    47  		Expect(mount).Should(Exit(0))
    48  		Expect(mount.OutputToString()).To(ContainSubstring(cid))
    49  
    50  		pmount := podmanTest.Podman([]string{"mount", "--no-trunc"})
    51  		pmount.WaitWithDefaultTimeout()
    52  		Expect(pmount).Should(Exit(0))
    53  		Expect(pmount.OutputToString()).To(ContainSubstring(cid))
    54  
    55  		stop := podmanTest.Podman([]string{"stop", cid})
    56  		stop.WaitWithDefaultTimeout()
    57  		Expect(stop).Should(Exit(0))
    58  
    59  		// We have to force cleanup so the unmount happens
    60  		podmanCleanupSession := podmanTest.Podman([]string{"container", "cleanup", cid})
    61  		podmanCleanupSession.WaitWithDefaultTimeout()
    62  		Expect(podmanCleanupSession).Should(Exit(0))
    63  
    64  		mount = SystemExec("mount", nil)
    65  		Expect(mount).Should(Exit(0))
    66  		Expect(mount.OutputToString()).NotTo(ContainSubstring(cid))
    67  
    68  		pmount = podmanTest.Podman([]string{"mount", "--no-trunc"})
    69  		pmount.WaitWithDefaultTimeout()
    70  		Expect(pmount).Should(Exit(0))
    71  		Expect(pmount.OutputToString()).NotTo(ContainSubstring(cid))
    72  
    73  	})
    74  })