-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HADOOP-19426. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure-datalake Part2. #7757
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. |
🎊 +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.
+1,LGTM @slfan1989
@anujmodi2021 Could you please help review this PR? Thank you very much! |
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 PR migrates the TestAdlPermissionLive
class from JUnit 4 to JUnit 5 parameterized tests and removes the custom Parallelized
runner.
- Converted JUnit 4 annotations and assertions to their JUnit 5 equivalents.
- Removed the
Parallelized
helper and switched to@ParameterizedTest
with@MethodSource
. - Updated imports and test setup/cleanup methods to use JUnit 5 APIs.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlPermissionLive.java | Migrated tests to JUnit 5 parameterized style, replaced annotations and assertions |
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/common/Parallelized.java | Removed obsolete JUnit 4 parallel runner helper |
Comments suppressed due to low confidence (2)
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlPermissionLive.java:54
- [nitpick] The method name
initTestAdlPermissionLive
is verbose; consider renaming to a more concise name likesetupPermissionTest
to better reflect its role.
public void initTestAdlPermissionLive(FsPermission pTestPermission) throws Exception {
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlPermissionLive.java:84
- Consider annotating this setup method with
@BeforeEach
(JUnit 5) instead of manual invocation in your init helper, to align with JUnit 5 conventions and reduce boilerplate.
public void setUp() throws Exception {
} | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static Collection adlCreateNonRecursiveTestData() |
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.
Use a parameterized generic return type Collection<FsPermission>
for the data provider to avoid raw-type warnings and improve type safety.
public static Collection adlCreateNonRecursiveTestData() | |
public static Collection<FsPermission[]> adlCreateNonRecursiveTestData() |
Copilot uses AI. Check for mistakes.
public static void cleanUp() throws IOException, URISyntaxException { | ||
if (AdlStorageConfiguration.isContractTestEnabled()) { | ||
Assert.assertTrue(AdlStorageConfiguration.createStorageConnector() | ||
assertTrue(AdlStorageConfiguration.createStorageConnector() | ||
.delete(testRoot, true)); |
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] Add a descriptive message to this assertion to clarify failure context, e.g., assertTrue(..., "Failed to clean up testRoot directory")
.
.delete(testRoot, true)); | |
.delete(testRoot, true), "Failed to clean up testRoot directory during cleanup."); |
Copilot uses AI. Check for mistakes.
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.
+1 LGTM
Just need to check if we need to add @beforeeach and @AfterEach at required places or not
.delete(testRoot, true)); | ||
} | ||
} | ||
|
||
@Before |
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.
Do we need @beforeeach here after removing @before?
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.
@anujmodi2021 Thank you for your question! ParameterizedTest in JUnit 5 is a special type of unit test. Unlike JUnit 4, ParameterizedTest requires the initialization of certain parameters directly in the test method, so the setup function is executed at that point. If we add @BeforeEach
, the variables in setup
would not be initialized yet. Therefore, we don't need to add @BeforeEach
; instead, we should call setup
within initTestAdlPermissionLive
.
Thanks a lot @slfan1989 |
@anujmodi2021 @zhtttylz Thank you very much for the review! |
Description of PR
JIRA: HADOOP-19426. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure-datalake Part2.
How was this patch tested?
mvn clean test & junit test.
For code changes:
LICENSE
,LICENSE-binary
,NOTICE-binary
files?