mirror of
https://github.com/floci-io/floci.git
synced 2026-11-28 16:11:48 -05:00
feat(redshift-serverless): add snapshot copy configuration actions (#5798)
* feat(redshift-serverless): add snapshot copy configuration actions Add CreateSnapshotCopyConfiguration, ListSnapshotCopyConfigurations, UpdateSnapshotCopyConfiguration and DeleteSnapshotCopyConfiguration. A configuration is recorded and echoed; Floci copies no snapshot. A namespace has one configuration at a time and the destination Region must differ from its own. The configuration is tied to the namespace by the namespace's generated id, so a namespace recreated under the same name does not inherit it. Required members come from the AWS model through RedshiftServerlessRequestShapes. The destination Region name and the retention range are checked by hand because the model leaves them unconstrained. * fix(redshift-serverless): validate boundary inputs and scope snapshot copy pagination tokens * refactor(redshift-serverless): share maxResults range check and invalidPagination helper
This commit is contained in:
1 parent
d4158b954b
commit
2a012cf9a4
13 files changed
+476
-18
No files matched your search
+34
@@ -11,6 +11,7 @@ import software.amazon.awssdk.services.redshiftserverless.RedshiftServerlessClie
|
||||
import software.amazon.awssdk.services.redshiftserverless.model.ConflictException;
|
||||
import software.amazon.awssdk.services.redshiftserverless.model.EndpointAccess;
|
||||
import software.amazon.awssdk.services.redshiftserverless.model.GetCredentialsResponse;
|
||||
import software.amazon.awssdk.services.redshiftserverless.model.InvalidPaginationException;
|
||||
import software.amazon.awssdk.services.redshiftserverless.model.Namespace;
|
||||
import software.amazon.awssdk.services.redshiftserverless.model.NamespaceStatus;
|
||||
import software.amazon.awssdk.services.redshiftserverless.model.ResourceNotFoundException;
|
||||
@@ -373,6 +374,39 @@ class RedshiftServerlessTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void snapshotCopyDestinationCanChangeOnlyAfterDeletion() {
|
||||
assumeFalse(TestFixtures.isRealAws(), "Asserts metadata-only snapshot copying");
|
||||
try (RedshiftServerlessClient client = TestFixtures.redshiftServerlessClient()) {
|
||||
String namespaceName = "floci-compat-copy-ns";
|
||||
try {
|
||||
client.createNamespace(request -> request.namespaceName(namespaceName).adminUsername("admin"));
|
||||
String copyId = client.createSnapshotCopyConfiguration(request -> request
|
||||
.namespaceName(namespaceName).destinationRegion("us-west-2"))
|
||||
.snapshotCopyConfiguration().snapshotCopyConfigurationId();
|
||||
assertThatThrownBy(() -> client.createSnapshotCopyConfiguration(request -> request
|
||||
.namespaceName(namespaceName).destinationRegion("eu-west-1")))
|
||||
.isInstanceOf(ConflictException.class);
|
||||
client.deleteSnapshotCopyConfiguration(request -> request.snapshotCopyConfigurationId(copyId));
|
||||
String replacementId = client.createSnapshotCopyConfiguration(request -> request
|
||||
.namespaceName(namespaceName).destinationRegion("eu-west-1"))
|
||||
.snapshotCopyConfiguration().snapshotCopyConfigurationId();
|
||||
assertThat(client.listSnapshotCopyConfigurations(request -> request.namespaceName(namespaceName))
|
||||
.snapshotCopyConfigurations()).extracting(configuration -> configuration.destinationRegion())
|
||||
.containsExactly("eu-west-1");
|
||||
assertThatThrownBy(() -> client.listSnapshotCopyConfigurations(request -> request
|
||||
.namespaceName(namespaceName).maxResults(0)))
|
||||
.isInstanceOf(ValidationException.class);
|
||||
assertThatThrownBy(() -> client.listSnapshotCopyConfigurations(request -> request
|
||||
.namespaceName(namespaceName).nextToken("bad-token")))
|
||||
.isInstanceOf(InvalidPaginationException.class);
|
||||
client.deleteSnapshotCopyConfiguration(request -> request.snapshotCopyConfigurationId(replacementId));
|
||||
} finally {
|
||||
deleteBestEffort(client, namespaceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteSnapshotBestEffort(RedshiftServerlessClient client, String snapshotName) {
|
||||
try {
|
||||
client.deleteSnapshot(request -> request.snapshotName(snapshotName));
|
||||
|
||||
Reference in new issue
Block a user