Skip to content

Conversation

@adoroszlai
Copy link
Contributor

What changes were proposed in this pull request?

TestNSSummaryTask and related tests are implemented as nested classes. If we run the nested test class directly (either explictly, or via some selector, e.g. package name), these nested classes run into exceptions, because JUnit does not execute the @BeforeClass setup code in the outer class.

This change converts these tests to JUnit5, which handles nested class setup properly.

https://issues.apache.org/jira/browse/HDDS-9252

How was this patch tested?

$ mvn -am -pl :ozone-recon -Dtest='TestNSSummaryTaskWithLegacy$TestProcess' clean test
...
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.hadoop.ozone.recon.tasks.TestNSSummaryTaskWithLegacy
[INFO] Running org.apache.hadoop.ozone.recon.tasks.TestNSSummaryTaskWithLegacy$TestProcess
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.055 s - in org.apache.hadoop.ozone.recon.tasks.TestNSSummaryTaskWithLegacy$TestProcess
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.768 s - in org.apache.hadoop.ozone.recon.tasks.TestNSSummaryTaskWithLegacy
...

$ mvn -am -pl :ozone-recon -Dtest='TestNSSummaryTask$TestReprocess' clean test
[INFO] Running org.apache.hadoop.ozone.recon.tasks.TestNSSummaryTask
[INFO] Running org.apache.hadoop.ozone.recon.tasks.TestNSSummaryTask$TestReprocess
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.04 s - in org.apache.hadoop.ozone.recon.tasks.TestNSSummaryTask$TestReprocess
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.876 s - in org.apache.hadoop.ozone.recon.tasks.TestNSSummaryTask
...

CI:
https://github.com/adoroszlai/hadoop-ozone/actions/runs/6163907068/job/16728478679

@adoroszlai adoroszlai self-assigned this Sep 12, 2023
@adoroszlai
Copy link
Contributor Author

@ArafatKhan2198 alternative fix for HDDS-9252, keeping nested test structure

Copy link
Contributor

@hemantk-12 hemantk-12 left a comment

Choose a reason for hiding this comment

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

LGTM +1

@adoroszlai adoroszlai merged commit 350d932 into apache:master Sep 15, 2023
@adoroszlai adoroszlai deleted the HDDS-9252-junit5 branch September 15, 2023 19:48
@adoroszlai
Copy link
Contributor Author

Thanks @hemantk-12 for the review.

@hevinhsu hevinhsu mentioned this pull request Oct 9, 2025
swamirishi pushed a commit to swamirishi/ozone that referenced this pull request Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants