use of com.epam.pipeline.controller.vo.PagingRunFilterVO in project cloud-pipeline by epam.
the class PipelineRunDaoTest method testLoadActiveServicesByUserInGroup.
@Test
public void testLoadActiveServicesByUserInGroup() {
List<RunSid> runSids = new ArrayList<>();
RunSid runSid = new RunSid();
runSid.setName(GROUP_NAME);
runSid.setIsPrincipal(false);
runSids.add(runSid);
Pipeline testPipeline = getPipeline();
PipelineRun run = createRunWithRunSids(testPipeline.getId(), null, runSids);
PagingRunFilterVO filterVO = new PagingRunFilterVO();
filterVO.setPage(1);
filterVO.setPageSize(TEST_PAGE_SIZE);
PipelineUser user = new PipelineUser();
user.setUserName(TEST_USER);
user.setGroups(Collections.singletonList(GROUP_NAME));
List<PipelineRun> runs = pipelineRunDao.loadActiveServices(filterVO, user);
assertEquals(1, runs.size());
assertEquals(run.getId(), runs.get(0).getId());
assertEquals(1, runs.size());
}
use of com.epam.pipeline.controller.vo.PagingRunFilterVO in project cloud-pipeline by epam.
the class PipelineRunDaoTest method testLoadActiveServicesByUserIsPrincipal.
@Test
public void testLoadActiveServicesByUserIsPrincipal() {
List<RunSid> runSids = new ArrayList<>();
RunSid runSid1 = new RunSid();
runSid1.setName(TEST_USER);
runSid1.setIsPrincipal(true);
runSids.add(runSid1);
Pipeline testPipeline = getPipeline();
PipelineRun run = createRunWithRunSids(testPipeline.getId(), null, runSids);
PagingRunFilterVO filterVO = new PagingRunFilterVO();
filterVO.setPage(1);
filterVO.setPageSize(TEST_PAGE_SIZE);
PipelineUser user = new PipelineUser();
user.setUserName(TEST_USER);
List<PipelineRun> runs = pipelineRunDao.loadActiveServices(filterVO, user);
assertEquals(1, runs.size());
assertEquals(run.getId(), runs.get(0).getId());
assertEquals(1, runs.size());
int servicesCount = pipelineRunDao.countActiveServices(user);
assertEquals(runs.size(), servicesCount);
}
use of com.epam.pipeline.controller.vo.PagingRunFilterVO in project cloud-pipeline by epam.
the class PipelineRunDaoTest method searchPipelineRuns.
@Test
public void searchPipelineRuns() {
Pipeline testPipeline2 = getPipeline();
LocalDate now = LocalDate.now();
LocalDate date = LocalDate.of(now.getYear(), now.getMonth(), 1);
PipelineRun stopped = new PipelineRun();
stopped.setPipelineId(testPipeline.getId());
stopped.setVersion(TEST_REVISION_1);
stopped.setStartDate(Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()));
stopped.setEndDate(stopped.getStartDate());
stopped.setStatus(TaskStatus.STOPPED);
stopped.setCommitStatus(CommitStatus.NOT_COMMITTED);
stopped.setLastChangeCommitTime(new Date());
stopped.setPodId(TEST_POD_ID);
stopped.setParams(TEST_PARAMS);
stopped.setOwner(USER);
stopped.setConfigurationId(CONFIGURATION_ID_1);
stopped.setEntitiesIds(Stream.of(ENTITY_ID_1, ENTITY_ID_2).collect(Collectors.toList()));
pipelineRunDao.createPipelineRun(stopped);
LocalDate date2 = LocalDate.of(now.getYear(), now.getMonth(), 2);
PipelineRun failed = new PipelineRun();
failed.setPipelineId(testPipeline.getId());
failed.setVersion(TEST_REVISION_3);
failed.setStartDate(Date.from(date2.atStartOfDay(ZoneId.systemDefault()).toInstant()));
failed.setEndDate(failed.getStartDate());
failed.setStatus(TaskStatus.FAILURE);
failed.setCommitStatus(CommitStatus.NOT_COMMITTED);
failed.setLastChangeCommitTime(new Date());
failed.setPodId(TEST_POD_ID);
failed.setParams(TEST_PARAMS);
failed.setOwner(USER);
failed.setConfigurationId(CONFIGURATION_ID_2);
failed.setEntitiesIds(Stream.of(ENTITY_ID_2, ENTITY_ID_3).collect(Collectors.toList()));
pipelineRunDao.createPipelineRun(failed);
LocalDate date3 = LocalDate.of(now.getYear(), now.getMonth(), 3);
PipelineRun running = new PipelineRun();
running.setPipelineId(testPipeline2.getId());
running.setVersion(TEST_REVISION_2);
running.setStartDate(Date.from(date3.atStartOfDay(ZoneId.systemDefault()).toInstant()));
running.setEndDate(running.getStartDate());
running.setStatus(TaskStatus.RUNNING);
running.setCommitStatus(CommitStatus.NOT_COMMITTED);
running.setLastChangeCommitTime(new Date());
running.setPodId(TEST_POD_ID);
running.setParams(TEST_PARAMS);
running.setOwner(USER);
running.setConfigurationId(CONFIGURATION_ID_3);
running.setEntitiesIds(Stream.of(ENTITY_ID_1, ENTITY_ID_3).collect(Collectors.toList()));
pipelineRunDao.createPipelineRun(running);
PagingRunFilterVO filterVO = new PagingRunFilterVO();
filterVO.setPage(1);
filterVO.setPageSize(TEST_PAGE_SIZE);
List<PipelineRun> runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertFalse(runs.isEmpty());
assertEquals(3, runs.size());
filterVO.setPipelineIds(Collections.singletonList(testPipeline.getId()));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(2, runs.size());
assertTrue(runs.stream().allMatch(r -> r.getVersion().equals(TEST_REVISION_1) || r.getVersion().equals(TEST_REVISION_3)));
filterVO.setStatuses(Arrays.asList(TaskStatus.FAILURE, TaskStatus.STOPPED));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(2, runs.size());
filterVO.setStatuses(null);
filterVO.setVersions(Collections.singletonList(TEST_REVISION_3));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(1, runs.size());
assertTrue(runs.stream().allMatch(r -> r.getVersion().equals(TEST_REVISION_3)));
filterVO.setStatuses(Collections.singletonList(TaskStatus.RUNNING));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertTrue(runs.isEmpty());
filterVO.setVersions(null);
filterVO.setPipelineIds(null);
filterVO.setStatuses(Collections.singletonList(TaskStatus.FAILURE));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(1, runs.size());
assertTrue(runs.stream().allMatch(r -> r.getStatus() == TaskStatus.FAILURE));
filterVO.setStatuses(null);
filterVO.setStartDateFrom(Date.from(date2.atStartOfDay(ZoneId.systemDefault()).toInstant()));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(2, runs.size());
assertTrue(runs.stream().allMatch(r -> r.getStartDate().getTime() >= date2.atStartOfDay(ZoneId.systemDefault()).toInstant().getEpochSecond()));
filterVO.setEndDateTo(Date.from(LocalDateTime.of(now.getYear(), now.getMonth(), 2, HOURS_23, MINUTES_59).atZone(ZoneId.systemDefault()).toInstant()));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(1, runs.size());
// test filter by configuration ids
filterVO.setStartDateFrom(null);
filterVO.setEndDateTo(null);
filterVO.setConfigurationIds(Stream.of(CONFIGURATION_ID_1, CONFIGURATION_ID_2).collect(Collectors.toList()));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(2, runs.size());
// test filter by entities ids
filterVO.setConfigurationIds(null);
filterVO.setEntitiesIds(Stream.of(ENTITY_ID_1, ENTITY_ID_2).collect(Collectors.toList()));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(3, runs.size());
filterVO.setEntitiesIds(Stream.of(ENTITY_ID_1).collect(Collectors.toList()));
runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(2, runs.size());
}
use of com.epam.pipeline.controller.vo.PagingRunFilterVO in project cloud-pipeline by epam.
the class PipelineRunDaoTest method checkOnlyOneParentPresent.
private void checkOnlyOneParentPresent(Long parentId) {
PagingRunFilterVO filterVO = new PagingRunFilterVO();
filterVO.setPage(1);
filterVO.setPageSize(TEST_PAGE_SIZE);
filterVO.setParentId(parentId);
List<PipelineRun> runs = pipelineRunDao.searchPipelineRuns(filterVO);
assertEquals(5, runs.size());
assertTrue(runs.stream().allMatch(run -> run.getPipelineRunParameters().stream().allMatch(param -> !param.getName().equals("parent-id") || param.getValue().equals(String.valueOf(parentId)))));
}
use of com.epam.pipeline.controller.vo.PagingRunFilterVO in project cloud-pipeline by epam.
the class PipelineRunDaoTest method searchGroupingRun.
@Test
public void searchGroupingRun() {
Pipeline testPipeline = getPipeline();
PipelineRun parent = createRun(testPipeline.getId(), null, TaskStatus.SUCCESS, null);
PipelineRun child = createRun(testPipeline.getId(), null, TaskStatus.SUCCESS, parent.getId());
PipelineRun lonely = createRun(testPipeline.getId(), null, TaskStatus.SUCCESS, null);
PagingRunFilterVO filterVO = new PagingRunFilterVO();
filterVO.setPage(1);
filterVO.setPageSize(TEST_PAGE_SIZE);
filterVO.setStatuses(Collections.singletonList(TaskStatus.SUCCESS));
List<PipelineRun> runs = pipelineRunDao.searchPipelineGroups(filterVO, null);
assertEquals(2, runs.size());
assertEquals(lonely.getId(), runs.get(0).getId());
assertEquals(parent.getId(), runs.get(1).getId());
assertEquals(1, runs.get(1).getChildRuns().size());
assertEquals(child.getId(), runs.get(1).getChildRuns().get(0).getId());
assertEquals(2L, pipelineRunDao.countRootRuns(filterVO, null).longValue());
}
Aggregations