use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testImportFailByPassiveJavaJobWithoutClass.
@Test
public void testImportFailByPassiveJavaJobWithoutClass() throws SaturnJobConsoleException, IOException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
when(currentJobConfigService.findConfigsByNamespace(namespace)).thenReturn(Lists.newArrayList(jobConfig4DB));
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))).thenReturn(JobType.PASSIVE_JAVA_JOB.name());
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
File file = jobService.exportJobs(namespace);
MultipartFile data = new MockMultipartFile("test.xls", new FileInputStream(file));
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage(StringContains.containsString("对于java作业,作业实现类必填。"));
jobService.importJobs(namespace, data, userName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testImportFailByVMSJobNotSupportFailover.
@Test
public void testImportFailByVMSJobNotSupportFailover() throws SaturnJobConsoleException, IOException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
when(currentJobConfigService.findConfigsByNamespace(namespace)).thenReturn(Lists.newArrayList(jobConfig4DB));
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))).thenReturn(JobType.MSG_JOB.name());
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_QUEUE_NAME))).thenReturn("queue");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS))).thenReturn("vip");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT))).thenReturn("1");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS))).thenReturn("*=1");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOCAL_MODE))).thenReturn("false");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_FAILOVER))).thenReturn("true");
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
File file = jobService.exportJobs(namespace);
MultipartFile data = new MockMultipartFile("test.xls", new FileInputStream(file));
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage(StringContains.containsString("消息作业不支持failover"));
jobService.importJobs(namespace, data, userName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testRunAtOnceFailByNoExecutor.
@Test
public void testRunAtOnceFailByNoExecutor() throws SaturnJobConsoleException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
jobConfig4DB.setEnabled(true);
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
when(curatorFrameworkOp.getChildren(JobNodePath.getServerNodePath(jobName))).thenReturn(null);
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage(String.format("没有executor接管该作业(%s),不能立即执行", jobName));
jobService.runAtOnce(namespace, jobName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testImportSuccess.
@Test
public void testImportSuccess() throws SaturnJobConsoleException, IOException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
when(currentJobConfigService.findConfigsByNamespace(namespace)).thenReturn(Lists.newArrayList(jobConfig4DB));
when(currentJobConfigService.findConfigsByNamespace(namespace)).thenReturn(Lists.newArrayList(jobConfig4DB));
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))).thenReturn(JobType.SHELL_JOB.name());
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CRON))).thenReturn("0 */2 * * * ?");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS))).thenReturn("vip");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT))).thenReturn("1");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS))).thenReturn("0=1");
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
File file = jobService.exportJobs(namespace);
MultipartFile data = new MockMultipartFile("test.xls", new FileInputStream(file));
when(systemConfigService.getIntegerValue(SystemConfigProperties.MAX_JOB_NUM, 100)).thenReturn(100);
jobService.importJobs(namespace, data, userName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testStopAtOneFailByNotStopping.
@Test
public void testStopAtOneFailByNotStopping() throws SaturnJobConsoleException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
jobConfig4DB.setEnabled(true);
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage(String.format("该作业(%s)不处于STOPPING状态,不能立即终止", jobName));
jobService.stopAtOnce(namespace, jobName);
}
Aggregations