Skip to content

Commit

Permalink
ssh: fix flake in TestHostKeyCert
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
davecheney committed Aug 2, 2015
1 parent 93b9801 commit d8af72f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ssh/certs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
}
}
}

0 comments on commit d8af72f

Please sign in to comment.