Search in sources :

Example 16 with FlightManager

use of bio.terra.buffer.service.resource.FlightManager 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);
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project) ResourceId(bio.terra.buffer.common.ResourceId) Pool(bio.terra.buffer.common.Pool) IntegrationUtils.preparePool(bio.terra.buffer.integration.IntegrationUtils.preparePool) FlightManager(bio.terra.buffer.service.resource.FlightManager) Test(org.junit.jupiter.api.Test) BaseIntegrationTest(bio.terra.buffer.common.BaseIntegrationTest)

Example 17 with FlightManager

use of bio.terra.buffer.service.resource.FlightManager 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));
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project) ResourceId(bio.terra.buffer.common.ResourceId) Pool(bio.terra.buffer.common.Pool) IntegrationUtils.preparePool(bio.terra.buffer.integration.IntegrationUtils.preparePool) FlightManager(bio.terra.buffer.service.resource.FlightManager) Test(org.junit.jupiter.api.Test) BaseIntegrationTest(bio.terra.buffer.common.BaseIntegrationTest)

Example 18 with FlightManager

use of bio.terra.buffer.service.resource.FlightManager 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());
}
Also used : ResourceId(bio.terra.buffer.common.ResourceId) Resource(bio.terra.buffer.common.Resource) IntegrationUtils.preparePool(bio.terra.buffer.integration.IntegrationUtils.preparePool) Pool(bio.terra.buffer.common.Pool) FlightManager(bio.terra.buffer.service.resource.FlightManager) StubSubmissionFlightFactory(bio.terra.buffer.integration.IntegrationUtils.StubSubmissionFlightFactory) BaseIntegrationTest(bio.terra.buffer.common.BaseIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

BaseIntegrationTest (bio.terra.buffer.common.BaseIntegrationTest)18 Pool (bio.terra.buffer.common.Pool)18 IntegrationUtils.preparePool (bio.terra.buffer.integration.IntegrationUtils.preparePool)18 FlightManager (bio.terra.buffer.service.resource.FlightManager)18 Test (org.junit.jupiter.api.Test)18 ResourceId (bio.terra.buffer.common.ResourceId)15 Project (com.google.api.services.cloudresourcemanager.v3.model.Project)13 StubSubmissionFlightFactory (bio.terra.buffer.integration.IntegrationUtils.StubSubmissionFlightFactory)7 Resource (bio.terra.buffer.common.Resource)6 bio.terra.buffer.generated.model (bio.terra.buffer.generated.model)3 Network (com.google.api.services.compute.model.Network)2 ServiceUsageCow (bio.terra.cloudres.google.serviceusage.ServiceUsageCow)1 ListConsumerOverridesResponse (com.google.api.services.serviceusage.v1beta1.model.ListConsumerOverridesResponse)1 QuotaOverride (com.google.api.services.serviceusage.v1beta1.model.QuotaOverride)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Disabled (org.junit.jupiter.api.Disabled)1