use of com.blackducksoftware.bdio2.model.Project in project terra-workspace-manager by DataBiosphere.
the class CreateGcpContextFlightV2Test method errorRevertsChanges.
@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void errorRevertsChanges() throws Exception {
UUID workspaceUuid = createWorkspace(spendUtils.defaultSpendId());
AuthenticatedUserRequest userRequest = userAccessUtils.defaultUserAuthRequest();
assertTrue(testUtils.getAuthorizedGcpCloudContext(workspaceUuid, userRequest).isEmpty());
// Submit a flight class that always errors.
Map<String, StepStatus> retrySteps = getStepNameToStepStatusMap();
FlightDebugInfo debugInfo = FlightDebugInfo.newBuilder().undoStepFailures(retrySteps).lastStepFailure(true).build();
FlightState flightState = StairwayTestUtils.blockUntilFlightCompletes(jobService.getStairway(), CreateGcpContextFlightV2.class, createInputParameters(workspaceUuid, userRequest), STAIRWAY_FLIGHT_TIMEOUT, debugInfo);
assertEquals(FlightStatus.ERROR, flightState.getFlightStatus());
assertTrue(testUtils.getAuthorizedGcpCloudContext(workspaceUuid, userRequest).isEmpty());
String projectId = flightState.getResultMap().get().get(WorkspaceFlightMapKeys.GCP_PROJECT_ID, String.class);
// The Project should exist, but requested to be deleted.
Project project = crl.getCloudResourceManagerCow().projects().get(projectId).execute();
assertEquals(projectId, project.getProjectId());
assertEquals("DELETE_REQUESTED", project.getState());
}
use of com.blackducksoftware.bdio2.model.Project in project terra-workspace-manager by DataBiosphere.
the class CreateGcpContextFlightV2Test method assertPolicyGroupsSynced.
/**
* Asserts that Sam groups are granted their appropriate IAM roles on a GCP project.
*/
private void assertPolicyGroupsSynced(UUID workspaceUuid, Project project) throws Exception {
Map<WsmIamRole, String> roleToSamGroup = Arrays.stream(WsmIamRole.values()).collect(Collectors.toMap(Function.identity(), role -> "group:" + SamRethrow.onInterrupted(() -> mockSamService.syncWorkspacePolicy(workspaceUuid, role, userAccessUtils.defaultUserAuthRequest()), "syncWorkspacePolicy")));
Policy currentPolicy = crl.getCloudResourceManagerCow().projects().getIamPolicy(project.getProjectId(), new GetIamPolicyRequest()).execute();
for (WsmIamRole role : WsmIamRole.values()) {
// Don't check MANAGER role, which isn't synced to GCP.
if (role.equals(WsmIamRole.MANAGER)) {
continue;
}
assertRoleBindingInPolicy(role, roleToSamGroup.get(role), currentPolicy, project.getProjectId());
}
}
use of com.blackducksoftware.bdio2.model.Project in project terra-cloud-resource-lib by DataBiosphere.
the class DnsCowTest method createAndGetZone.
@Test
public void createAndGetZone() throws Exception {
Project project = ProjectUtils.executeCreateProject();
String projectId = project.getProjectId();
CloudBillingUtils.setDefaultProjectBilling(projectId);
ServiceUsageUtils.enableServices(projectId, SERVICE_IDS);
DnsCow dnsCow = defaultDns();
String zoneName = "zone-name";
String dnsName = "googleapis.com.";
String visibility = "PRIVATE";
ManagedZone managedZone = new ManagedZone().setName(zoneName).setDnsName(dnsName).setVisibility(visibility).setDescription("description");
dnsCow.managedZones().create(project.getProjectId(), managedZone).execute();
ManagedZone createdManagedZone = dnsCow.managedZones().get(projectId, zoneName).execute();
assertEquals(dnsName, createdManagedZone.getDnsName());
assertEquals(zoneName, createdManagedZone.getName());
assertEquals(visibility, createdManagedZone.getVisibility());
}
use of com.blackducksoftware.bdio2.model.Project in project terra-cloud-resource-lib by DataBiosphere.
the class IamCowTest method createIamPreparedProject.
/**
* Create Project then set billing account, enable IAM api
*/
private static Project createIamPreparedProject() throws Exception {
Project project = ProjectUtils.executeCreateProject();
CloudBillingUtils.setDefaultProjectBilling(project.getProjectId());
ServiceUsageUtils.enableServices(project.getProjectId(), ImmutableList.of("iam.googleapis.com"));
return project;
}
use of com.blackducksoftware.bdio2.model.Project in project terra-cloud-resource-lib by DataBiosphere.
the class ServiceUsageCowTest method createListConsumerQuotaOverride.
@Test
public void createListConsumerQuotaOverride() throws Exception {
Project project = ProjectUtils.executeCreateProject();
// name is of the form `projects/415104041262`
long projectNumber = Long.parseLong(project.getName().substring("projects/".length()));
String parent = String.format("projects/%d/services/bigquery.googleapis.com/consumerQuotaMetrics/" + "bigquery.googleapis.com%%2Fquota%%2Fquery%%2Fusage/limits/%%2Fd%%2Fproject", projectNumber);
QuotaOverride quotaOverrideForRequest = buildQuotaOverride(projectNumber);
ServiceUsageCow.Services.ConsumerQuotaMetrics.Limits.ConsumerOverrides.Create create = defaultServiceUsage().services().consumerQuotaMetrics().limits().consumerOverrides().create(parent, quotaOverrideForRequest).setForce(true);
assertNotNull(create);
OperationTestUtils.pollAndAssertSuccess(defaultServiceUsage().operations().operationCow(create.execute()), Duration.ofSeconds(5), Duration.ofSeconds(60));
ServiceUsageCow.Services.ConsumerQuotaMetrics.Limits.ConsumerOverrides.List list = defaultServiceUsage().services().consumerQuotaMetrics().limits().consumerOverrides().list(parent);
ListConsumerOverridesResponse response = list.execute();
assertNotNull(response);
assertEquals(1, response.getOverrides().size());
QuotaOverride quotaOverrideRetrieved = response.getOverrides().get(0);
// returned name is of the form
// "projects/847486415500/services/bigquery.googleapis.com/consumerQuotaMetrics/bigquery.googleapis.com%2Fquota%2Fquery%2Fusage/limits/%2Fd%2Fproject/consumerOverrides/Cg1RdW90YU92ZXJyaWRl"
// content name is shorter:
// "projects/847486415500/services/bigquery.googleapis.com/consumerQuotaMetrics/bigquery.googleapis.com%2Fquota%2Fquery%2Fusage"
// Both of these are opaque and not to be relied on, but I can't help but think the fact that
// one is a prefix of the other is invariant.
assertTrue(quotaOverrideRetrieved.getName().contains(quotaOverrideForRequest.getName()));
assertEquals(OVERRIDE_VALUE_BYTES, quotaOverrideRetrieved.getOverrideValue());
assertTrue(null == quotaOverrideRetrieved.getDimensions() || quotaOverrideRetrieved.getDimensions().isEmpty());
// not returned for some reason
assertNull(quotaOverrideRetrieved.getMetric());
// not returned apparently
assertNull(quotaOverrideRetrieved.getUnit());
}
Aggregations