From ad140697fccd6b5b637651e4f448f9a7d361433b Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Fri, 5 Feb 2021 12:12:04 +0100 Subject: [PATCH] =?UTF-8?q?Remove=20the=20HEALTH=20status=20in=20`docker?= =?UTF-8?q?=20compose=20ps`=20and=20combine=20values=20from=20fields=20?= =?UTF-8?q?=E2=80=9Cstate=E2=80=9D=20and=20=E2=80=9Chealth=E2=80=9D.=20Ren?= =?UTF-8?q?ame=20column=20STATE=20=3D>=20STATUS.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guillaume Tardif --- cli/cmd/compose/ps.go | 8 ++++++-- local/e2e/compose/compose_test.go | 7 ++++++- local/e2e/compose/fixtures/sentences/compose.yaml | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cli/cmd/compose/ps.go b/cli/cmd/compose/ps.go index d73bb18af..617367ab0 100644 --- a/cli/cmd/compose/ps.go +++ b/cli/cmd/compose/ps.go @@ -93,8 +93,12 @@ func runPs(ctx context.Context, opts psOptions) error { ports = append(ports, fmt.Sprintf("%s->%d/%s", p.URL, p.TargetPort, p.Protocol)) } } - _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", container.Name, container.Service, container.State, container.Health, strings.Join(ports, ", ")) + status := container.State + if container.Health != "" { + status = fmt.Sprintf("%s (%s)", container.State, container.Health) + } + _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", container.Name, container.Service, status, strings.Join(ports, ", ")) } }, - "NAME", "SERVICE", "STATE", "HEALTH", "PORTS") + "NAME", "SERVICE", "STATUS", "PORTS") } diff --git a/local/e2e/compose/compose_test.go b/local/e2e/compose/compose_test.go index 9e095c9b7..2b0120a23 100644 --- a/local/e2e/compose/compose_test.go +++ b/local/e2e/compose/compose_test.go @@ -89,10 +89,15 @@ func TestLocalComposeUp(t *testing.T) { }) - t.Run("check healthcheck display", func(t *testing.T) { + t.Run("check healthcheck output", 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) + + res := c.RunDockerCmd("compose", "-p", projectName, "ps") + res.Assert(t, icmd.Expected{Out: `NAME SERVICE STATUS PORTS`}) + res.Assert(t, icmd.Expected{Out: `compose-e2e-demo_web_1 web running (healthy) 0.0.0.0:90->80/tcp`}) + res.Assert(t, icmd.Expected{Out: `compose-e2e-demo_db_1 db running 5432/tcp`}) }) t.Run("down", func(t *testing.T) { diff --git a/local/e2e/compose/fixtures/sentences/compose.yaml b/local/e2e/compose/fixtures/sentences/compose.yaml index 74d5ce38b..7916d1f4b 100644 --- a/local/e2e/compose/fixtures/sentences/compose.yaml +++ b/local/e2e/compose/fixtures/sentences/compose.yaml @@ -13,4 +13,4 @@ services: - "my-label=test" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:80/"] - interval: 5s + interval: 2s