YARN-7084. TestSchedulingMonitor#testRMStarts fails sporadically. Contributed by Jason Lowe.
(cherry picked from commit 7f6118f918
)
This commit is contained in:
parent
c0bfb385a8
commit
b0ba31c518
|
@ -25,42 +25,30 @@ import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity.ProportionalCapacityPreemptionPolicy;
|
import org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity.ProportionalCapacityPreemptionPolicy;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.timeout;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class TestSchedulingMonitor {
|
public class TestSchedulingMonitor {
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test(timeout = 10000)
|
||||||
public void testRMStarts() {
|
public void testRMStarts() throws Exception {
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
|
conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
|
||||||
conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES,
|
conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES,
|
||||||
ProportionalCapacityPreemptionPolicy.class.getCanonicalName());
|
ProportionalCapacityPreemptionPolicy.class.getCanonicalName());
|
||||||
|
|
||||||
ResourceManager rm = new MockRM();
|
ResourceManager rm = new MockRM();
|
||||||
try {
|
|
||||||
rm.init(conf);
|
rm.init(conf);
|
||||||
} catch (Exception e) {
|
|
||||||
fail("ResourceManager does not start when " +
|
|
||||||
YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS + " is set to true");
|
|
||||||
}
|
|
||||||
|
|
||||||
SchedulingEditPolicy mPolicy = mock(SchedulingEditPolicy.class);
|
SchedulingEditPolicy mPolicy = mock(SchedulingEditPolicy.class);
|
||||||
when(mPolicy.getMonitoringInterval()).thenReturn(1000L);
|
when(mPolicy.getMonitoringInterval()).thenReturn(1000L);
|
||||||
SchedulingMonitor monitor = new SchedulingMonitor(rm.getRMContext(),
|
SchedulingMonitor monitor = new SchedulingMonitor(rm.getRMContext(),
|
||||||
mPolicy);
|
mPolicy);
|
||||||
try {
|
|
||||||
monitor.serviceInit(conf);
|
monitor.serviceInit(conf);
|
||||||
monitor.serviceStart();
|
monitor.serviceStart();
|
||||||
} catch (Exception e) {
|
verify(mPolicy, timeout(10000)).editSchedule();
|
||||||
fail("SchedulingMonitor failes to start.");
|
|
||||||
}
|
|
||||||
verify(mPolicy, times(1)).editSchedule();
|
|
||||||
try {
|
|
||||||
monitor.close();
|
monitor.close();
|
||||||
rm.close();
|
rm.close();
|
||||||
} catch (Exception e) {
|
|
||||||
fail("Failed to close.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue