use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class ExtensionsValidatorTest method givenAValidCreation_shouldPass.
@Test
void givenAValidCreation_shouldPass() throws ValidationFailed {
final StackGresClusterReview review = getCreationReview();
review.getRequest().getObject().getSpec().getPostgres().setExtensions(null);
review.getRequest().getObject().getSpec().setToInstallPostgresExtensions(new ArrayList<>());
review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().addAll(defaultExtensions);
validator.validate(review);
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class ExtensionsValidatorTest method givenAnUpdate_shouldPass.
@Test
void givenAnUpdate_shouldPass() throws ValidationFailed {
final StackGresClusterReview review = getUpdateReview();
review.getRequest().getObject().getSpec().getPostgres().setExtensions(null);
review.getRequest().getObject().getSpec().setToInstallPostgresExtensions(new ArrayList<>());
review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().addAll(defaultExtensions);
validator.validate(review);
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class PoolingValidatorTest method givenValidStackGresPoolingOnCreation_shouldNotFail.
@Test
void givenValidStackGresPoolingOnCreation_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/valid_creation.json", StackGresClusterReview.class);
String poolingConfig = review.getRequest().getObject().getSpec().getConfiguration().getConnectionPoolingConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(configFinder.findByNameAndNamespace(poolingConfig, namespace)).thenReturn(Optional.of(pgbouncerConfig));
validator.validate(review);
verify(configFinder).findByNameAndNamespace(eq(poolingConfig), eq(namespace));
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class PoolingValidatorTest method giveInvalidStackGresPoolingOnCreation_shouldFail.
@Test
void giveInvalidStackGresPoolingOnCreation_shouldFail() {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/valid_creation.json", StackGresClusterReview.class);
String poolingConfig = review.getRequest().getObject().getSpec().getConfiguration().getConnectionPoolingConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(configFinder.findByNameAndNamespace(poolingConfig, namespace)).thenReturn(Optional.empty());
ValidationFailed ex = assertThrows(ValidationFailed.class, () -> {
validator.validate(review);
});
String resultMessage = ex.getMessage();
assertEquals("Pooling config " + poolingConfig + " not found", resultMessage);
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class PoolingValidatorTest method giveAnAttemptToUpdateToAnUnknownPoolingConfig_shouldFail.
@Test
void giveAnAttemptToUpdateToAnUnknownPoolingConfig_shouldFail() {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/connectionpooling_config_update.json", StackGresClusterReview.class);
String poolingConfig = review.getRequest().getObject().getSpec().getConfiguration().getConnectionPoolingConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(configFinder.findByNameAndNamespace(poolingConfig, namespace)).thenReturn(Optional.empty());
ValidationFailed ex = assertThrows(ValidationFailed.class, () -> {
validator.validate(review);
});
String resultMessage = ex.getMessage();
assertEquals("Cannot update to pooling config " + poolingConfig + " because it doesn't exists", resultMessage);
verify(configFinder).findByNameAndNamespace(eq(poolingConfig), eq(namespace));
}
Aggregations