Search in sources :

Example 6 with RunConfigurationEntry

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

the class RunConfigurationDaoTest method testCRUD.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCRUD() {
    // create
    RunConfigurationEntry entry = ObjectCreatorUtils.createConfigEntry(TEST_CONFIG_NAME, true, getTestConfig());
    RunConfiguration configuration = ObjectCreatorUtils.createConfiguration(TEST_NAME, TEST_DESCRIPTION, null, TEST_OWNER, Collections.singletonList(entry));
    RunConfiguration created = runConfigurationDao.create(configuration);
    verifyRunConfiguration(configuration, created);
    // load
    RunConfiguration loaded = runConfigurationDao.load(created.getId());
    verifyRunConfiguration(configuration, loaded);
    // loadAll
    List<RunConfiguration> configurations = runConfigurationDao.loadAll();
    Assert.assertEquals(1, configurations.size());
    verifyRunConfiguration(configuration, configurations.get(0));
    // loadRoot
    configurations = runConfigurationDao.loadRootEntities();
    Assert.assertEquals(1, configurations.size());
    verifyRunConfiguration(configuration, configurations.get(0));
    // load with folders
    loaded = runConfigurationDao.loadConfigurationWithParents(created.getId());
    verifyRunConfiguration(configuration, loaded);
    // update
    created.setDescription(TEST_DESCRIPTION + TEST_DESCRIPTION);
    created.setEntries(Arrays.asList(entry, entry));
    runConfigurationDao.update(created);
    verifyRunConfiguration(created, runConfigurationDao.load(created.getId()));
    // delete
    runConfigurationDao.delete(created.getId());
    Assert.assertTrue(runConfigurationDao.loadAll().isEmpty());
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) FirecloudRunConfigurationEntry(com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with RunConfigurationEntry

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

the class RunConfigurationDaoTest method shouldLoadRunConfigurationWithFolderTree.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldLoadRunConfigurationWithFolderTree() {
    Folder root = buildFolder(TEST_NAME, null);
    root.setParentId(0L);
    Folder folder = buildFolder(TEST_NAME_1, root.getId());
    folder.setParent(root);
    Folder parent = buildFolder(TEST_NAME_2, folder.getId());
    parent.setParent(folder);
    RunConfigurationEntry entry = ObjectCreatorUtils.createConfigEntry(TEST_CONFIG_NAME, true, getTestConfig());
    RunConfiguration configuration = ObjectCreatorUtils.createConfiguration(TEST_NAME, TEST_DESCRIPTION, parent.getId(), TEST_OWNER, Collections.singletonList(entry));
    RunConfiguration created = runConfigurationDao.create(configuration);
    verifyRunConfiguration(configuration, created);
    // load with folders
    RunConfiguration loaded = runConfigurationDao.loadConfigurationWithParents(created.getId());
    verifyRunConfiguration(configuration, loaded);
    verifyFolderTree(parent, loaded.getParent());
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) FirecloudRunConfigurationEntry(com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with RunConfigurationEntry

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

the class ObjectCreatorUtils method createConfigEntry.

public static RunConfigurationEntry createConfigEntry(String name, boolean defaultEntry, PipelineConfiguration configuration) {
    RunConfigurationEntry entry = new RunConfigurationEntry();
    entry.setName(name);
    entry.setDefaultConfiguration(defaultEntry);
    entry.setConfiguration(configuration);
    return entry;
}
Also used : AbstractRunConfigurationEntry(com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) FirecloudRunConfigurationEntry(com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry)

Example 9 with RunConfigurationEntry

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

the class RunConfigurationApiServiceTest method setUp.

@Before
public void setUp() {
    // Create SIDs for "test" users
    testUserSid1 = new AclTestDao.AclSid(true, TEST_USER_1);
    aclTestDao.createAclSid(testUserSid1);
    testUserSid2 = new AclTestDao.AclSid(true, TEST_USER_2);
    aclTestDao.createAclSid(testUserSid2);
    Folder sourceFolder = new Folder();
    sourceFolder.setName(TEST_FOLDER_NAME);
    sourceFolder.setOwner(TEST_USER_1);
    folderDao.createFolder(sourceFolder);
    Long folderId = folderDao.loadFolderByName(TEST_FOLDER_NAME).getId();
    AclTestDao.AclClass folderAclClass = new AclTestDao.AclClass(Folder.class.getCanonicalName());
    aclTestDao.createAclClassIfNotPresent(folderAclClass);
    AclTestDao.AclObjectIdentity folderIdentity = new AclTestDao.AclObjectIdentity(testUserSid1, folderId, folderAclClass.getId(), null, true);
    aclTestDao.createObjectIdentity(folderIdentity);
    AclTestDao.AclEntry folderAclEntry = new AclTestDao.AclEntry(folderIdentity, 1, testUserSid1, AclPermission.WRITE.getMask(), true);
    aclTestDao.createAclEntry(folderAclEntry);
    Pipeline pipeline = constructPipeline(TEST_NAME, TEST_NAME, folderId);
    pipeline.setOwner(TEST_USER_1);
    pipelineDao.createPipeline(pipeline);
    Pipeline loadPipelineByName = pipelineDao.loadPipelineByName(TEST_NAME);
    AclTestDao.AclClass pipelineAclClass = new AclTestDao.AclClass(Pipeline.class.getCanonicalName());
    aclTestDao.createAclClassIfNotPresent(pipelineAclClass);
    AclTestDao.AclObjectIdentity pipelineIdentity = new AclTestDao.AclObjectIdentity(testUserSid1, loadPipelineByName.getId(), pipelineAclClass.getId(), null, true);
    aclTestDao.createObjectIdentity(pipelineIdentity);
    AclTestDao.AclEntry pipelineAclEntry = new AclTestDao.AclEntry(pipelineIdentity, 1, testUserSid1, AclPermission.EXECUTE.getMask(), true);
    aclTestDao.createAclEntry(pipelineAclEntry);
    PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
    RunConfigurationEntry entryWithPipeline = createConfigEntry(TEST_NAME, true, pipelineConfiguration);
    entryWithPipeline.setPipelineId(pipeline.getId());
    entryWithPipeline.setPipelineVersion(TEST_NAME);
    runConfigurationVO = createRunConfigurationVO(TEST_NAME, TEST_DESCRIPTION, sourceFolder.getId(), Collections.singletonList(entryWithPipeline));
    ToolGroup toolGroup = createToolGroup();
    Tool tool = createTool(toolGroup);
    RunConfigurationEntry entryWithTool = createConfigEntry(TEST_NAME, true, pipelineConfiguration);
    pipelineConfiguration.setCmdTemplate(TEST_NAME);
    pipelineConfiguration.setDockerImage(tool.getImage());
    entryWithTool.setConfiguration(pipelineConfiguration);
    updatedRunConfigurationVO = createRunConfigurationVO(TEST_NAME, TEST_DESCRIPTION, sourceFolder.getId(), Collections.singletonList(entryWithTool));
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) AclTestDao(com.epam.pipeline.dao.util.AclTestDao) Before(org.junit.Before)

Example 10 with RunConfigurationEntry

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

the class FolderManagerTest method shouldCloneWithRunConfiguration.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneWithRunConfiguration() {
    Folder sourceFolder = new Folder();
    sourceFolder.setName(FOLDER_TO_CLONE);
    folderManager.create(sourceFolder);
    PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
    pipelineConfiguration.setCmdTemplate(TEST_NAME);
    RunConfigurationEntry entry = createConfigEntry(TEST_NAME, true, pipelineConfiguration);
    RunConfigurationVO runConfigurationVO = createRunConfigurationVO(TEST_NAME, TEST_DESCRIPTION, sourceFolder.getId(), Collections.singletonList(entry));
    RunConfiguration expectedRunConfiguration = runConfigurationManager.create(runConfigurationVO);
    Folder childSourceFolder = new Folder();
    childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
    childSourceFolder.setParentId(sourceFolder.getId());
    folderManager.create(childSourceFolder);
    runConfigurationVO.setParentId(childSourceFolder.getId());
    runConfigurationManager.create(runConfigurationVO);
    Folder destinationFolder = new Folder();
    destinationFolder.setName(TEST_NAME);
    folderManager.create(destinationFolder);
    folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
    destinationFolder = folderManager.loadByNameOrId(TEST_NAME);
    destinationFolder = folderManager.load(destinationFolder.getId());
    Folder clonedFolder = destinationFolder.getChildFolders().get(0);
    RunConfiguration clonedRunConfiguration = runConfigurationManager.loadAll().stream().filter(conf -> Objects.equals(conf.getParent().getId(), clonedFolder.getId())).collect(Collectors.toList()).get(0);
    assertRunConfiguration(expectedRunConfiguration, clonedRunConfiguration);
    Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
    clonedRunConfiguration = runConfigurationManager.loadAll().stream().filter(conf -> Objects.equals(conf.getParent().getId(), clonedChildFolder.getId())).collect(Collectors.toList()).get(0);
    assertRunConfiguration(expectedRunConfiguration, clonedRunConfiguration);
}
Also used : AwsRegionVO(com.epam.pipeline.controller.vo.AwsRegionVO) MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) Autowired(org.springframework.beans.factory.annotation.Autowired) ObjectCreatorUtils.constructPipelineVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructPipelineVO) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) Assert.assertThat(org.junit.Assert.assertThat) MockitoAnnotations(org.mockito.MockitoAnnotations) Folder(com.epam.pipeline.entity.pipeline.Folder) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Pair(org.apache.commons.lang3.tuple.Pair) MockS3Helper(com.epam.pipeline.manager.MockS3Helper) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Mockito.doReturn(org.mockito.Mockito.doReturn) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) S3StorageProvider(com.epam.pipeline.manager.datastorage.providers.aws.s3.S3StorageProvider) GitManager(com.epam.pipeline.manager.git.GitManager) SpyBean(org.springframework.boot.test.mock.mockito.SpyBean) Set(java.util.Set) Collectors(java.util.stream.Collectors) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Objects(java.util.Objects) Matchers.any(org.mockito.Matchers.any) List(java.util.List) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) ObjectCreatorUtils.constructDataStorageVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO) DataStorageManager(com.epam.pipeline.manager.datastorage.DataStorageManager) ObjectCreatorUtils.createConfigEntry(com.epam.pipeline.manager.ObjectCreatorUtils.createConfigEntry) EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Mock(org.mockito.Mock) HashMap(java.util.HashMap) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) RunConfigurationVO(com.epam.pipeline.controller.vo.configuration.RunConfigurationVO) MetadataManager(com.epam.pipeline.manager.metadata.MetadataManager) Value(org.springframework.beans.factory.annotation.Value) HashSet(java.util.HashSet) CollectionUtils(org.apache.commons.collections.CollectionUtils) Propagation(org.springframework.transaction.annotation.Propagation) PipelineVO(com.epam.pipeline.controller.vo.PipelineVO) Before(org.junit.Before) ObjectCreatorUtils.createRunConfigurationVO(com.epam.pipeline.manager.ObjectCreatorUtils.createRunConfigurationVO) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Test(org.junit.Test) DataStorageType(com.epam.pipeline.entity.datastorage.DataStorageType) Mockito.when(org.mockito.Mockito.when) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) Assert.assertNull(org.junit.Assert.assertNull) MetadataEntityManager(com.epam.pipeline.manager.metadata.MetadataEntityManager) AclClass(com.epam.pipeline.entity.security.acl.AclClass) RunConfigurationManager(com.epam.pipeline.manager.configuration.RunConfigurationManager) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) AwsRegionManager(com.epam.pipeline.manager.region.AwsRegionManager) Transactional(org.springframework.transaction.annotation.Transactional) RunConfigurationVO(com.epam.pipeline.controller.vo.configuration.RunConfigurationVO) ObjectCreatorUtils.createRunConfigurationVO(com.epam.pipeline.manager.ObjectCreatorUtils.createRunConfigurationVO) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

RunConfigurationEntry (com.epam.pipeline.entity.configuration.RunConfigurationEntry)13 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)10 Test (org.junit.Test)7 RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)6 FirecloudRunConfigurationEntry (com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry)4 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)4 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)3 AbstractRunConfigurationEntry (com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry)3 Transactional (org.springframework.transaction.annotation.Transactional)3 Folder (com.epam.pipeline.entity.pipeline.Folder)2 Before (org.junit.Before)2 MessageConstants (com.epam.pipeline.common.MessageConstants)1 MessageHelper (com.epam.pipeline.common.MessageHelper)1 AwsRegionVO (com.epam.pipeline.controller.vo.AwsRegionVO)1 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)1 EntityVO (com.epam.pipeline.controller.vo.EntityVO)1 MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)1 PipelineVO (com.epam.pipeline.controller.vo.PipelineVO)1 RunConfigurationVO (com.epam.pipeline.controller.vo.configuration.RunConfigurationVO)1 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)1