[fix][test] Add timeout to initial receives in ResendRequestTest.testSharedSingleAckedPartitionedTopic#25828
Open
merlimat wants to merge 1 commit into
Open
Conversation
…SharedSingleAckedPartitionedTopic
The test creates a partitioned topic with 3 partitions, produces 10
messages via RoundRobinPartition (so ~3-4 per partition), and subscribes
two consumers with a Shared subscription and receiverQueueSize=7. Because
the receive queue is larger than the per-partition message count, the
broker can dispatch every message to whichever consumer connected first,
leaving the other consumer's queue empty.
The test then calls consumer1.receive() followed by consumer2.receive()
with no timeout. If consumer2 got nothing, that second call blocks
forever and the test times out:
org.testng.internal.thread.ThreadTimeoutException: Method ... didn't finish within the time-out 60000
...
at GrowableArrayBlockingQueue.take(GrowableArrayBlockingQueue.java:200)
at MultiTopicsConsumerImpl.internalReceive(MultiTopicsConsumerImpl.java:388)
at ConsumerBase.receive(ConsumerBase.java:282)
at ResendRequestTest.testSharedSingleAckedPartitionedTopic(ResendRequestTest.java:517)
Use timeouts on the initial receives like the loop below does. The
totalMessages assertion at the end of the receive loop still verifies
that both consumers together got all 10 messages, so we don't lose
coverage by allowing a null on the first receive.
Example failure:
https://scans.gradle.com/s/by57j4rphce62/tests/task/:pulsar-broker:test/details/org.apache.pulsar.broker.service.ResendRequestTest/testSharedSingleAckedPartitionedTopic/2/output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ResendRequestTest.testSharedSingleAckedPartitionedTopiccreates a partitioned topic with 3 partitions, produces 10 messages viaRoundRobinPartition(so ~3-4 per partition), and subscribes two consumers with aSharedsubscription andreceiverQueueSize=7. Because the receive queue is larger than the per-partition message count, the broker can dispatch every message to whichever consumer connected first, leaving the other consumer's queue empty.The test then calls the two initial receives without a timeout:
If
consumer2got nothing, that second call blocks forever and the test trips the 60stimeOut:Example failure: https://scans.gradle.com/s/by57j4rphce62/tests/task/:pulsar-broker:test/details/org.apache.pulsar.broker.service.ResendRequestTest/testSharedSingleAckedPartitionedTopic/2/output
Modifications
Use timeouts on the initial receives, matching the loop below them. The
assertEquals(messageCount1 + messageCount2, totalMessages)check at the end of the receive loop still verifies that both consumers together got all 10 messages, so coverage isn't lost by tolerating a null on the very first receive.Verifying this change
This change is already covered by
ResendRequestTest.testSharedSingleAckedPartitionedTopic. Locally I ran 5 times with--rerun-tasks; all passed.Does this pull request potentially affect one of the following parts: