use of bio.terra.buffer.generated.model.ProjectIdSchema in project terra-resource-buffer by DataBiosphere.
the class PoolServiceTest method updateFromConfig_updateResourceConfigOnExistingPool_throwsException.
@Test
public void updateFromConfig_updateResourceConfigOnExistingPool_throwsException() throws Exception {
PoolId poolId = PoolId.create("poolId");
PoolConfig poolConfig = new PoolConfig().poolId(poolId.toString()).size(1).resourceConfigName(RESOURCE_CONFIG_NAME);
PoolWithResourceConfig parsedPoolConfig = PoolWithResourceConfig.create(poolConfig, newResourceConfig());
poolService.updateFromConfig(ImmutableList.of(parsedPoolConfig));
// Sets ResourceConfig's GCP project id prefix to newer value.
PoolWithResourceConfig updatedPoolConfig = PoolWithResourceConfig.create(poolConfig, newResourceConfig(new GcpProjectConfig().projectIdSchema(new ProjectIdSchema().prefix("aou-rw-test2").scheme(ProjectIdSchema.SchemeEnum.RANDOM_CHAR))));
assertThrows(RuntimeException.class, () -> poolService.updateFromConfig(ImmutableList.of(updatedPoolConfig)));
assertThat(bufferDao.retrievePools().stream().map(Pool::resourceConfig).collect(Collectors.toList()), Matchers.containsInAnyOrder(parsedPoolConfig.resourceConfig()));
}
use of bio.terra.buffer.generated.model.ProjectIdSchema 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"));
}
use of bio.terra.buffer.generated.model.ProjectIdSchema in project terra-resource-buffer by DataBiosphere.
the class GcpProjectIdGeneratorTest method generateId_wordPair.
@Test
public void generateId_wordPair() {
ProjectIdSchema generatorConfig = new ProjectIdSchema().prefix("prefix").scheme(TWO_WORDS_NUMBER);
String generatedID = gcpProjectIDGenerator.generateId(generatorConfig);
assertThat(generatedID, matchesPattern("prefix-[a-z]+-[a-z]+-[0-9]+"));
}
use of bio.terra.buffer.generated.model.ProjectIdSchema in project terra-resource-buffer by DataBiosphere.
the class GcpProjectIdGeneratorTest method generateId_randomChar.
@Test
public void generateId_randomChar() {
ProjectIdSchema generatorConfig = new ProjectIdSchema().prefix("prefix").scheme(RANDOM_CHAR);
String generatedID = gcpProjectIDGenerator.generateId(generatorConfig);
assertTrue(generatedID.startsWith("prefix-"));
assertEquals(RANDOM_ID_SIZE, generatedID.substring("prefix-".length()).length());
}
use of bio.terra.buffer.generated.model.ProjectIdSchema in project terra-resource-buffer by DataBiosphere.
the class GcpProjectIdGeneratorTest method generateIdWithRetries_retriesExhausted.
@Test
public void generateIdWithRetries_retriesExhausted() {
ProjectIdSchema generatorConfig = new ProjectIdSchema().prefix("prefixthatislongerthan30characters").scheme(TWO_WORDS_NUMBER);
InterruptedException interruptedException = assertThrows(InterruptedException.class, () -> gcpProjectIDGenerator.generateIdWithRetries(generatorConfig));
assertTrue(interruptedException.getMessage().contains("No project id found after maximum number of retries"));
}
Aggregations