use of bio.terra.buffer.common.Pool in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method errorCreateProject_noRollbackAfterResourceReady.
@Test
public void errorCreateProject_noRollbackAfterResourceReady() throws Exception {
// Verify project and db entity won't get deleted if resource id READY, even the flight fails.
FlightManager manager = new FlightManager(bufferDao, new StubSubmissionFlightFactory(ErrorAfterCreateResourceFlight.class), stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newBasicGcpConfig());
String flightId = manager.submitCreationFlight(pool).get();
extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
Resource resource = bufferDao.retrieveResourcesRandomly(pool.id(), ResourceState.READY, 1).get(0);
assertEquals("ACTIVE", rmCow.projects().get(resource.cloudResourceUid().getGoogleProjectUid().getProjectId()).execute().getState());
assertEquals(FlightStatus.ERROR, stairwayComponent.get().getFlightState(flightId).getFlightStatus());
}
use of bio.terra.buffer.common.Pool in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_keepDefaultComputeEngineServiceAcct.
@Test
public void testCreateGoogleProject_keepDefaultComputeEngineServiceAcct() throws Exception {
FlightManager manager = new FlightManager(bufferDao, flightSubmissionFactoryImpl, stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newBasicGcpConfig().computeEngine(new ComputeEngine().keepDefaultServiceAcct(true)));
String flightId = manager.submitCreationFlight(pool).get();
ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
Project project = assertProjectExists(resourceId);
assertDefaultServiceAccountExists(project);
}
use of bio.terra.buffer.common.Pool in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_basicCreation.
@Test
public void testCreateGoogleProject_basicCreation() throws Exception {
FlightManager manager = new FlightManager(bufferDao, flightSubmissionFactoryImpl, stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newBasicGcpConfig());
String flightId = manager.submitCreationFlight(pool).get();
ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
Project project = assertProjectExists(resourceId);
assertBillingIs(project, pool.resourceConfig().getGcpProjectConfig().getBillingAccount());
assertEnableApisContains(project, pool.resourceConfig().getGcpProjectConfig().getEnabledApis());
assertLogStorageBucketExists(project);
assertNetworkExists(project);
assertFirewallRulesExist(project);
assertSubnetsExist(project, NetworkMonitoring.DISABLED);
assertRouteNotExists(project);
assertDnsNotExists(project);
assertDefaultVpcNotExists(project);
assertDefaultServiceAccountNotExists(project);
String logBucketName = "storage-logs-" + project.getProjectId();
assertNotNull(storageCow.get(logBucketName));
}
use of bio.terra.buffer.common.Pool in project terra-resource-buffer by DataBiosphere.
the class DeleteProjectFlightIntegrationTest method testDeleteGoogleProject_errorWhenResourceStateChange.
@Test
public void testDeleteGoogleProject_errorWhenResourceStateChange() throws Exception {
LatchStep.startNewLatch();
Pool pool = preparePool(bufferDao, newBasicGcpConfig());
ResourceId resourceId = ResourceId.create(UUID.randomUUID());
bufferDao.createResource(Resource.builder().id(resourceId).poolId(pool.id()).creation(Instant.now()).state(ResourceState.READY).build());
Resource resource = bufferDao.retrieveResource(resourceId).get();
FlightManager manager = new FlightManager(bufferDao, new StubSubmissionFlightFactory(LatchBeforeAssertResourceStep.class), stairwayComponent, transactionTemplate);
String deleteFlightId = manager.submitDeletionFlight(resource, ResourceType.GOOGLE_PROJECT).get();
// 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, deleteFlightId));
// Resource is deleted.
assertFalse(bufferDao.retrieveResource(resource.id()).isPresent());
assertEquals(FlightStatus.ERROR, stairwayComponent.get().getFlightState(deleteFlightId).getFlightStatus());
}
Aggregations