From: Brad Fitzpatrick Date: Sun, 15 Feb 2015 17:35:18 +0000 (-0800) Subject: net: deflake TestPacketConn, increase timeout X-Git-Tag: go1.5beta1~1791 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=aedee3087008fd5493976a3c9e732f2fa5deb883;p=gostls13.git net: deflake TestPacketConn, increase timeout Tests sometimes failed with: ok mime/internal/quotedprintable 0.606s ok mime/multipart 0.819s --- FAIL: TestPacketConn (0.10s) packetconn_test.go:96: PacketConn.ReadFrom failed: WSARecvFrom udp 127.0.0.1:64156: i/o timeout FAIL FAIL net 3.602s ok net/http 4.618s ok net/http/cgi 0.576s Theory: 100 ms is too short. Small timer granularity on Wnidows, or an allocation in the middle causing a GC sometimes? In any case, increase it to 500 ms. Change-Id: I48cc4d600eb168db9f85c0fd05335dd630254c3c Reviewed-on: https://go-review.googlesource.com/4922 Reviewed-by: Alex Brainman --- diff --git a/src/net/packetconn_test.go b/src/net/packetconn_test.go index f00eacaf36..5bbfc0f82a 100644 --- a/src/net/packetconn_test.go +++ b/src/net/packetconn_test.go @@ -74,9 +74,9 @@ func TestPacketConn(t *testing.T) { } defer closer(c1, netstr[0], tt.addr1, tt.addr2) c1.LocalAddr() - c1.SetDeadline(time.Now().Add(100 * time.Millisecond)) - c1.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) - c1.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)) + c1.SetDeadline(time.Now().Add(500 * time.Millisecond)) + c1.SetReadDeadline(time.Now().Add(500 * time.Millisecond)) + c1.SetWriteDeadline(time.Now().Add(500 * time.Millisecond)) c2, err := ListenPacket(tt.net, tt.addr2) if err != nil { @@ -84,14 +84,14 @@ func TestPacketConn(t *testing.T) { } defer closer(c2, netstr[0], tt.addr1, tt.addr2) c2.LocalAddr() - c2.SetDeadline(time.Now().Add(100 * time.Millisecond)) - c2.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) - c2.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)) + c2.SetDeadline(time.Now().Add(500 * time.Millisecond)) + c2.SetReadDeadline(time.Now().Add(500 * time.Millisecond)) + c2.SetWriteDeadline(time.Now().Add(500 * time.Millisecond)) + rb2 := make([]byte, 128) if _, err := c1.WriteTo(wb, c2.LocalAddr()); err != nil { t.Fatalf("PacketConn.WriteTo failed: %v", err) } - rb2 := make([]byte, 128) if _, _, err := c2.ReadFrom(rb2); err != nil { t.Fatalf("PacketConn.ReadFrom failed: %v", err) } @@ -130,9 +130,9 @@ func TestConnAndPacketConn(t *testing.T) { } defer closer(c1, netstr[0], tt.addr1, tt.addr2) c1.LocalAddr() - c1.SetDeadline(time.Now().Add(100 * time.Millisecond)) - c1.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) - c1.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)) + c1.SetDeadline(time.Now().Add(500 * time.Millisecond)) + c1.SetReadDeadline(time.Now().Add(500 * time.Millisecond)) + c1.SetWriteDeadline(time.Now().Add(500 * time.Millisecond)) c2, err := Dial(tt.net, c1.LocalAddr().String()) if err != nil { @@ -141,9 +141,9 @@ func TestConnAndPacketConn(t *testing.T) { defer c2.Close() c2.LocalAddr() c2.RemoteAddr() - c2.SetDeadline(time.Now().Add(100 * time.Millisecond)) - c2.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) - c2.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)) + c2.SetDeadline(time.Now().Add(500 * time.Millisecond)) + c2.SetReadDeadline(time.Now().Add(500 * time.Millisecond)) + c2.SetWriteDeadline(time.Now().Add(500 * time.Millisecond)) if _, err := c2.Write(wb); err != nil { t.Fatalf("Conn.Write failed: %v", err)