You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "void-ptr974 (via GitHub)" <gi...@apache.org> on 2026/06/25 14:42:07 UTC

[PR] [fix][test] Stabilize non-persistent geo-replication test [pulsar]

void-ptr974 opened a new pull request, #26090:
URL: https://github.com/apache/pulsar/pull/26090

   ### Motivation
   
   `GeoReplicationTest.testTopicReplication` can fail for the `non-persistent` variant because the test sends messages immediately after creating the producer and consumer. Non-persistent replication can drop messages when the remote replicator producer is not connected yet, so the test can time out waiting for messages on the remote cluster.
   
   Fixes #15913.
   
   ### Modifications
   
   - Wait for every partition replicator to the remote cluster to be present and connected before sending messages for the non-persistent variant.
   - Keep the persistent and non-persistent variants in the existing data provider.
   - Use constants for the partition and message counts.
   - Increase the test timeout to account for the explicit replicator readiness wait.
   
   ### Verification
   
   - `./gradlew :tests:integration:compileTestJava --max-workers=1`
   - `./gradlew :tests:integration:checkstyleTest --max-workers=1`
   
   The container integration test was not run locally because the local Docker context is not available to Testcontainers.


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][test] Fix flaky GeoReplicationTest.testTopicReplication [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- merged PR #26090:
URL: https://github.com/apache/pulsar/pull/26090


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][test] Fix flaky GeoReplicationTest.testTopicReplication [pulsar]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #26090:
URL: https://github.com/apache/pulsar/pull/26090#discussion_r3489484604


##########
tests/integration/src/test/java/org/apache/pulsar/tests/integration/messaging/GeoReplicationTest.java:
##########
@@ -82,12 +87,12 @@ public void testTopicReplication(String domain) throws Exception {
         String topic = domain + "://public/default/testTopicReplication-" + UUID.randomUUID();
         Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
             try {
-                admin.topics().createPartitionedTopic(topic, 10);
+                admin.topics().createPartitionedTopic(topic, PARTITION_COUNT);
             } catch (Exception e) {
                 log.error().attr("topic", topic).exception(e).log("Failed to create partitioned topic .");
                 Assert.fail("Failed to create partitioned topic " + topic);
             }
-            Assert.assertEquals(admin.topics().getPartitionedTopicMetadata(topic).partitions, 10);
+            Assert.assertEquals(admin.topics().getPartitionedTopicMetadata(topic).partitions, PARTITION_COUNT);
         });

Review Comment:
   The `Awaitility` block mixes topic creation with metadata verification. If `createPartitionedTopic` succeeds but the metadata assertion fails transiently, the next poll will hit a conflict/"already exists" error and `Assert.fail(...)`, making the await loop unable to ever succeed. Handle the conflict case (already created) and continue to the metadata assertion so the await can converge.



##########
tests/integration/src/test/java/org/apache/pulsar/tests/integration/messaging/GeoReplicationTest.java:
##########
@@ -120,15 +125,19 @@ public void testTopicReplication(String domain) throws Exception {
                 .attr("topic", topic)
                 .log("Successfully create consumer in cluster for topic .");
 
-        for (int i = 0; i < 10; i++) {
+        if ("non-persistent".equals(domain)) {
+            waitForNonPersistentReplicators(admin, topic, cluster2);
+        }
+
+        for (int i = 0; i < MESSAGES; i++) {
             p.send(String.format("Message [%d]", i).getBytes(StandardCharsets.UTF_8));
         }
         log.info()
                 .attr("cluster", cluster1)
                 .attr("topic", topic)
                 .log("Successfully produce message to cluster for topic .");
 
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < MESSAGES; i++) {
             Message<byte[]> message = c.receive(10, TimeUnit.SECONDS);
             Assert.assertNotNull(message);
         }

Review Comment:
   Messages are received but never acknowledged. For persistent topics this leaves unacked backlog behind and can add noise to the integration environment (even if the topic is random). Acknowledge each message after the null check.



##########
tests/integration/src/test/java/org/apache/pulsar/tests/integration/messaging/GeoReplicationTest.java:
##########
@@ -137,4 +146,20 @@ public void testTopicReplication(String domain) throws Exception {
                 .attr("topic", topic)
                 .log("Successfully consume message from cluster for topic .");
     }
+
+    private void waitForNonPersistentReplicators(PulsarAdmin admin, String topic, String remoteCluster)
+            throws Exception {
+        TopicName topicName = TopicName.get(topic);
+        Awaitility.await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
+            for (int i = 0; i < PARTITION_COUNT; i++) {
+                String partitionName = topicName.getPartition(i).toString();
+                ReplicatorStats replicatorStats = admin.topics()
+                        .getStats(partitionName)
+                        .getReplication()
+                        .get(remoteCluster);
+                Assert.assertNotNull(replicatorStats);
+                Assert.assertTrue(replicatorStats.isConnected());
+            }
+        });

Review Comment:
   `waitForNonPersistentReplicators` can end up hammering the admin endpoint because Awaitility's default poll interval is very small, and each poll does `PARTITION_COUNT` HTTP calls. Setting an explicit poll interval (e.g., 1s) reduces load and helps avoid making the test itself flaky under CI contention.



##########
tests/integration/src/test/java/org/apache/pulsar/tests/integration/messaging/GeoReplicationTest.java:
##########
@@ -44,6 +46,9 @@
 @CustomLog
 public class GeoReplicationTest extends PulsarGeoClusterTestBase {
 
+    private static final int PARTITION_COUNT = 10;
+    private static final int MESSAGES = 10;

Review Comment:
   The constant name `MESSAGES` is a bit ambiguous compared to the convention used in other integration tests (e.g., `MESSAGE_COUNT` in `tests/integration/.../cli/PerfToolTest.java` and `ClientToolTest.java`). Consider renaming to `MESSAGE_COUNT` (or `MESSAGE_COUNT_PER_TEST`) to make intent clearer and consistent.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org