use of com.epam.pipeline.entity.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class PipelineConfigurationForRunnerTest method shouldGetDefaultConfigurationForToolVersionRun.
@Test
public void shouldGetDefaultConfigurationForToolVersionRun() {
Tool tool = new Tool();
tool.setImage(TEST_IMAGE);
tool.setRam(TEST_RAM);
tool.setCpu(TEST_CPU);
tool.setDisk(Integer.parseInt(TEST_HDD_SIZE));
PipelineStart vo = getPipelineStartVO();
vo.setHddSize(null);
PipelineConfiguration config = pipelineConfigurationManager.getPipelineConfiguration(vo, tool);
commonPipelineConfigurationAssertions(config);
assertThat(config).hasFieldOrPropertyWithValue(INSTANCE_DISK_FIELD, // from tool
TEST_HDD_SIZE);
assertThat(config.getParameters()).isNotEmpty().hasSize(2).containsKeys(TEST_PARAM_1, // from default configuration
TEST_PARAM_2);
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class PipelineConfigurationForRunnerTest method shouldGetConfigurationForPodRun.
@Test
public void shouldGetConfigurationForPodRun() {
PipelineStart vo = getPipelineStartVO();
PipelineConfiguration config = pipelineConfigurationManager.getPipelineConfiguration(vo);
commonPipelineConfigurationAssertions(config);
assertThat(config).hasFieldOrPropertyWithValue(INSTANCE_DISK_FIELD, TEST_HDD_SIZE);
assertThat(config.getParameters()).isNotEmpty().hasSize(1).containsKeys(TEST_PARAM_1);
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration 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.PipelineConfiguration in project cloud-pipeline by epam.
the class PipelineRunManagerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
notScannedTool = new Tool();
notScannedTool.setId(1L);
notScannedTool.setImage(TEST_IMAGE);
notScannedTool.setDefaultCommand("sleep");
configuration = new PipelineConfiguration();
configuration.setDockerImage(TEST_IMAGE);
configuration.setInstanceDisk("1");
configuration.setIsSpot(true);
price = new InstancePrice(configuration.getInstanceType(), Integer.valueOf(configuration.getInstanceDisk()), PRICE_PER_HOUR);
when(toolManager.loadByNameOrId(TEST_IMAGE)).thenReturn(notScannedTool);
when(instanceOfferManager.isInstanceAllowed(anyString())).thenReturn(true);
when(instanceOfferManager.isToolInstanceAllowed(anyString(), any())).thenReturn(true);
when(instanceOfferManager.isPriceTypeAllowed(anyString(), any())).thenReturn(true);
when(instanceOfferManager.getAllInstanceTypesObservable()).thenReturn(BehaviorSubject.create());
when(instanceOfferManager.getInstanceEstimatedPrice(anyString(), anyInt(), anyBoolean(), anyString())).thenReturn(price);
when(pipelineLauncher.launch(any(PipelineRun.class), any(), any(), anyString(), anyString())).thenReturn("sleep");
when(toolManager.loadToolVersionScan(notScannedTool.getId(), null)).thenReturn(Optional.empty());
when(toolVersionManager.loadToolVersion(anyLong(), anyString())).thenReturn(ToolVersion.builder().size(1L).build());
doReturn(configuration).when(pipelineConfigurationManager).getPipelineConfiguration(any());
doReturn(configuration).when(pipelineConfigurationManager).getPipelineConfiguration(any(), any());
AwsRegion region = new AwsRegion();
region.setAwsRegionName("us-east-1");
doReturn(region).when(awsRegionManager).loadDefaultRegion();
doNothing().when(entityManager).setManagers(any());
doNothing().when(resourceMonitoringManager).monitorResourceUsage();
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class PipelineConfigurationManagerTest method testGetUnregisteredPipelineConfiguration.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
@WithMockUser(username = TEST_OWNER1)
public void testGetUnregisteredPipelineConfiguration() {
PipelineStart vo = getPipelineStartVO();
PipelineConfiguration config = pipelineConfigurationManager.getPipelineConfiguration(vo);
Assert.assertFalse(config.getBuckets().isEmpty());
Assert.assertFalse(config.getNfsMountOptions().isEmpty());
String[] buckets = config.getBuckets().split(";");
Assert.assertEquals(2, buckets.length);
for (String bucket : buckets) {
Assert.assertTrue(dataStorages.stream().anyMatch(ds -> bucket.equals(ds.getPathMask())));
}
String[] nfsOptions = config.getNfsMountOptions().split(";");
Assert.assertEquals(1, nfsOptions.length);
for (String option : nfsOptions) {
if (StringUtils.isNotBlank(option)) {
Assert.assertTrue(dataStorages.stream().filter(ds -> ds instanceof NFSDataStorage).anyMatch(ds -> {
NFSDataStorage nfsDs = (NFSDataStorage) ds;
return nfsDs.getMountOptions().equals(option) || option.equals(nfsDs.getMountOptions() + ",ro");
}));
}
}
String[] mountPoints = config.getMountPoints().split(";");
for (String mountPoint : mountPoints) {
if (StringUtils.isNotBlank(mountPoint)) {
Assert.assertTrue(dataStorages.stream().anyMatch(ds -> mountPoint.equals(ds.getMountPoint())));
}
}
// Assert.assertTrue(Arrays.stream(nfsOptions).anyMatch(o -> o.endsWith(",ro")));
}
Aggregations