This is an automated email from the ASF dual-hosted git repository.
zixuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 0309a99ea26 [fix][test] Fix flaky InterceptorsTest and
ProduceWithMessageIdTest (#25499)
0309a99ea26 is described below
commit 0309a99ea266fd7235f4db62d3109d96643d155c
Author: Matteo Merli <[email protected]>
AuthorDate: Wed Apr 8 20:41:12 2026 -0700
[fix][test] Fix flaky InterceptorsTest and ProduceWithMessageIdTest (#25499)
---
.../src/test/java/org/apache/pulsar/client/api/InterceptorsTest.java | 4 +++-
.../java/org/apache/pulsar/client/impl/ProduceWithMessageIdTest.java | 5 +++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/InterceptorsTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/InterceptorsTest.java
index 3690ad80f3f..44c5361061f 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/InterceptorsTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/InterceptorsTest.java
@@ -1008,7 +1008,9 @@ public class InterceptorsTest extends
SharedPulsarBaseTest {
produceAndConsume(msgCount * 2, producer, reader);
Assert.assertFalse(interceptor1.encounterException.get());
Assert.assertTrue(interceptor2.encounterException.get());
- Assert.assertTrue(interceptor3.encounterException.get());
+ // interceptor3 is on reader2 (listener-based), so messages are
delivered asynchronously
+ Awaitility.await().untilAsserted(
+ () ->
Assert.assertTrue(interceptor3.encounterException.get()));
Assert.assertNull(reader.readNext(3, TimeUnit.SECONDS));
}
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProduceWithMessageIdTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProduceWithMessageIdTest.java
index ff72f23b0a2..8616b4c4907 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProduceWithMessageIdTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProduceWithMessageIdTest.java
@@ -18,7 +18,6 @@
*/
package org.apache.pulsar.client.impl;
-import static
org.apache.pulsar.client.impl.AbstractBatchMessageContainer.INITIAL_BATCH_BUFFER_SIZE;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletableFuture;
@@ -178,7 +177,9 @@ public class ProduceWithMessageIdTest extends
SharedPulsarBaseTest {
cdl.await();
OpSendMsgStats opSendMsgStats = sendMsgStats.get();
- Assert.assertEquals(opSendMsgStats.getUncompressedSize(),
totalUncompressedSize + INITIAL_BATCH_BUFFER_SIZE);
+ // uncompressedSize includes both message payloads and the batch
buffer allocation,
+ // whose actual capacity depends on the allocator and may differ from
the requested size
+ Assert.assertTrue(opSendMsgStats.getUncompressedSize() >=
totalUncompressedSize);
Assert.assertEquals(opSendMsgStats.getSequenceId(), 0);
Assert.assertEquals(opSendMsgStats.getRetryCount(), 1);
Assert.assertEquals(opSendMsgStats.getBatchSizeByte(), totalReadabled);