diff options
author | Brent Baude <bbaude@redhat.com> | 2019-06-12 22:30:41 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-06-18 10:43:53 -0500 |
commit | d87cb1a5f94e5f3dde9aa498ff1588674b4c2db9 (patch) | |
tree | 833acbcfcf910075997b0ad4d10c459c5accd934 /test/e2e/common_test.go | |
parent | 265d55edbf698b624adee081a48f47b3b73b6164 (diff) | |
download | podman-d87cb1a5f94e5f3dde9aa498ff1588674b4c2db9.tar.gz podman-d87cb1a5f94e5f3dde9aa498ff1588674b4c2db9.tar.bz2 podman-d87cb1a5f94e5f3dde9aa498ff1588674b4c2db9.zip |
fix port -l timing with healthchecks
many of the port tests use our nginx container image. in some cases, we have timing
issues between when the nginx and the container are running and when the port -l
command is run causing test flakes. we now use the container image's built in
healthcheck to ensure that nginx is running (and subsequently the container
itself) before running the port command.
Fixes: #3309
Signed-off-by: Brent Baude <bbaude@redhat.com>
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'test/e2e/common_test.go')
-rw-r--r-- | test/e2e/common_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 9529346b4..8b6eab892 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -10,6 +10,7 @@ import ( "sort" "strings" "testing" + "time" "github.com/containers/libpod/cmd/podman/shared" "github.com/containers/libpod/libpod" @@ -22,6 +23,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" + "github.com/pkg/errors" ) var ( @@ -367,6 +369,18 @@ func (p *PodmanTestIntegration) RunLsContainer(name string) (*PodmanSessionInteg return session, session.ExitCode(), session.OutputToString() } +// RunNginxWithHealthCheck runs the alpine nginx container with an optional name and adds a healthcheck into it +func (p *PodmanTestIntegration) RunNginxWithHealthCheck(name string) (*PodmanSessionIntegration, string) { + var podmanArgs = []string{"run"} + if name != "" { + podmanArgs = append(podmanArgs, "--name", name) + } + podmanArgs = append(podmanArgs, "-dt", "-P", "--healthcheck-command", "CMD-SHELL curl http://localhost/", nginx) + session := p.Podman(podmanArgs) + session.WaitWithDefaultTimeout() + return session, session.OutputToString() +} + func (p *PodmanTestIntegration) RunLsContainerInPod(name, pod string) (*PodmanSessionIntegration, int, string) { var podmanArgs = []string{"run", "--pod", pod} if name != "" { @@ -508,3 +522,16 @@ func (p *PodmanTestIntegration) ImageExistsInMainStore(idOrName string) bool { results.WaitWithDefaultTimeout() return Expect(results.ExitCode()).To(Equal(0)) } + +func (p *PodmanTestIntegration) RunHealthCheck(cid string) error { + for i := 0; i < 10; i++ { + hc := p.Podman([]string{"healthcheck", "run", cid}) + hc.WaitWithDefaultTimeout() + if hc.ExitCode() == 0 { + return nil + } + fmt.Printf("Waiting for %s to pass healthcheck\n", cid) + time.Sleep(1 * time.Second) + } + return errors.Errorf("unable to detect %s as running", cid) +} |