use of bio.terra.buffer.app.configuration.PrimaryConfiguration in project terra-resource-buffer by DataBiosphere.
the class FlightSchedulerTest method scheduleDeactivationFlights_enableDeletion.
@Test
public void scheduleDeactivationFlights_enableDeletion() throws Exception {
newPoolWithResourceCount(1, ImmutableMultiset.of(ResourceState.READY, ResourceState.READY));
PrimaryConfiguration primaryConfiguration = newPrimaryConfiguration();
primaryConfiguration.setDeleteExcessResources(true);
initializeScheduler(primaryConfiguration);
TimeUnit.SECONDS.sleep(4);
verify(flightManager).submitDeletionFlight(any(Resource.class), eq(ResourceType.GOOGLE_PROJECT));
}
use of bio.terra.buffer.app.configuration.PrimaryConfiguration in project terra-resource-buffer by DataBiosphere.
the class FlightSchedulerTest method scheduleDeactivationFlights_smallerLimitPerExecute.
@Test
public void scheduleDeactivationFlights_smallerLimitPerExecute() throws Exception {
// Pool1 size 5, need to deactivate the 4 READY resources.
// Expect number of resourceDeactivationPerPoolLimit(3) flights are submitted at most.
Pool pool = newPoolWithResourceCount(5, ImmutableMultiset.of(ResourceState.READY, ResourceState.READY, ResourceState.READY, ResourceState.READY, ResourceState.CREATING));
bufferDao.deactivatePools(ImmutableList.of(pool.id()));
List<Resource> resources = bufferDao.retrieveResourcesRandomly(pool.id(), ResourceState.READY, 4);
PrimaryConfiguration primaryConfiguration = newPrimaryConfiguration();
primaryConfiguration.setResourceDeletionPerPoolLimit(3);
initializeScheduler(primaryConfiguration);
TimeUnit.SECONDS.sleep(4);
verify(flightManager, times(3)).submitDeletionFlight(resourceArgumentCaptor.capture(), eq(ResourceType.GOOGLE_PROJECT));
assertThat(resources, (Matcher) Matchers.hasItems(resourceArgumentCaptor.getAllValues().toArray()));
verify(flightManager, never()).submitCreationFlight(any(Pool.class));
}
use of bio.terra.buffer.app.configuration.PrimaryConfiguration in project terra-resource-buffer by DataBiosphere.
the class FlightSchedulerTest method newPrimaryConfiguration.
private PrimaryConfiguration newPrimaryConfiguration() {
PrimaryConfiguration primaryConfiguration = new PrimaryConfiguration();
primaryConfiguration.setSchedulerEnabled(true);
primaryConfiguration.setResourceCreationPerPoolLimit(10);
primaryConfiguration.setResourceDeletionPerPoolLimit(10);
primaryConfiguration.setDeleteExcessResources(false);
// Sets submissionPeriod to a big number to make sure it is only runs once.
primaryConfiguration.setFlightSubmissionPeriod(Duration.ofHours(2));
return primaryConfiguration;
}
use of bio.terra.buffer.app.configuration.PrimaryConfiguration in project terra-resource-buffer by DataBiosphere.
the class FlightSchedulerTest method scheduleCreationFlights_smallerLimitPerExecute.
@Test
public void scheduleCreationFlights_smallerLimitPerExecute() throws Exception {
// Pool size 10, need to create 7 more resources.
// Expect number of resourceCreationPerPoolLimit(5) flights are submitted at most.
Pool pool = newPoolWithResourceCount(10, ImmutableMultiset.of(ResourceState.READY, ResourceState.READY, ResourceState.CREATING));
PrimaryConfiguration primaryConfiguration = newPrimaryConfiguration();
primaryConfiguration.setResourceCreationPerPoolLimit(5);
initializeScheduler(primaryConfiguration);
TimeUnit.SECONDS.sleep(4);
verify(flightManager, times(5)).submitCreationFlight(pool);
verify(flightManager, never()).submitDeletionFlight(any(Resource.class), any(ResourceType.class));
}
Aggregations