Skip to content

Commit

Permalink
Add flush to TestNoRaceWSNoCorruptionWithFrameSizeLimit test
Browse files Browse the repository at this point in the history
The test often fails because the subscription connections
end up becoming slow consumers.

Signed-off-by: Waldemar Quevedo <wally@nats.io>
  • Loading branch information
wallyqs committed May 19, 2024
1 parent e10cf16 commit e9512cb
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions server/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4356,6 +4356,7 @@ func TestWSWithPartialWrite(t *testing.T) {
func testWSNoCorruptionWithFrameSizeLimit(t *testing.T, total int) {
tmpl := `
listen: "127.0.0.1:-1"
http: "127.0.0.1:-1"
cluster {
name: "local"
port: -1
Expand All @@ -4381,17 +4382,22 @@ func testWSNoCorruptionWithFrameSizeLimit(t *testing.T, total int) {

checkClusterFormed(t, s1, s2, s3)

nc3 := natsConnect(t, fmt.Sprintf("ws://127.0.0.1:%d", o3.Websocket.Port))
errCh := make(chan error, 1)
disconnectCB := nats.DisconnectErrHandler(func(_ *nats.Conn, err error) {
if err != nil {
errCh <- fmt.Errorf("Client with subscription got an unexpected disconnect error: %w", err)
}
})
nc3 := natsConnect(t, fmt.Sprintf("ws://127.0.0.1:%d", o3.Websocket.Port), disconnectCB)
defer nc3.Close()

nc2 := natsConnect(t, fmt.Sprintf("ws://127.0.0.1:%d", o2.Websocket.Port))
nc2 := natsConnect(t, fmt.Sprintf("ws://127.0.0.1:%d", o2.Websocket.Port), disconnectCB)
defer nc2.Close()

payload := make([]byte, 100000)
payload := make([]byte, 100_000)
for i := 0; i < len(payload); i++ {
payload[i] = 'A' + byte(i%26)
}
errCh := make(chan error, 1)
doneCh := make(chan struct{}, 1)
count := int32(0)

Expand Down Expand Up @@ -4453,6 +4459,7 @@ func testWSNoCorruptionWithFrameSizeLimit(t *testing.T, total int) {
case err := <-errCh:
t.Fatalf("Error: %v", err)
default:
nc1.FlushTimeout(5 * time.Millisecond)
}
}
}
Expand Down

0 comments on commit e9512cb

Please sign in to comment.