use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.
the class SchedulerEngineTest method assertFinishedStatusUpdateWithoutLaunchedTasks.
@Test
public void assertFinishedStatusUpdateWithoutLaunchedTasks() {
TaskNode taskNode = TaskNode.builder().build();
schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())).setState(Protos.TaskState.TASK_FINISHED).setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build());
verify(facadeService).removeRunning(TaskContext.from(taskNode.getTaskNodeValue()));
verify(taskScheduler, times(0)).getTaskUnAssigner();
}
use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.
the class SchedulerEngineTest method assertLostStatusUpdate.
@Test
public void assertLostStatusUpdate() {
@SuppressWarnings("unchecked") Action2<String, String> taskUnAssigner = mock(Action2.class);
when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner);
TaskNode taskNode = TaskNode.builder().build();
when(facadeService.popMapping(taskNode.getTaskNodeValue())).thenReturn("localhost");
schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())).setState(Protos.TaskState.TASK_LOST).setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build());
verify(facadeService).recordFailoverTask(TaskContext.from(taskNode.getTaskNodeValue()));
verify(facadeService).removeRunning(TaskContext.from(taskNode.getTaskNodeValue()));
verify(taskUnAssigner).call(TaskContext.getIdForUnassignedSlave(taskNode.getTaskNodeValue()), "localhost");
verify(statisticManager).taskRunFailed();
}
use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.
the class SchedulerEngineTest method assertRunningStatusUpdateForOther.
@Test
public void assertRunningStatusUpdateForOther() {
TaskNode taskNode = TaskNode.builder().build();
schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())).setState(Protos.TaskState.TASK_RUNNING).setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build());
verify(facadeService, times(0)).updateDaemonStatus(TaskContext.from(taskNode.getTaskNodeValue()), eq(anyBoolean()));
}
use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.
the class SchedulerEngineTest method assertRunningStatusUpdateForDaemonJobComplete.
@Test
public void assertRunningStatusUpdateForDaemonJobComplete() {
TaskNode taskNode = TaskNode.builder().build();
schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())).setState(Protos.TaskState.TASK_RUNNING).setMessage("COMPLETE").setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build());
verify(facadeService).updateDaemonStatus(TaskContext.from(taskNode.getTaskNodeValue()), true);
}
use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.
the class SchedulerEngineTest method assertFailedStatusUpdate.
@Test
public void assertFailedStatusUpdate() {
@SuppressWarnings("unchecked") Action2<String, String> taskUnAssigner = mock(Action2.class);
when(taskScheduler.getTaskUnAssigner()).thenReturn(taskUnAssigner);
TaskNode taskNode = TaskNode.builder().build();
when(facadeService.popMapping(taskNode.getTaskNodeValue())).thenReturn("localhost");
schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())).setState(Protos.TaskState.TASK_FAILED).setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build());
verify(facadeService).recordFailoverTask(TaskContext.from(taskNode.getTaskNodeValue()));
verify(facadeService).removeRunning(TaskContext.from(taskNode.getTaskNodeValue()));
verify(taskUnAssigner).call(TaskContext.getIdForUnassignedSlave(taskNode.getTaskNodeValue()), "localhost");
verify(statisticManager).taskRunFailed();
}
Aggregations