Search in sources :

Example 21 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun 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());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineUser(com.epam.pipeline.entity.user.PipelineUser) RunSid(com.epam.pipeline.entity.pipeline.run.parameter.RunSid) ArrayList(java.util.ArrayList) 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 22 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.

the class PipelineRunDaoTest method runPipelineWithEntitiesIds.

@Test
public void runPipelineWithEntitiesIds() {
    Long entitiesId = 1L;
    PipelineRun run = createRunWithEntitiesIds(testPipeline.getId(), TaskStatus.SUCCESS, null, entitiesId);
    PipelineRun loadedRun = pipelineRunDao.loadPipelineRun(run.getId());
    assertEquals(Collections.singletonList(entitiesId), loadedRun.getEntitiesIds());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 23 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun 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);
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineUser(com.epam.pipeline.entity.user.PipelineUser) RunSid(com.epam.pipeline.entity.pipeline.run.parameter.RunSid) ArrayList(java.util.ArrayList) 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 24 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.

the class PipelineRunDaoTest method testLoadByIds.

@Test
public void testLoadByIds() {
    PipelineRun run1 = createTestPipelineRun();
    createTestPipelineRun();
    List<PipelineRun> pipelineRuns = pipelineRunDao.loadPipelineRuns(Collections.singletonList(run1.getId()));
    assertEquals(1, pipelineRuns.size());
    assertEquals(run1.getId(), pipelineRuns.get(0).getId());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 25 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.

the class PipelineRunDaoTest method pipelineRunShouldContainsCmdTemplateAndActualCmd.

@Test
public void pipelineRunShouldContainsCmdTemplateAndActualCmd() {
    PipelineRun run = new PipelineRun();
    run.setPipelineId(testPipeline.getId());
    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);
    String cmdTemplate = "cmdTemplate";
    String actualCmd = "ActualCmd";
    run.setCmdTemplate(cmdTemplate);
    run.setActualCmd(actualCmd);
    run.setDockerImage("dockerImage");
    pipelineRunDao.createPipelineRun(run);
    PipelineRun loadedRun = pipelineRunDao.loadPipelineRun(run.getId());
    assertEquals(loadedRun.getCmdTemplate(), cmdTemplate);
    assertEquals(loadedRun.getActualCmd(), actualCmd);
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) Date(java.util.Date) LocalDate(java.time.LocalDate) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

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