Search in sources :

Example 6 with NFSDataStorage

use of com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage in project cloud-pipeline by epam.

the class PipelineConfigurationManagerTest method setUp.

@Before
public void setUp() throws Exception {
    registry = new DockerRegistry();
    registry.setPath(TEST_REPO);
    registry.setOwner(TEST_USER);
    dockerRegistryDao.createDockerRegistry(registry);
    library = new ToolGroup();
    library.setName(TOOL_GROUP_NAME);
    library.setRegistryId(registry.getId());
    library.setOwner(TEST_USER);
    toolGroupDao.createToolGroup(library);
    tool = new Tool();
    tool.setImage(TEST_IMAGE);
    tool.setRam(TEST_RAM);
    tool.setCpu(TEST_CPU);
    tool.setOwner(TEST_USER);
    tool.setRegistryId(registry.getId());
    tool.setToolGroupId(library.getId());
    toolDao.createTool(tool);
    // Data storages of user 1
    NFSDataStorage dataStorage = new NFSDataStorage(dataStorageDao.createDataStorageId(), "testNFS", "test/path1");
    dataStorage.setMountOptions("testMountOptions1");
    dataStorage.setMountPoint("/some/other/path");
    dataStorage.setOwner(TEST_OWNER1);
    dataStorageDao.createDataStorage(dataStorage);
    dataStorages.add(dataStorage);
    S3bucketDataStorage bucketDataStorage = new S3bucketDataStorage(dataStorageDao.createDataStorageId(), "testBucket", "test/path2");
    bucketDataStorage.setOwner(TEST_OWNER1);
    dataStorageDao.createDataStorage(bucketDataStorage);
    dataStorages.add(bucketDataStorage);
    // Data storages of user 2
    dataStorage = new NFSDataStorage(dataStorageDao.createDataStorageId(), "testNFS2", "test/path3");
    dataStorage.setMountOptions("testMountOptions2");
    dataStorage.setOwner(TEST_OWNER2);
    dataStorageDao.createDataStorage(dataStorage);
    dataStorages.add(dataStorage);
    bucketDataStorage = new S3bucketDataStorage(dataStorageDao.createDataStorageId(), "testBucket2", "test/path4");
    bucketDataStorage.setOwner(TEST_OWNER2);
    dataStorageDao.createDataStorage(bucketDataStorage);
    dataStorages.add(bucketDataStorage);
    dataStorages.forEach(ds -> aclTestDao.createAclForObject(ds));
    aclTestDao.grantPermissions(dataStorage, TEST_OWNER1, Collections.singletonList((AclPermission) AclPermission.READ));
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) AclPermission(com.epam.pipeline.security.acl.AclPermission) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) NFSDataStorage(com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) Tool(com.epam.pipeline.entity.pipeline.Tool) Before(org.junit.Before)

Example 7 with NFSDataStorage

use of com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage in project cloud-pipeline by epam.

the class DataStorageDaoTest method setUp.

@Before
public void setUp() {
    testFolder = buildFolder(null);
    awsRegion = new AwsRegion();
    awsRegion.setName("Default");
    awsRegion.setDefault(true);
    awsRegion.setAwsRegionName("us-east-1");
    awsRegionDao.create(awsRegion);
    s3Bucket = new S3bucketDataStorage(null, TEST_STORAGE_NAME, TEST_STORAGE_PATH);
    s3Bucket.setDescription("testDescription");
    s3Bucket.setParentFolderId(testFolder.getId());
    s3Bucket.setRegionId(awsRegion.getId());
    s3Bucket.setOwner(TEST_OWNER);
    s3Bucket.setMountPoint("testMountPoint");
    s3Bucket.setMountOptions("testMountOptions");
    s3Bucket.setShared(true);
    s3Bucket.setAllowedCidrs(Arrays.asList("test1", "test2"));
    policy = new StoragePolicy();
    policy.setBackupDuration(BACKUP_DURATION);
    policy.setLongTermStorageDuration(LTS_DURATION);
    policy.setShortTermStorageDuration(STS_DURATION);
    policy.setVersioningEnabled(true);
    s3Bucket.setStoragePolicy(policy);
    nfsStorage = new NFSDataStorage(null, "NFS_STORAGE", "nfs_path");
    nfsStorage.setOwner(TEST_OWNER);
    nfsStorage.setDescription("NFS");
    nfsStorage.setParentFolderId(testFolder.getId());
    nfsStorage.setMountOptions("-s");
    nfsStorage.setMountPoint("nfs");
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) NFSDataStorage(com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) Before(org.junit.Before)

