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

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


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

commit da4d0d298269c771c7ad0d7b63fb071e4989363c
Author: Inigo Goiri <inigo...@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-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to