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());
}
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()));
}
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);
}
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());
}
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());
}
Aggregations