This is an automated email from the ASF dual-hosted git repository.

aajisaka pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 049d1762bd1 MAPREDUCE-7428. Fix failing MapReduce tests due to the 
JUnit upgrades in WebServicesTestUtils (#5243)
049d1762bd1 is described below

commit 049d1762bd1c3ccfcbbedd73e0c5da50f2a3a6f3
Author: Akira Ajisaka <aajis...@apache.org>
AuthorDate: Sat Dec 24 04:33:35 2022 +0900

    MAPREDUCE-7428. Fix failing MapReduce tests due to the JUnit upgrades in 
WebServicesTestUtils (#5243)
    
    Removed JUnit APIs from WebServicesTestUtils and TestContainerLogsUtils.
    They are used by MapReduce modules as well as YARN modules, so the
    APIs need to be removed to upgrade the JUnit version on a per-module basis.
    Also, this effectively reverts the prior fix in #5209 because it didn't 
actually
    fix the issue.
---
 .../hadoop-mapreduce-client-app/pom.xml             | 20 --------------------
 .../yarn/logaggregation/TestContainerLogsUtils.java | 21 ++++++++++++++-------
 .../hadoop/yarn/webapp/WebServicesTestUtils.java    | 17 ++++++-----------
 3 files changed, 20 insertions(+), 38 deletions(-)

diff --git 
a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
 
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
index ff268cbd049..e3b3511c0ce 100644
--- 
a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
+++ 
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
@@ -124,26 +124,6 @@
       <artifactId>assertj-core</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.junit.platform</groupId>
-      <artifactId>junit-platform-launcher</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.junit.jupiter</groupId>
-      <artifactId>junit-jupiter-api</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.junit.jupiter</groupId>
-      <artifactId>junit-jupiter-engine</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.junit.platform</groupId>
-      <artifactId>junit-platform-launcher</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
   <build>
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestContainerLogsUtils.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestContainerLogsUtils.java
index cce8a62ba1e..0cb71b59909 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestContainerLogsUtils.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestContainerLogsUtils.java
@@ -38,10 +38,10 @@ import 
org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileCo
 import 
org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
 import 
org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
 /**
  * This class contains several utility functions for log aggregation tests.
+ * Any assertion libraries shouldn't be used here because this class is used by
+ * multiple modules including MapReduce.
  */
 public final class TestContainerLogsUtils {
 
@@ -75,13 +75,16 @@ public final class TestContainerLogsUtils {
     if (fs.exists(rootLogDirPath)) {
       fs.delete(rootLogDirPath, true);
     }
-    assertTrue(fs.mkdirs(rootLogDirPath));
+    fs.mkdirs(rootLogDirPath);
+    // Make sure the target dir is created. If not, FileNotFoundException is 
thrown
+    fs.getFileStatus(rootLogDirPath);
     Path appLogsDir = new Path(rootLogDirPath, appId.toString());
     if (fs.exists(appLogsDir)) {
       fs.delete(appLogsDir, true);
     }
-    assertTrue(fs.mkdirs(appLogsDir));
-
+    fs.mkdirs(appLogsDir);
+    // Make sure the target dir is created. If not, FileNotFoundException is 
thrown
+    fs.getFileStatus(appLogsDir);
     createContainerLogInLocalDir(appLogsDir, containerToContent, fs, fileName);
     // upload container logs to remote log dir
 
@@ -95,7 +98,9 @@ public final class TestContainerLogsUtils {
     if (fs.exists(path) && deleteRemoteLogDir) {
       fs.delete(path, true);
     }
-    assertTrue(fs.mkdirs(path));
+    fs.mkdirs(path);
+    // Make sure the target dir is created. If not, FileNotFoundException is 
thrown
+    fs.getFileStatus(path);
     uploadContainerLogIntoRemoteDir(ugi, conf, rootLogDirList, nodeId, appId,
         containerToContent.keySet(), path);
   }
@@ -111,7 +116,9 @@ public final class TestContainerLogsUtils {
       if (fs.exists(containerLogsDir)) {
         fs.delete(containerLogsDir, true);
       }
-      assertTrue(fs.mkdirs(containerLogsDir));
+      fs.mkdirs(containerLogsDir);
+      // Make sure the target dir is created. If not, FileNotFoundException is 
thrown
+      fs.getFileStatus(containerLogsDir);
       Writer writer =
           new FileWriter(new File(containerLogsDir.toString(), fileName));
       writer.write(content);
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java
index f803c5313ca..ce93b06e70a 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java
@@ -27,8 +27,7 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class WebServicesTestUtils {
   public static long getXmlLong(Element element, String name) {
@@ -121,28 +120,24 @@ public class WebServicesTestUtils {
   }
 
   public static void checkStringMatch(String print, String expected, String 
got) {
-    assertTrue(
-        got.matches(expected),
-        print + " doesn't match, got: " + got + " expected: " + expected);
+    assertThat(got).as(print).matches(expected);
   }
 
   public static void checkStringContains(String print, String expected, String 
got) {
-    assertTrue(
-        got.contains(expected),
-        print + " doesn't contain expected string, got: " + got + " expected: 
" + expected);
+    assertThat(got).as(print).contains(expected);
   }
 
   public static void checkStringEqual(String print, String expected, String 
got) {
-    assertEquals(got, expected);
+    assertThat(got).as(print).isEqualTo(expected);
   }
 
   public static void assertResponseStatusCode(StatusType expected,
       StatusType actual) {
-    assertResponseStatusCode(null, expected, actual);
+    assertThat(expected.getStatusCode()).isEqualTo(actual.getStatusCode());
   }
 
   public static void assertResponseStatusCode(String errmsg,
       StatusType expected, StatusType actual) {
-    assertEquals(expected.getStatusCode(), actual.getStatusCode(), errmsg);
+    
assertThat(expected.getStatusCode()).withFailMessage(errmsg).isEqualTo(actual.getStatusCode());
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to