Search in sources :

Example 1 with ResourceConfig

use of bio.terra.buffer.generated.model.ResourceConfig in project terra-resource-buffer by DataBiosphere.

the class PoolConfigLoaderTest method combineParsedResult_resourceConfigNotFound.

@Test
public void combineParsedResult_resourceConfigNotFound() {
    String resourceConfigName = "configName";
    PoolConfig poolConfig = new PoolConfig().poolId("id").resourceConfigName("badName");
    PoolConfigs pools = new PoolConfigs().poolConfigs(ImmutableList.of(poolConfig, poolConfig));
    ResourceConfig resourceConfig = new ResourceConfig().configName(resourceConfigName);
    assertThrows(BadPoolConfigException.class, () -> combineParsedConfig(pools, ImmutableMap.of(resourceConfigName, resourceConfig)));
}
Also used : PoolConfigs(bio.terra.buffer.generated.model.PoolConfigs) PoolConfig(bio.terra.buffer.generated.model.PoolConfig) ResourceConfig(bio.terra.buffer.generated.model.ResourceConfig) Test(org.junit.jupiter.api.Test) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest)

Example 2 with ResourceConfig

use of bio.terra.buffer.generated.model.ResourceConfig 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());
    }
}
Also used : ResourceId(bio.terra.buffer.common.ResourceId) Pool(bio.terra.buffer.common.Pool) ResourceConfig(bio.terra.buffer.generated.model.ResourceConfig)

Example 3 with ResourceConfig

use of bio.terra.buffer.generated.model.ResourceConfig in project terra-resource-buffer by DataBiosphere.

the class ResourceConfigValidatorTest method testValidateGcpConfig_prefixTooLong.

@Test
public void testValidateGcpConfig_prefixTooLong() {
    ResourceConfig resourceConfig = new ResourceConfig().configName("testConfig").gcpProjectConfig(newValidGcpProjectConfig().projectIdSchema(new ProjectIdSchema().prefix("prefixlongerthan12characters").scheme(ProjectIdSchema.SchemeEnum.TWO_WORDS_NUMBER)));
    InvalidPoolConfigException exception = assertThrows(InvalidPoolConfigException.class, () -> new GcpResourceConfigValidator().validate(resourceConfig));
    assertTrue(exception.getMessage().contains("Project id prefix is too long for TWO_WORDS_NUMBER naming scheme"));
}
Also used : ProjectIdSchema(bio.terra.buffer.generated.model.ProjectIdSchema) ResourceConfig(bio.terra.buffer.generated.model.ResourceConfig) InvalidPoolConfigException(bio.terra.buffer.common.exception.InvalidPoolConfigException) Test(org.junit.jupiter.api.Test) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest)

Example 4 with ResourceConfig

use of bio.terra.buffer.generated.model.ResourceConfig in project terra-resource-buffer by DataBiosphere.

the class ResourceConfigValidatorTest method testValidateGcpConfig_missingBillingAccount.

@Test
public void testValidateGcpConfig_missingBillingAccount() {
    ResourceConfig resourceConfig = new ResourceConfig().configName("testConfig").gcpProjectConfig(newValidGcpProjectConfig().billingAccount(""));
    InvalidPoolConfigException exception = assertThrows(InvalidPoolConfigException.class, () -> new GcpResourceConfigValidator().validate(resourceConfig));
    assertTrue(exception.getMessage().contains("Missing billing account"));
}
Also used : ResourceConfig(bio.terra.buffer.generated.model.ResourceConfig) InvalidPoolConfigException(bio.terra.buffer.common.exception.InvalidPoolConfigException) Test(org.junit.jupiter.api.Test) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest)

Example 5 with ResourceConfig

use of bio.terra.buffer.generated.model.ResourceConfig in project terra-resource-buffer by DataBiosphere.

the class ResourceConfigValidatorTest method testValidateGcpConfig_success.

@Test
public void testValidateGcpConfig_success() {
    ResourceConfig resourceConfig = new ResourceConfig().configName("testConfig").gcpProjectConfig(newValidGcpProjectConfig());
    new GcpResourceConfigValidator().validate(resourceConfig);
}
Also used : ResourceConfig(bio.terra.buffer.generated.model.ResourceConfig) Test(org.junit.jupiter.api.Test) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest)

Aggregations

ResourceConfig (bio.terra.buffer.generated.model.ResourceConfig)14 Test (org.junit.jupiter.api.Test)8 BaseUnitTest (bio.terra.buffer.common.BaseUnitTest)7 PoolConfigs (bio.terra.buffer.generated.model.PoolConfigs)5 PoolConfig (bio.terra.buffer.generated.model.PoolConfig)4 Pool (bio.terra.buffer.common.Pool)3 InvalidPoolConfigException (bio.terra.buffer.common.exception.InvalidPoolConfigException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 IOException (java.io.IOException)2 Resource (org.springframework.core.io.Resource)2 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)2 PoolId (bio.terra.buffer.common.PoolId)1 Resource (bio.terra.buffer.common.Resource)1 ResourceId (bio.terra.buffer.common.ResourceId)1 ResourceState (bio.terra.buffer.common.ResourceState)1 CloudResourceUid (bio.terra.buffer.generated.model.CloudResourceUid)1 GoogleProjectUid (bio.terra.buffer.generated.model.GoogleProjectUid)1 ProjectIdSchema (bio.terra.buffer.generated.model.ProjectIdSchema)1