Example 8 with NFSDataStorage

use of com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage in project cloud-pipeline by epam.

the class NFSStorageProviderTest method testEditFile.

@Test
public void testEditFile() {
    NFSDataStorage dataStorage = new NFSDataStorage(0L, "testStorage", TEST_PATH + 3 + ":/test");
    nfsProvider.createStorage(dataStorage);
    String testFileName = "testFile.txt";
    byte[] testContent = "testContent".getBytes();
    byte[] newContent = "new content".getBytes();
    DataStorageFile file = nfsProvider.createFile(dataStorage, testFileName, testContent);
    Assert.assertArrayEquals(testContent, nfsProvider.getFile(dataStorage, testFileName, file.getVersion(), Long.MAX_VALUE).getContent());
    DataStorageFile updatedFile = nfsProvider.createFile(dataStorage, testFileName, newContent);
    Assert.assertArrayEquals(newContent, nfsProvider.getFile(dataStorage, testFileName, updatedFile.getVersion(), Long.MAX_VALUE).getContent());
}
Also used : DataStorageFile(com.epam.pipeline.entity.datastorage.DataStorageFile) NFSDataStorage(com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage) Matchers.anyString(org.mockito.Matchers.anyString) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 9 with NFSDataStorage

use of com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage in project cloud-pipeline by epam.

the class DataStorageEventServiceTest method shouldAddNFSEvent.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldAddNFSEvent() {
    doNothing().when(entityManager).setManagers(anyListOf(SecuredEntityManager.class));
    when(issueManager.loadIssuesForEntity(any())).thenReturn(Arrays.asList(Issue.builder().id(1L).build(), Issue.builder().id(2L).build()));
    when(dataStorageManager.load(1L)).thenReturn(new NFSDataStorage(1L, "", ""));
    doNothing().when(eventDao).insertUpdateEvent(anyString(), anyLong());
    dataStorageEventService.updateEventsWithChildrenAndIssues(1L);
    verify(eventDao).insertUpdateEvent("NFS", 1L);
    verify(eventDao).insertUpdateEvent(ISSUE, 1L);
    verify(eventDao).insertUpdateEvent(ISSUE, 2L);
    verifyNoMoreInteractions(eventDao);
}
Also used : SecuredEntityManager(com.epam.pipeline.manager.security.SecuredEntityManager) NFSDataStorage(com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

NFSDataStorage (com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage)9 Test (org.junit.Test)6 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)5 DataStorageFile (com.epam.pipeline.entity.datastorage.DataStorageFile)5 File (java.io.File)4 Before (org.junit.Before)4 Matchers.anyString (org.mockito.Matchers.anyString)4 Transactional (org.springframework.transaction.annotation.Transactional)4 DataStorageDao (com.epam.pipeline.dao.datastorage.DataStorageDao)3 DataStorageFolder (com.epam.pipeline.entity.datastorage.DataStorageFolder)3 S3bucketDataStorage (com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)2 AbstractDataStorageItem (com.epam.pipeline.entity.datastorage.AbstractDataStorageItem)2 DataStorageListing (com.epam.pipeline.entity.datastorage.DataStorageListing)2 DockerRegistry (com.epam.pipeline.entity.pipeline.DockerRegistry)2 Tool (com.epam.pipeline.entity.pipeline.Tool)2 ToolGroup (com.epam.pipeline.entity.pipeline.ToolGroup)2 CmdExecutor (com.epam.pipeline.manager.CmdExecutor)2 AclPermission (com.epam.pipeline.security.acl.AclPermission)2