Search in sources :

Example 21 with PipelineConfiguration

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

the class PipelineVersionManagerTest method getPipelineConfig.

@Test
@Ignore
public void getPipelineConfig() throws GitClientException, IOException {
    Pipeline mockPipeline = new Pipeline();
    mockPipeline.setRepository(TEST_HTTP_REPOSITORY);
    mockPipeline.setId(1L);
    Mockito.when(pipelineManagerMock.load(mockPipeline.getId())).thenReturn(mockPipeline);
    Mockito.when(gitManager.getConfigFileContent(mockPipeline, TEST_REVISION_1)).thenReturn(getFileContent(TEST_CONFIG));
    PipelineConfiguration configuration = pipelineVersionManager.loadParametersFromScript(1L, TEST_REVISION_1);
    Assert.assertNotNull(configuration);
    Assert.assertEquals(EXPECTED_DEFAULT_PARAMS, configuration.getParameters().size());
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest)

Example 22 with PipelineConfiguration

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

the class PipelineVersionManagerTest method testDockerImageSetFromConfig.

@Test
public void testDockerImageSetFromConfig() throws GitClientException, IOException {
    Tool mockTool = getMockTool(TEST_REPOSITORY, IMAGE_FROM_CONFIG);
    Mockito.when(gitManager.getConfigFileContent(Mockito.any(Pipeline.class), Mockito.anyString())).thenReturn(getFileContent(WITH_IMAGE_CONFIG));
    Mockito.when(toolManager.loadByNameOrId(IMAGE_FROM_CONFIG)).thenReturn(mockTool);
    PipelineConfiguration configuration = pipelineVersionManager.loadParametersFromScript(1L, "");
    Assert.assertEquals(TEST_REPOSITORY + "/" + IMAGE_FROM_CONFIG, 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)

Example 23 with PipelineConfiguration

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

the class PipelineVersionManagerTest method testImageWithValidRepository.

@Test
public void testImageWithValidRepository() throws GitClientException, IOException {
    Mockito.when(preferenceManager.getPreference(SystemPreferences.LAUNCH_DOCKER_IMAGE)).thenReturn(TEST_REPOSITORY + "/" + 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(TEST_REPOSITORY + "/" + 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)

Example 24 with PipelineConfiguration

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

the class RunConfigurationProviderTest method validateShouldUseToolResourceWhileCheckingToolAllowedIfDockerImageIsSpecified.

@Test
public void validateShouldUseToolResourceWhileCheckingToolAllowedIfDockerImageIsSpecified() {
    final PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
    pipelineConfiguration.setInstanceType(ALLOWED_INSTANCE_TYPE);
    pipelineConfiguration.setDockerImage(TOOL_IMAGE);
    final RunConfigurationEntry runConfigurationEntry = new RunConfigurationEntry();
    runConfigurationEntry.setConfiguration(pipelineConfiguration);
    runConfigurationProvider.validateEntry(runConfigurationEntry);
    verify(instanceOfferManager).isToolInstanceAllowed(any(), eq(TOOL_RESOURCE));
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Test(org.junit.Test)

Example 25 with PipelineConfiguration

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

the class RunConfigurationProviderTest method validateShouldFailIfConfigurationInstanceTypeIsNotAllowed.

@Test
public void validateShouldFailIfConfigurationInstanceTypeIsNotAllowed() {
    final PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
    pipelineConfiguration.setInstanceType(NOT_ALLOWED_INSTANCE_TYPE);
    final RunConfigurationEntry runConfigurationEntry = new RunConfigurationEntry();
    runConfigurationEntry.setConfiguration(pipelineConfiguration);
    assertThrows(IllegalArgumentException.class, () -> runConfigurationProvider.validateEntry(runConfigurationEntry));
    verify(instanceOfferManager).isToolInstanceAllowed(eq(NOT_ALLOWED_INSTANCE_TYPE), any());
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Test(org.junit.Test)

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