Search in sources :

Example 1 with RunStatus

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

the class RunStatusDaoTest method createStatus.

private RunStatus createStatus() {
    RunStatus runStatus = RunStatus.builder().runId(testRun.getId()).status(TaskStatus.RUNNING).timestamp(DateUtils.nowUTC()).build();
    runStatusDao.saveStatus(runStatus);
    return runStatus;
}
Also used : RunStatus(com.epam.pipeline.entity.pipeline.run.RunStatus)

Example 2 with RunStatus

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

the class PipelineRunMapper method buildRunStatus.

private void buildRunStatus(List<RunStatus> runStatuses, XContentBuilder jsonBuilder) throws IOException {
    if (CollectionUtils.isEmpty(runStatuses)) {
        return;
    }
    jsonBuilder.startArray("statuses");
    for (RunStatus runStatus : runStatuses) {
        jsonBuilder.startObject().field("status", runStatus.getStatus()).field("timestamp", parseLocalDataToString(runStatus.getTimestamp())).endObject();
    }
    jsonBuilder.endArray();
}
Also used : RunStatus(com.epam.pipeline.entity.pipeline.run.RunStatus)

Example 3 with RunStatus

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

the class LoaderVerificationUtils method verifyRunStatuses.

public static void verifyRunStatuses(final List<RunStatus> expectedRunStatuses, final List<RunStatus> actualRunStatuses) {
    verifyArray(expectedRunStatuses, actualRunStatuses);
    RunStatus expectedRunStatus = expectedRunStatuses.get(0);
    RunStatus actualRunStatus = actualRunStatuses.get(0);
    assertAll("runStatus", () -> assertEquals(expectedRunStatus.getRunId(), actualRunStatus.getRunId()), () -> assertEquals(expectedRunStatus.getStatus(), actualRunStatus.getStatus()));
}
Also used : RunStatus(com.epam.pipeline.entity.pipeline.run.RunStatus)

Example 4 with RunStatus

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

the class MapperVerificationUtils method verifyStatuses.

private static void verifyStatuses(final List<RunStatus> expected, final ArrayList<Map<String, Object>> content) {
    if (CollectionUtils.isEmpty(expected)) {
        if (CollectionUtils.isNotEmpty(content)) {
            throw new AssertException("Expected list is empty but actual not");
        }
        return;
    }
    assertEquals(expected.size(), content.size());
    // TODO: expand to all sizes
    RunStatus expectedRunStatus = expected.get(0);
    Map<String, Object> actualRunStatus = content.get(0);
    assertEquals(expectedRunStatus.getStatus().name(), actualRunStatus.get("status"));
}
Also used : AssertException(com.mchange.util.AssertException) RunStatus(com.epam.pipeline.entity.pipeline.run.RunStatus)

Example 5 with RunStatus

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

the class PipelineRunLoaderTest method shouldLoadPipelineRunTest.

