Search in sources :

Example 31 with PipelineRun

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;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) SystemParams(com.epam.pipeline.manager.execution.SystemParams) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Date(java.util.Date) LocalDate(java.time.LocalDate)

Example 32 with PipelineRun

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);
    });
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) LocalDateTime(java.time.LocalDateTime) Date(java.util.Date) LocalDate(java.time.LocalDate) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 33 with PipelineRun

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)))));
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineRunFilterVO(com.epam.pipeline.controller.vo.PipelineRunFilterVO) Arrays(java.util.Arrays) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) RunSid(com.epam.pipeline.entity.pipeline.run.parameter.RunSid) Date(java.util.Date) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) CommitStatus(com.epam.pipeline.entity.pipeline.CommitStatus) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) Propagation(org.springframework.transaction.annotation.Propagation) EnvVarsBuilder(com.epam.pipeline.manager.execution.EnvVarsBuilder) Map(java.util.Map) PipelineUser(com.epam.pipeline.entity.user.PipelineUser) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Before(org.junit.Before) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) DateUtils(com.epam.pipeline.entity.utils.DateUtils) RunInstance(com.epam.pipeline.entity.pipeline.RunInstance) TaskStatus(com.epam.pipeline.entity.pipeline.TaskStatus) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) PagingRunFilterVO(com.epam.pipeline.controller.vo.PagingRunFilterVO) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) LocalDate(java.time.LocalDate) SystemParams(com.epam.pipeline.manager.execution.SystemParams) Optional(java.util.Optional) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Transactional(org.springframework.transaction.annotation.Transactional) PagingRunFilterVO(com.epam.pipeline.controller.vo.PagingRunFilterVO)

Example 34 with PipelineRun

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());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PagingRunFilterVO(com.epam.pipeline.controller.vo.PagingRunFilterVO) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 35 with PipelineRun

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;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun)

Aggregations

PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)88 Test (org.junit.Test)31 Transactional (org.springframework.transaction.annotation.Transactional)29 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)23 EnvVarsBuilderTest (com.epam.pipeline.manager.execution.EnvVarsBuilderTest)22 ArrayList (java.util.ArrayList)18 RunInstance (com.epam.pipeline.entity.pipeline.RunInstance)17 Date (java.util.Date)15 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)14 List (java.util.List)14 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)13 Map (java.util.Map)11 LocalDateTime (java.time.LocalDateTime)10 Arrays (java.util.Arrays)10 Collectors (java.util.stream.Collectors)10 PipelineUser (com.epam.pipeline.entity.user.PipelineUser)9 Collections (java.util.Collections)9 HashMap (java.util.HashMap)9 MessageHelper (com.epam.pipeline.common.MessageHelper)8 RunSid (com.epam.pipeline.entity.pipeline.run.parameter.RunSid)8