github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/e2e/wait_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 6 . "github.com/containers/podman/v3/test/utils" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 var _ = Describe("Podman wait", 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 podmanTest.SeedImages() 27 }) 28 29 AfterEach(func() { 30 podmanTest.Cleanup() 31 f := CurrentGinkgoTestDescription() 32 processTestResult(f) 33 34 }) 35 36 It("podman wait on bogus container", func() { 37 session := podmanTest.Podman([]string{"wait", "1234"}) 38 session.WaitWithDefaultTimeout() 39 Expect(session).Should(Exit(125)) 40 41 }) 42 43 It("podman wait on a stopped container", func() { 44 session := podmanTest.Podman([]string{"run", "-d", ALPINE, "ls"}) 45 session.Wait(10) 46 cid := session.OutputToString() 47 Expect(session).Should(Exit(0)) 48 session = podmanTest.Podman([]string{"wait", cid}) 49 session.WaitWithDefaultTimeout() 50 Expect(session).Should(Exit(0)) 51 }) 52 53 It("podman wait on a sleeping container", func() { 54 session := podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"}) 55 session.Wait(20) 56 cid := session.OutputToString() 57 Expect(session).Should(Exit(0)) 58 session = podmanTest.Podman([]string{"wait", cid}) 59 session.Wait(20) 60 Expect(session).Should(Exit(0)) 61 }) 62 63 It("podman wait on latest container", func() { 64 session := podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"}) 65 session.Wait(20) 66 Expect(session).Should(Exit(0)) 67 if IsRemote() { 68 session = podmanTest.Podman([]string{"wait", session.OutputToString()}) 69 } else { 70 session = podmanTest.Podman([]string{"wait", "-l"}) 71 } 72 session.WaitWithDefaultTimeout() 73 Expect(session).Should(Exit(0)) 74 }) 75 76 It("podman container wait on latest container", func() { 77 session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"}) 78 session.Wait(20) 79 Expect(session).Should(Exit(0)) 80 if IsRemote() { 81 session = podmanTest.Podman([]string{"container", "wait", session.OutputToString()}) 82 } else { 83 session = podmanTest.Podman([]string{"container", "wait", "-l"}) 84 } 85 session.WaitWithDefaultTimeout() 86 Expect(session).Should(Exit(0)) 87 }) 88 89 It("podman container wait on latest container with --interval flag", func() { 90 session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"}) 91 session.Wait(20) 92 Expect(session).Should(Exit(0)) 93 session = podmanTest.Podman([]string{"container", "wait", "-i", "5000", session.OutputToString()}) 94 session.WaitWithDefaultTimeout() 95 Expect(session).Should(Exit(0)) 96 }) 97 98 It("podman container wait on latest container with --interval flag", func() { 99 session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"}) 100 session.WaitWithDefaultTimeout() 101 Expect(session).Should(Exit(0)) 102 session = podmanTest.Podman([]string{"container", "wait", "--interval", "1s", session.OutputToString()}) 103 session.WaitWithDefaultTimeout() 104 Expect(session).Should(Exit(0)) 105 }) 106 107 It("podman container wait on container with bogus --interval", func() { 108 session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"}) 109 session.WaitWithDefaultTimeout() 110 Expect(session).Should(Exit(0)) 111 session = podmanTest.Podman([]string{"container", "wait", "--interval", "100days", session.OutputToString()}) 112 session.WaitWithDefaultTimeout() 113 Expect(session).Should(Exit(125)) 114 }) 115 116 It("podman wait on three containers", func() { 117 session := podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"}) 118 session.Wait(20) 119 Expect(session).Should(Exit(0)) 120 cid1 := session.OutputToString() 121 session = podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"}) 122 session.Wait(20) 123 Expect(session).Should(Exit(0)) 124 cid2 := session.OutputToString() 125 session = podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"}) 126 session.Wait(20) 127 Expect(session).Should(Exit(0)) 128 cid3 := session.OutputToString() 129 session = podmanTest.Podman([]string{"wait", cid1, cid2, cid3}) 130 session.Wait(20) 131 Expect(session).Should(Exit(0)) 132 Expect(session.OutputToStringArray()).To(Equal([]string{"0", "0", "0"})) 133 }) 134 })