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;
}
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();
}
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()));
}
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"));
}
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());
}
Aggregations