Search in sources :

Example 11 with FlightManager

use of bio.terra.buffer.service.resource.FlightManager in project terra-resource-buffer by DataBiosphere.

the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_createLogBucket_false.

@Test
public void testCreateGoogleProject_createLogBucket_false() throws Exception {
    FlightManager manager = new FlightManager(bufferDao, flightSubmissionFactoryImpl, stairwayComponent, transactionTemplate);
    Pool pool = preparePool(bufferDao, newBasicGcpConfig().storage(new Storage().createLogBucket(false)));
    String flightId = manager.submitCreationFlight(pool).get();
    ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
    Project project = assertProjectExists(resourceId);
    String projectId = project.getProjectId();
    String logBucketName = "storage-logs-" + projectId;
    assertNull(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 12 with FlightManager

use of bio.terra.buffer.service.resource.FlightManager in project terra-resource-buffer by DataBiosphere.

the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_blockedRegions.

@Test
public void testCreateGoogleProject_blockedRegions() throws Exception {
    List<String> blockedRegions = ImmutableList.of("europe-west2", "us-west4");
    FlightManager manager = new FlightManager(bufferDao, flightSubmissionFactoryImpl, stairwayComponent, transactionTemplate);
    Pool pool = preparePool(bufferDao, newBasicGcpConfig().network(new bio.terra.buffer.generated.model.Network().blockedRegions(blockedRegions)));
    String flightId = manager.submitCreationFlight(pool).get();
    ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
    Project project = assertProjectExists(resourceId);
    assertNoSubnetsInBlockedRegions(project, blockedRegions);
}
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) bio.terra.buffer.generated.model(bio.terra.buffer.generated.model) FlightManager(bio.terra.buffer.service.resource.FlightManager) Test(org.junit.jupiter.api.Test) BaseIntegrationTest(bio.terra.buffer.common.BaseIntegrationTest)

Example 13 with FlightManager

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

Example 14 with FlightManager

use of bio.terra.buffer.service.resource.FlightManager in project terra-resource-buffer by DataBiosphere.

the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_enablePrivateGoogleAccessAndFlowLog.

@Test
public void testCreateGoogleProject_enablePrivateGoogleAccessAndFlowLog() throws Exception {
    FlightManager manager = new FlightManager(bufferDao, flightSubmissionFactoryImpl, stairwayComponent, transactionTemplate);
    Pool pool = preparePool(bufferDao, newBasicGcpConfig().network(new bio.terra.buffer.generated.model.Network().enableNetworkMonitoring(true).enablePrivateGoogleAccess(true)));
    String flightId = manager.submitCreationFlight(pool).get();
    ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
    Project project = assertProjectExists(resourceId);
    assertNetworkExists(project);
    assertSubnetsExist(project, NetworkMonitoring.ENABLED);
    assertRouteExists(project);
    assertDnsExists(project);
    assertDefaultVpcNotExists(project);
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project) ResourceId(bio.terra.buffer.common.ResourceId) Network(com.google.api.services.compute.model.Network) 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 15 with FlightManager

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

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