Search in sources :

Example 36 with PipelineConfiguration

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

the class CommandBuilderTest method constructConfiguration.

private PipelineConfiguration constructConfiguration() {
    PipelineConfiguration configuration = new PipelineConfiguration();
    configuration.setCmdTemplate(template);
    configuration.setMainFile(MAIN_FILE);
    configuration.setMainClass(MAIN_CLASS);
    configuration.setEnvironmentParams(new LinkedHashMap<String, String>() {

        {
            put("main_class", MAIN_CLASS);
            put("main_file", MAIN_FILE);
            put("cmd_template", template);
        }
    });
    configuration.setParameters(new LinkedHashMap<String, PipeConfValueVO>() {

        {
            put("sample", new PipeConfValueVO(SAMPLE));
            put("input-fastq", new PipeConfValueVO(INPUT_FASTQ));
        }
    });
    return configuration;
}
Also used : PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration)

Example 37 with PipelineConfiguration

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

the class EnvVarsBuilderTest method matchPipeConfig.

public static PipelineConfiguration matchPipeConfig() {
    PipelineConfiguration configuration = new PipelineConfiguration();
    configuration.setCmdTemplate(CMD_TEMPLATE);
    configuration.setMainClass(MAIN_CLASS_VALUE);
    configuration.setMainFile(MAIN_FILE_VALUE);
    configuration.buildEnvVariables();
    configuration.setParameters(new HashMap<String, PipeConfValueVO>() {

        {
            put(P1, new PipeConfValueVO(P1_VALUE, NUMBER_TYPE));
            put(P2, new PipeConfValueVO(P2_VALUE, STRING_TYPE));
        }
    });
    return configuration;
}
Also used : PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration)

Example 38 with PipelineConfiguration

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

the class FolderManagerTest method shouldCloneWithRunConfiguration.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneWithRunConfiguration() {
    Folder sourceFolder = new Folder();
    sourceFolder.setName(FOLDER_TO_CLONE);
    folderManager.create(sourceFolder);
    PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
    pipelineConfiguration.setCmdTemplate(TEST_NAME);
    RunConfigurationEntry entry = createConfigEntry(TEST_NAME, true, pipelineConfiguration);
    RunConfigurationVO runConfigurationVO = createRunConfigurationVO(TEST_NAME, TEST_DESCRIPTION, sourceFolder.getId(), Collections.singletonList(entry));
    RunConfiguration expectedRunConfiguration = runConfigurationManager.create(runConfigurationVO);
    Folder childSourceFolder = new Folder();
    childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
    childSourceFolder.setParentId(sourceFolder.getId());
    folderManager.create(childSourceFolder);
    runConfigurationVO.setParentId(childSourceFolder.getId());
    runConfigurationManager.create(runConfigurationVO);
    Folder destinationFolder = new Folder();
    destinationFolder.setName(TEST_NAME);
    folderManager.create(destinationFolder);
    folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
    destinationFolder = folderManager.loadByNameOrId(TEST_NAME);
    destinationFolder = folderManager.load(destinationFolder.getId());
    Folder clonedFolder = destinationFolder.getChildFolders().get(0);
    RunConfiguration clonedRunConfiguration = runConfigurationManager.loadAll().stream().filter(conf -> Objects.equals(conf.getParent().getId(), clonedFolder.getId())).collect(Collectors.toList()).get(0);
    assertRunConfiguration(expectedRunConfiguration, clonedRunConfiguration);
    Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
    clonedRunConfiguration = runConfigurationManager.loadAll().stream().filter(conf -> Objects.equals(conf.getParent().getId(), clonedChildFolder.getId())).collect(Collectors.toList()).get(0);
    assertRunConfiguration(expectedRunConfiguration, clonedRunConfiguration);
}
Also used : AwsRegionVO(com.epam.pipeline.controller.vo.AwsRegionVO) MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) Autowired(org.springframework.beans.factory.annotation.Autowired) ObjectCreatorUtils.constructPipelineVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructPipelineVO) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) Assert.assertThat(org.junit.Assert.assertThat) MockitoAnnotations(org.mockito.MockitoAnnotations) Folder(com.epam.pipeline.entity.pipeline.Folder) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Pair(org.apache.commons.lang3.tuple.Pair) MockS3Helper(com.epam.pipeline.manager.MockS3Helper) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Mockito.doReturn(org.mockito.Mockito.doReturn) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) S3StorageProvider(com.epam.pipeline.manager.datastorage.providers.aws.s3.S3StorageProvider) GitManager(com.epam.pipeline.manager.git.GitManager) SpyBean(org.springframework.boot.test.mock.mockito.SpyBean) Set(java.util.Set) Collectors(java.util.stream.Collectors) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Objects(java.util.Objects) Matchers.any(org.mockito.Matchers.any) List(java.util.List) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) ObjectCreatorUtils.constructDataStorageVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO) DataStorageManager(com.epam.pipeline.manager.datastorage.DataStorageManager) ObjectCreatorUtils.createConfigEntry(com.epam.pipeline.manager.ObjectCreatorUtils.createConfigEntry) EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Mock(org.mockito.Mock) HashMap(java.util.HashMap) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) RunConfigurationVO(com.epam.pipeline.controller.vo.configuration.RunConfigurationVO) MetadataManager(com.epam.pipeline.manager.metadata.MetadataManager) Value(org.springframework.beans.factory.annotation.Value) HashSet(java.util.HashSet) CollectionUtils(org.apache.commons.collections.CollectionUtils) Propagation(org.springframework.transaction.annotation.Propagation) PipelineVO(com.epam.pipeline.controller.vo.PipelineVO) Before(org.junit.Before) ObjectCreatorUtils.createRunConfigurationVO(com.epam.pipeline.manager.ObjectCreatorUtils.createRunConfigurationVO) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Test(org.junit.Test) DataStorageType(com.epam.pipeline.entity.datastorage.DataStorageType) Mockito.when(org.mockito.Mockito.when) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) Assert.assertNull(org.junit.Assert.assertNull) MetadataEntityManager(com.epam.pipeline.manager.metadata.MetadataEntityManager) AclClass(com.epam.pipeline.entity.security.acl.AclClass) RunConfigurationManager(com.epam.pipeline.manager.configuration.RunConfigurationManager) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) AwsRegionManager(com.epam.pipeline.manager.region.AwsRegionManager) Transactional(org.springframework.transaction.annotation.Transactional) RunConfigurationVO(com.epam.pipeline.controller.vo.configuration.RunConfigurationVO) ObjectCreatorUtils.createRunConfigurationVO(com.epam.pipeline.manager.ObjectCreatorUtils.createRunConfigurationVO) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 39 with PipelineConfiguration

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

