YARN-10161. TestRouterWebServicesREST is corrupting STDOUT. Contributed by Jim Brennan.
This commit is contained in:
parent
b420ddeada
commit
a43510e21d
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,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;
|
||||
|
@ -203,17 +204,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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue