use of bio.terra.stairway.FlightState in project jade-data-repo by DataBiosphere.
the class FlightStates method makeFlightRunningState.
public static FlightState makeFlightRunningState() {
DatasetSummaryModel req = buildMinimalDatasetSummary();
FlightMap resultMap = new FlightMap();
resultMap.put(JobMapKeys.RESPONSE.getKeyName(), req);
resultMap.put(JobMapKeys.STATUS_CODE.getKeyName(), HttpStatus.I_AM_A_TEAPOT);
resultMap.put(JobMapKeys.DESCRIPTION.getKeyName(), req.getDescription());
FlightState flightState = new FlightState();
flightState.setFlightId(testFlightId);
flightState.setFlightStatus(FlightStatus.RUNNING);
flightState.setSubmitted(submittedTime);
flightState.setInputParameters(resultMap);
flightState.setResultMap(resultMap);
return flightState;
}
use of bio.terra.stairway.FlightState in project jade-data-repo by DataBiosphere.
the class FlightStates method makeFlightSimpleState.
public static FlightState makeFlightSimpleState() {
// Construct a mock FlightState
FlightMap resultMap = new FlightMap();
resultMap.put(JobMapKeys.RESPONSE.getKeyName(), buildMinimalDatasetSummary());
resultMap.put(JobMapKeys.STATUS_CODE.getKeyName(), HttpStatus.I_AM_A_TEAPOT);
FlightState flightState = new FlightState();
flightState.setFlightId(testFlightId);
flightState.setFlightStatus(FlightStatus.SUCCESS);
flightState.setSubmitted(Instant.now());
// unused
flightState.setInputParameters(resultMap);
flightState.setResultMap(resultMap);
flightState.setCompleted(Instant.now());
return flightState;
}
use of bio.terra.stairway.FlightState in project stairway by DataBiosphere.
the class TestUtil method makeStairwayValidateRecovery.
// For cases where we want to validate recovery of a single stairway instance and that
// that a specific flight is READY and unowned.
public static Stairway makeStairwayValidateRecovery(String stairwayName, String flightId) throws DatabaseOperationException, QueueException, MigrateException, StairwayExecutionException, InterruptedException, DatabaseSetupException {
DataSource dataSource = makeDataSource();
Stairway stairway = Stairway.newBuilder().stairwayClusterName("stairway-cluster").stairwayName(stairwayName).workQueueProjectId(null).maxParallelFlights(2).build();
List<String> recordedStairways = stairway.initialize(dataSource, false, false);
assertThat("one stairway to recover", recordedStairways.size(), equalTo(1));
assertThat("stairway name matches", recordedStairways.get(0), equalTo(stairwayName));
FlightState state = stairway.getFlightState(flightId);
assertThat("State is ready", state.getFlightStatus(), equalTo(FlightStatus.READY));
assertNull(state.getStairwayId(), "Flight is unowned");
stairway.recoverAndStart(recordedStairways);
return stairway;
}
use of bio.terra.stairway.FlightState in project terra-workspace-manager by DataBiosphere.
the class CreateGcpContextFlightTest method createsProjectAndContext_noBillingAccount_flightFailsAndGcpProjectNotCreated.
@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void createsProjectAndContext_noBillingAccount_flightFailsAndGcpProjectNotCreated() throws Exception {
UUID workspaceId = createWorkspace(spendUtils.noBillingAccount());
AuthenticatedUserRequest userRequest = userAccessUtils.defaultUserAuthRequest();
assertTrue(testUtils.getAuthorizedGcpCloudContext(workspaceId, userRequest).isEmpty());
FlightState flightState = StairwayTestUtils.blockUntilFlightCompletes(jobService.getStairway(), CreateGcpContextFlight.class, createInputParameters(workspaceId, userRequest), STAIRWAY_FLIGHT_TIMEOUT, FlightDebugInfo.newBuilder().build());
assertEquals(FlightStatus.ERROR, flightState.getFlightStatus());
assertEquals(NoBillingAccountException.class, flightState.getException().get().getClass());
assertTrue(testUtils.getAuthorizedGcpCloudContext(workspaceId, userRequest).isEmpty());
assertFalse(flightState.getResultMap().get().containsKey(WorkspaceFlightMapKeys.GCP_PROJECT_ID));
}
use of bio.terra.stairway.FlightState in project terra-workspace-manager by DataBiosphere.
the class CreateGcpContextFlightTest method createsProjectAndContext_unauthorizedSpendProfile_flightFailsAndGcpProjectNotCreated.
@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void createsProjectAndContext_unauthorizedSpendProfile_flightFailsAndGcpProjectNotCreated() throws Exception {
Mockito.when(mockSamService.isAuthorized(Mockito.any(), Mockito.eq(SamResource.SPEND_PROFILE), Mockito.any(), Mockito.eq(SamSpendProfileAction.LINK))).thenReturn(false);
UUID workspaceId = createWorkspace(spendUtils.defaultSpendId());
AuthenticatedUserRequest unauthorizedUserRequest = userAccessUtils.secondUserAuthRequest();
FlightState flightState = StairwayTestUtils.blockUntilFlightCompletes(jobService.getStairway(), CreateGcpContextFlight.class, createInputParameters(workspaceId, unauthorizedUserRequest), STAIRWAY_FLIGHT_TIMEOUT, FlightDebugInfo.newBuilder().build());
assertEquals(FlightStatus.ERROR, flightState.getFlightStatus());
assertEquals(SpendUnauthorizedException.class, flightState.getException().get().getClass());
assertFalse(flightState.getResultMap().get().containsKey(WorkspaceFlightMapKeys.GCP_PROJECT_ID));
}
Aggregations