fix timing issues with some tests

some integration tests are inherently problematic due to timing issues.
one such case is running a valid health check on container that runs
nginx.  while the container may be running, nginx may not have finished
executing itself and therefore the healthcheck fails.

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude
2019-06-02 09:18:24 -05:00
parent 176a41c355
commit c727cd1dc6

View File

@ -5,6 +5,7 @@ package integration
import (
"fmt"
"os"
"time"
. "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
@ -47,9 +48,19 @@ var _ = Describe("Podman healthcheck run", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc.ExitCode()).To(Equal(0))
exitCode := 999
// Buy a little time to get container running
for i := 0; i < 5; i++ {
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
exitCode = hc.ExitCode()
if exitCode == 0 || i == 4 {
break
}
time.Sleep(1 * time.Second)
}
Expect(exitCode).To(Equal(0))
})
It("podman healthcheck that should fail", func() {