Merge pull request #1228 from gtardif/healthcheck_e2e

Adding e2e test for local compose healthcheck in compose ps
This commit is contained in:
Nicolas De loof 2021-02-03 14:04:42 +01:00 committed by GitHub
commit 09f9a117e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -53,7 +53,7 @@ func TestLocalComposeUp(t *testing.T) {
c.RunDockerCmd("compose", "-f", "./fixtures/sentences/compose.yaml", "--project-name", projectName, "up", "-d") c.RunDockerCmd("compose", "-f", "./fixtures/sentences/compose.yaml", "--project-name", projectName, "up", "-d")
}) })
t.Run("check running project", func(t *testing.T) { t.Run("check accessing running app", func(t *testing.T) {
res := c.RunDockerCmd("compose", "-p", projectName, "ps") res := c.RunDockerCmd("compose", "-p", projectName, "ps")
res.Assert(t, icmd.Expected{Out: `web`}) res.Assert(t, icmd.Expected{Out: `web`})
@ -89,6 +89,12 @@ func TestLocalComposeUp(t *testing.T) {
}) })
t.Run("check healthcheck display", func(t *testing.T) {
c.WaitForCmdResult(c.NewDockerCmd("compose", "-p", projectName, "ps", "--format", "json"),
StdoutContains(`"Name":"compose-e2e-demo_web_1","Project":"compose-e2e-demo","Service":"web","State":"running","Health":"healthy"`),
5*time.Second, 1*time.Second)
})
t.Run("down", func(t *testing.T) { t.Run("down", func(t *testing.T) {
_ = c.RunDockerCmd("compose", "--project-name", projectName, "down") _ = c.RunDockerCmd("compose", "--project-name", projectName, "down")
}) })

View File

@ -11,3 +11,6 @@ services:
- "90:80" - "90:80"
labels: labels:
- "my-label=test" - "my-label=test"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80/"]
interval: 5s