Search in sources :

Example 86 with PipelineRun

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

the class NotificationAspectTest method testNotifyRunStatusChanged.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testNotifyRunStatusChanged() {
    PipelineRun run = new PipelineRun();
    run.setStatus(TaskStatus.SUCCESS);
    run.setOwner(testOwner.getUserName());
    run.setStartDate(new Date());
    pipelineRunManager.updatePipelineStatus(run);
    List<NotificationMessage> messages = monitoringNotificationDao.loadAllNotifications();
    Assert.assertFalse(messages.isEmpty());
    NotificationMessage message = messages.get(0);
    Assert.assertEquals(testOwner.getId(), message.getToUserId());
    Assert.assertEquals(TaskStatus.SUCCESS.name(), message.getTemplateParameters().get("status"));
    Mockito.verify(pipelineRunDao).updateRunStatus(Mockito.any());
    Mockito.verify(runStatusManager).saveStatus(Mockito.any());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) NotificationMessage(com.epam.pipeline.entity.notification.NotificationMessage) Date(java.util.Date) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 87 with PipelineRun

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

the class PipelineRunLoader method loadPermissions.

@Override
protected PermissionsContainer loadPermissions(final Long id, final AclClass entityClass) {
    PipelineRun run = getApiClient().loadPipelineRun(id);
    Long pipelineId = run.getPipelineId();
    if (pipelineId == null) {
        PermissionsContainer permissionsContainer = new PermissionsContainer();
        permissionsContainer.add(Collections.emptyList(), run.getOwner());
        return permissionsContainer;
    }
    return super.loadPermissions(pipelineId, AclClass.PIPELINE);
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PermissionsContainer(com.epam.pipeline.elasticsearchagent.model.PermissionsContainer)

Example 88 with PipelineRun

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

the class RunMapperTest method shouldMapRun.

@Test
void shouldMapRun() throws IOException {
    PipelineRunMapper mapper = new PipelineRunMapper();
    PipelineRunWithLog pipelineRunWithLog = new PipelineRunWithLog();
    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 run = new PipelineRun();
    run.setId(1L);
    run.setName(TEST_NAME);
    run.setPipelineName(TEST_NAME);
    run.setInstance(instance);
    run.setStatus(TaskStatus.SUCCESS);
    run.setPipelineName(TEST_NAME);
    run.setVersion(TEST_VERSION);
    run.setRunStatuses(Collections.singletonList(runStatus));
    run.setPricePerHour(PRICE);
    run.setPipelineRunParameters(Collections.singletonList(parameter));
    RunLog runLog = new RunLog();
    runLog.setLogText(TEST_DESCRIPTION);
    runLog.setStatus(TaskStatus.SUCCESS);
    runLog.setTask(new PipelineTask(TEST_NAME));
    pipelineRunWithLog.setPipelineRun(run);
    pipelineRunWithLog.setRunOwner(USER);
    pipelineRunWithLog.setRunLogs(Collections.singletonList(runLog));
    EntityContainer<PipelineRunWithLog> container = EntityContainer.<PipelineRunWithLog>builder().entity(pipelineRunWithLog).owner(USER).permissions(PERMISSIONS_CONTAINER).build();
    XContentBuilder contentBuilder = mapper.map(container);
    verifyPipelineRun(run, TEST_NAME + " " + TEST_VERSION, contentBuilder);
    verifyRunParameters(Collections.singletonList(TEST_NAME + " " + TEST_VALUE), contentBuilder);
    verifyRunLogs(Collections.singletonList(TEST_NAME + " " + TEST_DESCRIPTION), contentBuilder);
    verifyPipelineUser(USER, contentBuilder);
    verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
}
Also used : MapperVerificationUtils.verifyPipelineRun(com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyPipelineRun) PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) RunStatus(com.epam.pipeline.entity.pipeline.run.RunStatus) RunLog(com.epam.pipeline.entity.pipeline.RunLog) PipelineRunWithLog(com.epam.pipeline.elasticsearchagent.model.PipelineRunWithLog) RunInstance(com.epam.pipeline.entity.pipeline.RunInstance) PipelineTask(com.epam.pipeline.entity.pipeline.PipelineTask) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) PipelineRunParameter(com.epam.pipeline.entity.pipeline.run.parameter.PipelineRunParameter) Test(org.junit.jupiter.api.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