|
@@ -34,12 +34,14 @@ import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
+import org.apache.hadoop.fs.FileSystem;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
|
import org.apache.hadoop.mapreduce.MRJobConfig;
|
|
|
import org.apache.hadoop.mapreduce.jobhistory.EventType;
|
|
|
import org.apache.hadoop.mapreduce.jobhistory.TestJobHistoryEventHandler;
|
|
|
import org.apache.hadoop.mapreduce.v2.MiniMRYarnCluster;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
+import org.apache.hadoop.test.GenericTestUtils;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationReport;
|
|
|
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
|
@@ -460,21 +462,21 @@ public class TestMRTimelineEventHandling {
|
|
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
|
|
conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_EMIT_TIMELINE_DATA, false);
|
|
|
MiniMRYarnCluster cluster = null;
|
|
|
+ FileSystem fs = null;
|
|
|
+ Path inDir = new Path(GenericTestUtils.getTempPath("input"));
|
|
|
+ Path outDir = new Path(GenericTestUtils.getTempPath("output"));
|
|
|
try {
|
|
|
+ fs = FileSystem.get(conf);
|
|
|
cluster = new MiniMRYarnCluster(
|
|
|
TestMRTimelineEventHandling.class.getSimpleName(), 1);
|
|
|
cluster.init(conf);
|
|
|
cluster.start();
|
|
|
conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
|
|
|
MiniYARNCluster.getHostname() + ":"
|
|
|
- + cluster.getApplicationHistoryServer().getPort());
|
|
|
+ + cluster.getApplicationHistoryServer().getPort());
|
|
|
TimelineStore ts = cluster.getApplicationHistoryServer()
|
|
|
.getTimelineStore();
|
|
|
|
|
|
- String localPathRoot = System.getProperty("test.build.data",
|
|
|
- "build/test/data");
|
|
|
- Path inDir = new Path(localPathRoot, "input");
|
|
|
- Path outDir = new Path(localPathRoot, "output");
|
|
|
RunningJob job =
|
|
|
UtilsForTests.runJobSucceed(new JobConf(conf), inDir, outDir);
|
|
|
Assert.assertEquals(JobStatus.SUCCEEDED,
|
|
@@ -496,6 +498,7 @@ public class TestMRTimelineEventHandling {
|
|
|
if (cluster != null) {
|
|
|
cluster.stop();
|
|
|
}
|
|
|
+ deletePaths(fs, inDir, outDir);
|
|
|
}
|
|
|
|
|
|
conf = new YarnConfiguration();
|
|
@@ -509,15 +512,10 @@ public class TestMRTimelineEventHandling {
|
|
|
cluster.start();
|
|
|
conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
|
|
|
MiniYARNCluster.getHostname() + ":"
|
|
|
- + cluster.getApplicationHistoryServer().getPort());
|
|
|
+ + cluster.getApplicationHistoryServer().getPort());
|
|
|
TimelineStore ts = cluster.getApplicationHistoryServer()
|
|
|
.getTimelineStore();
|
|
|
|
|
|
- String localPathRoot = System.getProperty("test.build.data",
|
|
|
- "build/test/data");
|
|
|
- Path inDir = new Path(localPathRoot, "input");
|
|
|
- Path outDir = new Path(localPathRoot, "output");
|
|
|
-
|
|
|
conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_EMIT_TIMELINE_DATA, false);
|
|
|
RunningJob job =
|
|
|
UtilsForTests.runJobSucceed(new JobConf(conf), inDir, outDir);
|
|
@@ -540,6 +538,20 @@ public class TestMRTimelineEventHandling {
|
|
|
if (cluster != null) {
|
|
|
cluster.stop();
|
|
|
}
|
|
|
+ deletePaths(fs, inDir, outDir);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** Delete input paths recursively. Paths should not be null. */
|
|
|
+ private void deletePaths(FileSystem fs, Path... paths) {
|
|
|
+ if (fs == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Path path : paths) {
|
|
|
+ try {
|
|
|
+ fs.delete(path, true);
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|