diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-26 08:36:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 08:36:36 -0400 |
commit | b3416d3292691788097389b8f41a632c56a926fa (patch) | |
tree | 202cc2bb1b8d2600f24221ee1102a23d7d3e5c5d | |
parent | 9db22fb58abda8ccaf9fe68490d8c8f9a8dc994f (diff) | |
parent | ee9d755c5b86ef996a7896f09e6e91ee5e488af7 (diff) | |
download | podman-b3416d3292691788097389b8f41a632c56a926fa.tar.gz podman-b3416d3292691788097389b8f41a632c56a926fa.tar.bz2 podman-b3416d3292691788097389b8f41a632c56a926fa.zip |
Merge pull request #13791 from edsantiago/curl_dash_f
Robustify nginx tests
-rw-r--r-- | test/e2e/common_test.go | 3 | ||||
-rw-r--r-- | test/e2e/pod_infra_container_test.go | 6 | ||||
-rw-r--r-- | test/e2e/run_staticip_test.go | 29 |
3 files changed, 25 insertions, 13 deletions
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 766f39964..6846a5677 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -462,7 +462,8 @@ func (p *PodmanTestIntegration) RunNginxWithHealthCheck(name string) (*PodmanSes if name != "" { podmanArgs = append(podmanArgs, "--name", name) } - podmanArgs = append(podmanArgs, "-dt", "-P", "--health-cmd", "curl http://localhost/", nginx) + // curl without -f exits 0 even if http code >= 400! + podmanArgs = append(podmanArgs, "-dt", "-P", "--health-cmd", "curl -f http://localhost/", nginx) session := p.Podman(podmanArgs) session.WaitWithDefaultTimeout() return session, session.OutputToString() diff --git a/test/e2e/pod_infra_container_test.go b/test/e2e/pod_infra_container_test.go index 6373b949a..2b56502b0 100644 --- a/test/e2e/pod_infra_container_test.go +++ b/test/e2e/pod_infra_container_test.go @@ -119,11 +119,11 @@ var _ = Describe("Podman pod create", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.Podman([]string{"run", "--pod", podID, fedoraMinimal, "curl", "localhost:80"}) + session = podmanTest.Podman([]string{"run", "--pod", podID, fedoraMinimal, "curl", "-f", "localhost:80"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.Podman([]string{"run", fedoraMinimal, "curl", "localhost"}) + session = podmanTest.Podman([]string{"run", fedoraMinimal, "curl", "-f", "localhost"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) }) @@ -219,7 +219,7 @@ var _ = Describe("Podman pod create", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.Podman([]string{"run", "--pod", podID, "--network", "bridge", nginx, "curl", "localhost"}) + session = podmanTest.Podman([]string{"run", "--pod", podID, "--network", "bridge", nginx, "curl", "-f", "localhost"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) }) diff --git a/test/e2e/run_staticip_test.go b/test/e2e/run_staticip_test.go index b78a37495..7e61e7c5e 100644 --- a/test/e2e/run_staticip_test.go +++ b/test/e2e/run_staticip_test.go @@ -102,22 +102,33 @@ var _ = Describe("Podman run with --ip flag", func() { It("Podman run two containers with the same IP", func() { ip := GetRandomIPAddress() - result := podmanTest.Podman([]string{"run", "-dt", "--ip", ip, nginx}) + result := podmanTest.Podman([]string{"run", "-d", "--name", "nginx", "--ip", ip, nginx}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - for i := 0; i < 10; i++ { - fmt.Println("Waiting for nginx", err) - time.Sleep(1 * time.Second) + + for retries := 20; retries > 0; retries-- { response, err := http.Get(fmt.Sprintf("http://%s", ip)) - if err != nil { - continue - } - if response.StatusCode == http.StatusOK { + if err == nil && response.StatusCode == http.StatusOK { break } + if retries == 1 { + logps := podmanTest.Podman([]string{"ps", "-a"}) + logps.WaitWithDefaultTimeout() + logps = podmanTest.Podman([]string{"logs", "nginx"}) + logps.WaitWithDefaultTimeout() + Fail("Timed out waiting for nginx container, see ps & log above.") + } + + if err != nil { + fmt.Printf("nginx not ready yet; error=%v; %d retries left...\n", err, retries) + } else { + fmt.Printf("nginx not ready yet; response=%v; %d retries left...\n", response.StatusCode, retries) + } + time.Sleep(1 * time.Second) } - result = podmanTest.Podman([]string{"run", "-ti", "--ip", ip, ALPINE, "ip", "addr"}) + result = podmanTest.Podman([]string{"run", "--ip", ip, ALPINE, "ip", "addr"}) result.WaitWithDefaultTimeout() Expect(result).To(ExitWithError()) + Expect(result.ErrorToString()).To(ContainSubstring(" address %s ", ip)) }) }) |