Search in sources :

Example 1 with TaskNode

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

the class FacadeServiceTest method assertGetFailoverTaskId.

@Test
public void assertGetFailoverTaskId() {
    TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
    when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
    TaskContext taskContext = TaskContext.from(taskNode.getTaskNodeValue());
    facadeService.recordFailoverTask(taskContext);
    verify(failoverService).add(taskContext);
    facadeService.getFailoverTaskId(taskContext.getMetaInfo());
    when(facadeService.getFailoverTaskId(taskContext.getMetaInfo())).thenReturn(Optional.of(taskNode.getTaskNodePath()));
    verify(failoverService).getTaskId(taskContext.getMetaInfo());
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) TaskContext(com.dangdang.ddframe.job.context.TaskContext) Test(org.junit.Test)

Example 2 with TaskNode

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

the class FacadeServiceTest method assertRecordFailoverTaskWhenIsFailoverDisabledAndIsDaemonJob.

@Test
public void assertRecordFailoverTaskWhenIsFailoverDisabledAndIsDaemonJob() {
    TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
    when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job", CloudJobExecutionType.DAEMON)));
    facadeService.recordFailoverTask(TaskContext.from(taskNode.getTaskNodeValue()));
    verify(failoverService).add(TaskContext.from(taskNode.getTaskNodeValue()));
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) Test(org.junit.Test)

Example 3 with TaskNode

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

the class FacadeServiceTest method assertRecordFailoverTaskWhenIsFailoverEnabled.

@Test
public void assertRecordFailoverTaskWhenIsFailoverEnabled() {
    TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
    when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
    TaskContext taskContext = TaskContext.from(taskNode.getTaskNodeValue());
    facadeService.recordFailoverTask(taskContext);
    verify(failoverService).add(taskContext);
}
Also used : TaskNode(com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode) TaskContext(com.dangdang.ddframe.job.context.TaskContext) Test(org.junit.Test)

Example 4 with TaskNode

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

the class FailoverServiceTest method assertAddWhenNotExistedAndTaskIsRunning.

@Test
public void assertAddWhenNotExistedAndTaskIsRunning() {
    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(false);
    when(runningService.isTaskRunning(TaskContext.MetaInfo.from(taskNode.getTaskNodePath()))).thenReturn(true);
    failoverService.add(TaskContext.from(taskNode.getTaskNodeValue()));
    verify(regCenter).isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath());
    verify(runningService).isTaskRunning(TaskContext.MetaInfo.from(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 5 with TaskNode

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

the class FailoverServiceTest method assertAddWhenJobIsOverQueueSize.

@Test
public void assertAddWhenJobIsOverQueueSize() {
    when(regCenter.getNumChildren(FailoverNode.ROOT)).thenReturn(BootstrapEnvironment.getInstance().getFrameworkConfiguration().getJobStateQueueSize() + 1);
    TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
    failoverService.add(TaskContext.from(taskNode.getTaskNodeValue()));
    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)

Aggregations

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