use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.
the class PipelineRunDaoTest method createTestPipelineRun.
private PipelineRun createTestPipelineRun(Long pipelineId) {
PipelineRun run = new PipelineRun();
run.setPipelineId(pipelineId);
run.setVersion("abcdefg");
run.setStartDate(new Date());
run.setEndDate(run.getStartDate());
run.setStatus(TaskStatus.RUNNING);
run.setCommitStatus(CommitStatus.NOT_COMMITTED);
run.setLastChangeCommitTime(new Date());
run.setPodId(TEST_POD_ID);
run.setParams(TEST_PARAMS);
run.setOwner(USER);
run.setServiceUrl(TEST_SERVICE_URL);
Map<SystemParams, String> systemParams = EnvVarsBuilderTest.matchSystemParams();
PipelineConfiguration configuration = EnvVarsBuilderTest.matchPipeConfig();
EnvVarsBuilder.buildEnvVars(run, configuration, systemParams, null);
run.setEnvVars(run.getEnvVars());
pipelineRunDao.createPipelineRun(run);
return run;
}
use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.
the class PipelineRunDaoTest method testUpdateRunsLastNotification.
@Test
public void testUpdateRunsLastNotification() {
PipelineRun run1 = createTestPipelineRun();
Date lastNotificationDate = DateUtils.now();
LocalDateTime lastIdleNotificationDate = DateUtils.nowUTC();
run1.setLastNotificationTime(lastNotificationDate);
run1.setLastIdleNotificationTime(lastIdleNotificationDate);
pipelineRunDao.updateRunLastNotification(run1);
PipelineRun loadedRun = pipelineRunDao.loadPipelineRun(run1.getId());
assertEquals(loadedRun.getLastNotificationTime(), lastNotificationDate);
assertEquals(loadedRun.getLastIdleNotificationTime(), lastIdleNotificationDate);
PipelineRun run2 = createTestPipelineRun();
PipelineRun run3 = createTestPipelineRun();
Stream.of(run2, run3).forEach(r -> {
r.setLastNotificationTime(lastNotificationDate);
r.setLastIdleNotificationTime(lastIdleNotificationDate);
});
pipelineRunDao.updateRunsLastNotification(Arrays.asList(run2, run3));
Stream.of(run2, run3).forEach(r -> {
PipelineRun loaded = pipelineRunDao.loadPipelineRun(r.getId());
assertEquals(loaded.getLastNotificationTime(), lastNotificationDate);
assertEquals(loaded.getLastIdleNotificationTime(), lastIdleNotificationDate);
});
List<PipelineRun> running = pipelineRunDao.loadRunningPipelineRuns();
assertFalse(running.isEmpty());
running.forEach(loaded -> {
assertEquals(loaded.getLastNotificationTime(), lastNotificationDate);
assertEquals(loaded.getLastIdleNotificationTime(), lastIdleNotificationDate);
});
}
use of com.epam.pipeline.entity.pipeline.PipelineRun 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.entity.pipeline.PipelineRun 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());
}
use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.
the class RestartRunDaoTest method createPipelineRun.
private PipelineRun createPipelineRun(Long runId, Long pipelineId, Long parentRunId) {
PipelineRun run = ObjectCreatorUtils.createPipelineRun(runId, pipelineId, parentRunId);
pipelineRunDao.createPipelineRun(run);
return run;
}
Aggregations