Merge pull request #1016 from gtardif/fix_compose_nw_flaky_e2e

Remove flakyness in compose e2e test : can’t count networks as we have several compose stacks start in //
This commit is contained in:
Nicolas De loof 2020-12-07 09:51:31 +01:00 committed by GitHub
commit e37dd90c22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -35,8 +35,6 @@ func TestLocalComposeUp(t *testing.T) {
const projectName = "compose-e2e-demo" const projectName = "compose-e2e-demo"
networkList := c.RunDockerCmd("--context", "default", "network", "ls")
t.Run("build", func(t *testing.T) { t.Run("build", func(t *testing.T) {
res := c.RunDockerCmd("compose", "build", "-f", "../../tests/composefiles/demo_multi_port.yaml") 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/"}) 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":`)) assert.Assert(t, strings.Contains(output, `"word":`))
res = c.RunDockerCmd("--context", "default", "network", "ls") 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) { 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) _ = c.RunDockerCmd("compose", "down", "--project-name", projectName)
}) })
t.Run("check compose labels", func(t *testing.T) { t.Run("check containers after down", func(t *testing.T) {
networksAfterDown := c.RunDockerCmd("--context", "default", "network", "ls") res := c.RunDockerCmd("ps", "--all")
assert.Equal(t, networkList.Stdout(), networksAfterDown.Stdout()) 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())
}) })
} }