Search in sources :

Example 36 with StackGresClusterReview

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

the class ClusterConstraintValidatorTest method invalidTolerationOperator_shouldFail.

@Test
void invalidTolerationOperator_shouldFail() {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().getPod().setScheduling(new StackGresClusterPodScheduling());
    review.getRequest().getObject().getSpec().getPod().getScheduling().setTolerations(new ArrayList<>());
    review.getRequest().getObject().getSpec().getPod().getScheduling().getTolerations().add(new Toleration());
    review.getRequest().getObject().getSpec().getPod().getScheduling().getTolerations().get(0).setKey("test");
    review.getRequest().getObject().getSpec().getPod().getScheduling().getTolerations().get(0).setOperator("NotExists");
    checkErrorCause(Toleration.class, "spec.pod.scheduling.tolerations[0].operator", "isOperatorValid", review, AssertTrue.class);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) StackGresClusterPodScheduling(io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling) Toleration(io.stackgres.common.crd.Toleration) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 37 with StackGresClusterReview

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

the class ClusterConstraintValidatorTest method validTolerationKeyEmpty_shouldPass.

@Test
void validTolerationKeyEmpty_shouldPass() throws ValidationFailed {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().getPod().setScheduling(new StackGresClusterPodScheduling());
    review.getRequest().getObject().getSpec().getPod().getScheduling().setTolerations(new ArrayList<>());
    review.getRequest().getObject().getSpec().getPod().getScheduling().getTolerations().add(new Toleration());
    review.getRequest().getObject().getSpec().getPod().getScheduling().getTolerations().get(0).setKey("");
    review.getRequest().getObject().getSpec().getPod().getScheduling().getTolerations().get(0).setOperator("Exists");
    validator.validate(review);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) StackGresClusterPodScheduling(io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling) Toleration(io.stackgres.common.crd.Toleration) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 38 with StackGresClusterReview

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

the class ClusterConstraintValidatorTest method nullVolumeSize_shouldFail.

@Test
void nullVolumeSize_shouldFail() {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().getPod().getPersistentVolume().setSize(null);
    checkNotNullErrorCause(StackGresPodPersistentVolume.class, "spec.pod.persistentVolume.size", review);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 39 with StackGresClusterReview

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

the class ClusterConstraintValidatorTest method invalidVolumeSize_shouldFail.

@Test
void invalidVolumeSize_shouldFail() {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().getPod().getPersistentVolume().setSize("512");
    checkErrorCause(StackGresPodPersistentVolume.class, "spec.pod.persistentVolume.size", review, Pattern.class);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 40 with StackGresClusterReview

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

the class ClusterConstraintValidatorTest method missingScriptFrom_shouldFail.

@Test
void missingScriptFrom_shouldFail() {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().setInitData(new StackGresClusterInitData());
    review.getRequest().getObject().getSpec().getInitData().setScripts(new ArrayList<>());
    review.getRequest().getObject().getSpec().getInitData().getScripts().add(new StackGresClusterScriptEntry());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).setScriptFrom(new StackGresClusterScriptFrom());
    checkErrorCause(StackGresClusterScriptFrom.class, new String[] { "spec.initData.scripts[0].scriptFrom.secretKeyRef", "spec.initData.scripts[0].scriptFrom.configMapKeyRef" }, "isSecretKeySelectorAndConfigMapKeySelectorMutuallyExclusiveAndRequired", review, AssertTrue.class);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) StackGresClusterScriptEntry(io.stackgres.common.crd.sgcluster.StackGresClusterScriptEntry) StackGresClusterInitData(io.stackgres.common.crd.sgcluster.StackGresClusterInitData) StackGresClusterScriptFrom(io.stackgres.common.crd.sgcluster.StackGresClusterScriptFrom) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

StackGresClusterReview (io.stackgres.operator.common.StackGresClusterReview)109 Test (org.junit.jupiter.api.Test)103 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)31 ConstraintValidationTest (io.stackgres.operator.validation.ConstraintValidationTest)29 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)26 ValidationFailed (io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed)24 StackGresClusterScriptEntry (io.stackgres.common.crd.sgcluster.StackGresClusterScriptEntry)15 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)13 StackGresClusterInitData (io.stackgres.common.crd.sgcluster.StackGresClusterInitData)12 StackGresClusterPodScheduling (io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling)9 StackGresClusterScriptFrom (io.stackgres.common.crd.sgcluster.StackGresClusterScriptFrom)9 StackGresClusterSpec (io.stackgres.common.crd.sgcluster.StackGresClusterSpec)9 SecretKeySelector (io.stackgres.common.crd.SecretKeySelector)8 Toleration (io.stackgres.common.crd.Toleration)7 QuarkusTest (io.quarkus.test.junit.QuarkusTest)5 ConfigMapKeySelector (io.stackgres.common.crd.ConfigMapKeySelector)5 StackGresClusterSsl (io.stackgres.common.crd.sgcluster.StackGresClusterSsl)4 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)3 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)2 List (java.util.List)2