@Test public void testPolicyInitializeAfterSchedulerInitialized() { @SuppressWarnings("resource") MockRM rm = new MockRM(conf); rm.init(conf); // ProportionalCapacityPreemptionPolicy should be initialized after // CapacityScheduler initialized. We will // 1) find SchedulingMonitor from RMActiveService's service list, // 2) check if ResourceCalculator in policy is null or not. // If it's not null, we can come to a conclusion that policy initialized // after scheduler got initialized for (Service service : rm.getRMActiveService().getServices()) { if (service instanceof SchedulingMonitor) { ProportionalCapacityPreemptionPolicy policy = (ProportionalCapacityPreemptionPolicy) ((SchedulingMonitor) service) .getSchedulingEditPolicy(); assertNotNull(policy.getResourceCalculator()); return; } } fail("Failed to find SchedulingMonitor service, please check what happened"); }
@Test public void testPolicyInitializeAfterSchedulerInitialized() { @SuppressWarnings("resource") MockRM rm = new MockRM(conf); rm.init(conf); // ProportionalCapacityPreemptionPolicy should be initialized after // CapacityScheduler initialized. We will // 1) find SchedulingMonitor from RMActiveService's service list, // 2) check if ResourceCalculator in policy is null or not. // If it's not null, we can come to a conclusion that policy initialized // after scheduler got initialized // Get SchedulingMonitor from SchedulingMonitorManager instead CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler(); SchedulingMonitorManager smm = cs.getSchedulingMonitorManager(); Service service = smm.getAvailableSchedulingMonitor(); if (service instanceof SchedulingMonitor) { ProportionalCapacityPreemptionPolicy policy = (ProportionalCapacityPreemptionPolicy) ((SchedulingMonitor) service) .getSchedulingEditPolicy(); assertNotNull(policy.getResourceCalculator()); return; } fail("Failed to find SchedulingMonitor service, please check what happened"); }