Skip to content

Commit

Permalink
Fix some test flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
rsafonseca committed Sep 13, 2023
1 parent 803d84b commit fe6afa5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
8 changes: 0 additions & 8 deletions acceptor/ws_acceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func mustConnectToWS(t *testing.T, write []byte, w *WSAcceptor, protocol string)
conn, _, err := dialer.Dial(addr, nil)
dialer.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
conn.WriteMessage(websocket.BinaryMessage, write)
defer conn.Close()
return err
}, nil, 30*time.Millisecond, 100*time.Millisecond)
}
Expand All @@ -98,7 +97,6 @@ func TestWSAcceptorListenAndServe(t *testing.T) {
go w.ListenAndServe()
mustConnectToWS(t, table.write, w, "ws")
conn := helpers.ShouldEventuallyReceive(t, c, 100*time.Millisecond).(*WSConn)
defer conn.Close()
assert.NotNil(t, conn)
})
}
Expand All @@ -113,7 +111,6 @@ func TestWSAcceptorListenAndServeTLS(t *testing.T) {
go w.ListenAndServeTLS("./fixtures/server.crt", "./fixtures/server.key")
mustConnectToWS(t, table.write, w, "wss")
conn := helpers.ShouldEventuallyReceive(t, c, 100*time.Millisecond).(*WSConn)
defer conn.Close()
assert.NotNil(t, conn)
})
}
Expand Down Expand Up @@ -142,7 +139,6 @@ func TestWSConnRead(t *testing.T) {
go w.ListenAndServe()
mustConnectToWS(t, table.write, w, "ws")
conn := helpers.ShouldEventuallyReceive(t, c, 100*time.Millisecond).(*WSConn)
defer conn.Close()
b := make([]byte, len(table.write))
n, err := conn.Read(b)
assert.NoError(t, err)
Expand All @@ -161,7 +157,6 @@ func TestWSConnWrite(t *testing.T) {
go w.ListenAndServe()
mustConnectToWS(t, table.write, w, "ws")
conn := helpers.ShouldEventuallyReceive(t, c, 100*time.Millisecond).(*WSConn)
defer conn.Close()
b := make([]byte, len(table.write))
n, err := conn.Write(b)
assert.NoError(t, err)
Expand All @@ -179,7 +174,6 @@ func TestWSConnLocalAddr(t *testing.T) {
go w.ListenAndServe()
mustConnectToWS(t, table.write, w, "ws")
conn := helpers.ShouldEventuallyReceive(t, c, 100*time.Millisecond).(*WSConn)
defer conn.Close()
a := conn.LocalAddr().String()
assert.NotEmpty(t, a)
})
Expand All @@ -195,7 +189,6 @@ func TestWSConnRemoteAddr(t *testing.T) {
go w.ListenAndServe()
mustConnectToWS(t, table.write, w, "ws")
conn := helpers.ShouldEventuallyReceive(t, c, 100*time.Millisecond).(*WSConn)
defer conn.Close()
a := conn.RemoteAddr().String()
assert.NotEmpty(t, a)
})
Expand All @@ -211,7 +204,6 @@ func TestWSConnSetDeadline(t *testing.T) {
go w.ListenAndServe()
mustConnectToWS(t, table.write, w, "ws")
conn := helpers.ShouldEventuallyReceive(t, c, 100*time.Millisecond).(*WSConn)
defer conn.Close()
conn.SetDeadline(time.Now().Add(5 * time.Millisecond))
time.Sleep(10 * time.Millisecond)
_, err := conn.Write(table.write)
Expand Down
4 changes: 2 additions & 2 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func TestAgentSendSerializeErr(t *testing.T) {
sessionPool := session.NewSessionPool()
ag := &agentImpl{ // avoid heartbeat and handshake to fully test serialize
conn: mockConn,
chSend: make(chan pendingWrite, 1),
chSend: make(chan pendingWrite, 10),
encoder: mockEncoder,
heartbeatTimeout: time.Second,
lastAt: time.Now().Unix(),
Expand Down Expand Up @@ -982,7 +982,7 @@ func TestAgentWriteChSend(t *testing.T) {
mockMetricsReporters := []metrics.Reporter{mockMetricsReporter}
ag := &agentImpl{ // avoid heartbeat and handshake to fully test serialize
conn: mockConn,
chSend: make(chan pendingWrite, 1),
chSend: make(chan pendingWrite, 10),
encoder: mockEncoder,
heartbeatTimeout: time.Second,
lastAt: time.Now().Unix(),
Expand Down

0 comments on commit fe6afa5

Please sign in to comment.