use of com.netflix.fenzo.SchedulingResult in project elastic-job by dangdangdotcom.
the class TaskLaunchScheduledServiceTest method assertRunOneIterationWithScriptJob.
@Test
public void assertRunOneIterationWithScriptJob() throws Exception {
when(facadeService.getEligibleJobContext()).thenReturn(Lists.newArrayList(JobContext.from(CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("script_job", 1), ExecutionType.READY)));
Map<String, VMAssignmentResult> vmAssignmentResultMap = new HashMap<>();
vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Lists.<VirtualMachineLease>newArrayList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))), Sets.newHashSet(mockTaskAssignmentResult("script_job", ExecutionType.READY))));
when(taskScheduler.scheduleOnce(anyListOf(TaskRequest.class), anyListOf(VirtualMachineLease.class))).thenReturn(new SchedulingResult(vmAssignmentResultMap));
when(facadeService.loadAppConfig("test_app")).thenReturn(Optional.of(CloudAppConfigurationBuilder.createCloudAppConfiguration("test_app")));
when(facadeService.load("script_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("script_job", 1)));
when(taskScheduler.getTaskAssigner()).thenReturn(mock(Action2.class));
taskLaunchScheduledService.runOneIteration();
verify(facadeService).removeLaunchTasksFromQueue(anyListOf(TaskContext.class));
verify(facadeService).isRunning(TaskContext.from(String.format("%s@-@0@-@%s@-@unassigned-slave@-@0", "script_job", ExecutionType.READY)));
verify(facadeService).loadAppConfig("test_app");
verify(jobEventBus).post(Matchers.<JobStatusTraceEvent>any());
}
use of com.netflix.fenzo.SchedulingResult in project elastic-job by dangdangdotcom.
the class TaskLaunchScheduledServiceTest method assertRunOneIteration.
@Test
public void assertRunOneIteration() throws Exception {
when(facadeService.getEligibleJobContext()).thenReturn(Lists.newArrayList(JobContext.from(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job", CloudJobExecutionType.DAEMON, 1), ExecutionType.FAILOVER)));
Map<String, VMAssignmentResult> vmAssignmentResultMap = new HashMap<>();
vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Lists.<VirtualMachineLease>newArrayList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))), Sets.newHashSet(mockTaskAssignmentResult("failover_job", ExecutionType.FAILOVER))));
when(taskScheduler.scheduleOnce(anyListOf(TaskRequest.class), anyListOf(VirtualMachineLease.class))).thenReturn(new SchedulingResult(vmAssignmentResultMap));
when(facadeService.load("failover_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job")));
when(facadeService.getFailoverTaskId(any(MetaInfo.class))).thenReturn(Optional.of(String.format("%s@-@0@-@%s@-@unassigned-slave@-@0", "failover_job", ExecutionType.FAILOVER.name())));
when(taskScheduler.getTaskAssigner()).thenReturn(mock(Action2.class));
taskLaunchScheduledService.runOneIteration();
verify(facadeService).removeLaunchTasksFromQueue(anyListOf(TaskContext.class));
verify(facadeService).loadAppConfig("test_app");
verify(jobEventBus).post(Matchers.<JobStatusTraceEvent>any());
}
Aggregations