github.com/containers/podman/v4@v4.9.4/test/e2e/system_reset_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 6 . "github.com/containers/podman/v4/test/utils" 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 ) 10 11 // system reset must run serial: https://github.com/containers/podman/issues/17903 12 var _ = Describe("podman system reset", Serial, func() { 13 14 It("podman system reset", func() { 15 SkipIfRemote("system reset not supported on podman --remote") 16 // system reset will not remove additional store images, so need to grab length 17 useCustomNetworkDir(podmanTest, tempdir) 18 19 session := podmanTest.Podman([]string{"rmi", "--force", "--all"}) 20 session.WaitWithDefaultTimeout() 21 Expect(session).Should(ExitCleanly()) 22 23 session = podmanTest.Podman([]string{"images", "-n"}) 24 session.WaitWithDefaultTimeout() 25 Expect(session).Should(ExitCleanly()) 26 l := len(session.OutputToStringArray()) 27 28 podmanTest.AddImageToRWStore(ALPINE) 29 session = podmanTest.Podman([]string{"volume", "create", "data"}) 30 session.WaitWithDefaultTimeout() 31 Expect(session).Should(ExitCleanly()) 32 33 session = podmanTest.Podman([]string{"create", "-v", "data:/data", ALPINE, "echo", "hello"}) 34 session.WaitWithDefaultTimeout() 35 Expect(session).Should(ExitCleanly()) 36 37 session = podmanTest.Podman([]string{"network", "create"}) 38 session.WaitWithDefaultTimeout() 39 Expect(session).Should(ExitCleanly()) 40 41 session = podmanTest.Podman([]string{"system", "reset", "-f"}) 42 session.WaitWithDefaultTimeout() 43 Expect(session).Should(ExitCleanly()) 44 45 Expect(session.ErrorToString()).To(Not(ContainSubstring("Failed to add pause process"))) 46 Expect(session.ErrorToString()).To(Not(ContainSubstring("/usr/share/containers/storage.conf"))) 47 48 session = podmanTest.Podman([]string{"images", "-n"}) 49 session.WaitWithDefaultTimeout() 50 Expect(session).Should(ExitCleanly()) 51 Expect(session.OutputToStringArray()).To(HaveLen(l)) 52 53 session = podmanTest.Podman([]string{"volume", "ls"}) 54 session.WaitWithDefaultTimeout() 55 Expect(session).Should(ExitCleanly()) 56 Expect(session.OutputToStringArray()).To(BeEmpty()) 57 58 session = podmanTest.Podman([]string{"container", "ls", "-q"}) 59 session.WaitWithDefaultTimeout() 60 Expect(session).Should(ExitCleanly()) 61 Expect(session.OutputToStringArray()).To(BeEmpty()) 62 63 session = podmanTest.Podman([]string{"network", "ls", "-q"}) 64 session.WaitWithDefaultTimeout() 65 Expect(session).Should(ExitCleanly()) 66 // default network should exists 67 Expect(session.OutputToStringArray()).To(HaveLen(1)) 68 69 // TODO: machine tests currently don't run outside of the machine test pkg 70 // no machines are created here to cleanup 71 // machine commands are rootless only 72 if isRootless() { 73 session = podmanTest.Podman([]string{"machine", "list", "-q"}) 74 session.WaitWithDefaultTimeout() 75 Expect(session).Should(ExitCleanly()) 76 Expect(session.OutputToStringArray()).To(BeEmpty()) 77 } 78 }) 79 80 It("system reset completely removes container", func() { 81 SkipIfRemote("system reset not supported on podman --remote") 82 useCustomNetworkDir(podmanTest, tempdir) 83 84 rmi := podmanTest.Podman([]string{"rmi", "--force", "--all"}) 85 rmi.WaitWithDefaultTimeout() 86 Expect(rmi).Should(ExitCleanly()) 87 podmanTest.AddImageToRWStore(ALPINE) 88 89 // The name ensures that we have a Libpod resource that we'll 90 // hit if we recreate the container after a reset and it still 91 // exists. The port does the same for a system-level resource. 92 ctrName := "testctr" 93 port1 := GetPort() 94 port2 := GetPort() 95 session := podmanTest.Podman([]string{"run", "--name", ctrName, "-p", fmt.Sprintf("%d:%d", port1, port2), "-d", ALPINE, "top"}) 96 session.WaitWithDefaultTimeout() 97 Expect(session).Should(ExitCleanly()) 98 99 reset := podmanTest.Podman([]string{"system", "reset", "--force"}) 100 reset.WaitWithDefaultTimeout() 101 Expect(reset).Should(ExitCleanly()) 102 103 session2 := podmanTest.Podman([]string{"run", "--name", ctrName, "-p", fmt.Sprintf("%d:%d", port1, port2), "-d", ALPINE, "top"}) 104 session2.WaitWithDefaultTimeout() 105 Expect(session2).Should(ExitCleanly()) 106 }) 107 })