use of bio.terra.buffer.common.ResourceId in project terra-resource-buffer by DataBiosphere.
the class PoolServiceTest method newReadyPool.
/**
* Creates a pool with resources with given size.
*/
private void newReadyPool(PoolId poolId, int poolSize) {
Pool pool = Pool.builder().creation(Instant.now()).id(poolId).resourceType(ResourceType.GOOGLE_PROJECT).size(poolSize).resourceConfig(new ResourceConfig().configName("resourceName")).status(PoolStatus.ACTIVE).build();
bufferDao.createPools(ImmutableList.of(pool));
for (int i = 0; i < poolSize; i++) {
ResourceId id = ResourceId.create(UUID.randomUUID());
bufferDao.createResource(Resource.builder().id(id).poolId(poolId).creation(Instant.now()).state(ResourceState.CREATING).build());
bufferDao.updateResourceAsReady(id, newProjectUid());
}
}
use of bio.terra.buffer.common.ResourceId in project terra-resource-buffer by DataBiosphere.
the class FlightManager method createResourceEntityAndSubmitFlight.
/**
* Create entity in resource table with CREATING and submit creation flight.
*
* <p>If the Stairway submission fails, the transaction will be rolled back. If the Stairway
* submission succeeds but the DB update transaction fails, the flight checks the DB state and
* aborts if the state is bad.
*/
private Optional<String> createResourceEntityAndSubmitFlight(Pool pool, TransactionStatus status) {
ResourceId resourceId = ResourceId.create(UUID.randomUUID());
bufferDao.createResource(Resource.builder().id(resourceId).poolId(pool.id()).creation(Instant.now()).state(ResourceState.CREATING).build());
return submitToStairway(flightSubmissionFactory.getCreationFlightSubmission(pool, resourceId), status);
}
use of bio.terra.buffer.common.ResourceId in project terra-resource-buffer by DataBiosphere.
the class UpdateResourceAsDeletedStep method doStep.
@Override
public StepResult doStep(FlightContext flightContext) {
ResourceId resourceId = ResourceId.retrieve(flightContext.getInputParameters());
bufferDao.updateResourceAsDeleted(resourceId, Instant.now());
return StepResult.getStepResultSuccess();
}
use of bio.terra.buffer.common.ResourceId in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_createGkeSA_true.
@Test
public void testCreateGoogleProject_createGkeSA_true() throws Exception {
FlightManager manager = new FlightManager(bufferDao, flightSubmissionFactoryImpl, stairwayComponent, transactionTemplate);
Pool pool = preparePool(bufferDao, newBasicGcpConfig().kubernetesEngine(new KubernetesEngine().createGkeDefaultServiceAccount(true)));
String flightId = manager.submitCreationFlight(pool).get();
ResourceId resourceId = extractResourceIdFromFlightState(blockUntilFlightComplete(stairwayComponent, flightId));
Project project = assertProjectExists(resourceId);
String projectId = project.getProjectId();
String serviceAccountEmail = ServiceAccountName.emailFromAccountId(GKE_SA_NAME, projectId);
assertServiceAccountExists(project, serviceAccountEmail);
List<IamBinding> expectedGkeSABindings = new ArrayList<>();
GKE_SA_ROLES.forEach(r -> expectedGkeSABindings.add(new IamBinding().role(r).addMembersItem("serviceAccount:" + serviceAccountEmail)));
assertIamBindingsContains(project, expectedGkeSABindings);
}
use of bio.terra.buffer.common.ResourceId in project terra-resource-buffer by DataBiosphere.
the class CreateProjectFlightIntegrationTest method testCreateGoogleProject_blockInternetAccessWithGcrDnsEnabled.
@Test
public void testCreateGoogleProject_blockInternetAccessWithGcrDnsEnabled() 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).enableCloudRegistryPrivateGoogleAccess(true).blockBatchInternetAccess(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);
assertGcrDnsExists(project);
assertDefaultVpcNotExists(project);
assertFirewallRulesExistForBlockInternetAccess(project);
}
Aggregations