the class PipelineConfigurationForRunnerTest method shouldGetConfigurationForPipelineRun.

@Test
public void shouldGetConfigurationForPipelineRun() {
    PipelineStart vo = getPipelineStartVO();
    vo.setPipelineId(1L);
    vo.setVersion("draft");
    PipelineConfiguration config = pipelineConfigurationManager.getPipelineConfiguration(vo);
    commonPipelineConfigurationAssertions(config);
    assertThat(config).hasFieldOrPropertyWithValue(INSTANCE_DISK_FIELD, TEST_HDD_SIZE).hasFieldOrPropertyWithValue(WORKED_CMD_FIELD, // from default configuration
    TEST_WORKED_CMD);
    assertThat(config.getParameters()).isNotEmpty().hasSize(2).containsKeys(TEST_PARAM_1, // from default configuration
    TEST_PARAM_2);
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) PipelineStart(com.epam.pipeline.entity.pipeline.run.PipelineStart) Test(org.junit.Test) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest)

Example 40 with PipelineConfiguration

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

the class PipelineVersionManagerTest method testDockerImageSetFromProperties.

@Test
public void testDockerImageSetFromProperties() throws GitClientException, IOException {
    Mockito.when(preferenceManager.getPreference(SystemPreferences.LAUNCH_DOCKER_IMAGE)).thenReturn(IMAGE_FROM_PROPERTIES);
    Tool mockTool = getMockTool(TEST_REPOSITORY, IMAGE_FROM_PROPERTIES);
    Mockito.when(gitManager.getConfigFileContent(Mockito.any(Pipeline.class), Mockito.anyString())).thenReturn(getFileContent(WITHOUT_IMAGE_CONFIG));
    Mockito.when(toolManager.loadByNameOrId(IMAGE_FROM_PROPERTIES)).thenReturn(mockTool);
    PipelineConfiguration configuration = pipelineVersionManager.loadParametersFromScript(1L, "");
    Assert.assertEquals(TEST_REPOSITORY + "/" + IMAGE_FROM_PROPERTIES, configuration.getDockerImage());
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Tool(com.epam.pipeline.entity.pipeline.Tool) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Test(org.junit.Test) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest)

Aggregations

PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)43 Test (org.junit.Test)16 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)12 Tool (com.epam.pipeline.entity.pipeline.Tool)12 RunConfigurationEntry (com.epam.pipeline.entity.configuration.RunConfigurationEntry)10 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)9 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)9 PipelineStart (com.epam.pipeline.entity.pipeline.run.PipelineStart)8 List (java.util.List)7 ConfigurationEntry (com.epam.pipeline.entity.configuration.ConfigurationEntry)6 Before (org.junit.Before)6 PipeConfValueVO (com.epam.pipeline.entity.configuration.PipeConfValueVO)5 HashMap (java.util.HashMap)5 Collectors (java.util.stream.Collectors)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Transactional (org.springframework.transaction.annotation.Transactional)5 RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)4 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)4 RunInstance (com.epam.pipeline.entity.pipeline.RunInstance)4 ArrayList (java.util.ArrayList)4