github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/e2e/system_reset_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 "os" 6 7 . "github.com/hanks177/podman/v4/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 }) 28 29 AfterEach(func() { 30 podmanTest.Cleanup() 31 f := CurrentGinkgoTestDescription() 32 timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds()) 33 _, _ = GinkgoWriter.Write([]byte(timedResult)) 34 }) 35 36 It("podman system reset", func() { 37 SkipIfRemote("system reset not supported on podman --remote") 38 // system reset will not remove additional store images, so need to grab length 39 40 // change the network dir so that we do not conflict with other tests 41 // that would use the same network dir and cause unnecessary flakes 42 podmanTest.NetworkConfigDir = tempdir 43 44 session := podmanTest.Podman([]string{"rmi", "--force", "--all"}) 45 session.WaitWithDefaultTimeout() 46 Expect(session).Should(Exit(0)) 47 48 session = podmanTest.Podman([]string{"images", "-n"}) 49 session.WaitWithDefaultTimeout() 50 Expect(session).Should(Exit(0)) 51 l := len(session.OutputToStringArray()) 52 53 podmanTest.AddImageToRWStore(ALPINE) 54 session = podmanTest.Podman([]string{"volume", "create", "data"}) 55 session.WaitWithDefaultTimeout() 56 Expect(session).Should(Exit(0)) 57 58 session = podmanTest.Podman([]string{"create", "-v", "data:/data", ALPINE, "echo", "hello"}) 59 session.WaitWithDefaultTimeout() 60 Expect(session).Should(Exit(0)) 61 62 session = podmanTest.Podman([]string{"network", "create"}) 63 session.WaitWithDefaultTimeout() 64 Expect(session).Should(Exit(0)) 65 66 session = podmanTest.Podman([]string{"system", "reset", "-f"}) 67 session.WaitWithDefaultTimeout() 68 Expect(session).Should(Exit(0)) 69 70 Expect(session.ErrorToString()).To(Not(ContainSubstring("Failed to add pause process"))) 71 72 session = podmanTest.Podman([]string{"images", "-n"}) 73 session.WaitWithDefaultTimeout() 74 Expect(session).Should(Exit(0)) 75 Expect(session.OutputToStringArray()).To(HaveLen(l)) 76 77 session = podmanTest.Podman([]string{"volume", "ls"}) 78 session.WaitWithDefaultTimeout() 79 Expect(session).Should(Exit(0)) 80 Expect(session.OutputToStringArray()).To(BeEmpty()) 81 82 session = podmanTest.Podman([]string{"container", "ls", "-q"}) 83 session.WaitWithDefaultTimeout() 84 Expect(session).Should(Exit(0)) 85 Expect(session.OutputToStringArray()).To(BeEmpty()) 86 87 session = podmanTest.Podman([]string{"network", "ls", "-q"}) 88 session.WaitWithDefaultTimeout() 89 Expect(session).Should(Exit(0)) 90 // default network should exists 91 Expect(session.OutputToStringArray()).To(HaveLen(1)) 92 93 // TODO: machine tests currently don't run outside of the machine test pkg 94 // no machines are created here to cleanup 95 session = podmanTest.Podman([]string{"machine", "list", "-q"}) 96 session.WaitWithDefaultTimeout() 97 Expect(session).Should(Exit(0)) 98 Expect(session.OutputToStringArray()).To(BeEmpty()) 99 }) 100 })