mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
test(rds): cover the snapshot lifecycle end to end (#4096)
* test(rds): cover the snapshot lifecycle end to end Add a Docker-backed integration test for the snapshot lifecycle of #4066: a row written before the snapshot comes back from an instance restored from a copy of it, deleting the source leaves the copy and its data, and each refusal carries the AWS error; and an AWS SDK for Java v2 compat case for copy, modify and delete through the SDK's typed exceptions. Refs #4083 * test(rds): stop asserting SourceDBSnapshotIdentifier on a same-region copy The DBSnapshot reference says the field only has a value for a cross-account or cross-Region copy; both tests copy within one account and region, so asserting it would pin a difference from AWS.
This commit is contained in:
1 parent
b4f4b386da
commit
98ffdc2af4
2 files changed
+277
No files matched your search
+54
@@ -16,6 +16,9 @@ import software.amazon.awssdk.services.rds.model.CreateDbSubnetGroupResponse;
|
||||
import software.amazon.awssdk.services.rds.model.CreateOptionGroupResponse;
|
||||
import software.amazon.awssdk.services.rds.model.DBInstance;
|
||||
import software.amazon.awssdk.services.rds.model.DBProxyTarget;
|
||||
import software.amazon.awssdk.services.rds.model.DBSnapshot;
|
||||
import software.amazon.awssdk.services.rds.model.DbSnapshotAlreadyExistsException;
|
||||
import software.amazon.awssdk.services.rds.model.DbSnapshotNotFoundException;
|
||||
import software.amazon.awssdk.services.rds.model.InvalidDbInstanceStateException;
|
||||
import software.amazon.awssdk.services.rds.model.DescribeDbSubnetGroupsResponse;
|
||||
import software.amazon.awssdk.services.rds.model.DescribeOptionGroupsResponse;
|
||||
@@ -25,6 +28,7 @@ import software.amazon.awssdk.services.rds.model.ModifyOptionGroupResponse;
|
||||
import software.amazon.awssdk.services.rds.model.OptionConfiguration;
|
||||
import software.amazon.awssdk.services.rds.model.OptionGroupNotFoundException;
|
||||
import software.amazon.awssdk.services.rds.model.OptionSetting;
|
||||
import software.amazon.awssdk.services.rds.model.Tag;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@@ -426,6 +430,56 @@ class RdsControlPlaneTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void sdkCopiesModifiesAndDeletesManualSnapshots() {
|
||||
String instanceName = TestFixtures.uniqueName("rds-snap-db");
|
||||
String snapshotName = TestFixtures.uniqueName("rds-snap");
|
||||
String copyName = snapshotName + "-copy";
|
||||
try {
|
||||
createDbInstance(rds, instanceName, "snap-secret");
|
||||
String sourceArn = rds.createDBSnapshot(b -> b
|
||||
.dbInstanceIdentifier(instanceName)
|
||||
.dbSnapshotIdentifier(snapshotName)
|
||||
.tags(Tag.builder().key("owner").value("platform").build()))
|
||||
.dbSnapshot().dbSnapshotArn();
|
||||
|
||||
DBSnapshot copy = rds.copyDBSnapshot(b -> b
|
||||
.sourceDBSnapshotIdentifier(sourceArn)
|
||||
.targetDBSnapshotIdentifier(copyName)
|
||||
.copyTags(true)
|
||||
.tags(Tag.builder().key("stage").value("test").build()))
|
||||
.dbSnapshot();
|
||||
assertThat(copy.dbSnapshotIdentifier()).isEqualTo(copyName);
|
||||
assertThat(copy.status()).isEqualTo("available");
|
||||
assertThat(copy.snapshotType()).isEqualTo("manual");
|
||||
assertThat(copy.tagList()).extracting(Tag::key).containsExactlyInAnyOrder("owner", "stage");
|
||||
|
||||
assertThatThrownBy(() -> rds.copyDBSnapshot(b -> b
|
||||
.sourceDBSnapshotIdentifier(snapshotName)
|
||||
.targetDBSnapshotIdentifier(copyName)))
|
||||
.isInstanceOf(DbSnapshotAlreadyExistsException.class);
|
||||
|
||||
DBSnapshot modified = rds.modifyDBSnapshot(b -> b
|
||||
.dbSnapshotIdentifier(snapshotName)
|
||||
.engineVersion("16.4"))
|
||||
.dbSnapshot();
|
||||
assertThat(modified.engineVersion()).isEqualTo("16.4");
|
||||
|
||||
DBSnapshot deleted = rds.deleteDBSnapshot(b -> b.dbSnapshotIdentifier(snapshotName)).dbSnapshot();
|
||||
assertThat(deleted.status()).isEqualTo("deleted");
|
||||
assertThatThrownBy(() -> rds.describeDBSnapshots(b -> b.dbSnapshotIdentifier(snapshotName)))
|
||||
.isInstanceOf(DbSnapshotNotFoundException.class);
|
||||
assertThat(rds.describeDBSnapshots(b -> b.dbInstanceIdentifier(instanceName)).dbSnapshots())
|
||||
.extracting(DBSnapshot::dbSnapshotIdentifier)
|
||||
.containsExactly(copyName);
|
||||
} finally {
|
||||
try {
|
||||
rds.deleteDBSnapshot(b -> b.dbSnapshotIdentifier(copyName));
|
||||
} catch (Exception ignored) {}
|
||||
deleteDbInstance(rds, instanceName);
|
||||
}
|
||||
}
|
||||
|
||||
private static CreateDbProxyResponse createIamProxy(RdsClient client, String name, List<String> vpcSubnetIds) {
|
||||
return client.createDBProxy(b -> b
|
||||
.dbProxyName(name)
|
||||
|
||||
Reference in new issue
Block a user