Search in sources :

Example 11 with TaskNode

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();
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Example 12 with TaskNode

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();
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Example 13 with TaskNode

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()));
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Example 14 with TaskNode

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);
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Example 15 with TaskNode

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();
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Aggregations

TaskNode (com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode)21 Test (org.junit.Test)21 TaskContext (com.dangdang.ddframe.job.context.TaskContext)2