mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 08:31:53 -05:00
test: isolate DMS compatibility subnet fixtures (#9717)
Reuse the shared default VPC subnets instead of borrowing peer-owned subnets. Track successful pagination group creations within cleanup scope so partial setup is cleaned up. Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
1 parent
f46e75ee73
commit
093955f9f2
1 file changed
+10
-27
@@ -11,7 +11,6 @@ import software.amazon.awssdk.services.ec2.model.Subnet;
|
||||
import software.amazon.awssdk.services.sts.StsClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -81,18 +80,16 @@ class DmsTest {
|
||||
void describeReplicationSubnetGroupsPagesByMarker() {
|
||||
List<String> subnetIds = twoSubnetsInOneVpcAcrossZones().stream().map(Subnet::subnetId).toList();
|
||||
List<String> created = new ArrayList<>();
|
||||
for (int i = 0; i < 25; i++) {
|
||||
created.add(PAGED_GROUP_PREFIX + String.format("%02d", i));
|
||||
}
|
||||
|
||||
try (DatabaseMigrationClient dms = TestFixtures.databaseMigrationClient()) {
|
||||
for (String identifier : created) {
|
||||
dms.createReplicationSubnetGroup(request -> request
|
||||
.replicationSubnetGroupIdentifier(identifier)
|
||||
.replicationSubnetGroupDescription("sdk pagination suite")
|
||||
.subnetIds(subnetIds));
|
||||
}
|
||||
try {
|
||||
for (int i = 0; i < 25; i++) {
|
||||
String identifier = PAGED_GROUP_PREFIX + String.format("%02d", i);
|
||||
dms.createReplicationSubnetGroup(request -> request
|
||||
.replicationSubnetGroupIdentifier(identifier)
|
||||
.replicationSubnetGroupDescription("sdk pagination suite")
|
||||
.subnetIds(subnetIds));
|
||||
created.add(identifier);
|
||||
}
|
||||
List<String> walked = new ArrayList<>();
|
||||
String marker = null;
|
||||
int pages = 0;
|
||||
@@ -175,24 +172,10 @@ class DmsTest {
|
||||
.collect(Collectors.toMap(Tag::key, Tag::value));
|
||||
}
|
||||
|
||||
/**
|
||||
* DMS requires the group's subnets to share a VPC and to cover at least two Availability
|
||||
* Zones, so pick a VPC that satisfies both rather than the first two subnets returned.
|
||||
*/
|
||||
private static List<Subnet> twoSubnetsInOneVpcAcrossZones() {
|
||||
List<String> subnetIds = TestFixtures.defaultVpcSubnets();
|
||||
try (Ec2Client ec2 = TestFixtures.ec2Client()) {
|
||||
Map<String, Map<String, Subnet>> byVpcAndZone = new LinkedHashMap<>();
|
||||
for (Subnet subnet : ec2.describeSubnets().subnets()) {
|
||||
byVpcAndZone
|
||||
.computeIfAbsent(subnet.vpcId(), vpc -> new LinkedHashMap<>())
|
||||
.putIfAbsent(subnet.availabilityZone(), subnet);
|
||||
}
|
||||
return byVpcAndZone.values().stream()
|
||||
.filter(byZone -> byZone.size() >= 2)
|
||||
.map(byZone -> byZone.values().stream().limit(2).toList())
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalStateException(
|
||||
"no VPC has subnets in two Availability Zones"));
|
||||
return ec2.describeSubnets(request -> request.subnetIds(subnetIds)).subnets();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user