Search in sources :

Example 6 with ConfigurationEntry

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

the class PipelineConfigurationForRunnerTest method shouldGetSpecifiedConfigurationForToolVersionRun.

@Test
public void shouldGetSpecifiedConfigurationForToolVersionRun() {
    Tool tool = new Tool();
    tool.setImage(TEST_IMAGE);
    tool.setRam(TEST_RAM);
    tool.setCpu(TEST_CPU);
    ConfigurationEntry otherConfigurationEntry = new ConfigurationEntry();
    otherConfigurationEntry.setName(TEST_CONFIGURATION_NAME);
    PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
    pipelineConfiguration.setInstanceDisk(TEST_HDD_SIZE);
    otherConfigurationEntry.setConfiguration(pipelineConfiguration);
    when(toolVersionManagerMock.loadToolVersionSettings(anyLong(), anyString())).thenReturn(Collections.singletonList(ToolVersion.builder().settings(Arrays.asList(configurationEntry, otherConfigurationEntry)).build()));
    PipelineStart vo = getPipelineStartVO();
    vo.setHddSize(null);
    vo.setConfigurationName(TEST_CONFIGURATION_NAME);
    PipelineConfiguration config = pipelineConfigurationManager.getPipelineConfiguration(vo, tool);
    commonPipelineConfigurationAssertions(config);
    assertThat(config).hasFieldOrPropertyWithValue(INSTANCE_DISK_FIELD, // from configuration
    TEST_HDD_SIZE);
    assertThat(config.getParameters()).isNotEmpty().hasSize(1).containsKeys(TEST_PARAM_1);
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry) Tool(com.epam.pipeline.entity.pipeline.Tool) PipelineStart(com.epam.pipeline.entity.pipeline.run.PipelineStart) Test(org.junit.Test) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest)

Example 7 with ConfigurationEntry

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

the class PipelineConfigurationForRunnerTest method setUp.

@Before
public void setUp() throws GitClientException {
    MockitoAnnotations.initMocks(this);
    PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
    pipelineConfiguration.setWorkerCmd(TEST_WORKED_CMD);
    pipelineConfiguration.setParameters(Collections.singletonMap(TEST_PARAM_2, TEST_PARAM_VALUE));
    configurationEntry = new ConfigurationEntry();
    configurationEntry.setConfiguration(pipelineConfiguration);
    configurationEntry.setDefaultConfiguration(true);
    when(toolManagerMock.getTagFromImageName(anyString())).thenReturn("latest");
    when(gitManagerMock.getGitCredentials(anyLong())).thenReturn(null);
    when(pipelineVersionManagerMock.loadConfigurationEntry(anyLong(), anyString(), anyString())).thenReturn(configurationEntry);
    when(pipelineVersionManagerMock.getValidDockerImage(anyString())).thenReturn(TEST_IMAGE);
    when(dataStorageApiServiceMock.getWritableStorages()).thenReturn(Collections.emptyList());
    when(permissionsServiceMock.isMaskBitSet(anyInt(), anyInt())).thenReturn(true);
    when(toolVersionManagerMock.loadToolVersionSettings(anyLong(), anyString())).thenReturn(Collections.singletonList(ToolVersion.builder().settings(Collections.singletonList(configurationEntry)).build()));
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry) Before(org.junit.Before)

Example 8 with ConfigurationEntry

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

the class PipelineConfigurationManager method getConfigurationFromRun.

public PipelineConfiguration getConfigurationFromRun(PipelineRun run) {
    PipelineConfiguration configuration = new PipelineConfiguration();
    configuration.setParameters(run.convertParamsToMap());
    configuration.setTimeout(run.getTimeout());
    configuration.setNodeCount(run.getNodeCount());
    configuration.setCmdTemplate(run.getCmdTemplate());
    configuration.setDockerImage(run.getDockerImage());
    RunInstance instance = run.getInstance();
    if (instance != null) {
        configuration.setInstanceDisk(String.valueOf(instance.getEffectiveNodeDisk()));
        configuration.setInstanceType(instance.getNodeType());
        configuration.setIsSpot(instance.getSpot());
        configuration.setInstanceImage(instance.getNodeImage());
        configuration.setAwsRegionId(awsRegionManager.loadByAwsRegionName(instance.getAwsRegionId()).getId());
    }
    setEndpointsErasure(configuration);
    if (run.getPipelineId() != null) {
        try {
            ConfigurationEntry entry = pipelineVersionManager.loadConfigurationEntry(run.getPipelineId(), run.getVersion(), run.getConfigName());
            PipelineConfiguration defaultConfiguration = entry.getConfiguration();
            configuration.setEnvironmentParams(defaultConfiguration.getEnvironmentParams());
            configuration.setMainClass(defaultConfiguration.getMainClass());
            configuration.setMainFile(defaultConfiguration.getMainFile());
        } catch (GitClientException e) {
            log.error(e.getMessage(), e);
        }
        configuration.setGitCredentials(gitManager.getGitCredentials(run.getPipelineId()));
    }
    configuration.buildEnvVariables();
    return configuration;
}
Also used : GitClientException(com.epam.pipeline.exception.git.GitClientException) RunInstance(com.epam.pipeline.entity.pipeline.RunInstance) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry)

Example 9 with ConfigurationEntry

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

the class PipelineVersionManager method loadConfigurationEntry.

public ConfigurationEntry loadConfigurationEntry(Long id, String version, String configName) throws GitClientException {
    List<ConfigurationEntry> configurations = loadConfigurationsFromScript(id, version);
    if (CollectionUtils.isEmpty(configurations)) {
        throw new ConfigurationReadingException(CONFIG_FILE_NAME);
    }
    if (StringUtils.hasText(configName)) {
        return configurations.stream().filter(conf -> conf.getName() != null && conf.getName().equals(configName)).findFirst().orElseThrow(() -> new IllegalArgumentException(messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NOT_FOUND, configName)));
    }
    ConfigurationEntry defaultConfig = getDefaultConfig(configurations);
    return defaultConfig == null ? configurations.get(0) : defaultConfig;
}
Also used : ConfigurationReadingException(com.epam.pipeline.exception.ConfigurationReadingException) ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry)

Aggregations

ConfigurationEntry (com.epam.pipeline.entity.configuration.ConfigurationEntry)9 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)5 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)3 Test (org.junit.Test)2 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)1 PipeConfValueVO (com.epam.pipeline.entity.configuration.PipeConfValueVO)1 ToolVersion (com.epam.pipeline.entity.docker.ToolVersion)1 RunInstance (com.epam.pipeline.entity.pipeline.RunInstance)1 Tool (com.epam.pipeline.entity.pipeline.Tool)1 PipelineStart (com.epam.pipeline.entity.pipeline.run.PipelineStart)1 ConfigurationReadingException (com.epam.pipeline.exception.ConfigurationReadingException)1 GitClientException (com.epam.pipeline.exception.git.GitClientException)1 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)1 Before (org.junit.Before)1