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
diff --git a/src/pkg/net/tcp_test.go b/src/pkg/net/tcp_test.go
index 8859510..c8c2a9c 100644
--- a/src/pkg/net/tcp_test.go
+++ b/src/pkg/net/tcp_test.go
@@ -445,9 +445,6 @@
}
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 @@
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) {