Skip to content

Commit

Permalink
fix: fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleiphir2769 committed Jul 15, 2023
1 parent 5277465 commit cbac56e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pulsar/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2061,20 +2061,16 @@ func TestMemLimitRejectProducerMessagesWithChunking(t *testing.T) {
DisableBatching: true,
EnableChunking: true,
MaxPendingMessages: 1,
ChunkMaxMessageSize: 5 * 1024,
ChunkMaxMessageSize: 1024,
SendTimeout: 2 * time.Second,
})

producer1.SendAsync(context.Background(), &ProducerMessage{
Payload: make([]byte, 5*1024),
}, func(id MessageID, message *ProducerMessage, e error) {})

// producer2 will reserve 5*1024+1 bytes and then release 1 byte (release the second chunk)
// producer2 will reserve 2*1024 bytes and then release 1024 byte (release the second chunk)
// because it reaches MaxPendingMessages in chunking
_, _ = producer2.Send(context.Background(), &ProducerMessage{
Payload: make([]byte, 5*1024+1),
Payload: make([]byte, 2*1024),
})
assert.Equal(t, int64(10*1024), c.(*client).memLimit.CurrentUsage())
assert.Equal(t, int64(1024), c.(*client).memLimit.CurrentUsage())
}

func TestMemLimitContextCancel(t *testing.T) {
Expand Down

0 comments on commit cbac56e

Please sign in to comment.