mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat: add RDS cluster parameter group actions (#838)
Implement the missing Aurora cluster parameter group APIs that the Pulumi/Terraform AWS provider invokes via aws.rds.ClusterParameterGroup: - CreateDBClusterParameterGroup - DescribeDBClusterParameterGroups - DeleteDBClusterParameterGroup - ModifyDBClusterParameterGroup - DescribeDBClusterParameters Storage and handler logic mirrors the existing instance-level parameter group implementation. Without these actions, any IaC stack that defines an Aurora ClusterParameterGroup fails with UnsupportedOperation and never reaches Aurora cluster creation. Tests cover the new XML envelope shape, required-field validation, service round-trip, duplicate rejection, and parameter modification.
This commit is contained in:
1 parent
b63329f53e
commit
5cae86fc4d
5 files changed
+320
No files matched your search
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.rds;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbCluster;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbClusterParameterGroup;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstance;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstanceStatus;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbParameterGroup;
|
||||
@@ -215,6 +216,77 @@ class RdsQueryHandlerTest {
|
||||
assertTrue(((String) response.getEntity()).contains("UnsupportedOperation"));
|
||||
}
|
||||
|
||||
// ──────────────────────────── DBClusterParameterGroups ──────────────────────
|
||||
|
||||
@Test
|
||||
void describeDbClusterParameterGroups_usesDBClusterParameterGroupTag() {
|
||||
DbClusterParameterGroup group = new DbClusterParameterGroup("cpg1", "aurora-postgresql16", "test cluster group");
|
||||
when(service.listDbClusterParameterGroups(null)).thenReturn(List.of(group));
|
||||
|
||||
Response response = handler.handle("DescribeDBClusterParameterGroups", params());
|
||||
|
||||
String body = (String) response.getEntity();
|
||||
assertTrue(body.contains("<DBClusterParameterGroup>"), "Expected <DBClusterParameterGroup> element in response");
|
||||
assertFalse(body.contains("<member><DBClusterParameterGroupName>"), "Did not expect <member> wrapping DBClusterParameterGroup");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDbClusterParameterGroup_requiresName() {
|
||||
Response response = handler.handle("CreateDBClusterParameterGroup", params());
|
||||
|
||||
assertEquals(400, response.getStatus());
|
||||
assertTrue(((String) response.getEntity()).contains("DBClusterParameterGroupName is required."));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDbClusterParameterGroup_passesArgumentsToService() {
|
||||
DbClusterParameterGroup group = new DbClusterParameterGroup("cpg1", "aurora-postgresql16", "desc");
|
||||
when(service.createDbClusterParameterGroup("cpg1", "aurora-postgresql16", "desc")).thenReturn(group);
|
||||
|
||||
MultivaluedMap<String, String> p = params();
|
||||
p.add("DBClusterParameterGroupName", "cpg1");
|
||||
p.add("DBParameterGroupFamily", "aurora-postgresql16");
|
||||
p.add("Description", "desc");
|
||||
Response response = handler.handle("CreateDBClusterParameterGroup", p);
|
||||
|
||||
verify(service).createDbClusterParameterGroup("cpg1", "aurora-postgresql16", "desc");
|
||||
String body = (String) response.getEntity();
|
||||
assertTrue(body.contains("<DBClusterParameterGroupName>cpg1</DBClusterParameterGroupName>"));
|
||||
assertTrue(body.contains("<DBParameterGroupFamily>aurora-postgresql16</DBParameterGroupFamily>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbClusterParameterGroup_ignoresParametersWithoutValue() {
|
||||
DbClusterParameterGroup group = new DbClusterParameterGroup("cpg1", "aurora-postgresql16", "test group");
|
||||
when(service.modifyDbClusterParameterGroup(eq("cpg1"), eq(java.util.Map.of("log_statement", "all"))))
|
||||
.thenReturn(group);
|
||||
|
||||
MultivaluedMap<String, String> p = params();
|
||||
p.add("DBClusterParameterGroupName", "cpg1");
|
||||
p.add("Parameters.member.1.ParameterName", "log_statement");
|
||||
p.add("Parameters.member.1.ParameterValue", "all");
|
||||
p.add("Parameters.member.2.ParameterName", "ignored_without_value");
|
||||
handler.handle("ModifyDBClusterParameterGroup", p);
|
||||
|
||||
verify(service).modifyDbClusterParameterGroup("cpg1", java.util.Map.of("log_statement", "all"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeDbClusterParameters_requiresParameterGroupName() {
|
||||
Response response = handler.handle("DescribeDBClusterParameters", params());
|
||||
|
||||
assertEquals(400, response.getStatus());
|
||||
assertTrue(((String) response.getEntity()).contains("DBClusterParameterGroupName is required."));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteDbClusterParameterGroup_requiresName() {
|
||||
Response response = handler.handle("DeleteDBClusterParameterGroup", params());
|
||||
|
||||
assertEquals(400, response.getStatus());
|
||||
assertTrue(((String) response.getEntity()).contains("DBClusterParameterGroupName is required."));
|
||||
}
|
||||
|
||||
// ──────────────────────────── DBSubnetGroup shape ───────────────────────────
|
||||
|
||||
@Test
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.rds.model.DatabaseEngine;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbCluster;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbClusterParameterGroup;
|
||||
import io.github.hectorvent.floci.services.rds.container.RdsContainerHandle;
|
||||
import io.github.hectorvent.floci.services.rds.container.RdsContainerManager;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstance;
|
||||
@@ -116,4 +117,56 @@ class RdsServiceTest {
|
||||
assertEquals("InvalidDBClusterStateFault", exception.getErrorCode());
|
||||
assertTrue(exception.getMessage().contains("still has DB instances"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDbClusterParameterGroupRoundTrip() {
|
||||
DbClusterParameterGroup created = rdsService.createDbClusterParameterGroup(
|
||||
"cpg1", "aurora-postgresql16", "test cluster group");
|
||||
|
||||
assertEquals("cpg1", created.getDbClusterParameterGroupName());
|
||||
assertEquals("aurora-postgresql16", created.getDbParameterGroupFamily());
|
||||
|
||||
DbClusterParameterGroup fetched = rdsService.getDbClusterParameterGroup("cpg1");
|
||||
assertEquals("cpg1", fetched.getDbClusterParameterGroupName());
|
||||
|
||||
Collection<DbClusterParameterGroup> listed = rdsService.listDbClusterParameterGroups(null);
|
||||
assertEquals(1, listed.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDbClusterParameterGroupRejectsDuplicate() {
|
||||
rdsService.createDbClusterParameterGroup("cpg1", "aurora-postgresql16", "desc");
|
||||
|
||||
AwsException exception = assertThrows(AwsException.class, () ->
|
||||
rdsService.createDbClusterParameterGroup("cpg1", "aurora-postgresql16", "desc"));
|
||||
|
||||
assertEquals("DBParameterGroupAlreadyExists", exception.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbClusterParameterGroupAppliesParameters() {
|
||||
rdsService.createDbClusterParameterGroup("cpg1", "aurora-postgresql16", "desc");
|
||||
|
||||
DbClusterParameterGroup modified = rdsService.modifyDbClusterParameterGroup(
|
||||
"cpg1", java.util.Map.of("log_statement", "all", "shared_preload_libraries", "pg_stat_statements"));
|
||||
|
||||
assertEquals("all", modified.getParameters().get("log_statement"));
|
||||
assertEquals("pg_stat_statements", modified.getParameters().get("shared_preload_libraries"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteDbClusterParameterGroupMissingThrows() {
|
||||
AwsException exception = assertThrows(AwsException.class, () ->
|
||||
rdsService.deleteDbClusterParameterGroup("nonexistent"));
|
||||
|
||||
assertEquals("DBParameterGroupNotFound", exception.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDbClusterParameterGroupMissingThrows() {
|
||||
AwsException exception = assertThrows(AwsException.class, () ->
|
||||
rdsService.getDbClusterParameterGroup("nonexistent"));
|
||||
|
||||
assertEquals("DBParameterGroupNotFound", exception.getErrorCode());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user