-
Couldn't load subscription status.
- Fork 9.1k
HDFS-12431. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-hdfs Part14. #7895
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
Conversation
|
🎊 +1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request upgrades JUnit from version 4 to version 5 in part 14 of the hadoop-hdfs test migration. The main purpose is to modernize the testing framework by replacing JUnit 4 annotations, assertions, and test patterns with their JUnit 5 equivalents.
- Updates JUnit 4 imports to JUnit 5 equivalents across multiple test files
- Replaces deprecated
@Before/@Afterwith@BeforeEach/@AfterEach - Migrates from
@Test(timeout=...)to@Testwith@Timeoutannotation - Converts
Assert.*static methods toAssertions.* - Replaces
@Rule ExpectedExceptionpattern withassertThrows()
Reviewed Changes
Copilot reviewed 49 out of 49 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| TestWebHdfsDataLocality.java | Migrated JUnit 4 to 5, replaced ExpectedException with assertThrows |
| TestWebHdfsCreatePermissions.java | Updated annotations and assertions to JUnit 5 |
| TestRollingWindowManager.java | Converted test lifecycle and assertion methods |
| TestRollingWindow.java | Updated JUnit imports and assertion methods |
| TestStartupProgressMetrics.java | Migrated annotations to JUnit 5 |
| TestStartupProgress.java | Updated lifecycle annotations and timeout handling |
| TestXAttrWithSnapshot.java | Replaced ExpectedException with assertThrows pattern |
| TestUpdatePipelineWithSnapshots.java | Simple import update to JUnit 5 |
| TestSnapshottableDirListing.java | Updated annotations and timeout declarations |
| TestSnapshotStatsMXBean.java | Migrated imports and assertions |
| TestSnapshotReplication.java | Updated lifecycle annotations and timeouts |
| TestSnapshotRename.java | Replaced ExpectedException with assertThrows |
| TestSnapshotNameWithInvalidCharacters.java | Updated annotations and timeout handling |
| TestSnapshotMetrics.java | Migrated lifecycle annotations |
| TestSnapshotManager.java | Updated assertions and timeout declarations |
| TestSnapshotListing.java | Converted annotations and timeout handling |
| TestSnapshotFileLength.java | Updated imports and assertion methods with assertj |
| TestSnapshotDiffReport.java | Migrated annotations and assertion methods |
| TestSnapshotDeletion.java | Replaced ExpectedException with assertThrows |
| TestSnapshotBlocksMap.java | Updated lifecycle and assertion methods |
| TestSnapshot.java | Replaced ExpectedException with assertThrows |
| TestSnapRootDescendantDiff.java | Simple import migration |
| TestSetQuotaWithSnapshot.java | Removed ExpectedException rule |
| TestRenameWithSnapshots.java | Updated lifecycle and assertion methods |
| TestRenameWithOrderedSnapshotDeletion.java | Migrated annotations and assertions |
| TestRandomOpsWithSnapshots.java | Updated lifecycle and assertion methods |
| TestOrderedSnapshotDeletionGc.java | Migrated annotations and assertions |
| TestOrderedSnapshotDeletion.java | Updated lifecycle and timeout handling |
| TestOpenFilesWithSnapshot.java | Migrated annotations and assertion methods |
| TestNestedSnapshots.java | Updated lifecycle and assertion methods |
| TestListSnapshot.java | Migrated annotations and timeout handling |
| TestINodeFileUnderConstructionWithSnapshot.java | Updated imports and lifecycle |
| TestGetContentSummaryWithSnapshot.java | Removed ExpectedException rule |
| TestFsShellMoveToTrashWithSnapshots.java | Updated annotations and assertions |
| TestFileWithSnapshotFeature.java | Migrated assertion imports |
| TestFileContextSnapshot.java | Updated lifecycle and assertion methods |
| TestFSImageWithOrderedSnapshotDeletion.java | Migrated annotations and assertions |
| TestDisallowModifyROSnapshot.java | Replaced expected exceptions with assertThrows |
| TestDiffListBySkipList.java | Updated lifecycle and assertion methods |
| TestCheckpointsWithSnapshots.java | Simple annotation migration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
| import static org.junit.jupiter.api.Assertions.fail; | ||
| import static org.assertj.core.api.Assertions.assertThat; |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import should use JUnit 5 assertions instead of AssertJ. Replace import static org.assertj.core.api.Assertions.assertThat; with import static org.junit.jupiter.api.Assertions.assertThat; to maintain consistency with the rest of the migration.
| import static org.assertj.core.api.Assertions.assertThat; | |
| import static org.junit.jupiter.api.Assertions.assertThat; |
| Assertions | ||
| .assertTrue(ioe.getMessage().contains("are not under the" + " same snapshot root.")); |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The string concatenation is split awkwardly across the line break. Consider keeping the complete string on one line or properly formatting the concatenation for better readability.
| Assertions | |
| .assertTrue(ioe.getMessage().contains("are not under the" + " same snapshot root.")); | |
| Assertions.assertTrue(ioe.getMessage().contains("are not under the same snapshot root.")); |
| @Test | ||
| @Timeout(value = 60) |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| aclEntry(ACCESS, USER, "diana", READ_EXECUTE), | ||
| aclEntry(ACCESS, GROUP, NONE) }, returned); | ||
| assertArrayEquals(new AclEntry[]{aclEntry(ACCESS, USER, "diana", READ_EXECUTE), | ||
| aclEntry(ACCESS, GROUP, NONE)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkstyle issue ?
| aclEntry(ACCESS, USER, "bruce", READ_WRITE), | ||
| aclEntry(ACCESS, GROUP, NONE) }, returned); | ||
| assertArrayEquals(new AclEntry[]{aclEntry(ACCESS, USER, "bruce", READ_WRITE), | ||
| aclEntry(ACCESS, GROUP, NONE)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkstyle issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review. I’ll roll out the updates soon.
|
🎊 +1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
@zhtttylz Thanks for the contribution! Merged into trunk. |
|
Thanks @slfan1989 for reviewing and merging! |
Description of PR
JIRA:HDFS-12431. Upgrade JUnit from 4 to 5 in hadoop-hdfs Part14.
How was this patch tested?
Junit Test.
For code changes:
LICENSE,LICENSE-binary,NOTICE-binaryfiles?