[fix][test] Fix flaky SchemaServiceTest.testSchemaRegistryMetrics - #25645
Merged
Conversation
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
approved these changes
May 1, 2026
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
pulsar_schema_*_ops_failed_totalcounters inSchemaRegistryStatsare 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@BeforeMethodbroker restarts. So assertingcollection.size() == 0fails non-deterministically whenever any prior code path observed a failed op.Filter the assertion to the test's own 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