Skip to content

Commit 01b8111

Browse files
committed
fix TestUberAM Junit Error.
1 parent d9c3308 commit 01b8111

File tree

2 files changed

+36
-5
lines changed
  • hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2

2 files changed

+36
-5
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobs.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,41 @@ public static void setup() throws IOException {
183183
localFs.setPermission(APP_JAR, new FsPermission("700"));
184184
}
185185

186+
@BeforeAll
187+
public static void setupUberAM() throws IOException {
188+
try {
189+
dfsCluster = new MiniDFSCluster.Builder(conf).numDataNodes(2)
190+
.format(true).racks(null).build();
191+
remoteFs = dfsCluster.getFileSystem();
192+
} catch (IOException io) {
193+
throw new RuntimeException("problem starting mini dfs cluster", io);
194+
}
195+
196+
if (!(new File(MiniMRYarnCluster.APPJAR)).exists()) {
197+
LOG.info("MRAppJar {} not found. Not running test.",
198+
MiniMRYarnCluster.APPJAR);
199+
return;
200+
}
201+
202+
if (mrCluster == null) {
203+
mrCluster = new MiniMRYarnCluster(TestMRJobs.class.getName(),
204+
NUM_NODE_MGRS);
205+
Configuration conf = new Configuration();
206+
conf.set("fs.defaultFS", remoteFs.getUri().toString()); // use HDFS
207+
conf.set(MRJobConfig.MR_AM_STAGING_DIR, "/apps_staging_dir");
208+
conf.setInt(YarnConfiguration.MAX_CLUSTER_LEVEL_APPLICATION_PRIORITY, 10);
209+
conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, true);
210+
conf.setInt(MRJobConfig.JOB_UBERTASK_MAXREDUCES, 3);
211+
mrCluster.init(conf);
212+
mrCluster.start();
213+
}
214+
215+
// Copy MRAppJar and make it private. TODO: FIXME. This is a hack to
216+
// workaround the absent public discache.
217+
localFs.copyFromLocalFile(new Path(MiniMRYarnCluster.APPJAR), APP_JAR);
218+
localFs.setPermission(APP_JAR, new FsPermission("700"));
219+
}
220+
186221
@AfterAll
187222
public static void tearDown() throws IOException {
188223
if (mrCluster != null) {

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestUberAM.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ public class TestUberAM extends TestMRJobs {
4545

4646
@BeforeAll
4747
public static void setup() throws IOException {
48-
TestMRJobs.setup();
49-
if (mrCluster != null) {
50-
mrCluster.getConfig().setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, true);
51-
mrCluster.getConfig().setInt(MRJobConfig.JOB_UBERTASK_MAXREDUCES, 3);
52-
}
48+
TestMRJobs.setupUberAM();
5349
}
5450

5551
@Override

0 commit comments

Comments
 (0)