Remove flaky TestReadLoopMaxDataSize
This commit is contained in:
parent
3a7d331967
commit
862116c050
1 changed files with 0 additions and 54 deletions
|
|
@ -1,11 +1,9 @@
|
||||||
package udp
|
package udp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -303,58 +301,6 @@ func TestShutdown(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadLoopMaxDataSize(t *testing.T) {
|
|
||||||
if runtime.GOOS == "darwin" {
|
|
||||||
// sudo sysctl -w net.inet.udp.maxdgram=65507
|
|
||||||
t.Skip("Skip test on darwin as the maximum dgram size is set to 9216 bytes by default")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Theoretical maximum size of data in a UDP datagram.
|
|
||||||
// 65535 − 8 (UDP header) − 20 (IP header).
|
|
||||||
dataSize := 65507
|
|
||||||
|
|
||||||
doneCh := make(chan struct{})
|
|
||||||
|
|
||||||
l, err := Listen(net.ListenConfig{}, "udp", ":0", 3*time.Second)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
err := l.Close()
|
|
||||||
require.NoError(t, err)
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
defer close(doneCh)
|
|
||||||
|
|
||||||
conn, err := l.Accept()
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
buffer := make([]byte, dataSize)
|
|
||||||
|
|
||||||
n, err := conn.Read(buffer)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
assert.Equal(t, dataSize, n)
|
|
||||||
}()
|
|
||||||
|
|
||||||
c, err := net.Dial("udp", l.Addr().String())
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
data := make([]byte, dataSize)
|
|
||||||
|
|
||||||
_, err = rand.Read(data)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
_, err = c.Write(data)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-doneCh:
|
|
||||||
case <-time.Tick(5 * time.Second):
|
|
||||||
t.Fatal("Timeout waiting for datagram read")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// requireEcho tests that the conn session is live and functional,
|
// requireEcho tests that the conn session is live and functional,
|
||||||
// by writing data through it, and expecting the same data as a response when reading on it.
|
// by writing data through it, and expecting the same data as a response when reading on it.
|
||||||
// It fatals if the read blocks longer than timeout,
|
// It fatals if the read blocks longer than timeout,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue