github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/e2e/system_reset_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 "os" 6 7 . "github.com/containers/podman/v3/test/utils" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 . "github.com/onsi/gomega/gexec" 11 ) 12 13 var _ = Describe("podman system reset", func() { 14 var ( 15 tempdir string 16 err error 17 podmanTest *PodmanTestIntegration 18 ) 19 20 BeforeEach(func() { 21 tempdir, err = CreateTempDirInTempDir() 22 if err != nil { 23 os.Exit(1) 24 } 25 podmanTest = PodmanTestCreate(tempdir) 26 podmanTest.Setup() 27 podmanTest.SeedImages() 28 }) 29 30 AfterEach(func() { 31 podmanTest.Cleanup() 32 f := CurrentGinkgoTestDescription() 33 timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds()) 34 GinkgoWriter.Write([]byte(timedResult)) 35 }) 36 37 It("podman system reset", func() { 38 SkipIfRemote("system reset not supported on podman --remote") 39 // system reset will not remove additional store images, so need to grab length 40 41 session := podmanTest.Podman([]string{"rmi", "--force", "--all"}) 42 session.WaitWithDefaultTimeout() 43 Expect(session).Should(Exit(0)) 44 45 session = podmanTest.Podman([]string{"images", "-n"}) 46 session.WaitWithDefaultTimeout() 47 Expect(session).Should(Exit(0)) 48 l := len(session.OutputToStringArray()) 49 50 podmanTest.AddImageToRWStore(ALPINE) 51 session = podmanTest.Podman([]string{"volume", "create", "data"}) 52 session.WaitWithDefaultTimeout() 53 Expect(session).Should(Exit(0)) 54 55 session = podmanTest.Podman([]string{"create", "-v", "data:/data", ALPINE, "echo", "hello"}) 56 session.WaitWithDefaultTimeout() 57 Expect(session).Should(Exit(0)) 58 59 session = podmanTest.Podman([]string{"system", "reset", "-f"}) 60 session.WaitWithDefaultTimeout() 61 Expect(session).Should(Exit(0)) 62 63 Expect(session.ErrorToString()).To(Not(ContainSubstring("Failed to add pause process"))) 64 65 // If remote then the API service should have exited 66 // On local tests this is a noop 67 podmanTest.StartRemoteService() 68 69 session = podmanTest.Podman([]string{"images", "-n"}) 70 session.WaitWithDefaultTimeout() 71 Expect(session).Should(Exit(0)) 72 Expect(len(session.OutputToStringArray())).To(Equal(l)) 73 74 session = podmanTest.Podman([]string{"volume", "ls"}) 75 session.WaitWithDefaultTimeout() 76 Expect(session).Should(Exit(0)) 77 Expect(len(session.OutputToStringArray())).To(Equal(0)) 78 79 session = podmanTest.Podman([]string{"container", "ls", "-q"}) 80 session.WaitWithDefaultTimeout() 81 Expect(session).Should(Exit(0)) 82 Expect(len(session.OutputToStringArray())).To(Equal(0)) 83 }) 84 })