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

RobertIndie pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 2b1d6a079f6c0bad5fe6bd29fac2b806266982d8
Author: Matteo Merli <[email protected]>
AuthorDate: Fri May 1 10:32:26 2026 -0700

    [fix][test] Fix flaky SchemaServiceTest.testSchemaRegistryMetrics (#25645)
    
    (cherry picked from commit c3fde128619e562d70c77f9a242242a9617d6d3b)
---
 .../apache/pulsar/broker/service/schema/SchemaServiceTest.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/SchemaServiceTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/SchemaServiceTest.java
index d164559e858..757dfd827ff 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/SchemaServiceTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/SchemaServiceTest.java
@@ -173,12 +173,16 @@ public class SchemaServiceTest extends 
MockedPulsarServiceBaseTest {
         String metricsStr = output.toString(StandardCharsets.UTF_8);
         Multimap<String, Metric> metrics = parseMetrics(metricsStr);
 
+        // The *_ops_failed_total counters are registered on the default 
Prometheus
+        // registry (a JVM-wide static), so labels accumulated by other tests 
in the
+        // same JVM persist here. Only assert that no failed metric exists for 
THIS
+        // test's namespace.
         Collection<Metric> delMetrics = 
metrics.get("pulsar_schema_del_ops_failed_total");
-        Assert.assertEquals(delMetrics.size(), 0);
+        assertThat(delMetrics).noneMatch(metric -> 
namespace.equals(metric.tags.get("namespace")));
         Collection<Metric> getMetrics = 
metrics.get("pulsar_schema_get_ops_failed_total");
-        Assert.assertEquals(getMetrics.size(), 0);
+        assertThat(getMetrics).noneMatch(metric -> 
namespace.equals(metric.tags.get("namespace")));
         Collection<Metric> putMetrics = 
metrics.get("pulsar_schema_put_ops_failed_total");
-        Assert.assertEquals(putMetrics.size(), 0);
+        assertThat(putMetrics).noneMatch(metric -> 
namespace.equals(metric.tags.get("namespace")));
 
         Collection<Metric> deleteLatency = 
metrics.get("pulsar_schema_del_ops_latency_count");
         assertThat(deleteLatency).anySatisfy(metric -> {

Reply via email to