Search in sources :

Example 11 with DataStorageVO

use of com.epam.pipeline.controller.vo.DataStorageVO in project cloud-pipeline by epam.

the class DataStorageManagerTest method testCreateENSDataStorage.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCreateENSDataStorage() {
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.NFS, PATH, WITHOUT_PARENT_ID, TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    AbstractDataStorage saved = storageManager.create(storageVO, false, false, false);
    AbstractDataStorage loaded = storageManager.load(saved.getId());
    compareDataStorage(saved, loaded);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with DataStorageVO

use of com.epam.pipeline.controller.vo.DataStorageVO in project cloud-pipeline by epam.

the class DataStorageManagerTest method testFailCreateOfStorageWithForbiddenMountPointWildCard2.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testFailCreateOfStorageWithForbiddenMountPointWildCard2() {
    Preference preference = SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.toPreference();
    preference.setValue(SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.getDefaultValue() + makeSysIndependentPath(",/runs/**/dir"));
    preferenceManager.update(Collections.singletonList(preference));
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.NFS, PATH, WITHOUT_PARENT_ID, FORBIDDEN_MOUNT_POINT_3, TEST_MOUNT_OPTIONS);
    storageManager.create(storageVO, false, false, false);
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with DataStorageVO

use of com.epam.pipeline.controller.vo.DataStorageVO in project cloud-pipeline by epam.

the class DataStorageManagerTest method testFailUpdateOfStorageWithForbiddenMountPoint.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testFailUpdateOfStorageWithForbiddenMountPoint() {
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.NFS, PATH, WITHOUT_PARENT_ID, TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    AbstractDataStorage saved = storageManager.create(storageVO, false, false, false);
    storageVO.setId(saved.getId());
    storageVO.setMountPoint(FORBIDDEN_MOUNT_POINT);
    storageManager.update(storageVO);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with DataStorageVO

use of com.epam.pipeline.controller.vo.DataStorageVO in project cloud-pipeline by epam.

the class FolderManagerTest method shouldCloneFolderWithDataStorages.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneFolderWithDataStorages() {
    Folder sourceFolder = new Folder();
    sourceFolder.setName(FOLDER_TO_CLONE);
    folderManager.create(sourceFolder);
    DataStorageVO dataStorageVO = constructDataStorageVO(TEST_NAME, TEST_DESCRIPTION, DataStorageType.S3, TEST_PATH, STS_DURATION, LTS_DURATION, sourceFolder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    StoragePolicy storagePolicy = dataStorageVO.getStoragePolicy();
    storagePolicy.setBackupDuration(BACKUP_DURATION);
    dataStorageVO.setStoragePolicy(storagePolicy);
    AbstractDataStorage expectedDataStorage = dataStorageManager.create(dataStorageVO, true, true, false);
    Folder childSourceFolder = new Folder();
    childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
    childSourceFolder.setParentId(sourceFolder.getId());
    folderManager.create(childSourceFolder);
    dataStorageVO.setParentFolderId(childSourceFolder.getId());
    dataStorageVO.setName(TEST_NAME_1);
    dataStorageVO.setPath(TEST_NAME_1);
    dataStorageManager.create(dataStorageVO, true, true, false);
    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);
    AbstractDataStorage clonedDataStorage = clonedFolder.getStorages().get(0);
    clonedDataStorage = dataStorageManager.load(clonedDataStorage.getId());
    assertTrue(clonedDataStorage.getName().startsWith(TEST_CLONE_PREFIX + storageSuffix));
    assertTrue(clonedDataStorage.getPath().startsWith((TEST_CLONE_PREFIX + storageSuffix).toLowerCase()));
    assertDataStorages(expectedDataStorage, clonedDataStorage);
    Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
    clonedDataStorage = clonedChildFolder.getStorages().get(0);
    clonedDataStorage = dataStorageManager.load(clonedDataStorage.getId());
    assertTrue(clonedDataStorage.getName().startsWith(TEST_CLONE_PREFIX + storageSuffix));
    assertTrue(clonedDataStorage.getPath().startsWith((TEST_CLONE_PREFIX + storageSuffix).toLowerCase()));
    assertDataStorages(expectedDataStorage, clonedDataStorage);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) ObjectCreatorUtils.constructDataStorageVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with DataStorageVO

use of com.epam.pipeline.controller.vo.DataStorageVO in project cloud-pipeline by epam.

the class FolderManagerTest method deleteFolderWithStorage.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void deleteFolderWithStorage() throws Exception {
    folderManager.create(folder);
    DataStorageVO storageVO = constructDataStorageVO(TEST_NAME, TEST_DESCRIPTION, DataStorageType.S3, TEST_PATH, STS_DURATION, LTS_DURATION, folder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    dataStorageManager.create(storageVO, false, false, false);
    folderManager.delete(folder.getId());
}
Also used : DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) ObjectCreatorUtils.constructDataStorageVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)18 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)14 Test (org.junit.Test)14 Transactional (org.springframework.transaction.annotation.Transactional)14 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)10 ObjectCreatorUtils.constructDataStorageVO (com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO)5 Folder (com.epam.pipeline.entity.pipeline.Folder)3 Preference (com.epam.pipeline.entity.preference.Preference)3 PipelineVO (com.epam.pipeline.controller.vo.PipelineVO)2 StoragePolicy (com.epam.pipeline.entity.datastorage.StoragePolicy)2 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)2 ObjectCreatorUtils.constructPipelineVO (com.epam.pipeline.manager.ObjectCreatorUtils.constructPipelineVO)2