Skip to content

Commit 5f0e32d

Browse files
committed
Fix TestBatchMessageIDWithAckTracker
1 parent 1c39b66 commit 5f0e32d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pulsar/consumer_partition_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package pulsar
2020
import (
2121
"sync"
2222
"testing"
23+
"time"
2324

2425
"github.com/apache/pulsar-client-go/pulsar/internal"
2526
"github.com/apache/pulsar-client-go/pulsar/internal/crypto"
@@ -121,14 +122,18 @@ func TestBatchMessageIDWithAckTracker(t *testing.T) {
121122

122123
// ensure the tracker was set on the message id
123124
var messageIDs []*trackingMessageID
124-
for i := 0; i < 10; i++ {
125+
running := true
126+
for running {
125127
select {
126128
case m := <-pc.queueCh.outCh:
127129
id := m.ID().(*trackingMessageID)
128130
assert.NotNil(t, id.tracker)
129131
messageIDs = append(messageIDs, id)
130-
default:
131-
break
132+
if len(messageIDs) == 10 {
133+
running = false
134+
}
135+
case <-time.After(5 * time.Second):
136+
running = false
132137
}
133138
}
134139

0 commit comments

Comments
 (0)