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));
}
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");
}
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());
}
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);
}
Aggregations