Search in sources :

Example 26 with StackGresDbOpsReview

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

the class DbOpsSecurityUpgradeValidatorTest method givenInvalidStackGresVersionOnCreation_shouldFail.

@Test
void givenInvalidStackGresVersionOnCreation_shouldFail() {
    final StackGresDbOpsReview review = getCreationReview();
    String sgcluster = review.getRequest().getObject().getSpec().getSgCluster();
    String namespace = review.getRequest().getObject().getMetadata().getNamespace();
    cluster.getSpec().getPostgres().setVersion("11.11");
    when(clusterFinder.findByNameAndNamespace(sgcluster, namespace)).thenReturn(Optional.of(cluster));
    ValidationFailed ex = assertThrows(ValidationFailed.class, () -> {
        validator.validate(review);
    });
    String resultMessage = ex.getMessage();
    assertEquals("Major version upgrade must be performed on StackGresCluster before performing" + " the upgrade since Postgres version 11.11 will not be" + " supported after the upgrade is completed", resultMessage);
}
Also used : StackGresDbOpsReview(io.stackgres.operator.common.StackGresDbOpsReview) ValidationFailed(io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed) Test(org.junit.jupiter.api.Test)

Example 27 with StackGresDbOpsReview

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

the class DbOpsVacuumConstraintValidatorTest method nullVacuum_shouldPass.

@Test
void nullVacuum_shouldPass() throws ValidationFailed {
    StackGresDbOpsReview review = getValidReview();
    review.getRequest().getObject().getSpec().setBenchmark(null);
    validator.validate(review);
}
Also used : StackGresDbOpsReview(io.stackgres.operator.common.StackGresDbOpsReview) Test(org.junit.jupiter.api.Test) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest)

Example 28 with StackGresDbOpsReview

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

the class DbOpsVacuumConstraintValidatorTest method getInvalidReview.

@Override
protected StackGresDbOpsReview getInvalidReview() {
    final StackGresDbOpsReview review = JsonUtil.readFromJson("dbops_allow_requests/valid_vacuum_creation.json", StackGresDbOpsReview.class);
    review.getRequest().getObject().setSpec(null);
    return review;
}
Also used : StackGresDbOpsReview(io.stackgres.operator.common.StackGresDbOpsReview)

Aggregations

StackGresDbOpsReview (io.stackgres.operator.common.StackGresDbOpsReview)28 Test (org.junit.jupiter.api.Test)24 ConstraintValidationTest (io.stackgres.operator.validation.ConstraintValidationTest)22 ValidationFailed (io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed)2