Skip to content

[Testing] Add unit tests to verify Prometheus JMX template regexp patterns#18414

Merged
noob-se7en merged 3 commits intoapache:masterfrom
Akanksha-kedia:test/prometheus-template-regexp-13588
May 8, 2026
Merged

[Testing] Add unit tests to verify Prometheus JMX template regexp patterns#18414
noob-se7en merged 3 commits intoapache:masterfrom
Akanksha-kedia:test/prometheus-template-regexp-13588

Conversation

@Akanksha-kedia
Copy link
Copy Markdown
Contributor

@Akanksha-kedia Akanksha-kedia commented May 4, 2026

Summary

Closes #13588

Adds PrometheusTemplateRegexpTest to validate the regexp patterns defined in the JMX exporter YAML config files under docker/images/pinot/etc/jmx_prometheus_javaagent/configs/.

What the tests cover:

  • Parameterized validity check: verifies all patterns in broker.yml, server.yml, controller.yml, minion.yml, and pinot.yml compile as valid Java regexps — catches syntax errors introduced when editing these files
  • Targeted correctness tests for key patterns across all four components, verifying that expected JMX metric name strings match and that capture groups produce correct label values (table, tableType, database, taskType, measurement type)

Test cases included:

Component Pattern JMX sample
Broker meter scoped to tableNameWithType pinot.broker.myTable_REALTIME.queries
Broker meter scoped to tableNameWithType + database prefix pinot.broker.myDb.myTable_OFFLINE.queries
Broker meter scoped to rawTableName pinot.broker.myTable.queries
Broker global gauge pinot.broker.totalDocuments
Server meter scoped to tableNameWithType pinot.server.myTable_OFFLINE.segmentUploadFailure
Server gauge scoped to tableNameWithType + partition pinot.server.queries.myTable_REALTIME.3
Controller task-type gauge pinot.controller.numMinionTasksInProgress.SegmentGenerationAndPush
Controller meter scoped to tableNameWithType pinot.controller.myTable_OFFLINE.segmentUploadFailure
Minion meter scoped to tableNameWithType + taskType pinot.minion.myTable_REALTIME.SegmentGenerationAndPush.segmentUploadFailure
Minion meter scoped to table/id pinot.minion.myTable.numberOfSegmentsQueued

Test plan

  • mvn -pl pinot-common test -Dtest=PrometheusTemplateRegexpTest passes locally
  • Parameterized test covers all 5 YAML files

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.64%. Comparing base (642f07d) to head (33f3ec3).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18414      +/-   ##
============================================
+ Coverage     63.55%   63.64%   +0.09%     
- Complexity     1717     1735      +18     
============================================
  Files          3252     3254       +2     
  Lines        199051   199446     +395     
  Branches      30838    30977     +139     
============================================
+ Hits         126503   126942     +439     
+ Misses        62471    62365     -106     
- Partials      10077    10139      +62     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-21 63.64% <ø> (+0.09%) ⬆️
temurin 63.64% <ø> (+0.09%) ⬆️
unittests 63.64% <ø> (+0.09%) ⬆️
unittests1 55.69% <ø> (+0.06%) ⬆️
unittests2 34.96% <ø> (+0.02%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@noob-se7en noob-se7en left a comment

Choose a reason for hiding this comment

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

1 major test correctness.

@noob-se7en noob-se7en added testing Related to tests or test infrastructure test-coverage Adds or improves test coverage labels May 4, 2026
Akanksha-kedia and others added 2 commits May 5, 2026 16:06
…terns

Adds PrometheusTemplateRegexpTest to validate the regexp patterns defined
in the JMX exporter YAML config files under
docker/images/pinot/etc/jmx_prometheus_javaagent/configs/.

Tests include:
- Parameterized validity check: all patterns in broker.yml, server.yml,
  controller.yml, minion.yml, and pinot.yml compile as valid Java regexps
- Targeted correctness tests for key patterns (broker/server/controller/minion),
  verifying that expected JMX metric name strings match and that capture
  groups produce the expected table, tableType, database, taskType, and
  measurement labels

Fixes apache#13588
Replace hardcoded inline pattern strings in targeted tests with calls to
a new loadPattern(configFile, ruleIndex) helper that reads the pattern
directly from the YAML file under test. This ensures tests always validate
the live pattern — editing the YAML without updating the test will now
surface a failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Akanksha-kedia Akanksha-kedia force-pushed the test/prometheus-template-regexp-13588 branch from b95bb16 to 7e75603 Compare May 5, 2026 10:36
@Akanksha-kedia
Copy link
Copy Markdown
Contributor Author

@noob-se7en @xiangfu0 pleased help to review

Copy link
Copy Markdown
Contributor

@noob-se7en noob-se7en left a comment

Choose a reason for hiding this comment

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

1 medium test robustness.

@Akanksha-kedia
Copy link
Copy Markdown
Contributor Author

@noob-se7en @xiangfu0 please merge

@noob-se7en
Copy link
Copy Markdown
Contributor

@noob-se7en @xiangfu0 please merge

@Akanksha-kedia there is still 1 open comment, will request to address/reply to it before just marking it resolved.

Replace loadPattern(file, index) with loadPatternByName(file, name),
which finds the rule whose YAML `name` field matches (e.g. "pinot_$1_$6_$7").
Inserting or reordering a rule in the config files no longer silently
shifts indices and causes tests to match a wrong rule.

Addresses review comment from noob-se7en on apache#18414.
@noob-se7en noob-se7en merged commit ac8b901 into apache:master May 8, 2026
18 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test-coverage Adds or improves test coverage testing Related to tests or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test to verify the prometheus template regexp

4 participants