github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/docker/pause_test.go (about) 1 // Copyright (c) 2018 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package docker 6 7 import ( 8 "strings" 9 "time" 10 11 . "github.com/onsi/ginkgo" 12 . "github.com/onsi/gomega" 13 ) 14 15 var _ = Describe("pause", func() { 16 var id string 17 18 AfterEach(func() { 19 Expect(RemoveDockerContainer(id)).To(BeTrue()) 20 Expect(ExistDockerContainer(id)).NotTo(BeTrue()) 21 }) 22 23 Describe("pause with docker", func() { 24 Context("check pause functionality", func() { 25 It("should not be running", func() { 26 id = randomDockerName() 27 _, _, exitCode := dockerRun("-td", "--name", id, Image, "sh") 28 Expect(exitCode).To(Equal(0)) 29 _, _, exitCode = dockerPause(id) 30 Expect(exitCode).To(Equal(0)) 31 stdout, _, exitCode := dockerPs("-a", "--filter", "status=paused", "--filter", "name="+id) 32 Expect(exitCode).To(Equal(0)) 33 Expect(stdout).To(ContainSubstring("Paused")) 34 _, _, exitCode = dockerUnpause(id) 35 Expect(exitCode).To(Equal(0)) 36 stdout, _, exitCode = dockerPs("-a", "--filter", "status=running", "--filter", "name="+id) 37 Expect(exitCode).To(Equal(0)) 38 Expect(stdout).To(ContainSubstring("Up")) 39 }) 40 }) 41 }) 42 }) 43 44 // To get more info about this test, see https://github.com/kata-containers/agent/issues/231 45 var _ = Describe("check yamux IO timeout", func() { 46 var ( 47 id string 48 msg string 49 stdout string 50 exitCode int 51 waitTime time.Duration 52 ) 53 54 BeforeEach(func() { 55 id = randomDockerName() 56 msg = "Hi!" 57 // By default in yamux keepalive time is 30s and connection timeout is 10s. 58 // Wait 45s before unpausing and checking the container. 59 waitTime = 45 * time.Second 60 }) 61 62 AfterEach(func() { 63 Expect(RemoveDockerContainer(id)).To(BeTrue()) 64 Expect(ExistDockerContainer(id)).NotTo(BeTrue()) 65 }) 66 67 Describe("pause, wait and unpause a container", func() { 68 Context("check yamux IO connection", func() { 69 It("should keep alive", func() { 70 _, _, exitCode = dockerRun("-td", "--name", id, Image, "sh") 71 Expect(0).To(Equal(exitCode)) 72 _, _, exitCode = dockerPause(id) 73 Expect(0).To(Equal(exitCode)) 74 time.Sleep(waitTime) 75 _, _, exitCode = dockerUnpause(id) 76 Expect(0).To(Equal(exitCode)) 77 stdout, _, exitCode = dockerExec(id, "echo", msg) 78 Expect(msg).To(Equal(strings.Trim(stdout, "\n\t "))) 79 }) 80 }) 81 }) 82 }) 83 84 var _ = Describe("remove paused container", func() { 85 var ( 86 id string 87 exitCode int 88 ) 89 90 BeforeEach(func() { 91 id = randomDockerName() 92 }) 93 94 AfterEach(func() { 95 Expect(ExistDockerContainer(id)).NotTo(BeTrue()) 96 }) 97 98 Describe("start, pause, remove container", func() { 99 Context("check if a paused container can be removed", func() { 100 It("should be removed", func() { 101 _, _, exitCode = dockerRun("-td", "--name", id, Image, "sh") 102 Expect(0).To(Equal(exitCode)) 103 _, _, exitCode = dockerPause(id) 104 Expect(0).To(Equal(exitCode)) 105 _, _, exitCode = dockerRm("-f", id) 106 Expect(0).To(Equal(exitCode)) 107 }) 108 }) 109 }) 110 })