This is an automated email from the ASF dual-hosted git repository.

mimaison pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d55e0cb2c5c KAFKA-20545: Fix flaky MirrorConnectorsIntegrationSSLTest 
testConnectorMetrics* tests (#22291)
d55e0cb2c5c is described below

commit d55e0cb2c5c33403c0121cb3e4dd32c51b16ff54
Author: nileshkumar3 <[email protected]>
AuthorDate: Mon May 18 07:19:53 2026 -0500

    KAFKA-20545: Fix flaky MirrorConnectorsIntegrationSSLTest 
testConnectorMetrics* tests (#22291)
    
    Clear the static `CollectAllMetricsReporter.METRICS` map in `@AfterEach`
    and at the start of `testConnectorMetrics` so metric counts are not
    polluted by prior tests in the same JVM.
    
    Fixes flaky failures where `assertMetrics` never reached the expected
    156 source / 4 checkpoint metrics and `waitForCondition` timed out with
    "Unable to find the MirrorMaker metrics".
    
    Reviewers: Mickael Maison <[email protected]>, Murali Basani
    <[email protected]>
---
 .../mirror/integration/MirrorConnectorsIntegrationBaseTest.java    | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git 
a/connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/MirrorConnectorsIntegrationBaseTest.java
 
b/connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/MirrorConnectorsIntegrationBaseTest.java
index d73caf96307..56d2bf49740 100644
--- 
a/connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/MirrorConnectorsIntegrationBaseTest.java
+++ 
b/connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/MirrorConnectorsIntegrationBaseTest.java
@@ -287,6 +287,8 @@ public class MirrorConnectorsIntegrationBaseTest {
             } finally {
                 Exit.resetExitProcedure();
                 Exit.resetHaltProcedure();
+                // Shared by all CollectAllMetricsReporter instances; avoid 
cross-test accumulation.
+                CollectAllMetricsReporter.METRICS.clear();
             }
         }
     }
@@ -1628,5 +1630,10 @@ public class MirrorConnectorsIntegrationBaseTest {
         public void metricChange(KafkaMetric metric) {
             METRICS.put(metric.metricName(), metric);
         }
+
+        @Override
+        public void metricRemoval(KafkaMetric metric) {
+            METRICS.remove(metric.metricName());
+        }
     }
 }

Reply via email to