Search in sources :

Example 16 with PipelineRun

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

the class FirecloudRunner method runAnalysis.

@Override
public List<PipelineRun> runAnalysis(AnalysisConfiguration<FirecloudRunConfigurationEntry> configuration) {
    Assert.state(CollectionUtils.isNotEmpty(configuration.getEntitiesIds()), "Entities are required to run analysis in Firecloud");
    FolderWithMetadata project = folderManager.getProject(configuration.getConfigurationId(), AclClass.CONFIGURATION);
    Assert.notNull(project, "Project folder must be specified to run analysis in Firecloud.");
    List<Long> entities = parameterMapper.fetchAndExpandInputEntities(configuration).values().stream().flatMap(Collection::stream).map(BaseEntity::getId).collect(Collectors.toList());
    // TODO: after merge - add check that FC class is filled
    configuration.getEntries().forEach(this::validateFirecloudConfiguration);
    FirecloudConfiguration settings = buildFirecloudConfig(configuration.getRefreshToken());
    return configuration.getEntries().stream().map(entry -> runFirecloudAnalysis(settings, entry, configuration.getConfigurationId(), entities, project.getId())).collect(Collectors.toList());
}
Also used : CredentialsManager(com.epam.pipeline.manager.google.CredentialsManager) PasswordGenerator(com.epam.pipeline.utils.PasswordGenerator) Arrays(java.util.Arrays) ParameterMapper(com.epam.pipeline.manager.pipeline.ParameterMapper) FirecloudCredentials(com.epam.pipeline.manager.google.FirecloudCredentials) PipelineRunManager(com.epam.pipeline.manager.pipeline.PipelineRunManager) RequiredArgsConstructor(lombok.RequiredArgsConstructor) SystemPreferences(com.epam.pipeline.manager.preference.SystemPreferences) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) FireCloudClass(com.epam.pipeline.entity.metadata.FireCloudClass) Service(org.springframework.stereotype.Service) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) BaseEntity(com.epam.pipeline.entity.BaseEntity) FirecloudPreferences(com.epam.pipeline.entity.pipeline.run.FirecloudPreferences) PipelineConfigurationManager(com.epam.pipeline.manager.pipeline.PipelineConfigurationManager) PreferenceManager(com.epam.pipeline.manager.preference.PreferenceManager) FolderManager(com.epam.pipeline.manager.pipeline.FolderManager) Collection(java.util.Collection) FirecloudRunConfigurationEntry(com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry) Collectors(java.util.stream.Collectors) List(java.util.List) Builder(lombok.Builder) MetadataEntityManager(com.epam.pipeline.manager.metadata.MetadataEntityManager) Data(lombok.Data) AclClass(com.epam.pipeline.entity.security.acl.AclClass) SystemParams(com.epam.pipeline.manager.execution.SystemParams) PipelineStart(com.epam.pipeline.entity.pipeline.run.PipelineStart) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) Assert(org.springframework.util.Assert) Collection(java.util.Collection) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata)

Example 17 with PipelineRun

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

the class GrantPermissionManager method runPermission.

public boolean runPermission(Long runId, String permissionName) {
    PipelineRun pipelineRun = runManager.loadPipelineRun(runId);
    if (permissionsHelper.isOwner(pipelineRun)) {
        return true;
    }
    AbstractSecuredEntity parent = pipelineRun.getParent();
    if (parent == null) {
        return false;
    }
    return permissionEvaluator.hasPermission(SecurityContextHolder.getContext().getAuthentication(), parent, permissionName);
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) AbstractSecuredEntity(com.epam.pipeline.entity.AbstractSecuredEntity)

Example 18 with PipelineRun

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

the class PipelineRunDaoTest method testUpdateWithPrettyUrlRun.

@Test
public void testUpdateWithPrettyUrlRun() {
    PipelineRun run = createTestPipelineRun(testPipeline.getId());
    run.setPrettyUrl(PRETTY_URL);
    pipelineRunDao.updateRun(run);
    PipelineRun loaded = pipelineRunDao.loadPipelineRun(run.getId());
    assertEquals(run.getId(), loaded.getId());
    assertEquals(PRETTY_URL, loaded.getPrettyUrl());
    Optional<PipelineRun> runByPrettyUrl = pipelineRunDao.loadRunByPrettyUrl(PRETTY_URL);
    assertTrue(runByPrettyUrl.isPresent());
    assertEquals(run.getId(), runByPrettyUrl.get().getId());
}
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 19 with PipelineRun

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

the class PipelineRunDaoTest method updateRunStatus.

@Test
public void updateRunStatus() {
    PipelineRun run = createTestPipelineRun();
    run.setStatus(TaskStatus.SUCCESS);
    run.setEndDate(new Date());
    run.setTerminating(true);
    pipelineRunDao.updateRunStatus(run);
    PipelineRun loadedRun = pipelineRunDao.loadPipelineRun(run.getId());
    assertEquals(run.getEndDate(), loadedRun.getEndDate());
    assertEquals(run.getStatus(), loadedRun.getStatus());
    assertEquals(run.isTerminating(), loadedRun.isTerminating());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) Date(java.util.Date) LocalDate(java.time.LocalDate) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 20 with PipelineRun

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

the class PipelineRunDaoTest method testLoadRunWithoutPipeline.

@Test
public void testLoadRunWithoutPipeline() {
    PipelineRun run = createTestPipelineRun(null);
    PipelineRun loadedRun = pipelineRunDao.loadPipelineRun(run.getId());
    assertNull(loadedRun.getPipelineId());
}
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