Search in sources :

Example 11 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class JobServiceImplTest method testImportFailByWithoutJobType.

@Test
public void testImportFailByWithoutJobType() throws SaturnJobConsoleException, IOException {
    JobConfig4DB jobConfig4DB = new JobConfig4DB();
    jobConfig4DB.setJobName(jobName);
    when(currentJobConfigService.findConfigsByNamespace(namespace)).thenReturn(Lists.newArrayList(jobConfig4DB));
    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);
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MultipartFile(org.springframework.web.multipart.MultipartFile) JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 12 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class JobServiceImplTest method testAddJobFailByHasDownStreamButIsAncestor.

@Test
public void testAddJobFailByHasDownStreamButIsAncestor() throws Exception {
    JobConfig jobConfig = new JobConfig();
    jobConfig.setJobName(jobName);
    jobConfig.setJobType(JobType.PASSIVE_SHELL_JOB.name());
    jobConfig.setShardingTotalCount(1);
    jobConfig.setShardingItemParameters("0=0");
    jobConfig.setUpStream("test1");
    jobConfig.setDownStream("test1");
    JobConfig4DB test1 = new JobConfig4DB();
    test1.setJobName("test1");
    test1.setJobType(JobType.PASSIVE_SHELL_JOB.name());
    test1.setShardingTotalCount(1);
    test1.setShardingItemParameters("0=0");
    when(currentJobConfigService.findConfigsByNamespace(eq(namespace))).thenReturn(Arrays.asList(test1));
    when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
    when(curatorFrameworkOp.inTransaction()).thenReturn(curatorTransactionOp);
    when(curatorTransactionOp.replaceIfChanged(anyString(), anyString())).thenReturn(curatorTransactionOp);
    when(curatorTransactionOp.create(anyString(), anyString())).thenReturn(curatorTransactionOp);
    expectedException.expect(SaturnJobConsoleException.class);
    expectedException.expectMessage(String.format("该域(%s)作业编排有误,存在环: %s", namespace, "[testJob, test1, testJob]"));
    jobService.addJob(namespace, jobConfig, userName);
}
Also used : JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB) Test(org.junit.Test)

Example 13 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class JobServiceImplTest method testGetJobConfigVoSuccess.

@Test
public void testGetJobConfigVoSuccess() throws SaturnJobConsoleException {
    when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(new JobConfig4DB());
    when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
    assertNotNull(jobService.getJobConfigVo(namespace, jobName));
}
Also used : JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB) Test(org.junit.Test)

Example 14 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class JobServiceImplTest method testAddJobFailByHasDownStreamButIsAncestor2.

@Test
public void testAddJobFailByHasDownStreamButIsAncestor2() throws Exception {
    JobConfig jobConfig = new JobConfig();
    jobConfig.setJobName(jobName);
    jobConfig.setJobType(JobType.PASSIVE_SHELL_JOB.name());
    jobConfig.setShardingTotalCount(1);
    jobConfig.setShardingItemParameters("0=0");
    jobConfig.setUpStream("test2");
    jobConfig.setDownStream("test1");
    JobConfig4DB test1 = new JobConfig4DB();
    test1.setJobName("test1");
    test1.setJobType(JobType.PASSIVE_SHELL_JOB.name());
    test1.setShardingTotalCount(1);
    test1.setShardingItemParameters("0=0");
    test1.setDownStream("test2");
    JobConfig4DB test2 = new JobConfig4DB();
    test2.setJobName("test2");
    test2.setJobType(JobType.PASSIVE_SHELL_JOB.name());
    test2.setShardingTotalCount(1);
    test2.setShardingItemParameters("0=0");
    test2.setUpStream("test1");
    when(currentJobConfigService.findConfigsByNamespace(eq(namespace))).thenReturn(Arrays.asList(test1, test2));
    when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
    when(curatorFrameworkOp.inTransaction()).thenReturn(curatorTransactionOp);
    when(curatorTransactionOp.replaceIfChanged(anyString(), anyString())).thenReturn(curatorTransactionOp);
    when(curatorTransactionOp.create(anyString(), anyString())).thenReturn(curatorTransactionOp);
    expectedException.expect(SaturnJobConsoleException.class);
    expectedException.expectMessage(String.format("该域(%s)作业编排有误,存在环: %s", namespace, "[testJob, test2, test1, testJob]"));
    jobService.addJob(namespace, jobConfig, userName);
}
Also used : JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB) Test(org.junit.Test)

Example 15 with JobConfig4DB

use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.

the class JobServiceImplTest method testSetPreferListFailByLocalModeNotStop.

@Test
public void testSetPreferListFailByLocalModeNotStop() throws SaturnJobConsoleException {
    JobConfig4DB jobConfig4DB = new JobConfig4DB();
    jobConfig4DB.setJobName(jobName);
    jobConfig4DB.setEnabled(true);
    jobConfig4DB.setLocalMode(true);
    when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
    expectedException.expect(SaturnJobConsoleException.class);
    expectedException.expectMessage(String.format("启用状态的本地模式作业(%s),不能设置优先Executor,请先禁用它", jobName));
    jobService.setPreferList(namespace, jobName, "preferList", userName);
}
Also used : JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB) Test(org.junit.Test)

Aggregations

JobConfig4DB (com.vip.saturn.job.console.mybatis.entity.JobConfig4DB)103 Test (org.junit.Test)70 File (java.io.File)28 FileInputStream (java.io.FileInputStream)28 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)28 MultipartFile (org.springframework.web.multipart.MultipartFile)28 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)23 CuratorRepository (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)11 Transactional (org.springframework.transaction.annotation.Transactional)10 CuratorFrameworkOp (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)8 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)5 Stat (org.apache.zookeeper.data.Stat)4 JobConfig (com.vip.saturn.job.console.domain.JobConfig)2 JobDiffInfo (com.vip.saturn.job.console.domain.JobDiffInfo)2 ParseException (java.text.ParseException)2 Audit (com.vip.saturn.job.console.aop.annotation.Audit)1 GetJobConfigVo (com.vip.saturn.job.console.vo.GetJobConfigVo)1 JobConfigInfo (com.vip.saturn.job.integrate.entity.JobConfigInfo)1 UpdateJobConfigException (com.vip.saturn.job.integrate.exception.UpdateJobConfigException)1 Boolean (java.lang.Boolean)1