TonyJob extends HadoopJavaJob { public Configuration getTonyJobConf() { return tonyConf; } TonyJob(String jobid, Props sysProps, Props jobProps, Logger log); Configuration getTonyJobConf(); @Override void run(); @Override String getJavaClass(); static final String HADOOP_OPTS; static final String HADOOP_GLOBAL_OPTS; static final String WORKER_ENV_PREFIX; static final String TONY_APPLICATION_TAGS; }
@Test public void testFlowInfoPropagation() { final Props jobProps = new Props(); jobProps.put(TonyJobArg.HDFS_CLASSPATH.azPropName, "hdfs: jobProps.put(CommonJobProperties.PROJECT_NAME, "unit_test"); jobProps.put(CommonJobProperties.FLOW_ID, "1"); jobProps.put(CommonJobProperties.EXEC_ID, "0"); final TonyJob tonyJob = new TonyJob("test_tony_job", new Props(), jobProps, log) { @Override public String getWorkingDirectory() { return System.getProperty("java.io.tmpdir"); } }; Configuration conf = tonyJob.getTonyJobConf(); Set<String> values = new HashSet<>( conf.getStringCollection(TonyJob.TONY_APPLICATION_TAGS)); values.remove(""); Map<String, String> parsedTags = new HashMap<>(); for (String value : values) { String[] pair = value.split(":"); Assert.assertTrue(pair.length == 2); parsedTags.put(pair[0], pair[1]); } Assert.assertEquals(parsedTags.get(CommonJobProperties.EXEC_ID), "0"); Assert.assertEquals(parsedTags.get(CommonJobProperties.FLOW_ID), "1"); Assert.assertEquals(parsedTags.get(CommonJobProperties.PROJECT_NAME), "unit_test"); }