@Test
void shouldLoadPipelineRunTest() throws EntityNotFoundException {
    RunInstance instance = new RunInstance();
    instance.setNodeType("type");
    instance.setAwsRegionId(TEST_REGION);
    instance.setSpot(true);
    instance.setNodeDisk(NODE_DISK);
    instance.setNodeId("id");
    instance.setNodeImage(TEST_PATH);
    instance.setNodeName(TEST_NAME);
    RunStatus runStatus = new RunStatus();
    runStatus.setRunId(1L);
    runStatus.setStatus(TaskStatus.SUCCESS);
    PipelineRunParameter parameter = new PipelineRunParameter();
    parameter.setName(TEST_NAME);
    parameter.setValue(TEST_VALUE);
    PipelineRun expectedPipelineRun = new PipelineRun();
    expectedPipelineRun.setId(1L);
    expectedPipelineRun.setName(TEST_NAME);
    expectedPipelineRun.setPipelineName(TEST_NAME);
    expectedPipelineRun.setPipelineId(1L);
    expectedPipelineRun.setInstance(instance);
    expectedPipelineRun.setStatus(TaskStatus.SUCCESS);
    expectedPipelineRun.setVersion(TEST_VERSION);
    expectedPipelineRun.setRunStatuses(Collections.singletonList(runStatus));
    expectedPipelineRun.setPricePerHour(PRICE);
    expectedPipelineRun.setOwner(TEST_NAME);
    expectedPipelineRun.setPipelineRunParameters(Collections.singletonList(parameter));
    RunLog runLog = new RunLog();
    runLog.setLogText(TEST_DESCRIPTION);
    runLog.setStatus(TaskStatus.SUCCESS);
    runLog.setTask(new PipelineTask(TEST_NAME));
    List<RunLog> runLogs = Collections.singletonList(runLog);
    PipelineRunWithLog expectedPipelineRunWithLog = new PipelineRunWithLog();
    expectedPipelineRunWithLog.setPipelineRun(expectedPipelineRun);
    expectedPipelineRunWithLog.setRunOwner(USER);
    expectedPipelineRunWithLog.setRunLogs(runLogs);
    PipelineRunLoader pipelineRunLoader = new PipelineRunLoader(apiClient);
    when(apiClient.loadPipelineRunWithLogs(anyLong())).thenReturn(expectedPipelineRunWithLog);
    when(apiClient.loadPipelineRun(anyLong())).thenReturn(expectedPipelineRun);
    Optional<EntityContainer<PipelineRunWithLog>> container = pipelineRunLoader.loadEntity(1L);
    EntityContainer<PipelineRunWithLog> pipelineRunEntityContainer = container.orElseThrow(AssertionError::new);
    PipelineRunWithLog actualPipelineRunWithLog = pipelineRunEntityContainer.getEntity();
    assertNotNull(actualPipelineRunWithLog);
    PipelineRun actualPipelineRun = actualPipelineRunWithLog.getPipelineRun();
    assertNotNull(actualPipelineRun);
    List<RunLog> actualRunLogs = actualPipelineRunWithLog.getRunLogs();
    assertNotNull(actualRunLogs);
    verifyPipelineRun(expectedPipelineRun, actualPipelineRun);
    verifyRunInstance(expectedPipelineRun.getInstance(), actualPipelineRun.getInstance());
    verifyRunStatuses(expectedPipelineRun.getRunStatuses(), actualPipelineRun.getRunStatuses());
    verifyRunParameters(expectedPipelineRun.getPipelineRunParameters(), actualPipelineRun.getPipelineRunParameters());
    verifyRunLogs(runLogs, actualRunLogs);
    verifyPipelineUser(pipelineRunEntityContainer.getOwner());
    verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, pipelineRunEntityContainer.getPermissions());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) LoaderVerificationUtils.verifyPipelineRun(com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyPipelineRun) RunStatus(com.epam.pipeline.entity.pipeline.run.RunStatus) RunLog(com.epam.pipeline.entity.pipeline.RunLog) EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) LoaderVerificationUtils.verifyRunInstance(com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyRunInstance) RunInstance(com.epam.pipeline.entity.pipeline.RunInstance) PipelineTask(com.epam.pipeline.entity.pipeline.PipelineTask) PipelineRunWithLog(com.epam.pipeline.elasticsearchagent.model.PipelineRunWithLog) PipelineRunParameter(com.epam.pipeline.entity.pipeline.run.parameter.PipelineRunParameter) Test(org.junit.jupiter.api.Test)

Aggregations

RunStatus (com.epam.pipeline.entity.pipeline.run.RunStatus)7 PipelineRunWithLog (com.epam.pipeline.elasticsearchagent.model.PipelineRunWithLog)2 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)2 PipelineTask (com.epam.pipeline.entity.pipeline.PipelineTask)2 RunInstance (com.epam.pipeline.entity.pipeline.RunInstance)2 RunLog (com.epam.pipeline.entity.pipeline.RunLog)2 PipelineRunParameter (com.epam.pipeline.entity.pipeline.run.parameter.PipelineRunParameter)2 Test (org.junit.jupiter.api.Test)2 LoaderVerificationUtils.verifyPipelineRun (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyPipelineRun)1 LoaderVerificationUtils.verifyRunInstance (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyRunInstance)1 MapperVerificationUtils.verifyPipelineRun (com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyPipelineRun)1 EntityContainer (com.epam.pipeline.elasticsearchagent.model.EntityContainer)1 AssertException (com.mchange.util.AssertException)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1