github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/wait_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 6 . "github.com/containers/libpod/test/utils" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 ) 10 11 var _ = Describe("Podman wait", 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.SeedImages() 26 }) 27 28 AfterEach(func() { 29 podmanTest.Cleanup() 30 f := CurrentGinkgoTestDescription() 31 processTestResult(f) 32 33 }) 34 35 It("podman wait on bogus container", func() { 36 session := podmanTest.Podman([]string{"wait", "1234"}) 37 session.Wait() 38 Expect(session.ExitCode()).To(Equal(125)) 39 40 }) 41 42 It("podman wait on a stopped container", func() { 43 session := podmanTest.Podman([]string{"run", "-d", ALPINE, "ls"}) 44 session.Wait(10) 45 cid := session.OutputToString() 46 Expect(session.ExitCode()).To(Equal(0)) 47 session = podmanTest.Podman([]string{"wait", cid}) 48 session.Wait() 49 }) 50 51 It("podman wait on a sleeping container", func() { 52 session := podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"}) 53 session.Wait(20) 54 cid := session.OutputToString() 55 Expect(session.ExitCode()).To(Equal(0)) 56 session = podmanTest.Podman([]string{"wait", cid}) 57 session.Wait(20) 58 }) 59 60 It("podman wait on latest container", func() { 61 session := podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"}) 62 session.Wait(20) 63 Expect(session.ExitCode()).To(Equal(0)) 64 session = podmanTest.Podman([]string{"wait", "-l"}) 65 session.Wait(20) 66 }) 67 It("podman container wait on latest container", func() { 68 session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"}) 69 session.Wait(20) 70 Expect(session.ExitCode()).To(Equal(0)) 71 session = podmanTest.Podman([]string{"container", "wait", "-l"}) 72 session.Wait(20) 73 }) 74 })