use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class SamServiceTest method createWorkspaceForUser.
private UUID createWorkspaceForUser(AuthenticatedUserRequest userRequest) {
UUID uuid = UUID.randomUUID();
Workspace request = Workspace.builder().workspaceId(uuid).userFacingId("a" + uuid.toString()).workspaceStage(WorkspaceStage.MC_WORKSPACE).build();
return workspaceService.createWorkspace(request, userRequest);
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class ControlledResourceServiceTest method createDefaultPrivateAiNotebookInstance.
/**
* Create a controlled AI Notebook instance with default private settings.
*/
private ControlledAiNotebookInstanceResource createDefaultPrivateAiNotebookInstance(String instanceId, UserAccessUtils.TestUser user) {
Workspace workspace = reusableWorkspace(user);
ApiGcpAiNotebookInstanceCreationParameters creationParameters = ControlledResourceFixtures.defaultNotebookCreationParameters().instanceId(instanceId).location(DEFAULT_NOTEBOOK_LOCATION);
ControlledAiNotebookInstanceResource resource = makeNotebookTestResource(workspace.getWorkspaceId(), instanceId, instanceId);
String createJobId = controlledResourceService.createAiNotebookInstance(resource, creationParameters, DEFAULT_ROLE, new ApiJobControl().id(UUID.randomUUID().toString()), null, user.getAuthenticatedRequest());
jobService.waitForJob(createJobId);
JobService.JobResultOrException<ControlledAiNotebookInstanceResource> creationResult = jobService.retrieveJobResult(createJobId, ControlledAiNotebookInstanceResource.class, user.getAuthenticatedRequest());
assertNull(creationResult.getException(), "Error creating controlled AI notebook instance");
assertNotNull(creationResult.getResult(), "Unexpected null created controlled AI notebook instance");
return creationResult.getResult();
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class AzureDisabledTest method azureDisabledTest.
@Test
public void azureDisabledTest() throws InterruptedException {
Workspace request = Workspace.builder().workspaceId(UUID.randomUUID()).userFacingId("a" + UUID.randomUUID()).workspaceStage(WorkspaceStage.MC_WORKSPACE).build();
UUID workspaceUuid = workspaceService.createWorkspace(request, userAccessUtils.defaultUserAuthRequest());
AuthenticatedUserRequest userRequest = userAccessUtils.defaultUserAuthRequest();
final UUID uuid = UUID.randomUUID();
assertThrows(FeatureNotSupportedException.class, () -> workspaceService.createAzureCloudContext(workspaceUuid, uuid.toString(), userRequest, null, null));
assertThrows(FeatureNotSupportedException.class, () -> workspaceService.getAuthorizedAzureCloudContext(workspaceUuid, userRequest));
final ApiAzureIpCreationParameters ipCreationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
ControlledResourceFields commonFields = ControlledResourceFixtures.makeDefaultControlledResourceFields(workspaceUuid);
ControlledAzureIpResource ipResource = ControlledAzureIpResource.builder().common(commonFields).ipName(ipCreationParameters.getName()).region(ipCreationParameters.getRegion()).build();
assertThrows(FeatureNotSupportedException.class, () -> controlledResourceService.createControlledResourceSync(ipResource, null, userRequest, ipCreationParameters));
final ApiAzureDiskCreationParameters diskCreationParameters = ControlledResourceFixtures.getAzureDiskCreationParameters();
ControlledAzureDiskResource diskResource = ControlledAzureDiskResource.builder().common(commonFields).diskName(diskCreationParameters.getName()).region(diskCreationParameters.getRegion()).size(diskCreationParameters.getSize()).build();
assertThrows(FeatureNotSupportedException.class, () -> controlledResourceService.createControlledResourceSync(diskResource, null, userRequest, diskCreationParameters));
final ApiAzureNetworkCreationParameters networkCreationParameters = ControlledResourceFixtures.getAzureNetworkCreationParameters();
ControlledAzureNetworkResource networkResource = ControlledAzureNetworkResource.builder().common(commonFields).networkName(networkCreationParameters.getName()).region(networkCreationParameters.getRegion()).subnetName(networkCreationParameters.getSubnetName()).addressSpaceCidr(networkCreationParameters.getAddressSpaceCidr()).subnetAddressCidr(networkCreationParameters.getSubnetAddressCidr()).build();
assertThrows(FeatureNotSupportedException.class, () -> controlledResourceService.createControlledResourceSync(networkResource, null, userRequest, networkCreationParameters));
final ApiAzureVmCreationParameters vmCreationParameters = ControlledResourceFixtures.getAzureVmCreationParameters();
ControlledAzureVmResource vmResource = ControlledAzureVmResource.builder().common(commonFields).vmName(vmCreationParameters.getName()).vmSize(vmCreationParameters.getVmSize()).vmImage(AzureVmUtils.getImageData(vmCreationParameters.getVmImage())).region(vmCreationParameters.getRegion()).ipId(ipResource.getResourceId()).diskId(diskResource.getResourceId()).networkId(networkResource.getResourceId()).build();
assertThrows(FeatureNotSupportedException.class, () -> controlledResourceService.createAzureVm(vmResource, vmCreationParameters, null, null, null, userRequest));
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class StoreControlledResourceMetadataStepTest method testEntersInfo.
@Test
public void testEntersInfo() throws InterruptedException, RetryException {
// Generate a fake workspace and cloud context so that the
// database insert will pass FK constraints.
UUID workspaceUuid = UUID.randomUUID();
Workspace workspace = Workspace.builder().workspaceStage(WorkspaceStage.RAWLS_WORKSPACE).workspaceId(workspaceUuid).userFacingId("a" + workspaceUuid).build();
workspaceDao.createWorkspace(workspace);
gcpCloudContextService.createGcpCloudContextStart(workspaceUuid, "flight-testentersinfo");
gcpCloudContextService.createGcpCloudContextFinish(workspaceUuid, new GcpCloudContext("fake-project"), "flight-testentersinfo");
StoreMetadataStep storeGoogleBucketMetadataStep = new StoreMetadataStep(resourceDao);
// Stub the flight map as of this step
ControlledGcsBucketResource bucketResource = ControlledResourceFixtures.makeDefaultControlledGcsBucketBuilder(workspaceUuid).build();
final FlightMap inputFlightMap = new FlightMap();
inputFlightMap.put(ResourceKeys.RESOURCE, bucketResource);
inputFlightMap.makeImmutable();
doReturn(inputFlightMap).when(mockFlightContext).getInputParameters();
final StepResult result = storeGoogleBucketMetadataStep.doStep(mockFlightContext);
assertThat(result, equalTo(StepResult.getStepResultSuccess()));
WsmResource daoResource = resourceDao.getResource(bucketResource.getWorkspaceId(), bucketResource.getResourceId());
assertThat(daoResource.getResourceType(), equalTo(WsmResourceType.CONTROLLED_GCP_GCS_BUCKET));
ControlledGcsBucketResource daoBucket = (ControlledGcsBucketResource) daoResource;
assertThat(bucketResource, equalTo(daoBucket));
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class ReferencedResourceServiceTest method createMcTestWorkspace.
/**
* Test utility which creates a workspace with a random ID, no spend profile, and stage
* MC_WORKSPACE. Returns the generated workspace ID.
*/
private UUID createMcTestWorkspace() {
UUID uuid = UUID.randomUUID();
Workspace request = Workspace.builder().workspaceId(uuid).userFacingId("a" + uuid.toString()).spendProfileId(null).workspaceStage(WorkspaceStage.MC_WORKSPACE).build();
return workspaceService.createWorkspace(request, USER_REQUEST);
}
Aggregations