Search in sources :

Example 26 with Tool

use of com.epam.pipeline.entity.pipeline.Tool 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 27 with Tool

use of com.epam.pipeline.entity.pipeline.Tool 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);
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) 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 28 with Tool

use of com.epam.pipeline.entity.pipeline.Tool 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();
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) AwsRegion(com.epam.pipeline.entity.region.AwsRegion) InstancePrice(com.epam.pipeline.entity.cluster.InstancePrice) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Tool(com.epam.pipeline.entity.pipeline.Tool) Before(org.junit.Before)

Example 29 with Tool

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

the class ToolApiServiceTest method generateTool.

static Tool generateTool() {
    Tool tool = new Tool();
    tool.setImage(TEST_IMAGE);
    tool.setRam(TEST_RAM);
    tool.setCpu(TEST_CPU);
    return tool;
}
Also used : Tool(com.epam.pipeline.entity.pipeline.Tool)

Example 30 with Tool

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

the class PipelineConfigurationManagerTest method setUp.

@Before
public void setUp() throws Exception {
    registry = new DockerRegistry();
    registry.setPath(TEST_REPO);
    registry.setOwner(TEST_USER);
    dockerRegistryDao.createDockerRegistry(registry);
    library = new ToolGroup();
    library.setName(TOOL_GROUP_NAME);
    library.setRegistryId(registry.getId());
    library.setOwner(TEST_USER);
    toolGroupDao.createToolGroup(library);
    tool = new Tool();
    tool.setImage(TEST_IMAGE);
    tool.setRam(TEST_RAM);
    tool.setCpu(TEST_CPU);
    tool.setOwner(TEST_USER);
    tool.setRegistryId(registry.getId());
    tool.setToolGroupId(library.getId());
    toolDao.createTool(tool);
    // Data storages of user 1
    NFSDataStorage dataStorage = new NFSDataStorage(dataStorageDao.createDataStorageId(), "testNFS", "test/path1");
    dataStorage.setMountOptions("testMountOptions1");
    dataStorage.setMountPoint("/some/other/path");
    dataStorage.setOwner(TEST_OWNER1);
    dataStorageDao.createDataStorage(dataStorage);
    dataStorages.add(dataStorage);
    S3bucketDataStorage bucketDataStorage = new S3bucketDataStorage(dataStorageDao.createDataStorageId(), "testBucket", "test/path2");
    bucketDataStorage.setOwner(TEST_OWNER1);
    dataStorageDao.createDataStorage(bucketDataStorage);
    dataStorages.add(bucketDataStorage);
    // Data storages of user 2
    dataStorage = new NFSDataStorage(dataStorageDao.createDataStorageId(), "testNFS2", "test/path3");
    dataStorage.setMountOptions("testMountOptions2");
    dataStorage.setOwner(TEST_OWNER2);
    dataStorageDao.createDataStorage(dataStorage);
    dataStorages.add(dataStorage);
    bucketDataStorage = new S3bucketDataStorage(dataStorageDao.createDataStorageId(), "testBucket2", "test/path4");
    bucketDataStorage.setOwner(TEST_OWNER2);
    dataStorageDao.createDataStorage(bucketDataStorage);
    dataStorages.add(bucketDataStorage);
    dataStorages.forEach(ds -> aclTestDao.createAclForObject(ds));
    aclTestDao.grantPermissions(dataStorage, TEST_OWNER1, Collections.singletonList((AclPermission) AclPermission.READ));
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) AclPermission(com.epam.pipeline.security.acl.AclPermission) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) NFSDataStorage(com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) Tool(com.epam.pipeline.entity.pipeline.Tool) Before(org.junit.Before)

Aggregations

Tool (com.epam.pipeline.entity.pipeline.Tool)72 Transactional (org.springframework.transaction.annotation.Transactional)28 DockerRegistry (com.epam.pipeline.entity.pipeline.DockerRegistry)24 Test (org.junit.Test)22 ToolGroup (com.epam.pipeline.entity.pipeline.ToolGroup)14 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)11 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)9 DockerClient (com.epam.pipeline.manager.docker.DockerClient)9 List (java.util.List)9 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)8 MessageHelper (com.epam.pipeline.common.MessageHelper)7 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)7 ToolVersionScanResult (com.epam.pipeline.entity.scan.ToolVersionScanResult)7 ToolScanExternalServiceException (com.epam.pipeline.exception.ToolScanExternalServiceException)7 DockerRegistryManager (com.epam.pipeline.manager.docker.DockerRegistryManager)7 Optional (java.util.Optional)7 MessageConstants (com.epam.pipeline.common.MessageConstants)6 ManifestV2 (com.epam.pipeline.entity.docker.ManifestV2)6 ToolScanStatus (com.epam.pipeline.entity.pipeline.ToolScanStatus)6 DockerClientFactory (com.epam.pipeline.manager.docker.DockerClientFactory)6