Search in sources :

Example 6 with TaskNode

use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.

the class FailoverServiceTest method assertAddWhenExisted.

@Test
public void assertAddWhenExisted() {
    TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
    when(configService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
    when(regCenter.isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath())).thenReturn(true);
    failoverService.add(TaskContext.from(taskNode.getTaskNodeValue()));
    verify(regCenter).isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath());
    verify(regCenter, times(0)).persist("/state/failover/test_job/" + taskNode.getTaskNodePath(), taskNode.getTaskNodeValue());
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Example 7 with TaskNode

use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.

the class FailoverServiceTest method assertGetTaskId.

@Test
public void assertGetTaskId() {
    TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
    when(configService.load("test_job")).thenReturn(Optional.<CloudJobConfiguration>absent());
    failoverService.add(TaskContext.from(taskNode.getTaskNodeValue()));
    when(regCenter.isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath())).thenReturn(true);
    when(regCenter.get("/state/failover/test_job/" + taskNode.getTaskNodePath())).thenReturn(taskNode.getTaskNodeValue());
    assertThat(failoverService.getTaskId(taskNode.getMetaInfo()).get(), is(taskNode.getTaskNodeValue()));
    verify(regCenter, times(2)).isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath());
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Example 8 with TaskNode

use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.

the class RunningServiceTest method assertAddWithData.

@Test
public void assertAddWithData() {
    when(regCenter.get("/config/job/other_job")).thenReturn(CloudJsonConstants.getJobJson("other_job"));
    TaskNode taskNode = TaskNode.builder().jobName("other_job").build();
    runningService.add(TaskContext.from(taskNode.getTaskNodeValue()));
    assertThat(runningService.getRunningTasks("other_job").size(), is(1));
    assertThat(runningService.getRunningTasks("other_job").iterator().next(), is(TaskContext.from(taskNode.getTaskNodeValue())));
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Example 9 with TaskNode

use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.

the class FacadeServiceTest method assertRecordFailoverTaskWhenJobConfigNotExisted.

@Test
public void assertRecordFailoverTaskWhenJobConfigNotExisted() {
    TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
    when(jobConfigService.load("test_job")).thenReturn(Optional.<CloudJobConfiguration>absent());
    facadeService.recordFailoverTask(TaskContext.from(taskNode.getTaskNodeValue()));
    verify(failoverService, times(0)).add(TaskContext.from(taskNode.getTaskNodeValue()));
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Example 10 with TaskNode

use of com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode in project elastic-job by dangdangdotcom.

the class SchedulerEngineTest method assertRunningStatusUpdateForDaemonJobBegin.

@Test
public void assertRunningStatusUpdateForDaemonJobBegin() {
    TaskNode taskNode = TaskNode.builder().build();
    schedulerEngine.statusUpdate(null, Protos.TaskStatus.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskNode.getTaskNodeValue())).setState(Protos.TaskState.TASK_RUNNING).setMessage("BEGIN").setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0")).build());
    verify(facadeService).updateDaemonStatus(TaskContext.from(taskNode.getTaskNodeValue()), false);
}
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