YARN-9817. Fix failing testcases due to not initialized AsyncDispatcher - ArithmeticException: / by zero. Contributed by Prabhu Joseph.

This commit is contained in:
Tao Yang 2019-09-07 07:39:02 +08:00
parent bb0b922a71
commit 5d497abe21
3 changed files with 9 additions and 4 deletions

View File

@ -208,7 +208,9 @@ public class TestMRApp {
@Test @Test
public void testUpdatedNodes() throws Exception { public void testUpdatedNodes() throws Exception {
int runCount = 0; int runCount = 0;
Dispatcher disp = Mockito.spy(new AsyncDispatcher()); AsyncDispatcher dispatcher = new AsyncDispatcher();
dispatcher.init(new Configuration());
Dispatcher disp = Mockito.spy(dispatcher);
MRApp app = new MRAppWithHistory(2, 2, false, this.getClass().getName(), MRApp app = new MRAppWithHistory(2, 2, false, this.getClass().getName(),
true, ++runCount, disp); true, ++runCount, disp);
Configuration conf = new Configuration(); Configuration conf = new Configuration();

View File

@ -128,6 +128,9 @@ public class TestRuntimeEstimators {
estimator = testedEstimator; estimator = testedEstimator;
clock = new ControlledClock(); clock = new ControlledClock();
dispatcher = new AsyncDispatcher(); dispatcher = new AsyncDispatcher();
Configuration conf = new Configuration();
dispatcher.init(conf);
myJob = null; myJob = null;
slotsInUse.set(0); slotsInUse.set(0);
completedMaps.set(0); completedMaps.set(0);
@ -137,8 +140,6 @@ public class TestRuntimeEstimators {
clock.tickMsec(1000); clock.tickMsec(1000);
Configuration conf = new Configuration();
myAppContext = new MyAppContext(MAP_TASKS, REDUCE_TASKS); myAppContext = new MyAppContext(MAP_TASKS, REDUCE_TASKS);
myJob = myAppContext.getAllJobs().values().iterator().next(); myJob = myAppContext.getAllJobs().values().iterator().next();
@ -165,7 +166,6 @@ public class TestRuntimeEstimators {
dispatcher.register(TaskEventType.class, new SpeculationRequestEventHandler()); dispatcher.register(TaskEventType.class, new SpeculationRequestEventHandler());
dispatcher.init(conf);
dispatcher.start(); dispatcher.start();

View File

@ -499,6 +499,8 @@ public class TestJobImpl {
// not initializing dispatcher to avoid potential race condition between // not initializing dispatcher to avoid potential race condition between
// the dispatcher thread & test thread - see MAPREDUCE-6831 // the dispatcher thread & test thread - see MAPREDUCE-6831
AsyncDispatcher dispatcher = new AsyncDispatcher(); AsyncDispatcher dispatcher = new AsyncDispatcher();
dispatcher.init(conf);
OutputCommitter committer = new StubbedOutputCommitter() { OutputCommitter committer = new StubbedOutputCommitter() {
@Override @Override
@ -959,6 +961,7 @@ public class TestJobImpl {
public void testJobPriorityUpdate() throws Exception { public void testJobPriorityUpdate() throws Exception {
Configuration conf = new Configuration(); Configuration conf = new Configuration();
AsyncDispatcher dispatcher = new AsyncDispatcher(); AsyncDispatcher dispatcher = new AsyncDispatcher();
dispatcher.init(conf);
Priority submittedPriority = Priority.newInstance(5); Priority submittedPriority = Priority.newInstance(5);
AppContext mockContext = mock(AppContext.class); AppContext mockContext = mock(AppContext.class);