Search in sources :

Example 1 with PipelineStart

use of com.epam.pipeline.entity.pipeline.run.PipelineStart 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 2 with PipelineStart

use of com.epam.pipeline.entity.pipeline.run.PipelineStart 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 3 with PipelineStart

use of com.epam.pipeline.entity.pipeline.run.PipelineStart 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);
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) PipelineStart(com.epam.pipeline.entity.pipeline.run.PipelineStart) Test(org.junit.Test) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest)

Example 4 with PipelineStart

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

the class PipelineRunManagerTest method testRunCmdFailed.

/**
 * Tests that Aspect will deny PipelineRunManager::runCmd method execution
 */
@Test(expected = ToolExecutionDeniedException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testRunCmdFailed() {
    PipelineStart startVO = new PipelineStart();
    preferenceManager.update(Arrays.asList(new Preference(SystemPreferences.DOCKER_SECURITY_TOOL_POLICY_DENY_NOT_SCANNED.getKey(), Boolean.toString(true))));
    startVO.setDockerImage(TEST_IMAGE);
    pipelineRunManager.runCmd(startVO);
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) PipelineStart(com.epam.pipeline.entity.pipeline.run.PipelineStart) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with PipelineStart

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

the class PipelineRunManagerTest method testAdminRunForce.

/**
 * Tests that Admin can run any tool
 */
@WithMockUser(roles = "ADMIN")
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testAdminRunForce() {
    PipelineStart startVO = new PipelineStart();
    startVO.setDockerImage(TEST_IMAGE);
    startVO.setForce(true);
    startVO.setInstanceType(INSTANCE_TYPE);
    startVO.setHddSize(1);
    pipelineRunManager.runCmd(startVO);
    verify(notificationManager).notifyRunStatusChanged(any());
}
Also used : PipelineStart(com.epam.pipeline.entity.pipeline.run.PipelineStart) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PipelineStart (com.epam.pipeline.entity.pipeline.run.PipelineStart)16 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)7 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)7 Test (org.junit.Test)7 Tool (com.epam.pipeline.entity.pipeline.Tool)4 PipeConfValueVO (com.epam.pipeline.entity.configuration.PipeConfValueVO)3 Transactional (org.springframework.transaction.annotation.Transactional)3 ConfigurationEntry (com.epam.pipeline.entity.configuration.ConfigurationEntry)2 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)2 NFSDataStorage (com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage)2 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)2 AclPermission (com.epam.pipeline.security.acl.AclPermission)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2 TestApplicationWithAclSecurity (com.epam.pipeline.app.TestApplicationWithAclSecurity)1 MessageConstants (com.epam.pipeline.common.MessageConstants)1 MessageHelper (com.epam.pipeline.common.MessageHelper)1