From ff1808644c99d8ce2dea1c2e06a8b2bfe8944824 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 7 Dec 2020 09:31:32 +0100 Subject: [PATCH] =?UTF-8?q?Remove=20flakyness=20in=20compose=20e2e=20test?= =?UTF-8?q?=20:=20can=E2=80=99t=20count=20networks=20as=20we=20have=20seve?= =?UTF-8?q?ral=20compose=20stacks=20start=20in=20//?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guillaume Tardif --- local/e2e/compose_test.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/local/e2e/compose_test.go b/local/e2e/compose_test.go index e7fa0d83c..806c179f8 100644 --- a/local/e2e/compose_test.go +++ b/local/e2e/compose_test.go @@ -35,8 +35,6 @@ func TestLocalComposeUp(t *testing.T) { const projectName = "compose-e2e-demo" - networkList := c.RunDockerCmd("--context", "default", "network", "ls") - t.Run("build", func(t *testing.T) { res := c.RunDockerCmd("compose", "build", "-f", "../../tests/composefiles/demo_multi_port.yaml") res.Assert(t, icmd.Expected{Out: "COPY words.sql /docker-entrypoint-initdb.d/"}) @@ -57,7 +55,7 @@ func TestLocalComposeUp(t *testing.T) { assert.Assert(t, strings.Contains(output, `"word":`)) res = c.RunDockerCmd("--context", "default", "network", "ls") - assert.Equal(t, len(Lines(res.Stdout())), len(Lines(networkList.Stdout()))+1) + res.Assert(t, icmd.Expected{Out: projectName + "_default"}) }) t.Run("check compose labels", func(t *testing.T) { @@ -81,9 +79,14 @@ func TestLocalComposeUp(t *testing.T) { _ = c.RunDockerCmd("compose", "down", "--project-name", projectName) }) - t.Run("check compose labels", func(t *testing.T) { - networksAfterDown := c.RunDockerCmd("--context", "default", "network", "ls") - assert.Equal(t, networkList.Stdout(), networksAfterDown.Stdout()) + t.Run("check containers after down", func(t *testing.T) { + res := c.RunDockerCmd("ps", "--all") + assert.Assert(t, !strings.Contains(res.Combined(), projectName), res.Combined()) + }) + + t.Run("check networks after down", func(t *testing.T) { + res := c.RunDockerCmd("--context", "default", "network", "ls") + assert.Assert(t, !strings.Contains(res.Combined(), projectName), res.Combined()) }) }