]> Cypherpunks repositories - gostls13.git/commitdiff
net: deflake TestTCPConcurrentAccept
authorMikio Hara <mikioh.mikioh@gmail.com>
Mon, 24 Mar 2014 17:56:37 +0000 (02:56 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Mon, 24 Mar 2014 17:56:37 +0000 (02:56 +0900)
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

index 8859510bfffac4c6aeb0b20cb4c8e844559a13d1..c8c2a9c0d21debfcf761e7dd45cd0366d3f8e1c4 100644 (file)
@@ -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) {