Skip to content

Commit

Permalink
Add flush to TestNoRaceWSNoCorruptionWithFrameSizeLimit test
Browse files Browse the repository at this point in the history
Signed-off-by: Waldemar Quevedo <wally@nats.io>
  • Loading branch information
wallyqs committed May 19, 2024
1 parent e10cf16 commit 29b5970
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 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 @@ -4365,6 +4366,7 @@ func testWSNoCorruptionWithFrameSizeLimit(t *testing.T, total int) {
listen: "127.0.0.1:-1"
no_tls: true
}
max_pending: 64mb
`
conf1 := createConfFile(t, []byte(fmt.Sprintf(tmpl, _EMPTY_)))
s1, o1 := RunServerWithConfig(conf1)
Expand All @@ -4381,13 +4383,20 @@ 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))
errCB := nats.ErrorHandler(func(_ *nats.Conn, _ *nats.Subscription, err error){
t.Logf("Error: %v", err)
})
disconnectCB := nats.DisconnectErrHandler(func(_ *nats.Conn, err error){
t.Logf("Disconnect: %v", err)
})

nc3 := natsConnect(t, fmt.Sprintf("ws://127.0.0.1:%d", o3.Websocket.Port), errCB, 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), errCB, 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)
}
Expand Down Expand Up @@ -4429,7 +4438,7 @@ func testWSNoCorruptionWithFrameSizeLimit(t *testing.T, total int) {

checkSubInterest(t, s1, globalAccountName, "foo", time.Second)

nc1 := natsConnect(t, fmt.Sprintf("ws://127.0.0.1:%d", o1.Websocket.Port))
nc1 := natsConnect(t, fmt.Sprintf("ws://127.0.0.1:%d", o1.Websocket.Port), errCB, disconnectCB)
defer nc1.Close()
natsFlush(t, nc1)

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

0 comments on commit 29b5970

Please sign in to comment.