Browse Source

Adding e2e test for local compose healthcheck in compose ps

Signed-off-by: Guillaume Tardif <[email protected]>
Guillaume Tardif 4 years ago
parent
commit
bf56815251

+ 7 - 1
local/e2e/compose/compose_test.go

@@ -53,7 +53,7 @@ func TestLocalComposeUp(t *testing.T) {
 		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.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) {
 		_ = c.RunDockerCmd("compose", "--project-name", projectName, "down")
 	})

+ 3 - 0
local/e2e/compose/fixtures/sentences/compose.yaml

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