use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class PostgresVersionValidatorTest method givenValidMajorPostgresVersion_shouldNotFail.
@Test
void givenValidMajorPostgresVersion_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/valid_creation.json", StackGresClusterReview.class);
StackGresClusterSpec spec = review.getRequest().getObject().getSpec();
spec.getPostgres().setVersion(getMajorPostgresVersion(getRandomPostgresVersion()));
String postgresProfile = spec.getConfiguration().getPostgresConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(configFinder.findByNameAndNamespace(eq(postgresProfile), eq(namespace))).thenReturn(Optional.of(postgresConfig));
final String randomVersion = getRandomPostgresVersion();
spec.getPostgres().setVersion(randomVersion);
postgresConfig.getSpec().setPostgresVersion(getMajorPostgresVersion(randomVersion));
validator.validate(review);
verify(configFinder).findByNameAndNamespace(eq(postgresProfile), eq(namespace));
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class ProfileReferenceValidatorTest method giveAnAttemptToDelete_shouldNotFail.
@Test
void giveAnAttemptToDelete_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/profile_config_update.json", StackGresClusterReview.class);
review.getRequest().setOperation(Operation.DELETE);
validator.validate(review);
verify(profileFinder, never()).findByNameAndNamespace(anyString(), anyString());
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class ProfileReferenceValidatorTest method giveAnAttemptToUpdateToAnUnknownProfile_shouldFail.
@Test
void giveAnAttemptToUpdateToAnUnknownProfile_shouldFail() {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/profile_config_update.json", StackGresClusterReview.class);
String resourceProfile = review.getRequest().getObject().getSpec().getResourceProfile();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(profileFinder.findByNameAndNamespace(resourceProfile, namespace)).thenReturn(Optional.empty());
ValidationFailed ex = assertThrows(ValidationFailed.class, () -> {
validator.validate(review);
});
String resultMessage = ex.getMessage();
assertEquals("Cannot update to profile " + resourceProfile + " because it doesn't exists", resultMessage);
verify(profileFinder).findByNameAndNamespace(anyString(), anyString());
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class ProfileReferenceValidatorTest method givenValidStackGresReferenceOnCreation_shouldNotFail.
@Test
void givenValidStackGresReferenceOnCreation_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/valid_creation.json", StackGresClusterReview.class);
String resourceProfile = review.getRequest().getObject().getSpec().getResourceProfile();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(profileFinder.findByNameAndNamespace(resourceProfile, namespace)).thenReturn(Optional.of(profileSizeXs));
validator.validate(review);
verify(profileFinder).findByNameAndNamespace(eq(resourceProfile), eq(namespace));
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class RestoreConfigValidatorTest method givenACreationWithNoRestoreConfig_shouldDoNothing.
@Test
void givenACreationWithNoRestoreConfig_shouldDoNothing() throws ValidationFailed {
final StackGresClusterReview review = getCreationReview();
review.getRequest().getObject().getSpec().getInitData().setRestore(null);
validator.validate(review);
verify(scanner, never()).findResources(anyString());
}
Aggregations