From 3676bd8569f4df28a4f850cd4814e3558d8c03f6 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 5 Dec 2017 11:25:37 -0800 Subject: [PATCH] TestBuildNotVerboseFailureRemote: fix false positive I got the following test failure on power: 10:00:56 10:00:56 ---------------------------------------------------------------------- 10:00:56 FAIL: docker_cli_build_test.go:3521: DockerSuite.TestBuildNotVerboseFailureRemote 10:00:56 10:00:56 docker_cli_build_test.go:3536: 10:00:56 c.Fatal(fmt.Errorf("Test[%s] expected that quiet stderr and verbose stdout are equal; quiet [%v], verbose [%v]", name, quietResult.Stderr(), result.Combined())) 10:00:56 ... Error: Test[quiet_build_wrong_remote] expected that quiet stderr and verbose stdout are equal; quiet [ 10:00:56 unable to prepare context: unable to download remote context http://something.invalid: Get http://something.invalid: dial tcp: lookup something.invalid on 172.29.128.11:53: no such host 10:00:56 ], verbose [unable to prepare context: unable to download remote context http://something.invalid: Get http://something.invalid: dial tcp: lookup something.invalid on 8.8.8.8:53: no such host 10:00:56 ] 10:00:56 10:00:56 10:00:56 ---------------------------------------------------------------------- The reason is, either more than one name server is configured, or nameserver was reconfigured in the middle of the test run. In any case, different nameserver IP in an error messages should not be treated as a failure, so let's strip those out. Signed-off-by: Kir Kolyshkin --- integration-cli/docker_cli_build_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index e60f4d5a6e..8ae5e05ed8 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -3532,7 +3532,17 @@ func (s *DockerSuite) TestBuildNotVerboseFailureRemote(c *check.C) { result.Assert(c, icmd.Expected{ ExitCode: 1, }) - if strings.TrimSpace(quietResult.Stderr()) != strings.TrimSpace(result.Combined()) { + + // An error message should contain name server IP and port, like this: + // "dial tcp: lookup something.invalid on 172.29.128.11:53: no such host" + // The IP:port need to be removed in order to not trigger a test failur + // when more than one nameserver is configured. + // While at it, also strip excessive newlines. + normalize := func(msg string) string { + return strings.TrimSpace(regexp.MustCompile("[1-9][0-9.]+:[0-9]+").ReplaceAllLiteralString(msg, "")) + } + + if normalize(quietResult.Stderr()) != normalize(result.Combined()) { c.Fatal(fmt.Errorf("Test[%s] expected that quiet stderr and verbose stdout are equal; quiet [%v], verbose [%v]", name, quietResult.Stderr(), result.Combined())) } }