diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/JavaProcess.java 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 6c0938cc2ab..e2611d91ba7 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/JavaProcess.java +++ 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 @@ 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 addClasspaths) + public JavaProcess(Class clazz, List addClasspaths, File output) throws IOException, InterruptedException { String javaHome = System.getProperty("java.home"); String javaBin = @@ -48,7 +49,9 @@ public JavaProcess(Class clazz, List addClasspaths) 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 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java 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 b66df4cbd7d..4db03c71857 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java @@ -72,6 +72,7 @@ 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; @@ -203,17 +204,27 @@ public Boolean get() { 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 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"); }