use of bio.terra.service.resourcemanagement.google.GoogleBucketResource in project jade-data-repo by DataBiosphere.
the class BucketResourceTest method twoThreadsCompeteForLockTest.
@Test
public // after it's been created, confirm it succeeds.
void twoThreadsCompeteForLockTest() throws Exception {
String flightIdBase = "twoThreadsCompeteForLockTest";
String bucketName = "twothreadscompeteforlocktest";
bucketNames.add(bucketName);
GoogleBucketRequest bucketRequest = buildBucketRequest(bucketName);
BucketResourceLockTester resourceLockA = new BucketResourceLockTester(resourceService, bucketRequest, flightIdBase + "A");
BucketResourceLockTester resourceLockB = new BucketResourceLockTester(resourceService, bucketRequest, flightIdBase + "B");
BucketResourceLockTester resourceLockC = new BucketResourceLockTester(resourceService, bucketRequest, flightIdBase + "C");
Thread threadA = new Thread(resourceLockA);
Thread threadB = new Thread(resourceLockB);
Thread threadC = new Thread(resourceLockC);
configService.setFault(ConfigEnum.BUCKET_LOCK_CONFLICT_STOP_FAULT.name(), true);
threadA.start();
TimeUnit.SECONDS.sleep(1);
threadB.start();
threadB.join();
assertTrue("Thread B did get a lock exception", resourceLockB.gotLockException());
configService.setFault(ConfigEnum.BUCKET_LOCK_CONFLICT_CONTINUE_FAULT.name(), true);
threadA.join();
assertFalse("Thread A did not get a lock exception", resourceLockA.gotLockException());
GoogleBucketResource bucketResource = resourceLockA.getBucketResource();
assertNotNull("Thread A did create the bucket", bucketResource);
checkBucketExists(bucketResource.getResourceId());
threadC.start();
threadC.join();
assertFalse("Thread C did not get a lock exception", resourceLockC.gotLockException());
assertNotNull("Thread C did get the bucket", resourceLockC.getBucketResource());
deleteBucket(bucketResource.getName());
checkBucketDeleted(bucketResource.getName(), bucketResource.getResourceId());
}
use of bio.terra.service.resourcemanagement.google.GoogleBucketResource in project jade-data-repo by DataBiosphere.
the class BucketResourceTest method createAndDeleteBucketTest.
@Test
public // create and delete the bucket, checking that the metadata and cloud state match what is expected
void createAndDeleteBucketTest() throws Exception {
String bucketName = "testbucket_createanddeletebuckettest";
String flightId = "createAndDeleteBucketTest";
bucketNames.add(bucketName);
// create the bucket and metadata
GoogleBucketRequest googleBucketRequest = buildBucketRequest(bucketName);
GoogleBucketResource bucketResource = resourceService.getOrCreateBucket(googleBucketRequest, flightId);
// check the bucket and metadata exist
checkBucketExists(bucketResource.getResourceId());
// delete the bucket and metadata
deleteBucket(bucketResource.getName());
checkBucketDeleted(bucketResource.getName(), bucketResource.getResourceId());
}
use of bio.terra.service.resourcemanagement.google.GoogleBucketResource in project jade-data-repo by DataBiosphere.
the class BucketResourceTest method checkBucketExists.
private void checkBucketExists(UUID bucketResourceId) {
// confirm the metadata row is unlocked and the bucket exists
GoogleBucketResource bucketResource = resourceService.getBucketResourceById(bucketResourceId, false);
assertNotNull("bucket metadata row exists", bucketResource);
assertNull("bucket metadata is unlocked", bucketResource.getFlightId());
Bucket bucket = storage.get(bucketResource.getName());
assertNotNull("bucket exists in the cloud", bucket);
}
use of bio.terra.service.resourcemanagement.google.GoogleBucketResource in project jade-data-repo by DataBiosphere.
the class DrsService method drsObjectFromFSFile.
private DRSObject drsObjectFromFSFile(FSFile fsFile, String snapshotId, AuthenticatedUserRequest authUser) {
DRSObject fileObject = makeCommonDrsObject(fsFile, snapshotId);
GoogleBucketResource bucketResource = locationService.lookupBucketMetadata(fsFile.getBucketResourceId());
DRSAccessURL gsAccessURL = new DRSAccessURL().url(fsFile.getGspath());
DRSAccessMethod gsAccessMethod = new DRSAccessMethod().type(DRSAccessMethod.TypeEnum.GS).accessUrl(gsAccessURL).region(bucketResource.getRegion());
DRSAccessURL httpsAccessURL = new DRSAccessURL().url(makeHttpsFromGs(fsFile.getGspath())).headers(makeAuthHeader(authUser));
DRSAccessMethod httpsAccessMethod = new DRSAccessMethod().type(DRSAccessMethod.TypeEnum.HTTPS).accessUrl(httpsAccessURL).region(bucketResource.getRegion());
List<DRSAccessMethod> accessMethods = new ArrayList<>();
accessMethods.add(gsAccessMethod);
accessMethods.add(httpsAccessMethod);
fileObject.mimeType(fsFile.getMimeType()).checksums(fileService.makeChecksums(fsFile)).accessMethods(accessMethods);
return fileObject;
}
Aggregations