Search in sources :

Example 1 with PoolingReview

use of io.stackgres.operator.common.PoolingReview in project stackgres by ongres.

the class PoolingBlocklistValidatorTest method givenConfigurationWithDatabasesBlockedParameters_shouldFail.

@Test
void givenConfigurationWithDatabasesBlockedParameters_shouldFail() {
    PoolingReview review = getCreatePoolingReview();
    var pgBouncer = review.getRequest().getObject().getSpec().getPgBouncer();
    pgBouncer.getPgbouncerIni().setDatabases(new HashMap<>());
    pgBouncer.getPgbouncerIni().getDatabases().put("foodb", Map.of("user", "user1", "host", "example.com"));
    ValidationFailed assertThrows = assertThrows(ValidationFailed.class, () -> validator.validate(review));
    assertEquals("Invalid PgBouncer configuration, properties: [host, user] cannot be set", assertThrows.getMessage());
}
Also used : ValidationFailed(io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed) PoolingReview(io.stackgres.operator.common.PoolingReview) Test(org.junit.jupiter.api.Test)

Example 2 with PoolingReview

use of io.stackgres.operator.common.PoolingReview in project stackgres by ongres.

the class PoolingConstraintValidatorTest method nullSpec_shouldFail.

@Test
void nullSpec_shouldFail() {
    PoolingReview review = getInvalidReview();
    checkNotNullErrorCause(StackGresPoolingConfig.class, "spec", review);
}
Also used : PoolingReview(io.stackgres.operator.common.PoolingReview) Test(org.junit.jupiter.api.Test) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest)

Example 3 with PoolingReview

use of io.stackgres.operator.common.PoolingReview in project stackgres by ongres.

the class PoolingConstraintValidatorTest method emptyPgBouncerConf_shouldFail.

@Test
void emptyPgBouncerConf_shouldFail() {
    PoolingReview review = getValidReview();
    review.getRequest().getObject().getSpec().getPgBouncer().getPgbouncerIni().setParameters(Map.of());
    checkNotEmptyErrorCause(StackGresPoolingConfigPgBouncerPgbouncerIni.class, "spec.pgBouncer.pgbouncerIni.parameters", review);
}
Also used : PoolingReview(io.stackgres.operator.common.PoolingReview) Test(org.junit.jupiter.api.Test) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest)

Example 4 with PoolingReview

use of io.stackgres.operator.common.PoolingReview in project stackgres by ongres.

the class PoolingValidationPipelineTest method getConstraintViolatingReview.

@Override
public PoolingReview getConstraintViolatingReview() {
    PoolingReview review = getValidReview();
    review.getRequest().getObject().getSpec().getPgBouncer().getPgbouncerIni().setParameters(Map.of());
    return review;
}
Also used : PoolingReview(io.stackgres.operator.common.PoolingReview)

Example 5 with PoolingReview

use of io.stackgres.operator.common.PoolingReview in project stackgres by ongres.

the class PoolingBlocklistValidatorTest method givenValidConfigurationWithDatabases_shouldNotFail.

@Test
void givenValidConfigurationWithDatabases_shouldNotFail() {
    PoolingReview review = getCreatePoolingReview();
    var pgBouncer = review.getRequest().getObject().getSpec().getPgBouncer();
    pgBouncer.getPgbouncerIni().setDatabases(new HashMap<>());
    pgBouncer.getPgbouncerIni().getDatabases().put("foodb", Map.of("dbname", "bardb"));
    assertDoesNotThrow(() -> validator.validate(review));
}
Also used : PoolingReview(io.stackgres.operator.common.PoolingReview) Test(org.junit.jupiter.api.Test)

Aggregations

PoolingReview (io.stackgres.operator.common.PoolingReview)10 Test (org.junit.jupiter.api.Test)6 ConstraintValidationTest (io.stackgres.operator.validation.ConstraintValidationTest)3 ValidationFailed (io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed)1