Skip to content

[fix][test] Fix flaky SchemaServiceTest.testSchemaRegistryMetrics - #25645

Merged
lhotari merged 1 commit into
apache:masterfrom
merlimat:fix-flaky-schema-service-test
May 1, 2026
Merged

[fix][test] Fix flaky SchemaServiceTest.testSchemaRegistryMetrics#25645
lhotari merged 1 commit into
apache:masterfrom
merlimat:fix-flaky-schema-service-test

Conversation

@merlimat

@merlimat merlimat commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary

The pulsar_schema_*_ops_failed_total counters in SchemaRegistryStats are registered on the default Prometheus registry — a JVM-wide static. Labels accumulated by other tests (or by broker-internal failed schema gets unrelated to this test) survive across @BeforeMethod broker restarts. So asserting collection.size() == 0 fails non-deterministically whenever any prior code path observed a failed op.

Filter the assertion to the test's own namespace:

assertThat(getMetrics).noneMatch(metric -> namespace.equals(metric.tags.get("namespace")));

This catches the bug the test was meant to catch (this test's ops shouldn't increment failed counters) without being polluted by global counter state.

Test plan

  • Test passes locally with the change applied
  • CI is green

The pulsar_schema_*_ops_failed_total counters in SchemaRegistryStats are
registered on the default Prometheus registry — a JVM-wide static. Labels
accumulated by other tests (or by broker-internal failed gets unrelated
to this test) survive across @BeforeMethod broker restarts, so asserting
collection.size() == 0 fails whenever any prior code path observed a
failed op.

Filter the assertion to the test's own namespace: noneMatch metric where
namespace tag equals the test's namespace. Catches the bug the test was
meant to catch (this test's ops shouldn't increment failed counters)
without being polluted by global counter state.
@lhotari
lhotari merged commit c3fde12 into apache:master May 1, 2026
79 of 83 checks passed
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request May 6, 2026
@lhotari lhotari added this to the 5.0.0-M1 milestone Jun 12, 2026
lhotari pushed a commit that referenced this pull request Jun 29, 2026
RobertIndie pushed a commit that referenced this pull request Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants