Search in sources :

Example 76 with PipelineRun

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

the class PipelineRunDaoTest method testUpdateWithRunSids.

@Test
public void testUpdateWithRunSids() {
    List<RunSid> runSids = new ArrayList<>();
    RunSid runSid1 = new RunSid();
    runSid1.setName(TEST_USER);
    runSid1.setIsPrincipal(true);
    runSids.add(runSid1);
    RunSid runSid2 = new RunSid();
    runSid2.setName(GROUP_NAME);
    runSid2.setIsPrincipal(false);
    Pipeline testPipeline = getPipeline();
    PipelineRun run = createRunWithRunSids(testPipeline.getId(), null, runSids);
    pipelineRunDao.deleteRunSids(run.getId());
    PipelineRun loadedRuns = pipelineRunDao.loadPipelineRun(run.getId());
    assertTrue(loadedRuns.getRunSids().isEmpty());
    runSids.add(runSid2);
    pipelineRunDao.createRunSids(run.getId(), runSids);
    loadedRuns = pipelineRunDao.loadPipelineRun(run.getId());
    assertEquals(2, loadedRuns.getRunSids().size());
    assertTrue(runSids.equals(loadedRuns.getRunSids()));
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) RunSid(com.epam.pipeline.entity.pipeline.run.parameter.RunSid) ArrayList(java.util.ArrayList) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 77 with PipelineRun

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

the class PipelineRunDaoTest method updateRunCommitStatus.

@Test
public void updateRunCommitStatus() {
    PipelineRun run = createTestPipelineRun();
    run.setCommitStatus(CommitStatus.SUCCESS);
    pipelineRunDao.updateRunCommitStatus(run);
    PipelineRun loadedRun = pipelineRunDao.loadPipelineRun(run.getId());
    assertEquals(run.getCommitStatus(), loadedRun.getCommitStatus());
}
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 78 with PipelineRun

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

the class PipelineRunDaoTest method updateProlongedAtTimeTest.

@Test
public void updateProlongedAtTimeTest() {
    PipelineRun run = createTestPipelineRun();
    LocalDateTime time = DateUtils.nowUTC();
    PipelineRun loadedRun = pipelineRunDao.loadPipelineRun(run.getId());
    assertNull(loadedRun.getProlongedAtTime());
    run.setProlongedAtTime(time);
    pipelineRunDao.updateProlongIdleRunAndLastIdleNotificationTime(run);
    loadedRun = pipelineRunDao.loadPipelineRun(run.getId());
    assertEquals(time, loadedRun.getProlongedAtTime());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) LocalDateTime(java.time.LocalDateTime) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 79 with PipelineRun

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

the class PipelineRunDaoTest method loadRunningPipelineRuns.

@Test
public void loadRunningPipelineRuns() {
    PipelineRun run = createTestPipelineRun();
    List<PipelineRun> running = pipelineRunDao.loadRunningAndTerminatedPipelineRuns();
    assertFalse(running.isEmpty());
    assertTrue(running.stream().anyMatch(r -> Objects.equals(r.getId(), run.getId())));
    run.setStatus(TaskStatus.FAILURE);
    run.setTerminating(true);
    pipelineRunDao.updateRunStatus(run);
    List<PipelineRun> terminating = pipelineRunDao.loadRunningAndTerminatedPipelineRuns();
    assertFalse(terminating.isEmpty());
    assertFalse(terminating.stream().anyMatch(r -> r.getStatus() == TaskStatus.RUNNING));
    assertTrue(terminating.stream().anyMatch(r -> Objects.equals(r.getId(), run.getId())));
}
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) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 80 with PipelineRun

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

the class PipelineRunDaoTest method testLoadRunWithPricePerHour.

@Test
public void testLoadRunWithPricePerHour() {
    PipelineRun run = createTestPipelineRun(testPipeline.getId());
    run.setPricePerHour(PRICE_PER_HOUR);
    pipelineRunDao.updateRun(run);
    PipelineRun loaded = pipelineRunDao.loadPipelineRun(run.getId());
    assertEquals(run.getId(), loaded.getId());
    assertEquals(PRICE_PER_HOUR, loaded.getPricePerHour());
}
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)

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