Skip to content

Commit 909c877

Browse files
committed
Fix timeout tests on linux and windows
1 parent e33f9c9 commit 909c877

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

statsd/uds_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,13 @@ func TestUDSStreamPartialWrite(t *testing.T) {
203203

204204
// Force a connection
205205
w.ensureConnection()
206+
conn, err := listener.Accept()
207+
defer conn.Close()
208+
206209
// Set a very low buffer size to force a partial write, but still enough to write the header
207-
w.conn.(*net.UnixConn).SetWriteBuffer(8)
210+
w.conn.(*net.UnixConn).SetWriteBuffer(1)
211+
// On linux we need to force a timeout this way
212+
w.connectTimeout = -1 * time.Millisecond
208213

209214
msg := []byte("some data")
210215
n, err := w.Write(msg)

statsd/uds_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ import (
1010

1111
// newUDSWriter is disabled on Windows, SOCK_DGRAM are still unavailable but
1212
// SOCK_STREAM should work once implemented in the agent (https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/)
13-
func newUDSWriter(_ string, _ time.Duration, _ string) (Transport, error) {
13+
func newUDSWriter(_ string, _ time.Duration, _ time.Duration, _ string) (Transport, error) {
1414
return nil, fmt.Errorf("Unix socket is not available on Windows")
1515
}

0 commit comments

Comments
 (0)