github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/test/e2e/run_cleanup_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"os"
     5  
     6  	. "github.com/containers/podman/v2/test/utils"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  )
    10  
    11  var _ = Describe("Podman run exit", func() {
    12  	var (
    13  		tempdir    string
    14  		err        error
    15  		podmanTest *PodmanTestIntegration
    16  	)
    17  
    18  	BeforeEach(func() {
    19  		tempdir, err = CreateTempDirInTempDir()
    20  		if err != nil {
    21  			os.Exit(1)
    22  		}
    23  		podmanTest = PodmanTestCreate(tempdir)
    24  		podmanTest.Setup()
    25  		podmanTest.RestoreArtifact(ALPINE)
    26  	})
    27  
    28  	AfterEach(func() {
    29  		podmanTest.Cleanup()
    30  		f := CurrentGinkgoTestDescription()
    31  		processTestResult(f)
    32  
    33  	})
    34  
    35  	It("podman run -d mount cleanup test", func() {
    36  		SkipIfRemote("podman-remote does not support mount")
    37  		SkipIfRootless("FIXME podman mount requires podman unshare first")
    38  
    39  		result := podmanTest.Podman([]string{"run", "-dt", ALPINE, "top"})
    40  		result.WaitWithDefaultTimeout()
    41  		cid := result.OutputToString()
    42  		Expect(result.ExitCode()).To(Equal(0))
    43  
    44  		mount := SystemExec("mount", nil)
    45  		Expect(mount.ExitCode()).To(Equal(0))
    46  		Expect(mount.OutputToString()).To(ContainSubstring(cid))
    47  
    48  		pmount := podmanTest.Podman([]string{"mount", "--notruncate"})
    49  		pmount.WaitWithDefaultTimeout()
    50  		Expect(pmount.ExitCode()).To(Equal(0))
    51  		Expect(pmount.OutputToString()).To(ContainSubstring(cid))
    52  
    53  		stop := podmanTest.Podman([]string{"stop", cid})
    54  		stop.WaitWithDefaultTimeout()
    55  		Expect(stop.ExitCode()).To(Equal(0))
    56  
    57  		// We have to force cleanup so the unmount happens
    58  		podmanCleanupSession := podmanTest.Podman([]string{"container", "cleanup", cid})
    59  		podmanCleanupSession.WaitWithDefaultTimeout()
    60  		Expect(podmanCleanupSession.ExitCode()).To(Equal(0))
    61  
    62  		mount = SystemExec("mount", nil)
    63  		Expect(mount.ExitCode()).To(Equal(0))
    64  		Expect(mount.OutputToString()).NotTo(ContainSubstring(cid))
    65  
    66  		pmount = podmanTest.Podman([]string{"mount", "--notruncate"})
    67  		pmount.WaitWithDefaultTimeout()
    68  		Expect(pmount.ExitCode()).To(Equal(0))
    69  		Expect(pmount.OutputToString()).NotTo(ContainSubstring(cid))
    70  
    71  	})
    72  })