use of io.stackgres.common.crd.Toleration 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);
}
use of io.stackgres.common.crd.Toleration 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);
}
use of io.stackgres.common.crd.Toleration 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);
}
use of io.stackgres.common.crd.Toleration 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);
}
use of io.stackgres.common.crd.Toleration 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);
}
Aggregations