Search in sources :

Example 11 with RunConfiguration

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

the class RunConfigurationManager method create.

@Transactional(propagation = Propagation.REQUIRED)
public RunConfiguration create(RunConfigurationVO configuration) {
    RunConfiguration newConfig = runConfigurationMapper.toRunConfiguration(configuration);
    validateConfiguration(newConfig);
    newConfig.setOwner(authManager.getAuthorizedUser());
    return runConfigurationDao.create(newConfig);
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with RunConfiguration

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

the class FolderManager method loadTree.

public Folder loadTree() {
    List<Folder> result = folderDao.loadAllFolders();
    List<Pipeline> rootPipelines = pipelineManager.loadRootPipelines();
    List<AbstractDataStorage> rootDataStorages = dataStorageManager.loadRootDataStorages();
    List<RunConfiguration> rootRunConfigurations = configurationManager.loadRootConfigurations();
    Map<String, Integer> rootMetadataEntityCount = metadataEntityManager.loadRootMetadataEntities();
    Folder root = new Folder();
    root.setChildFolders(result);
    if (!CollectionUtils.isEmpty(rootPipelines)) {
        root.setPipelines(rootPipelines);
    }
    if (!CollectionUtils.isEmpty(rootDataStorages)) {
        root.setStorages(rootDataStorages);
    }
    if (!CollectionUtils.isEmpty(rootRunConfigurations)) {
        root.setConfigurations(rootRunConfigurations);
    }
    if (!CollectionUtils.sizeIsEmpty(rootMetadataEntityCount)) {
        root.setMetadata(rootMetadataEntityCount);
    }
    return root;
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Folder(com.epam.pipeline.entity.pipeline.Folder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 13 with RunConfiguration

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

the class ConfigurationRunner method runConfiguration.

/**
 * Schedules execution of a {@link RunConfiguration} and creates a number
 * of associated {@link PipelineRun} instances. Default values of {@link RunConfiguration}
 * may be overriden by {@code runConfiguration} parameter. If {@code entitiesIds} or {@code metadataClass}
 * are passed method will try to resolve {@link RunConfiguration} parameters according to
 * {@link MetadataEntity} instances. For {@code metadataClass} method will try to find
 * {@link MetadataEntity} instances in the whole project with matching {@link MetadataClass}.
 * For each resolved {@link MetadataEntity} instance a separate {@link PipelineRun} or several ones
 * will be created.
 *
 * @param refreshToken      authorization token for Firecloud
 * @param runConfiguration  to run. Must specify {@code id} parameter of existing in DB
 *                          {@link RunConfiguration} instance. Any other parameter may be specified,
 *                          in this case it will override the same parameter from DB instance.
 *                          For cluster (producing several {@link PipelineRun}) configurations if a list of
 *                          {@link RunConfigurationEntry} is passed in {@code entries} field,
 *                          only entries from this list will be scheduled. If {@code entitiesIds} are specified in
 *                          {@link RunConfigurationWithEntitiesVO} for each entity id a separate run(s)
 *                          of {@link RunConfiguration} will be scheduled. If {@code metadataClass} is set
 *                          a separate run(s) will be scheduled for each {@link MetadataEntity} instance
 *                          with a matching {@link MetadataClass} in current project.
 * @param expansionExpression   expression to convert actual entities from {@code entitiesIds}
 *                              to required {@code rootEntityId} specified in {@link RunConfigurationEntry}
 * @return list of scheduled {@link PipelineRun}
 */
public List<PipelineRun> runConfiguration(String refreshToken, RunConfigurationWithEntitiesVO runConfiguration, String expansionExpression) {
    RunConfiguration dbConfiguration = configurationManager.load(runConfiguration.getId());
    RunConfiguration configuration = mergeRunConfigurations(dbConfiguration, runConfigurationMapper.toRunConfiguration(runConfiguration));
    configurationManager.validateConfiguration(configuration);
    configuration.getEntries().forEach(entry -> configurationProvider.assertExecutionEnvironment(entry));
    List<Long> entitiesIds = getIdsToProcess(runConfiguration);
    return configuration.getEntries().stream().collect(Collectors.groupingBy(AbstractRunConfigurationEntry::getExecutionEnvironment)).entrySet().stream().map(env -> {
        AnalysisConfiguration<AbstractRunConfigurationEntry> conf = AnalysisConfiguration.builder().configurationId(configuration.getId()).entries(env.getValue()).entitiesIds(entitiesIds).expansionExpression(expansionExpression).refreshToken(refreshToken).build();
        return configurationProvider.runAnalysis(conf);
    }).flatMap(Collection::stream).collect(Collectors.toList());
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) AbstractRunConfigurationEntry(com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry)

Example 14 with RunConfiguration

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

the class RunConfigurationDaoTest method testCRUD.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCRUD() {
    // create
    RunConfigurationEntry entry = ObjectCreatorUtils.createConfigEntry(TEST_CONFIG_NAME, true, getTestConfig());
    RunConfiguration configuration = ObjectCreatorUtils.createConfiguration(TEST_NAME, TEST_DESCRIPTION, null, TEST_OWNER, Collections.singletonList(entry));
    RunConfiguration created = runConfigurationDao.create(configuration);
    verifyRunConfiguration(configuration, created);
    // load
    RunConfiguration loaded = runConfigurationDao.load(created.getId());
    verifyRunConfiguration(configuration, loaded);
    // loadAll
    List<RunConfiguration> configurations = runConfigurationDao.loadAll();
    Assert.assertEquals(1, configurations.size());
    verifyRunConfiguration(configuration, configurations.get(0));
    // loadRoot
    configurations = runConfigurationDao.loadRootEntities();
    Assert.assertEquals(1, configurations.size());
    verifyRunConfiguration(configuration, configurations.get(0));
    // load with folders
    loaded = runConfigurationDao.loadConfigurationWithParents(created.getId());
    verifyRunConfiguration(configuration, loaded);
    // update
    created.setDescription(TEST_DESCRIPTION + TEST_DESCRIPTION);
    created.setEntries(Arrays.asList(entry, entry));
    runConfigurationDao.update(created);
    verifyRunConfiguration(created, runConfigurationDao.load(created.getId()));
    // delete
    runConfigurationDao.delete(created.getId());
    Assert.assertTrue(runConfigurationDao.loadAll().isEmpty());
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) FirecloudRunConfigurationEntry(com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with RunConfiguration

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

the class RunConfigurationDaoTest method shouldLoadRunConfigurationWithFolderTree.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldLoadRunConfigurationWithFolderTree() {
    Folder root = buildFolder(TEST_NAME, null);
    root.setParentId(0L);
    Folder folder = buildFolder(TEST_NAME_1, root.getId());
    folder.setParent(root);
    Folder parent = buildFolder(TEST_NAME_2, folder.getId());
    parent.setParent(folder);
    RunConfigurationEntry entry = ObjectCreatorUtils.createConfigEntry(TEST_CONFIG_NAME, true, getTestConfig());
    RunConfiguration configuration = ObjectCreatorUtils.createConfiguration(TEST_NAME, TEST_DESCRIPTION, parent.getId(), TEST_OWNER, Collections.singletonList(entry));
    RunConfiguration created = runConfigurationDao.create(configuration);
    verifyRunConfiguration(configuration, created);
    // load with folders
    RunConfiguration loaded = runConfigurationDao.loadConfigurationWithParents(created.getId());
    verifyRunConfiguration(configuration, loaded);
    verifyFolderTree(parent, loaded.getParent());
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) FirecloudRunConfigurationEntry(com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)23 Folder (com.epam.pipeline.entity.pipeline.Folder)10 Transactional (org.springframework.transaction.annotation.Transactional)9 Test (org.junit.Test)8 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)7 RunConfigurationEntry (com.epam.pipeline.entity.configuration.RunConfigurationEntry)6 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)6 FirecloudRunConfigurationEntry (com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry)5 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)4 MapperVerificationUtils.verifyRunConfiguration (com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyRunConfiguration)3 AbstractRunConfigurationEntry (com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry)3 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)3 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)3 ConfigurationEntryDoc (com.epam.pipeline.elasticsearchagent.model.ConfigurationEntryDoc)2 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)2 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)2 AclClass (com.epam.pipeline.entity.security.acl.AclClass)2 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)2 Test (org.junit.jupiter.api.Test)2 AwsRegionVO (com.epam.pipeline.controller.vo.AwsRegionVO)1