use of io.stackgres.common.crd.sgcluster.StackGresClusterRestoreFromBackup in project stackgres by ongres.
the class ClusterRequiredResourcesGeneratorTest method givenAClusterInvalidRestoreData_getRequiredResourcesShouldNotScanForBackups.
@Test
void givenAClusterInvalidRestoreData_getRequiredResourcesShouldNotScanForBackups() {
cluster.getSpec().getInitData().getRestore().setFromBackup(new StackGresClusterRestoreFromBackup());
cluster.getSpec().getInitData().getRestore().getFromBackup().setUid(UUID.randomUUID().toString());
final ObjectMeta metadata = cluster.getMetadata();
final String clusterName = metadata.getName();
final String clusterNamespace = metadata.getNamespace();
final StackGresClusterSpec clusterSpec = cluster.getSpec();
final StackGresClusterConfiguration clusterConfiguration = clusterSpec.getConfiguration();
final String backupConfigName = clusterConfiguration.getBackupConfig();
mockBackupConfig(clusterNamespace, backupConfigName);
final String postgresConfigName = clusterConfiguration.getPostgresConfig();
mockPgConfig(clusterNamespace, postgresConfigName);
final String connectionPoolingConfig = clusterConfiguration.getConnectionPoolingConfig();
mockPoolingConfig(clusterNamespace, connectionPoolingConfig);
final String resourceProfile = clusterSpec.getResourceProfile();
when(profileConfigFinder.findByNameAndNamespace(resourceProfile, clusterNamespace)).thenReturn(Optional.of(instanceProfile));
when(backupScanner.getResources()).thenReturn(backups);
assertException("SGCluster " + clusterNamespace + "/" + clusterName + " have an invalid restore backup Uid");
verify(backupConfigFinder).findByNameAndNamespace(backupConfigName, clusterNamespace);
verify(postgresConfigFinder).findByNameAndNamespace(postgresConfigName, clusterNamespace);
verify(poolingConfigFinder).findByNameAndNamespace(connectionPoolingConfig, clusterNamespace);
verify(profileConfigFinder).findByNameAndNamespace(resourceProfile, clusterNamespace);
verify(backupScanner, atLeastOnce()).getResources();
}
use of io.stackgres.common.crd.sgcluster.StackGresClusterRestoreFromBackup in project stackgres by ongres.
the class ClusterTransformer method getResourceRestoreFromBackup.
private ClusterRestoreFromBackup getResourceRestoreFromBackup(StackGresClusterRestoreFromBackup source) {
if (source == null) {
return null;
}
ClusterRestoreFromBackup transformation = new ClusterRestoreFromBackup();
transformation.setUid(source.getUid());
transformation.setPointInTimeRecovery(getResourceRestorePitr(source.getPointInTimeRecovery()));
return transformation;
}
use of io.stackgres.common.crd.sgcluster.StackGresClusterRestoreFromBackup in project stackgres by ongres.
the class DefaultRestoreMutatorTest method clusteRestorerWithNoDownloadDiskConcurrency_shouldSetDefaultValue.
@Test
void clusteRestorerWithNoDownloadDiskConcurrency_shouldSetDefaultValue() throws JsonPatchException {
StackGresClusterRestore restore = new StackGresClusterRestore();
restore.setDownloadDiskConcurrency(null);
restore.setFromBackup(new StackGresClusterRestoreFromBackup());
restore.getFromBackup().setUid(UUID.randomUUID().toString());
review.getRequest().getObject().getSpec().getInitData().setRestore(restore);
List<JsonPatchOperation> operations = mutator.mutate(review);
JsonNode crJson = JSON_MAPPER.valueToTree(review.getRequest().getObject());
JsonPatch jp = new JsonPatch(operations);
JsonNode newConfig = jp.apply(crJson);
Integer defaultDownloadDisConcurrency = Integer.parseInt(defaultRestoreValues.getProperty("downloadDiskConcurrency"));
int actualDownloadDiskConcurrency = newConfig.get("spec").get("initialData").get("restore").get("downloadDiskConcurrency").asInt();
assertEquals(defaultDownloadDisConcurrency, actualDownloadDiskConcurrency);
}
use of io.stackgres.common.crd.sgcluster.StackGresClusterRestoreFromBackup in project stackgres by ongres.
the class ClusterTransformer method getCustomResourceRestoreFromBackup.
private StackGresClusterRestoreFromBackup getCustomResourceRestoreFromBackup(ClusterRestoreFromBackup source) {
if (source == null) {
return null;
}
StackGresClusterRestoreFromBackup transformation = new StackGresClusterRestoreFromBackup();
transformation.setUid(source.getUid());
transformation.setPointInTimeRecovery(getCustomResourceRestorePitr(source.getPointInTimeRecovery()));
return transformation;
}
Aggregations