use of bio.terra.buffer.integration.IntegrationUtils.StubSubmissionFlightFactory in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_createsConsumerOverride.
@Test
public void testCreateGoogleProject_createsConsumerOverride() throws Exception {
FlightManager manager = new FlightManager(bufferDao, new StubSubmissionFlightFactory(LatchBeforeAssertResourceStep.class), stairwayComponent, transactionTemplate);
GcpProjectConfig gcpProjectConfig = newBasicGcpConfig().serviceUsage(new ServiceUsage().bigQuery(new BigQueryQuotas().overrideBigQueryDailyUsageQuota(true).bigQueryDailyUsageQuotaOverrideValueMebibytes(new BigDecimal(CONSUMER_QUOTA_OVERRIDE_VALUE_MEBIBYTES))));
Pool pool = preparePool(bufferDao, gcpProjectConfig);
String flightId = manager.submitCreationFlight(pool).orElseThrow();
ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
Project project = assertProjectExists(resourceId);
String projectNumber = getProjectNumberFromName(project.getName());
String parent = String.format("projects/%s/services/bigquery.googleapis.com/consumerQuotaMetrics/" + "bigquery.googleapis.com%%2Fquota%%2Fquery%%2Fusage/limits/%%2Fd%%2Fproject", projectNumber);
ServiceUsageCow.Services.ConsumerQuotaMetrics.Limits.ConsumerOverrides.List list = serviceUsageCow.services().consumerQuotaMetrics().limits().consumerOverrides().list(parent);
ListConsumerOverridesResponse response = list.execute();
assertEquals(1, response.getOverrides().size(), "single override expected");
QuotaOverride quotaOverride = response.getOverrides().get(0);
assertEquals(CONSUMER_QUOTA_OVERRIDE_VALUE_MEBIBYTES, quotaOverride.getOverrideValue());
}
use of bio.terra.buffer.integration.IntegrationUtils.StubSubmissionFlightFactory in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_errorWhenResourceStateChange.
@Test
public void testCreateGoogleProject_errorWhenResourceStateChange() throws Exception {
LatchStep.startNewLatch();
FlightManager manager = new FlightManager(bufferDao, new StubSubmissionFlightFactory(LatchBeforeAssertResourceStep.class), stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newBasicGcpConfig());
String flightId = manager.submitCreationFlight(pool).get();
// Resource is created in db
Resource resource = pollUntilResourcesMatch(bufferDao, pool.id(), ResourceState.CREATING, 1).get(0);
// Delete the resource from DB.
assertTrue(bufferDao.deleteResource(resource.id()));
// Release the latch, and resume the flight, assert flight failed.
LatchStep.releaseLatch();
extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
// Resource is deleted.
assertFalse(bufferDao.retrieveResource(resource.id()).isPresent());
assertEquals(FlightStatus.ERROR, stairwayComponent.get().getFlightState(flightId).getFlightStatus());
}
use of bio.terra.buffer.integration.IntegrationUtils.StubSubmissionFlightFactory in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_errorDuringProjectCreation.
@Test
public void testCreateGoogleProject_errorDuringProjectCreation() throws Exception {
// Verify flight is able to successfully rollback when project fails to create and doesn't
// exist.
LatchStep.startNewLatch();
FlightManager manager = new FlightManager(bufferDao, new StubSubmissionFlightFactory(ErrorCreateProjectFlight.class), stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newBasicGcpConfig());
String flightId = manager.submitCreationFlight(pool).get();
// Resource is created in db
Resource resource = pollUntilResourcesMatch(bufferDao, pool.id(), ResourceState.CREATING, 1).get(0);
LatchStep.releaseLatch();
extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
// Resource is deleted.
assertFalse(bufferDao.retrieveResource(resource.id()).isPresent());
assertEquals(FlightStatus.ERROR, stairwayComponent.get().getFlightState(flightId).getFlightStatus());
}
use of bio.terra.buffer.integration.IntegrationUtils.StubSubmissionFlightFactory in project terra-resource-buffer by DataBiosphere.
the class DeleteProjectFlightIntegrationTest method testDeleteGoogleProject_fatalIfHasError.
@Test
public void testDeleteGoogleProject_fatalIfHasError() throws Exception {
FlightManager manager = new FlightManager(bufferDao, flightSubmissionFactoryImpl, stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newBasicGcpConfig());
String createFlightId = manager.submitCreationFlight(pool).get();
ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, createFlightId));
Resource resource = bufferDao.retrieveResource(resourceId).get();
// An errors occurs after resource deleted. Expect project is deleted, but we resource state is
// READY.
FlightManager errorManager = new FlightManager(bufferDao, new StubSubmissionFlightFactory(ErrorAfterDeleteResourceFlight.class), stairwayComponent, transactionTemplate);
String deleteFlightId = errorManager.submitDeletionFlight(resource, ResourceType.GOOGLE_PROJECT).get();
blockUntilFlightComplete(stairwayComponent, deleteFlightId);
assertEquals(FlightStatus.FATAL, stairwayComponent.get().getFlightState(deleteFlightId).getFlightStatus());
}
use of bio.terra.buffer.integration.IntegrationUtils.StubSubmissionFlightFactory in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_multipleSteps.
@Test
public void testCreateGoogleProject_multipleSteps() throws Exception {
// Verify flight is able to finish with multiple same steps exists.
FlightManager manager = new FlightManager(bufferDao, new StubSubmissionFlightFactory(MultiInstanceStepFlight.class), stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newFullGcpConfig());
String flightId = manager.submitCreationFlight(pool).get();
ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
Project project = assertProjectExists(resourceId);
assertIamBindingsContains(project, IAM_BINDINGS);
assertNetworkExists(project);
assertSubnetsExist(project, NetworkMonitoring.ENABLED);
assertRouteExists(project);
assertDnsExists(project);
}
Aggregations