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);
}
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()));
}
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;
}
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;
}
Aggregations