lhotari commented on code in PR #25445:
URL: https://github.com/apache/pulsar/pull/25445#discussion_r3016978702
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/api/KeySharedSubscriptionTest.java:
##########
@@ -820,7 +808,7 @@ public void
testRemoveFirstConsumer(KeySharedImplementationType impl) throws Exc
}
// C2 will not be able to receive any messages until C1 is done
processing whatever he got prefetched
- assertNull(c2.receive(1, TimeUnit.SECONDS));
+ assertNull(c2.receive(200, TimeUnit.MILLISECONDS));
Review Comment:
This change might not be necessary to speed up the test. In the past, using
short timeouts has caused flakiness when CI runner is under heavy load. I'm not
sure if it would happen any more since GitHub Action Runners are more
performant (2 vCPU -> 4 vCPU) and have more RAM (6GB->16GB).
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/api/KeySharedSubscriptionTest.java:
##########
@@ -2441,14 +2422,11 @@ public void
testOrderingAfterReconnects(KeySharedImplementationType impl) throws
remainingMessageValues.add(i);
}
- Thread.sleep(2 * pauseTime);
Review Comment:
These were also needed to reproduce the issue.
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/api/KeySharedSubscriptionTest.java:
##########
@@ -1775,37 +1766,27 @@ public void
testStickyKeyRangesRestartConsumers(KeySharedImplementationType impl
})
.subscribe();
- Future producerFuture = pulsar.getExecutor().submit(() -> {
- try {
- try (Producer<String> producer =
pulsarClient.newProducer(Schema.STRING)
- .topic(topic)
- .enableBatching(false)
- .create()) {
- for (int i = 0; i < numMessages; i++) {
- String key = "test" + i;
- sentMessages.add(key);
- producer.newMessage()
- .key(key)
- .value("test" + i).
- send();
- Thread.sleep(100);
- }
- }
- } catch (Throwable t) {
- log.error("error", t);
- }
- });
+ @Cleanup
+ Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
+ .topic(topic)
+ .enableBatching(false)
+ .create();
+ for (int i = 0; i < numMessages; i++) {
+ String key = "test" + i;
+ sentMessages.add(key);
+ producer.newMessage()
+ .key(key)
+ .value("test" + i)
+ .sendAsync();
+ }
+ producer.flush();
// wait for some messages to be received by both of the consumers
count1.await(5, TimeUnit.SECONDS);
count2.await(5, TimeUnit.SECONDS);
consumer1.close();
consumer2.close();
- // this sleep is to trigger a race condition that happens
- // when there are some messages that cannot be dispatched while
consuming
- Thread.sleep(3000);
Review Comment:
Some of the sleeps were required to trigger race conditions that reproduced
real production issues. Without them, the tests won't catch regressions of
these fixes in the future. Another option is to move very slow tests to only
run in a scheduled job on the master branch to catch such regressions. That
approach might be useful for some cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]