Search in sources :

Example 6 with DataStorageVO

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

the class DataStorageManagerTest method updateDataStorageTest.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void updateDataStorageTest() throws Exception {
    Folder folder = new Folder();
    folder.setName("testfolder");
    folderManager.create(folder);
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.S3, PATH, STS_DURATION, LTS_DURATION, folder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    AbstractDataStorage saved = storageManager.create(storageVO, false, false, false);
    Folder newFolder = new Folder();
    newFolder.setName("newtestfolder");
    folderManager.create(newFolder);
    // test that we can change parent folder for storage
    storageVO.setId(saved.getId());
    storageVO.setParentFolderId(newFolder.getId());
    storageManager.update(storageVO);
    AbstractDataStorage loaded = storageManager.load(saved.getId());
    assertDataStorageAccordingToUpdateStorageVO(storageVO, loaded);
    // test that we can change description for storage
    storageVO.setDescription(CHANGED);
    storageManager.update(storageVO);
    loaded = storageManager.load(saved.getId());
    assertDataStorageAccordingToUpdateStorageVO(storageVO, loaded);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with DataStorageVO

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

the class DataStorageManagerTest method testFailCreateStorageWithRootMountPoint.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testFailCreateStorageWithRootMountPoint() {
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.NFS, PATH, WITHOUT_PARENT_ID, "/", TEST_MOUNT_OPTIONS);
    storageManager.create(storageVO, false, false, false);
}
Also used : DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with DataStorageVO

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

the class DataStorageManagerTest method testFailCreateOfStorageWithForbiddenMountPoint.

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

Example 9 with DataStorageVO

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

the class ObjectCreatorUtils method constructDataStorageVO.

public static DataStorageVO constructDataStorageVO(String name, String description, DataStorageType storageType, String path, Integer stsDuration, Integer ltsDuration, Long parentFolderId, String mountPoint, String mountOptions) {
    DataStorageVO storageVO = constructDataStorageVO(name, description, storageType, path, parentFolderId, mountPoint, mountOptions);
    StoragePolicy policy = new StoragePolicy();
    if (stsDuration != null) {
        policy.setShortTermStorageDuration(stsDuration);
    }
    if (ltsDuration != null) {
        policy.setLongTermStorageDuration(ltsDuration);
    }
    storageVO.setStoragePolicy(policy);
    return storageVO;
}
Also used : DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy)

Example 10 with DataStorageVO

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

the class DataStorageManagerTest method testFailCreateOfStorageWithForbiddenMountPointWildCard.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testFailCreateOfStorageWithForbiddenMountPointWildCard() {
    Preference preference = SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.toPreference();
    preference.setValue(SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.getDefaultValue() + makeSysIndependentPath(",/runs/*"));
    preferenceManager.update(Collections.singletonList(preference));
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.NFS, PATH, WITHOUT_PARENT_ID, FORBIDDEN_MOUNT_POINT_2, 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)

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