|
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.when;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
@@ -115,6 +114,11 @@ public class TestYARNRunner extends TestCase {
|
|
|
private static final Log LOG = LogFactory.getLog(TestYARNRunner.class);
|
|
|
private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
|
|
|
|
|
|
+ // prefix before <LOG_DIR>/profile.out
|
|
|
+ private static final String PROFILE_PARAMS =
|
|
|
+ MRJobConfig.DEFAULT_TASK_PROFILE_PARAMS.substring(0,
|
|
|
+ MRJobConfig.DEFAULT_TASK_PROFILE_PARAMS.lastIndexOf("%"));
|
|
|
+
|
|
|
private YARNRunner yarnRunner;
|
|
|
private ResourceMgrDelegate resourceMgrDelegate;
|
|
|
private YarnConfiguration conf;
|
|
@@ -423,6 +427,8 @@ public class TestYARNRunner extends TestCase {
|
|
|
|
|
|
for(String command : commands) {
|
|
|
if(command != null) {
|
|
|
+ assertFalse("Profiler should be disabled by default",
|
|
|
+ command.contains(PROFILE_PARAMS));
|
|
|
adminPos = command.indexOf("-Djava.net.preferIPv4Stack=true");
|
|
|
if(adminPos >= 0)
|
|
|
adminIndex = index;
|
|
@@ -479,6 +485,30 @@ public class TestYARNRunner extends TestCase {
|
|
|
"using yarn.app.mapreduce.am.env config settings."));
|
|
|
}
|
|
|
|
|
|
+ @Test(timeout=20000)
|
|
|
+ public void testAMProfiler() throws Exception {
|
|
|
+ JobConf jobConf = new JobConf();
|
|
|
+
|
|
|
+ jobConf.setBoolean(MRJobConfig.MR_AM_PROFILE, true);
|
|
|
+
|
|
|
+ YARNRunner yarnRunner = new YARNRunner(jobConf);
|
|
|
+
|
|
|
+ ApplicationSubmissionContext submissionContext =
|
|
|
+ buildSubmitContext(yarnRunner, jobConf);
|
|
|
+
|
|
|
+ ContainerLaunchContext containerSpec = submissionContext.getAMContainerSpec();
|
|
|
+ List<String> commands = containerSpec.getCommands();
|
|
|
+
|
|
|
+ for(String command : commands) {
|
|
|
+ if (command != null) {
|
|
|
+ if (command.contains(PROFILE_PARAMS)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new IllegalStateException("Profiler opts not found!");
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testAMStandardEnv() throws Exception {
|
|
|
final String ADMIN_LIB_PATH = "foo";
|