use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceServiceTest method createMcWorkspaceUndoSteps.
@Test
void createMcWorkspaceUndoSteps() {
Workspace request = defaultRequestBuilder(UUID.randomUUID()).build();
// Retry undo steps once and fail at the end of the flight.
Map<String, StepStatus> retrySteps = new HashMap<>();
retrySteps.put(CreateWorkspaceAuthzStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
retrySteps.put(CreateWorkspaceStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
FlightDebugInfo debugInfo = FlightDebugInfo.newBuilder().undoStepFailures(retrySteps).lastStepFailure(true).build();
jobService.setFlightDebugInfoForTest(debugInfo);
// Service methods which wait for a flight to complete will throw an
// InvalidResultStateException when that flight fails without a cause, which occurs when a
// flight fails via debugInfo.
assertThrows(InvalidResultStateException.class, () -> workspaceService.createWorkspace(request, USER_REQUEST));
assertThrows(WorkspaceNotFoundException.class, () -> workspaceService.getWorkspace(request.getWorkspaceId(), USER_REQUEST));
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceServiceTest method createMcWorkspaceDoSteps.
@Test
void createMcWorkspaceDoSteps() {
Workspace request = defaultRequestBuilder(UUID.randomUUID()).build();
Map<String, StepStatus> retrySteps = new HashMap<>();
retrySteps.put(CreateWorkspaceAuthzStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
retrySteps.put(CreateWorkspaceStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
FlightDebugInfo debugInfo = FlightDebugInfo.newBuilder().doStepFailures(retrySteps).build();
jobService.setFlightDebugInfoForTest(debugInfo);
UUID createdId = workspaceService.createWorkspace(request, USER_REQUEST);
assertEquals(createdId, request.getWorkspaceId());
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceServiceTest method deleteWorkspaceWithGoogleContext.
@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void deleteWorkspaceWithGoogleContext() throws Exception {
Workspace request = defaultRequestBuilder(UUID.randomUUID()).spendProfileId(spendUtils.defaultSpendId()).workspaceStage(WorkspaceStage.MC_WORKSPACE).build();
workspaceService.createWorkspace(request, USER_REQUEST);
String jobId = UUID.randomUUID().toString();
workspaceService.createGcpCloudContext(request.getWorkspaceId(), jobId, USER_REQUEST, "/fake/value");
jobService.waitForJob(jobId);
assertNull(jobService.retrieveJobResult(jobId, Object.class, USER_REQUEST).getException());
Workspace workspace = workspaceService.getWorkspace(request.getWorkspaceId(), USER_REQUEST);
String projectId = workspaceService.getAuthorizedRequiredGcpProject(workspace.getWorkspaceId(), USER_REQUEST);
// Verify project exists by retrieving it.
crl.getCloudResourceManagerCow().projects().get(projectId).execute();
workspaceService.deleteWorkspace(request.getWorkspaceId(), USER_REQUEST);
// Check that project is now being deleted.
Project project = crl.getCloudResourceManagerCow().projects().get(projectId).execute();
assertEquals("DELETE_REQUESTED", project.getState());
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceServiceTest method createRawlsWorkspaceDoSteps.
@Test
void createRawlsWorkspaceDoSteps() throws InterruptedException {
Workspace request = defaultRequestBuilder(UUID.randomUUID()).workspaceStage(WorkspaceStage.RAWLS_WORKSPACE).build();
// Ensure the auth check in CheckSamWorkspaceAuthzStep always succeeds.
doReturn(true).when(mockSamService).isAuthorized(any(), any(), any(), any());
Map<String, StepStatus> retrySteps = new HashMap<>();
retrySteps.put(CheckSamWorkspaceAuthzStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
retrySteps.put(CreateWorkspaceStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
FlightDebugInfo debugInfo = FlightDebugInfo.newBuilder().doStepFailures(retrySteps).build();
jobService.setFlightDebugInfoForTest(debugInfo);
UUID createdId = workspaceService.createWorkspace(request, USER_REQUEST);
assertEquals(createdId, request.getWorkspaceId());
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceServiceTest method duplicateWorkspaceIdRequestsRejected.
@Test
void duplicateWorkspaceIdRequestsRejected() {
Workspace request = defaultRequestBuilder(UUID.randomUUID()).build();
workspaceService.createWorkspace(request, USER_REQUEST);
Workspace duplicateWorkspace = defaultRequestBuilder(request.getWorkspaceId()).description("slightly different workspace").build();
assertThrows(DuplicateWorkspaceException.class, () -> workspaceService.createWorkspace(duplicateWorkspace, USER_REQUEST));
}
Aggregations