Search in sources :

Example 1 with PoolId

use of bio.terra.buffer.common.PoolId in project terra-resource-buffer by DataBiosphere.

the class BufferDaoTest method updatePoolSize.

@Test
public void updatePoolSize() {
    PoolId poolId = PoolId.create("poolId");
    Pool pool = newPool(poolId);
    bufferDao.createPools(ImmutableList.of(pool));
    Pool retrievedPool = bufferDao.retrievePools().get(0);
    Pool resizedPool = pool.toBuilder().size(retrievedPool.size() + 10).build();
    bufferDao.updatePoolsSizes(ImmutableMap.of(poolId, resizedPool.size()));
    assertThat(bufferDao.retrievePools(), Matchers.containsInAnyOrder(resizedPool));
}
Also used : PoolId(bio.terra.buffer.common.PoolId) Pool(bio.terra.buffer.common.Pool) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Example 2 with PoolId

use of bio.terra.buffer.common.PoolId in project terra-resource-buffer by DataBiosphere.

the class PoolServiceTest method handoutResource_deactivatedPool.

@Test
public void handoutResource_deactivatedPool() throws Exception {
    PoolId poolId = PoolId.create("poolId");
    RequestHandoutId requestHandoutId = RequestHandoutId.create("handoutId");
    newReadyPool(poolId, 1);
    bufferDao.deactivatePools(ImmutableList.of(poolId));
    assertThrows(BadRequestException.class, () -> poolService.handoutResource(poolId, requestHandoutId));
}
Also used : PoolId(bio.terra.buffer.common.PoolId) RequestHandoutId(bio.terra.buffer.common.RequestHandoutId) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Example 3 with PoolId

use of bio.terra.buffer.common.PoolId in project terra-resource-buffer by DataBiosphere.

the class PoolServiceTest method updateFromConfig_createPool.

@Test
public void updateFromConfig_createPool() throws Exception {
    PoolId poolId = PoolId.create("poolId");
    PoolWithResourceConfig parsedPoolConfig = PoolWithResourceConfig.create(new PoolConfig().poolId(poolId.toString()).size(10).resourceConfigName(RESOURCE_CONFIG_NAME), newResourceConfig());
    poolService.updateFromConfig(ImmutableList.of(parsedPoolConfig));
    List<Pool> pools = bufferDao.retrievePools();
    assertEquals(1, pools.size());
    Pool createdPool = pools.get(0);
    assertEquals(poolId, createdPool.id());
    assertEquals(ResourceType.GOOGLE_PROJECT, createdPool.resourceType());
    assertEquals(PoolStatus.ACTIVE, createdPool.status());
    assertEquals(parsedPoolConfig.resourceConfig(), createdPool.resourceConfig());
}
Also used : PoolId(bio.terra.buffer.common.PoolId) PoolConfig(bio.terra.buffer.generated.model.PoolConfig) Pool(bio.terra.buffer.common.Pool) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Example 4 with PoolId

use of bio.terra.buffer.common.PoolId in project terra-resource-buffer by DataBiosphere.

the class PoolServiceTest method handoutResource_noReadyResource.

@Test
public void handoutResource_noReadyResource() throws Exception {
    PoolId poolId = PoolId.create("poolId");
    RequestHandoutId requestHandoutId = RequestHandoutId.create("handoutId");
    newReadyPool(poolId, 0);
    assertThrows(NotFoundException.class, () -> poolService.handoutResource(poolId, requestHandoutId));
}
Also used : PoolId(bio.terra.buffer.common.PoolId) RequestHandoutId(bio.terra.buffer.common.RequestHandoutId) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Example 5 with PoolId

use of bio.terra.buffer.common.PoolId in project terra-resource-buffer by DataBiosphere.

the class PoolServiceTest method updateFromConfig_alreadyExists.

@Test
public void updateFromConfig_alreadyExists() throws Exception {
    PoolId poolId = PoolId.create("poolId");
    PoolWithResourceConfig parsedPoolConfig = PoolWithResourceConfig.create(new PoolConfig().poolId(poolId.toString()).size(10).resourceConfigName(RESOURCE_CONFIG_NAME), newResourceConfig());
    poolService.updateFromConfig(ImmutableList.of(parsedPoolConfig));
    List<Pool> pools = bufferDao.retrievePools();
    assertEquals(1, pools.size());
    Pool createdPool = pools.get(0);
    assertEquals(poolId, createdPool.id());
    assertEquals(ResourceType.GOOGLE_PROJECT, createdPool.resourceType());
    assertEquals(PoolStatus.ACTIVE, createdPool.status());
    assertEquals(parsedPoolConfig.resourceConfig(), createdPool.resourceConfig());
    poolService.updateFromConfig(ImmutableList.of(parsedPoolConfig));
    assertThat(bufferDao.retrievePools(), Matchers.containsInAnyOrder(pools.toArray()));
}
Also used : PoolId(bio.terra.buffer.common.PoolId) PoolConfig(bio.terra.buffer.generated.model.PoolConfig) Pool(bio.terra.buffer.common.Pool) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Aggregations

PoolId (bio.terra.buffer.common.PoolId)19 Test (org.junit.jupiter.api.Test)16 BaseUnitTest (bio.terra.buffer.common.BaseUnitTest)15 Pool (bio.terra.buffer.common.Pool)13 PoolConfig (bio.terra.buffer.generated.model.PoolConfig)7 RequestHandoutId (bio.terra.buffer.common.RequestHandoutId)4 Resource (bio.terra.buffer.common.Resource)4 CloudResourceUid (bio.terra.buffer.generated.model.CloudResourceUid)3 ResourceState (bio.terra.buffer.common.ResourceState)2 ResourceConfig (bio.terra.buffer.generated.model.ResourceConfig)2 HashMap (java.util.HashMap)2 BUFFER_JDBC_TEMPLATE (bio.terra.buffer.app.configuration.BeanNames.BUFFER_JDBC_TEMPLATE)1 OBJECT_MAPPER (bio.terra.buffer.app.configuration.BeanNames.OBJECT_MAPPER)1 BaseIntegrationTest (bio.terra.buffer.common.BaseIntegrationTest)1 PoolAndResourceStates (bio.terra.buffer.common.PoolAndResourceStates)1 PoolStatus (bio.terra.buffer.common.PoolStatus)1 ResourceId (bio.terra.buffer.common.ResourceId)1 ResourceType (bio.terra.buffer.common.ResourceType)1 GcpProjectConfig (bio.terra.buffer.generated.model.GcpProjectConfig)1 GoogleProjectUid (bio.terra.buffer.generated.model.GoogleProjectUid)1