You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/08/20 00:40:25 UTC
[GitHub] [hadoop] smengcl commented on pull request #3304: HADOOP-14693. Test PR: Ran rewrite plugin on hadoop-hdfs module to upgrade to JUnit 5
smengcl commented on pull request #3304:
URL: https://github.com/apache/hadoop/pull/3304#issuecomment-902345346
Thanks @aajisaka for trying out the _rewrite_ plugin.
Overall the tool seems to be doing a pretty good job.
1. In the case of `TestHDFSContractPathHandle.java`, It somehow attempts to import `org.junit.jupiter.api.Assertions.super` and rearrange the argument order to `super()` call, which is kinda amusing.
```diff
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/contract/hdfs/TestHDFSContractPathHandle.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/contract/hdfs/TestHDFSContractPathHandle.java
index c65a60b18b1..a5ea66782cf 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/contract/hdfs/TestHDFSContractPathHandle.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/contract/hdfs/TestHDFSContractPathHandle.java
@@ -21,11 +21,13 @@
...
+import static org.junit.jupiter.api.Assertions.super;
+
/**
* Verify HDFS compliance with {@link org.apache.hadoop.fs.PathHandle}
* semantics.
@@ -35,15 +37,15 @@
public TestHDFSContractPathHandle(String testname, Options.HandleOpt[] opts,
boolean serialized) {
- super(testname, opts, serialized);
+ super(opts, serialized, testname);
}
...
```
2. In the case of `TestDiskBalancerRPC.java`, it does remove JUnit 4's `ExpectedException` variables, but it doesn't seem to rewrite the `ExpectedException.expect` usages.
For instance,
```java
@Rule
public ExpectedException thrown = ExpectedException.none();
...
@Test
public void testSubmitPlanWithInvalidVersion() throws Exception {
...
thrown.expect(DiskBalancerException.class);
thrown.expect(new DiskBalancerResultVerifier(Result.INVALID_PLAN_VERSION));
dataNode.submitDiskBalancerPlan(planHash, planVersion, PLAN_FILE,
plan.toJson(), false);
```
should have been rewritten into something like:
```java
final DiskBalancerException thrown =
Assertions.assertThrows(DiskBalancerException.class, () -> {
dataNode.submitDiskBalancerPlan(planHash, planVersion, PLAN_FILE,
plan.toJson(), false);
});
Assertions.assertEquals(thrown.getResult(), Result.INVALID_PLAN_VERSION);
```
... and some other interesting changes by rewrite plugin.
I have included some fixes my fork of your branch that addresses some of those rewrite errors I mentioned above: https://github.com/smengcl/hadoop/compare/rewrite-junit5-hdfs..aajisaka:rewrite-junit5-hdfs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org