Add restart test with timeout

Test the --timeout flag with a container which can not be stopped with
SIGSTOP. This means the container should can not be stopped and will be
killed then restart with timeout value. Test steps:
  Start a container with STOPSIGNAL=SIGKILL
  Restart it with --timeout set to 2s
  Check the restart command will finished more than 2s and less than
  10s(the default timeout)

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
This commit is contained in:
Yiqiao Pu
2018-04-23 17:21:23 +08:00
parent 18c98375a0
commit 04b58bc80c

View File

@ -2,6 +2,7 @@ package integration
import (
"os"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -118,4 +119,17 @@ var _ = Describe("Podman restart", func() {
Expect(restartTime.OutputToStringArray()[0]).To(Equal(startTime.OutputToStringArray()[0]))
Expect(restartTime.OutputToStringArray()[1]).To(Not(Equal(startTime.OutputToStringArray()[1])))
})
It("Podman restart non-stop container with short timeout", func() {
session := podmanTest.Podman([]string{"run", "-d", "--name", "test1", "--env", "STOPSIGNAL=SIGKILL", ALPINE, "sleep", "999"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
startTime := time.Now()
session = podmanTest.Podman([]string{"restart", "-t", "2", "test1"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
timeSince := time.Since(startTime)
Expect(timeSince < 10*time.Second).To(BeTrue())
Expect(timeSince > 2*time.Second).To(BeTrue())
})
})