Search in sources :

Example 1 with StackGresClusterPodScheduling

use of io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling in project stackgres by ongres.

the class ClusterConstraintValidatorTest method validToleration_shouldPass.

@Test
void validToleration_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("test");
    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 2 with StackGresClusterPodScheduling

use of io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling 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 3 with StackGresClusterPodScheduling

use of io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling 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 4 with StackGresClusterPodScheduling

use of io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling in project stackgres by ongres.

the class ClusterConstraintValidatorTest method givenTolerationsSetAndEffectNoExecute_shouldPass.

@Test
void givenTolerationsSetAndEffectNoExecute_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("test");
    review.getRequest().getObject().getSpec().getPod().getScheduling().getTolerations().get(0).setTolerationSeconds(100L);
    review.getRequest().getObject().getSpec().getPod().getScheduling().getTolerations().get(0).setEffect("NoExecute");
    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 5 with StackGresClusterPodScheduling

use of io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling in project stackgres by ongres.

the class ClusterConstraintValidatorTest method givenTolerationsSetAndEffectOtherThanNoExecute_shouldFail.

@Test
void givenTolerationsSetAndEffectOtherThanNoExecute_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).setTolerationSeconds(100L);
    review.getRequest().getObject().getSpec().getPod().getScheduling().getTolerations().get(0).setEffect(new Random().nextBoolean() ? "NoSchedule" : "PreferNoSchedule");
    checkErrorCause(Toleration.class, "spec.pod.scheduling.tolerations[0].effect", "isEffectNoExecuteIfTolerationIsSet", review, AssertTrue.class);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) StackGresClusterPodScheduling(io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling) Random(java.util.Random) Toleration(io.stackgres.common.crd.Toleration) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

StackGresClusterPodScheduling (io.stackgres.common.crd.sgcluster.StackGresClusterPodScheduling)15 StackGresClusterReview (io.stackgres.operator.common.StackGresClusterReview)9 ConstraintValidationTest (io.stackgres.operator.validation.ConstraintValidationTest)9 Test (org.junit.jupiter.api.Test)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 Toleration (io.stackgres.common.crd.Toleration)7 StackGresClusterPod (io.stackgres.common.crd.sgcluster.StackGresClusterPod)3 StackGresClusterSpec (io.stackgres.common.crd.sgcluster.StackGresClusterSpec)3 StackGresClusterSpecMetadata (io.stackgres.common.crd.sgcluster.StackGresClusterSpecMetadata)3 ClusterPodScheduling (io.stackgres.apiweb.dto.cluster.ClusterPodScheduling)2 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)2 StackGresClusterInitData (io.stackgres.common.crd.sgcluster.StackGresClusterInitData)2 StackGresClusterNonProduction (io.stackgres.common.crd.sgcluster.StackGresClusterNonProduction)2 StackGresClusterScriptEntry (io.stackgres.common.crd.sgcluster.StackGresClusterScriptEntry)2 StackGresClusterSpecLabels (io.stackgres.common.crd.sgcluster.StackGresClusterSpecLabels)2 StackGresPodPersistentVolume (io.stackgres.common.crd.sgcluster.StackGresPodPersistentVolume)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 AffinityBuilder (io.fabric8.kubernetes.api.model.AffinityBuilder)1 Container (io.fabric8.kubernetes.api.model.Container)1 LabelSelectorBuilder (io.fabric8.kubernetes.api.model.LabelSelectorBuilder)1