use of com.blackducksoftware.bdio2.model.Project 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 com.blackducksoftware.bdio2.model.Project in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_keepDefaultNetwork.
@Disabled("In Broad deployment, skipDefaultNetworkCreation is turned on orignization policy")
@Test
public void testCreateGoogleProject_keepDefaultNetwork() throws Exception {
FlightManager manager = new FlightManager(bufferDao, flightSubmissionFactoryImpl, stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newBasicGcpConfig().network(new bio.terra.buffer.generated.model.Network().keepDefaultNetwork(true)));
String flightId = manager.submitCreationFlight(pool).get();
ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
Project project = assertProjectExists(resourceId);
assertNetworkExists(project);
assertFirewallRulesExist(project);
assertDefaultVpcExists(project);
assertFirewallRulesExistForDefaultVpc(project);
}
use of com.blackducksoftware.bdio2.model.Project in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_blockedRegions_invalidBlockedRegion.
@Test
public void testCreateGoogleProject_blockedRegions_invalidBlockedRegion() throws Exception {
// If a blocked region is invalid, project configuration still succeeds.
String validBlockedRegion = "europe-west2";
String invalidBlockedRegion = "u-west4";
List<String> blockedRegions = ImmutableList.of(validBlockedRegion, invalidBlockedRegion);
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, ImmutableList.of(validBlockedRegion));
}
use of com.blackducksoftware.bdio2.model.Project in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method assertGcrDnsExists.
private void assertGcrDnsExists(Project project) throws Exception {
String projectId = project.getProjectId();
ManagedZone managedZone = dnsCow.managedZones().get(projectId, GCR_MANAGED_ZONE_NAME).execute();
Map<String, ResourceRecordSet> resourceRecordSets = dnsCow.resourceRecordSets().list(project.getProjectId(), GCR_MANAGED_ZONE_NAME).execute().getRrsets().stream().collect(Collectors.toMap(ResourceRecordSet::getType, r -> r));
ResourceRecordSet aRecordSet = resourceRecordSets.get(GCR_A_RECORD.getType());
ResourceRecordSet cnameRecordSet = resourceRecordSets.get(GCR_CNAME_RECORD.getType());
assertEquals(GCR_MANAGED_ZONE_TEMPLATE.getName(), managedZone.getName());
assertEquals(GCR_MANAGED_ZONE_TEMPLATE.getVisibility(), managedZone.getVisibility().toLowerCase());
assertEquals(GCR_MANAGED_ZONE_TEMPLATE.getDescription(), managedZone.getDescription());
assertResourceRecordSetMatch(GCR_A_RECORD, aRecordSet);
assertResourceRecordSetMatch(GCR_CNAME_RECORD, cnameRecordSet);
}
use of com.blackducksoftware.bdio2.model.Project in project terra-resource-buffer by DataBiosphere.
the class DeleteProjectFlightIntegrationTest method testDeleteGoogleProject_success.
@Test
public void testDeleteGoogleProject_success() throws Exception {
FlightManager manager = new FlightManager(bufferDao, flightSubmissionFactoryImpl, stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newFullGcpConfig());
String createFlightId = manager.submitCreationFlight(pool).get();
ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, createFlightId));
Project project = assertProjectExists(resourceId);
Resource resource = bufferDao.retrieveResourcesRandomly(pool.id(), ResourceState.READY, 1).get(0);
String deleteFlightId = manager.submitDeletionFlight(resource, ResourceType.GOOGLE_PROJECT).get();
blockUntilFlightComplete(stairwayComponent, deleteFlightId);
assertProjectDeleting(project.getProjectId());
}
Aggregations