use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class BackupConfigValidatorTest method giveAnAttemptToUpdateToAnKnownBackup_shouldNotFail.
@Test
void giveAnAttemptToUpdateToAnKnownBackup_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/backup_config_update.json", StackGresClusterReview.class);
String backupConfig = review.getRequest().getObject().getSpec().getConfiguration().getBackupConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(configFinder.findByNameAndNamespace(backupConfig, namespace)).thenReturn(Optional.of(this.backupConfig));
validator.validate(review);
verify(configFinder).findByNameAndNamespace(eq(backupConfig), eq(namespace));
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class BackupConfigValidatorTest method giveAnAttemptToDelete_shouldNotFail.
@Test
void giveAnAttemptToDelete_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/backup_config_update.json", StackGresClusterReview.class);
review.getRequest().setOperation(Operation.DELETE);
String backupConfig = review.getRequest().getObject().getSpec().getConfiguration().getBackupConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
validator.validate(review);
verify(configFinder, never()).findByNameAndNamespace(eq(backupConfig), eq(namespace));
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class BackupConfigValidatorTest method givenValidStackGresBackupOnCreation_shouldNotFail.
@Test
void givenValidStackGresBackupOnCreation_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/valid_creation.json", StackGresClusterReview.class);
String backupConfig = review.getRequest().getObject().getSpec().getConfiguration().getBackupConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(configFinder.findByNameAndNamespace(backupConfig, namespace)).thenReturn(Optional.of(this.backupConfig));
validator.validate(review);
verify(configFinder).findByNameAndNamespace(eq(backupConfig), eq(namespace));
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class BackupSourceValidatorTest method givenValidStackGresBackupOnCreation_shouldNotFail.
@Test
void givenValidStackGresBackupOnCreation_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/valid_creation.json", StackGresClusterReview.class);
String backupConfig = review.getRequest().getObject().getSpec().getConfiguration().getBackupConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(configFinder.findByNameAndNamespace(backupConfig, namespace)).thenReturn(Optional.of(this.backupConfig));
validator.validate(review);
verify(configFinder).findByNameAndNamespace(eq(backupConfig), eq(namespace));
}
use of io.stackgres.operator.common.StackGresClusterReview 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);
}
Aggregations