From 5565b43ca3b6651e59f12837a8373fefda7e6f52 Mon Sep 17 00:00:00 2001 From: Dave Cheney <1977446+desdeel2d0m@users.noreply.github.com> Date: Fri, 31 Jul 2015 14:55:01 +1000 Subject: [PATCH] ssh: fix flake in TestHostKeyCert Update golang/go#11811 The increased default concurrency in Go 1.5 showed up a test flake in the TestHostKeyCert test. Under load, when the client provided incorrect data, both sides would race to tear down the connection, which would often lead to the server side, running in its own goroutine to see an unexpected EOF or connection reset. Fix this flake (and the incorrect use of t.Fatalf) by passing the error back to the main goroutine for inspection. This also lets us ignore the expected error in the unsuccessful path Change-Id: I5a95c6d240479e9d537f34177e5ca8023b1b08e9 Reviewed-on: https://go-review.googlesource.com/12916 Reviewed-by: Brad Fitzpatrick --- ssh/certs_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ssh/certs_test.go b/ssh/certs_test.go index d6c4a33..c5f2e53 100644 --- a/ssh/certs_test.go +++ b/ssh/certs_test.go @@ -186,15 +186,15 @@ func TestHostKeyCert(t *testing.T) { defer c1.Close() defer c2.Close() + errc := make(chan error) + go func() { conf := ServerConfig{ NoClientAuth: true, } conf.AddHostKey(certSigner) _, _, _, err := NewServerConn(c1, &conf) - if err != nil { - t.Fatalf("NewServerConn: %v", err) - } + errc <- err }() config := &ClientConfig{ @@ -207,5 +207,10 @@ func TestHostKeyCert(t *testing.T) { if (err == nil) != succeed { t.Fatalf("NewClientConn(%q): %v", name, err) } + + err = <-errc + if (err == nil) != succeed { + t.Fatalf("NewServerConn(%q): %v", name, err) + } } }