Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue 873] Fix flaky test TestRLQMultiTopics() and TestRLQSpecifiedPartitionTopic() #874

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions pulsar/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (

var (
adminURL = "http://localhost:8080"
lookupURL = "pulsar://localhost:6650"
lookupURL = "pulsar://10.105.7.225:6650"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right to change to a fixed private IP? Would that work in CI and other localhost environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have find the real reason. #875

It's a consumer bug caused by availablePermitsCh.

)

func TestProducerConsumer(t *testing.T) {
Expand Down Expand Up @@ -1421,7 +1421,8 @@ func TestRLQMultiTopics(t *testing.T) {
subName := fmt.Sprintf("sub01-%d", time.Now().Unix())
maxRedeliveries := 2
N := 100
ctx := context.Background()
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()

client, err := NewClient(ClientOptions{URL: lookupURL})
assert.Nil(t, err)
Expand All @@ -1440,15 +1441,6 @@ func TestRLQMultiTopics(t *testing.T) {
assert.Nil(t, err)
defer rlqConsumer.Close()

// subscribe DLQ Topic
dlqConsumer, err := client.Subscribe(ConsumerOptions{
Topic: subName + "-DLQ",
SubscriptionName: subName,
SubscriptionInitialPosition: SubscriptionPositionEarliest,
})
assert.Nil(t, err)
defer dlqConsumer.Close()

// create multi producers
producer01, err := client.CreateProducer(ProducerOptions{Topic: topic01})
assert.Nil(t, err)
Expand Down Expand Up @@ -1483,6 +1475,15 @@ func TestRLQMultiTopics(t *testing.T) {
assert.Error(t, err)
assert.Nil(t, msg)

// subscribe DLQ Topic
dlqConsumer, err := client.Subscribe(ConsumerOptions{
Topic: subName + "-DLQ",
SubscriptionName: subName,
SubscriptionInitialPosition: SubscriptionPositionEarliest,
})
assert.Nil(t, err)
defer dlqConsumer.Close()

// 3. Create consumer on the DLQ topic to verify the routing
dlqReceived := 0
for dlqReceived < 2*N {
Expand Down Expand Up @@ -1547,15 +1548,6 @@ func TestRLQSpecifiedPartitionTopic(t *testing.T) {
assert.Nil(t, err)
defer rlqConsumer.Close()

// subscribe DLQ Topic
dlqConsumer, err := client.Subscribe(ConsumerOptions{
Topic: subName + "-DLQ",
SubscriptionName: subName,
SubscriptionInitialPosition: SubscriptionPositionEarliest,
})
assert.Nil(t, err)
defer dlqConsumer.Close()

// create producer
producer, err := client.CreateProducer(ProducerOptions{Topic: normalTopic})
assert.Nil(t, err)
Expand Down Expand Up @@ -1584,6 +1576,15 @@ func TestRLQSpecifiedPartitionTopic(t *testing.T) {
assert.Error(t, err)
assert.Nil(t, msg)

// subscribe DLQ Topic
dlqConsumer, err := client.Subscribe(ConsumerOptions{
Topic: subName + "-DLQ",
SubscriptionName: subName,
SubscriptionInitialPosition: SubscriptionPositionEarliest,
})
assert.Nil(t, err)
defer dlqConsumer.Close()

// 3. Create consumer on the DLQ topic to verify the routing
dlqReceived := 0
for dlqReceived < N {
Expand Down