Search in sources :

Example 1 with RestartRun

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

the class PipelineRunManager method restartRun.

/**
 * Restarts spot run
 * @param run {@link PipelineRun} which will be restart
 * @return Restarted pipeline run
 */
@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun restartRun(final PipelineRun run) {
    final PipelineConfiguration configuration = configurationManager.getConfigurationFromRun(run);
    final PipelineRun restartedRun = createRestartRun(run);
    final Tool tool = getToolForRun(configuration);
    final List<String> endpoints = configuration.isEraseRunEndpoints() ? Collections.emptyList() : tool.getEndpoints();
    configuration.setSecretName(tool.getSecretName());
    final String launchedCommand = pipelineLauncher.launch(restartedRun, configuration, endpoints, restartedRun.getId().toString(), null);
    restartedRun.setActualCmd(launchedCommand);
    save(restartedRun);
    final RestartRun restartRun = new RestartRun();
    restartRun.setParentRunId(run.getId());
    restartRun.setRestartedRunId(restartedRun.getId());
    restartRun.setDate(DateUtils.now());
    restartRunManager.createRestartRun(restartRun);
    return run;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) RestartRun(com.epam.pipeline.entity.pipeline.run.RestartRun) Tool(com.epam.pipeline.entity.pipeline.Tool) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with RestartRun

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

the class PipelineRunManager method loadPipelineRunWithRestartedRuns.

@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun loadPipelineRunWithRestartedRuns(Long id) {
    PipelineRun run = loadPipelineRun(id);
    List<RestartRun> restartedRuns = restartRunManager.loadRestartedRunsForInitialRun(id);
    run.setRestartedRuns(restartedRuns);
    run.setRunStatuses(runStatusManager.loadRunStatus(id));
    return run;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) RestartRun(com.epam.pipeline.entity.pipeline.run.RestartRun) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with RestartRun

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

the class RestartRunDaoTest method setup.

@Before
public void setup() {
    testPipeline = new Pipeline();
    testPipeline.setName(TEST_NAME);
    testPipeline.setRepository(TEST_REPOSITORY);
    testPipeline.setOwner(TEST_NAME);
    pipelineDao.createPipeline(testPipeline);
    Long pipelineId = testPipeline.getId();
    createPipelineRun(TEST_RUN_ID_1, pipelineId, null);
    restartRun1 = new RestartRun();
    restartRun1.setParentRunId(TEST_RUN_ID_1);
    restartRun1.setRestartedRunId(TEST_RUN_ID_2);
    restartRun1.setDate(new Date());
    createPipelineRun(TEST_RUN_ID_2, pipelineId, TEST_RUN_ID_1);
    restartRun2 = new RestartRun();
    restartRun2.setParentRunId(TEST_RUN_ID_2);
    restartRun2.setRestartedRunId(TEST_RUN_ID_3);
    restartRun2.setDate(new Date());
    createPipelineRun(TEST_RUN_ID_3, pipelineId, TEST_RUN_ID_2);
    restartRun3 = new RestartRun();
    restartRun3.setParentRunId(TEST_RUN_ID_3);
    restartRun3.setRestartedRunId(TEST_RUN_ID_4);
    restartRun3.setDate(new Date());
    createPipelineRun(TEST_RUN_ID_5, pipelineId, null);
    restartRun4 = new RestartRun();
    restartRun4.setParentRunId(TEST_RUN_ID_5);
    restartRun4.setRestartedRunId(TEST_RUN_ID_6);
    restartRun4.setDate(new Date());
}
Also used : RestartRun(com.epam.pipeline.entity.pipeline.run.RestartRun) Date(java.util.Date) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Before(org.junit.Before)

Example 4 with RestartRun

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

the class RestartRunDaoTest method testCreateAndLoadPipelineRestartRun.

@Test
public void testCreateAndLoadPipelineRestartRun() {
    restartRunDao.createPipelineRestartRun(restartRun1);
    RestartRun loadRestartRun = restartRunDao.loadPipelineRestartedRunForParentRun(restartRun1.getParentRunId());
    assertNotNull(loadRestartRun);
    assertEquals(loadRestartRun.getParentRunId(), restartRun1.getParentRunId());
    assertEquals(loadRestartRun.getRestartedRunId(), restartRun1.getRestartedRunId());
}
Also used : RestartRun(com.epam.pipeline.entity.pipeline.run.RestartRun) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Aggregations

RestartRun (com.epam.pipeline.entity.pipeline.run.RestartRun)4 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)2 Transactional (org.springframework.transaction.annotation.Transactional)2 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)1 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)1 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)1 Tool (com.epam.pipeline.entity.pipeline.Tool)1 Date (java.util.Date)1 Before (org.junit.Before)1 Test (org.junit.Test)1