use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testEnabledJobSuccess.
@Test
public void testEnabledJobSuccess() throws Exception {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
jobConfig4DB.setEnabled(Boolean.FALSE);
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
when(curatorFrameworkOp.getChildren(JobNodePath.getExecutionNodePath(jobName))).thenReturn(Lists.newArrayList("1"));
when(curatorFrameworkOp.checkExists(eq(JobNodePath.getExecutionNodePath(jobName, "1", "completed")))).thenReturn(true);
when(curatorFrameworkOp.checkExists(eq(JobNodePath.getExecutionNodePath(jobName, "1", "running")))).thenReturn(false);
jobService.enableJob(namespace, jobName, userName);
verify(currentJobConfigService).updateByPrimaryKey(jobConfig4DB);
verify(curatorFrameworkOp).update(eq(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED)), eq(true));
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method buildJobConfig4DBList.
private List<JobConfig4DB> buildJobConfig4DBList(String namespace, String jobName, int count) {
List<JobConfig4DB> config4DBList = new ArrayList<>();
for (int i = 0; i < count; i++) {
JobConfig4DB config = new JobConfig4DB();
config.setNamespace(namespace);
config.setJobName(jobName + i);
config.setEnabled(true);
config.setEnabledReport(true);
config.setJobType(JobType.JAVA_JOB.toString());
config4DBList.add(config);
}
return config4DBList;
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testRunAtOnceSuccess.
@Test
public void testRunAtOnceSuccess() throws SaturnJobConsoleException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
jobConfig4DB.setEnabled(true);
String executor = "executor";
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
when(curatorFrameworkOp.getChildren(JobNodePath.getServerNodePath(jobName))).thenReturn(Lists.newArrayList(executor));
when(curatorFrameworkOp.getData(JobNodePath.getServerNodePath(jobName, executor, "status"))).thenReturn("true");
jobService.runAtOnce(namespace, jobName);
verify(curatorFrameworkOp).create(JobNodePath.getRunOneTimePath(jobName, executor), "null");
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testImportFailByLoadLevelInvalid.
@Test
public void testImportFailByLoadLevelInvalid() 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.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(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOAD_LEVEL))).thenReturn("error");
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("负荷有误"));
jobService.importJobs(namespace, data, userName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testUpdateJobConfigSuccess.
@Test
public void testUpdateJobConfigSuccess() throws SaturnJobConsoleException {
JobConfig jobConfig = new JobConfig();
jobConfig.setJobName(jobName);
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobConfig.getJobName())).thenReturn(jobConfig4DB);
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
jobService.getJobConfigVo(namespace, jobName);
}
Aggregations