You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by in...@apache.org on 2020/02/27 21:23:20 UTC

[hadoop] branch branch-3.2 updated: YARN-10161. TestRouterWebServicesREST is corrupting STDOUT. Contributed by Jim Brennan.

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

inigoiri pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.2 by this push:
     new 733f9b7  YARN-10161. TestRouterWebServicesREST is corrupting STDOUT. Contributed by Jim Brennan.
733f9b7 is described below

commit 733f9b76b6cf0ccc4c366ea39e90c72594b0e7a8
Author: Inigo Goiri <in...@apache.org>
AuthorDate: Thu Feb 27 13:18:30 2020 -0800

    YARN-10161. TestRouterWebServicesREST is corrupting STDOUT. Contributed by Jim Brennan.
    
    (cherry picked from commit a43510e21d01e6c78e98e7ad9469cbea70a66466)
---
 .../hadoop/yarn/server/router/webapp/JavaProcess.java   | 11 +++++++----
 .../server/router/webapp/TestRouterWebServicesREST.java | 17 ++++++++++++++---
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/JavaProcess.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/JavaProcess.java
index 6c0938c..e2611d9 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/JavaProcess.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/JavaProcess.java
@@ -29,11 +29,12 @@ public class JavaProcess {
 
   private Process process = null;
 
-  public JavaProcess(Class<?> clazz) throws IOException, InterruptedException {
-    this(clazz, null);
+  public JavaProcess(Class<?> clazz, File output)
+      throws IOException, InterruptedException {
+    this(clazz, null, output);
   }
 
-  public JavaProcess(Class<?> clazz, List<String> addClasspaths)
+  public JavaProcess(Class<?> clazz, List<String> addClasspaths, File output)
       throws IOException, InterruptedException {
     String javaHome = System.getProperty("java.home");
     String javaBin =
@@ -48,7 +49,9 @@ public class JavaProcess {
     String className = clazz.getCanonicalName();
     ProcessBuilder builder =
         new ProcessBuilder(javaBin, "-cp", classpath, className);
-    builder.inheritIO();
+    builder.redirectInput(ProcessBuilder.Redirect.INHERIT);
+    builder.redirectOutput(output);
+    builder.redirectError(output);
     process = builder.start();
   }
 
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java
index cf4a044..2f4c7ab 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java
@@ -70,6 +70,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
+import java.io.File;
 import java.io.IOException;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
@@ -196,17 +197,27 @@ public class TestRouterWebServicesREST {
   public static void setUp() throws Exception {
     conf = new YarnConfiguration();
 
+    File baseDir = GenericTestUtils.getTestDir("processes");
+    baseDir.mkdirs();
+    String baseName = TestRouterWebServicesREST.class.getSimpleName();
+
+    File rmOutput = new File(baseDir, baseName + "-rm.log");
+    rmOutput.createNewFile();
     List<String> addClasspath = new LinkedList<>();
     addClasspath.add("../hadoop-yarn-server-timelineservice/target/classes");
-    rm = new JavaProcess(ResourceManager.class, addClasspath);
+    rm = new JavaProcess(ResourceManager.class, addClasspath, rmOutput);
     rmAddress = getRMWebAppURLWithScheme(conf);
     waitWebAppRunning(rmAddress, RM_WEB_SERVICE_PATH);
 
-    router = new JavaProcess(Router.class);
+    File routerOutput = new File(baseDir, baseName + "-router.log");
+    routerOutput.createNewFile();
+    router = new JavaProcess(Router.class, routerOutput);
     routerAddress = getRouterWebAppURLWithScheme(conf);
     waitWebAppRunning(routerAddress, RM_WEB_SERVICE_PATH);
 
-    nm = new JavaProcess(NodeManager.class);
+    File nmOutput = new File(baseDir, baseName + "-nm.log");
+    nmOutput.createNewFile();
+    nm = new JavaProcess(NodeManager.class, nmOutput);
     nmAddress = "http://" + getNMWebAppURLWithoutScheme(conf);
     waitWebAppRunning(nmAddress, "/ws/v1/node");
   }


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