Skip to content

[fix][test] Fix flaky PrometheusMetricsTest.testBrokerMetrics #24042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025

Conversation

pdolif
Copy link
Contributor

@pdolif pdolif commented Mar 1, 2025

Fixes #24041

Motivation

The test contains the following assertion:

assertEquals(systemCursorOutBytes, systemInBytes)

systemInBytes is set to the value of the pulsar_broker_in_bytes_total metric for the system topic.

systemCursorOutBytes is currently set to the value of

  • pulsar_out_bytes_total of the system reader subscription or
  • pulsar_out_bytes_total of the compaction subscription.

The pulsar_out_bytes_total metric is always present for both the system reader and compaction subscription, but the order is not deterministic. Therefore, it happens that instead of setting systemCursorOutBytes to pulsar_out_bytes_total for the system reader subscription, it is set to pulsar_out_bytes_total of the compaction subscription (which always seems to be 0).

double systemCursorOutBytes = 0.0;
for (Metric metric : topicLevelBytesOutTotal) {
    if (metric.tags.get("subscription").startsWith(SystemTopicNames.SYSTEM_READER_PREFIX)
            || metric.tags.get("subscription").equals(Compactor.COMPACTION_SUBSCRIPTION)) {
        systemCursorOutBytes = metric.value;
    }
}

Modifications

Remove the metric.tags.get("subscription").equals(Compactor.COMPACTION_SUBSCRIPTION) case.

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: pdolif#8

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 1, 2025
@Technoboy- Technoboy- added this to the 4.1.0 milestone Mar 4, 2025
@Technoboy- Technoboy- closed this Mar 4, 2025
@Technoboy- Technoboy- reopened this Mar 4, 2025
@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.36%. Comparing base (bbc6224) to head (3aac8f4).
Report is 1090 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24042      +/-   ##
============================================
+ Coverage     73.57%   74.36%   +0.78%     
+ Complexity    32624     2379   -30245     
============================================
  Files          1877     1861      -16     
  Lines        139502   144804    +5302     
  Branches      15299    16538    +1239     
============================================
+ Hits         102638   107679    +5041     
+ Misses        28908    28678     -230     
- Partials       7956     8447     +491     
Flag Coverage Δ
inttests 26.73% <ø> (+2.15%) ⬆️
systests 23.09% <ø> (-1.23%) ⬇️
unittests 73.87% <ø> (+1.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1059 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great job @pdolif

@lhotari lhotari merged commit 694969f into apache:master Mar 14, 2025
107 of 108 checks passed
lhotari pushed a commit that referenced this pull request Mar 17, 2025
lhotari pushed a commit that referenced this pull request Mar 17, 2025
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Mar 29, 2025
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Mar 31, 2025
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.

Flaky-test: PrometheusMetricsTest.testBrokerMetrics
6 participants