From 4f1aecf2c408da2ddf6fd2b4542b9fe1d239c5e3 Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Tue, 25 Mar 2014 02:56:37 +0900 Subject: [PATCH] net: deflake TestTCPConcurrentAccept Some platform that implements inp_localgroup-like shared internet protocol control block group looks a bit sensitive about transport layer protocol's address:port reuse. Sometimes it rejects a TCP SYN packet using TCP RST, and sometimes silence. For now, until test case refactoring, we admit few Dial failures on TestTCPConcurrentAccept as a workaround. Update #7400 Update #7541 LGTM=jsing R=jsing CC=golang-codereviews https://golang.org/cl/75920043 --- src/pkg/net/tcp_test.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/pkg/net/tcp_test.go b/src/pkg/net/tcp_test.go index 8859510bff..c8c2a9c0d2 100644 --- a/src/pkg/net/tcp_test.go +++ b/src/pkg/net/tcp_test.go @@ -445,9 +445,6 @@ func TestIPv6LinkLocalUnicastTCP(t *testing.T) { } func TestTCPConcurrentAccept(t *testing.T) { - if runtime.GOOS == "solaris" { - t.Skip("skipping on Solaris, see issue 7400") - } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) ln, err := Listen("tcp", "127.0.0.1:0") if err != nil { @@ -468,15 +465,25 @@ func TestTCPConcurrentAccept(t *testing.T) { wg.Done() }() } - for i := 0; i < 10*N; i++ { - c, err := Dial("tcp", ln.Addr().String()) + attempts := 10 * N + fails := 0 + d := &Dialer{Timeout: 200 * time.Millisecond} + for i := 0; i < attempts; i++ { + c, err := d.Dial("tcp", ln.Addr().String()) if err != nil { - t.Fatalf("Dial failed: %v", err) + fails++ + } else { + c.Close() } - c.Close() } ln.Close() wg.Wait() + if fails > attempts/9 { // see issues 7400 and 7541 + t.Fatalf("too many Dial failed: %v", fails) + } + if fails > 0 { + t.Logf("# of failed Dials: %v", fails) + } } func TestTCPReadWriteMallocs(t *testing.T) { -- 2.48.1