mirror of https://github.com/docker/compose.git
Fix flakiness in ECS E2E : wait when reaching nginx welcome page, sometimes stack is not fully up and we get 503 errors
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
bff1fa1872
commit
73f5f030ac
|
@ -27,9 +27,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
|
"gotest.tools/v3/poll"
|
||||||
|
|
||||||
|
"gotest.tools/v3/icmd"
|
||||||
|
|
||||||
. "github.com/docker/api/tests/framework"
|
. "github.com/docker/api/tests/framework"
|
||||||
"gotest.tools/v3/icmd"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var binDir string
|
var binDir string
|
||||||
|
@ -99,12 +101,20 @@ func TestCompose(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("nginx GET", func(t *testing.T) {
|
t.Run("nginx GET", func(t *testing.T) {
|
||||||
r, err := http.Get(url)
|
checkUp := func(t poll.LogT) poll.Result {
|
||||||
assert.NilError(t, err)
|
r, err := http.Get(url)
|
||||||
assert.Equal(t, r.StatusCode, http.StatusOK)
|
if err != nil {
|
||||||
b, err := ioutil.ReadAll(r.Body)
|
return poll.Continue("Err while getting %s : %v", url, err)
|
||||||
assert.NilError(t, err)
|
} else if r.StatusCode != http.StatusOK {
|
||||||
assert.Assert(t, strings.Contains(string(b), "Welcome to nginx!"))
|
return poll.Continue("status %s while getting %s", r.Status, url)
|
||||||
|
}
|
||||||
|
b, err := ioutil.ReadAll(r.Body)
|
||||||
|
if err == nil && strings.Contains(string(b), "Welcome to nginx!") {
|
||||||
|
return poll.Success()
|
||||||
|
}
|
||||||
|
return poll.Error(fmt.Errorf("No nginx welcome page received at %s: \n%s", url, string(b)))
|
||||||
|
}
|
||||||
|
poll.WaitOn(t, checkUp, poll.WithDelay(2*time.Second), poll.WithTimeout(60*time.Second))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("compose down", func(t *testing.T) {
|
t.Run("compose down", func(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue