use of io.stackgres.operator.common.BackupConfigReview in project stackgres by ongres.
the class StorageValidatorTest method givenCreationWithGcsAndS3Properties_shouldFail.
@Test
void givenCreationWithGcsAndS3Properties_shouldFail() {
BackupConfigReview review = JsonUtil.readFromJson("backupconfig_allow_request/invalid_creation_gcs_and_s3.json", BackupConfigReview.class);
ValidationFailed ex = assertThrows(ValidationFailed.class, () -> {
validator.validate(review);
});
String errorMessage = ex.getResult().getMessage();
assertEquals("Invalid backup configuration," + " source gcs must not be set when source type is s3", errorMessage);
}
use of io.stackgres.operator.common.BackupConfigReview in project stackgres by ongres.
the class BackupConfigConstraintValidationTest method nullStorage_shouldFail.
@Test
void nullStorage_shouldFail() {
BackupConfigReview review = getValidReview();
review.getRequest().getObject().getSpec().setStorage(null);
checkNotNullErrorCause(StackGresBackupConfigSpec.class, "spec.storage", review);
}
use of io.stackgres.operator.common.BackupConfigReview in project stackgres by ongres.
the class BackupConfigConstraintValidationTest method zeroOrNegativeRetention_shouldFail.
@Test
void zeroOrNegativeRetention_shouldFail() {
int negativeRetention = new Random().nextInt(10) * -1;
BackupConfigReview review = getValidReview();
review.getRequest().getObject().getSpec().getBaseBackups().setRetention(negativeRetention);
checkErrorCause(StackGresBaseBackupConfig.class, "spec.baseBackups.retention", review, Positive.class);
}
use of io.stackgres.operator.common.BackupConfigReview in project stackgres by ongres.
the class BackupConfigConstraintValidationTest method givenStorageClass_shouldPass.
@ParameterizedTest
@EnumSource(value = StorageClassS3.class)
void givenStorageClass_shouldPass(StorageClassS3 storageClass) {
BackupConfigReview review = JsonUtil.readFromJson("backupconfig_allow_request/update.json", BackupConfigReview.class);
review.getRequest().getObject().getSpec().getStorage().getS3Compatible().setStorageClass(storageClass.toString());
assertDoesNotThrow(() -> validator.validate(review));
}
use of io.stackgres.operator.common.BackupConfigReview in project stackgres by ongres.
the class BackupConfigConstraintValidationTest method getInvalidReview.
@Override
protected BackupConfigReview getInvalidReview() {
final BackupConfigReview backupConfigReview = JsonUtil.readFromJson("backupconfig_allow_request/create.json", BackupConfigReview.class);
backupConfigReview.getRequest().getObject().setSpec(null);
return backupConfigReview;
}
Aggregations