Skip to content

Report unit test coverage across modules - #5891

Merged
penghuo merged 2 commits into
opensearch-project:mainfrom
LantaoJin:cross-module-coverage
Oct 16, 2026
Merged

penghuo merged 2 commits into
opensearch-project:mainfrom
LantaoJin:cross-module-coverage

Conversation

@LantaoJin

@LantaoJin LantaoJin commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Description

JaCoCo coverage is reported per Gradle module, so a class gets credit only for the tests in its own module. Much of core is tested from other modules: CalciteRelNodeVisitor is tested almost only by ppl's CalcitePPL*Test, yet core's report shows 11 of its 2,622 lines covered. As a result, codecov/patch reports about 0% for any PR that changes such a class, however well the PR tests it (for example #5783).

This PR adds a root task, jacocoAggregatedReport. It merges the unit test execution data of every module that applies jacoco (including opensearch-sql-plugin and integ-test:test, whose tests also run code in other modules) and reports it against the classes of the 12 modules whose reports CI uploaded so far. It reuses each module's own jacocoTestReport class directories, so the per-module excludes (for example core's **/ast/**) still apply, and the set of reported classes does not change. The CI unit job now runs the task and uploads this one XML to Codecov instead of the 12 per-module files.

Line coverage of the same 41,033 lines, after ./gradlew test on JDK 21:

Module Before (own tests) After (all unit tests)
core 11,359 / 20,257 (56.1%) 16,383 / 20,257 (80.9%)
async-query-core 1,826 / 1,993 (91.6%) 1,839 / 1,993 (92.3%)
ppl 2,734 / 2,991 (91.4%) 2,737 / 2,991 (91.5%)
api 376 / 447 (84.1%) 377 / 447 (84.3%)
other 8 modules unchanged unchanged
Total 27,094 / 41,033 (66.0%) 32,135 / 41,033 (78.3%)

CalciteRelNodeVisitor goes from 11 to 2,271 of 2,622 lines, and JoinAndLookupUtils from 14 to 55 of 55. Branch coverage goes from 55.2% to 67.2%.

What does not change:

  • The per-module jacocoTestReport reports and the per-module jacocoTestCoverageVerification rules. They still measure each module's own tests, so no threshold changes meaning.
  • Which classes are reported: legacy, common and opensearch-sql-plugin classes stay out, as before.
  • Integration tests: they run against a separate cluster JVM and are still not measured.

Related Issues

Resolves #5890

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Per-module JaCoCo reports credit a class only with the tests of its own
module, so classes tested from another module show as uncovered. For
example core's CalciteRelNodeVisitor is tested almost only by ppl's
CalcitePPL*Test, and its report showed 11 of 2,622 lines covered, which
made codecov/patch report about 0% for any change to it.

Add a root jacocoAggregatedReport task that merges the unit test
execution data of every module that applies jacoco and reports it
against the same classes, with the same excludes, as the per-module
reports that CI uploaded. CI now uploads this one report to Codecov.

Line coverage of those classes goes from 27,094 / 41,033 (66.0%) to
32,135 / 41,033 (78.3%); core alone from 56.1% to 80.9%, and
CalciteRelNodeVisitor to 2,271 of 2,622 lines. The per-module reports
and jacocoTestCoverageVerification rules are unchanged.

Signed-off-by: Lantao Jin <ltjin@amazon.com>
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit e2fdc20)

Here are some key observations to aid the review process:

🧪 No relevant tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Latest suggestions up to e2fdc20
Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Avoid redundant test execution

The jacocoAggregatedReport task depends on test results, but running it after build
may cause redundant test execution. Consider running jacocoAggregatedReport
separately or ensure it doesn't duplicate the test execution already performed by
build.

.github/workflows/sql-test-and-build-workflow.yml [109]

-./gradlew --continue build jacocoAggregatedReport -x spotlessCheck -x integTest -x tracingIntegTest -x yamlRestTest -x doctest
+./gradlew --continue build -x spotlessCheck -x integTest -x tracingIntegTest -x yamlRestTest -x doctest
+./gradlew --continue jacocoAggregatedReport
Suggestion importance[1-10]: 3

__

Why: While the suggestion raises a valid concern about potential redundant test execution, the improved_code splits the command into two separate lines which may not be the optimal solution. The build task typically includes test, and jacocoAggregatedReport depends on test results, so running them together in one command is often intentional and efficient. The suggestion's impact is minor as the current approach is a common pattern in Gradle workflows.

Low

Previous suggestions

Suggestions up to commit 4c9ce10
CategorySuggestion                                                                                                                                    Impact
General
Separate coverage report generation from build

The jacocoAggregatedReport task may fail if the build task fails, causing the
workflow to not upload coverage reports. Consider running jacocoAggregatedReport
separately after the build to ensure coverage is generated even if some tests fail.

.github/workflows/sql-test-and-build-workflow.yml [109]

-./gradlew --continue build jacocoAggregatedReport -x spotlessCheck -x integTest -x tracingIntegTest -x yamlRestTest -x doctest
+./gradlew --continue build -x spotlessCheck -x integTest -x tracingIntegTest -x yamlRestTest -x doctest
+./gradlew --continue jacocoAggregatedReport
Suggestion importance[1-10]: 4

__

Why: The suggestion to separate jacocoAggregatedReport from build has merit for resilience, but the --continue flag already ensures the workflow continues on failures. The separation would add minimal value since coverage generation requires successful test execution anyway, which is part of the build task.

Low

@LantaoJin LantaoJin added the infrastructure Changes to infrastructure, testing, CI/CD, pipelines, etc. label Oct 16, 2026
jacocoAggregatedReport depended on every unit test task, so with
--continue a single failing test skipped the report, and the CI
coverage upload failed with no file to upload. The per-module reports
it replaces are finalizers of the test task and are still generated
when a test fails, because JaCoCo writes the execution data anyway.

Order the report after the test tasks instead of depending on them,
as each module's jacocoTestReport does. It no longer runs the tests by
itself, so the developer guide now says ./gradlew test
jacocoAggregatedReport. The CI command already runs build first.

Signed-off-by: Lantao Jin <ltjin@amazon.com>
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.15%. Comparing base (4d98393) to head (e2fdc20).
⚠️ Report is 3 commits behind head on main.

❌ Your project check has failed because the head coverage (75.15%) is below the target coverage (99.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@              Coverage Diff              @@
##               main    #5891       +/-   ##
=============================================
+ Coverage     63.87%   75.15%   +11.27%     
- Complexity     9091    10328     +1237     
=============================================
  Files           962      962               
  Lines         41033    41048       +15     
  Branches       4668     4669        +1     
=============================================
+ Hits          26211    30848     +4637     
+ Misses        13944     8904     -5040     
- Partials        878     1296      +418     
Flag Coverage Δ
sql-engine 75.15% <ø> (+11.27%) ⬆️

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

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

🚀 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.

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit e2fdc20

@LantaoJin

LantaoJin commented Oct 16, 2026 •

Copy link
Copy Markdown
Member Author

Codecov Report

✅ All modified and coverable lines are covered by tests. ✅ Project coverage is 75.15%. Comparing base (4d98393) to head (4c9ce10). ⚠️ Report is 3 commits behind head on main.

❌ Your project check has failed because the head coverage (75.15%) is below the target coverage (99.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

@@              Coverage Diff              @@
##               main    #5891       +/-   ##
=============================================
+ Coverage     63.87%   75.15%   +11.27%     
- Complexity     9091    10328     +1237     
=============================================
  Files           962      962               
  Lines         41033    41048       +15     
  Branches       4668     4669        +1     
=============================================
+ Hits          26211    30848     +4637     
+ Misses        13944     8904     -5040     
- Partials        878     1296      +418     

Flag Coverage Δ
sql-engine 75.15% <ø> (+11.27%) ⬆️
Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:

Non-blocking: Next is to change the target coverage. This PR increase the coverage to 75%+ from 63%. How about 75% as short term target and 85% for long term?

@penghuo
penghuo merged commit 3c77ca1 into opensearch-project:main Oct 16, 2026
48 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Changes to infrastructure, testing, CI/CD, pipelines, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Count unit tests from every module in code coverage, so codecov/patch is not 0% for code tested from another module

2 participants