fix(rds): return Source and ApplyMethod from DescribeDBParameters (#7018)

* fix(rds): return Source and ApplyMethod from DescribeDBParameters

DescribeDBParameters and DescribeDBClusterParameters now render Source=user
and the ApplyMethod sent on modify (default immediate). Apply methods are
stored per group, copied on copy, dropped on reset, and absent in older
persisted state.

* test(rds): cover apply-method copy, reset and reload for parameter groups

* test(rds): assert reset clears stored apply methods

* fix(rds): refuse ApplyMethod values outside immediate | pending-reboot

ModifyDBParameterGroup and ModifyDBClusterParameterGroup echoed back any
ApplyMethod string. The RDS model declares the ApplyMethod enum as
immediate | pending-reboot, so any other value (including a different
case) now fails with InvalidParameterValue (400) before the group is
touched. A missing ApplyMethod still defaults to immediate.

The value and apply-method loops shared everything but the member name,
so both now go through one parseParameterMember(params, member) helper.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-10-30 14:34:34 -04:00
1 parent 06d4fcfa57
commit 2463708199
8 files changed
+286 -27

No files matched your search

@@ -1556,9 +1556,9 @@ public class RdsQueryHandler {
if (name == null || name.isBlank()) {
return AwsQueryResponse.error("InvalidParameterValue", "DBParameterGroupName is required.", AwsNamespaces.RDS, 400);
}
Map<String, String> parameters = parseParameterOverrides(params);
Map<String, String> parameters = parseParameterMember(params, "ParameterValue");
try {
DbParameterGroup group = service.modifyDbParameterGroup(name, parameters, region);
DbParameterGroup group = service.modifyDbParameterGroup(name, parameters, parseApplyMethods(params), region);
String result = new XmlBuilder()
.elem("DBParameterGroupName", group.getDbParameterGroupName())
.build();
@@ -1569,26 +1569,43 @@ public class RdsQueryHandler {
}
/**
* Parses the {@code Parameters} list of a modify request. The RDS model declares the list
* ApplyMethod of each modified parameter; omitted means the provider default. The RDS model
* declares the {@code ApplyMethod} enum as {@code immediate | pending-reboot}, so anything else
* is refused before the group is touched.
*/
private static Map<String, String> parseApplyMethods(MultivaluedMap<String, String> params) {
Map<String, String> methods = parseParameterMember(params, "ApplyMethod");
for (Map.Entry<String, String> e : methods.entrySet()) {
if (!"immediate".equals(e.getValue()) && !"pending-reboot".equals(e.getValue())) {
throw new AwsException("InvalidParameterValue", "Invalid ApplyMethod '" + e.getValue()
+ "' for parameter " + e.getKey() + ". Valid values: immediate, pending-reboot.", 400);
}
}
return methods;
}
/**
* Parses {@code member} of each entry in the {@code Parameters} list of a modify request, keyed
* by name; entries without it are skipped. The RDS model declares the list
* with {@code locationName: Parameter}, so every SDK and the CLI send
* {@code Parameters.Parameter.N.*}; the {@code Parameters.member.N.*} form is the plain Query
* encoding older or hand-built callers use, and is accepted as well.
*/
private static Map<String, String> parseParameterOverrides(MultivaluedMap<String, String> params) {
Map<String, String> parameters = new LinkedHashMap<>();
private static Map<String, String> parseParameterMember(MultivaluedMap<String, String> params, String member) {
Map<String, String> values = new LinkedHashMap<>();
for (String prefix : List.of("Parameters.Parameter", "Parameters.member")) {
for (int n = 1; ; n++) {
String paramName = params.getFirst(prefix + "." + n + ".ParameterName");
if (paramName == null) {
break;
}
String paramValue = params.getFirst(prefix + "." + n + ".ParameterValue");
if (paramValue != null) {
parameters.put(paramName, paramValue);
String value = params.getFirst(prefix + "." + n + "." + member);
if (value != null) {
values.put(paramName, value);
}
}
}
return parameters;
return values;
}
private Response handleCopyDbParameterGroup(
@@ -1662,6 +1679,8 @@ public class RdsQueryHandler {
xml.start("member")
.elem("ParameterName", entry.getKey())
.elem("ParameterValue", entry.getValue())
.elem("Source", "user")
.elem("ApplyMethod", group.getApplyMethods().getOrDefault(entry.getKey(), "immediate"))
.elem("IsModifiable", true)
.end("member");
}
@@ -1733,10 +1752,10 @@ public class RdsQueryHandler {
if (name == null || name.isBlank()) {
return AwsQueryResponse.error("InvalidParameterValue", "DBClusterParameterGroupName is required.", AwsNamespaces.RDS, 400);
}
Map<String, String> parameters = parseParameterOverrides(params);
Map<String, String> parameters = parseParameterMember(params, "ParameterValue");
try {
DbClusterParameterGroup group = service.modifyDbClusterParameterGroup(
name, parameters, region);
name, parameters, parseApplyMethods(params), region);
String result = new XmlBuilder()
.elem("DBClusterParameterGroupName", group.getDbClusterParameterGroupName())
.build();
@@ -1802,6 +1821,8 @@ public class RdsQueryHandler {
xml.start("member")
.elem("ParameterName", entry.getKey())
.elem("ParameterValue", entry.getValue())
.elem("Source", "user")
.elem("ApplyMethod", group.getApplyMethods().getOrDefault(entry.getKey(), "immediate"))
.elem("IsModifiable", true)
.end("member");
}
@@ -7524,15 +7524,17 @@ public class RdsService implements Resettable, ResourceProvider {
public DbParameterGroup modifyDbParameterGroup(String name,
Map<String, String> parameters) {
return modifyDbParameterGroup(
name, parameters, regionResolver.getDefaultRegion());
name, parameters, null, regionResolver.getDefaultRegion());
}
public DbParameterGroup modifyDbParameterGroup(
String name, Map<String, String> parameters, String region) {
String name, Map<String, String> parameters, Map<String, String> applyMethods, String region) {
String effectiveRegion = effectiveRegion(region);
DbParameterGroup group = getDbParameterGroup(name, effectiveRegion);
if (parameters != null) {
group.getParameters().putAll(parameters);
parameters.keySet().forEach(k -> group.getApplyMethods().put(
k, applyMethods == null ? "immediate" : applyMethods.getOrDefault(k, "immediate")));
}
putParameterGroupForRegion(name, effectiveRegion, group);
return group;
@@ -7554,6 +7556,7 @@ public class RdsService implements Resettable, ResourceProvider {
DbParameterGroup target = createDbParameterGroup(
targetName, source.getDbParameterGroupFamily(), targetDescription, effectiveRegion);
target.getParameters().putAll(source.getParameters());
target.getApplyMethods().putAll(source.getApplyMethods());
putParameterGroupForRegion(targetName, effectiveRegion, target);
return target;
}
@@ -7567,6 +7570,7 @@ public class RdsService implements Resettable, ResourceProvider {
String effectiveRegion = effectiveRegion(region);
DbParameterGroup group = getDbParameterGroup(name, effectiveRegion);
resetParameters(group.getParameters(), resetAllParameters, parameterNames);
resetParameters(group.getApplyMethods(), resetAllParameters, parameterNames);
putParameterGroupForRegion(name, effectiveRegion, group);
return group;
}
@@ -7798,11 +7802,11 @@ public class RdsService implements Resettable, ResourceProvider {
public DbClusterParameterGroup modifyDbClusterParameterGroup(String name,
Map<String, String> parameters) {
return modifyDbClusterParameterGroup(
name, parameters, regionResolver.getDefaultRegion());
name, parameters, null, regionResolver.getDefaultRegion());
}
public DbClusterParameterGroup modifyDbClusterParameterGroup(
String name, Map<String, String> parameters, String region) {
String name, Map<String, String> parameters, Map<String, String> applyMethods, String region) {
String effectiveRegion = effectiveRegion(region);
if (managedClusterParameterGroup(name) != null) {
throw new AwsException("InvalidDBParameterGroupState",
@@ -7811,6 +7815,8 @@ public class RdsService implements Resettable, ResourceProvider {
DbClusterParameterGroup group = getDbClusterParameterGroup(name, effectiveRegion);
if (parameters != null) {
group.getParameters().putAll(parameters);
parameters.keySet().forEach(k -> group.getApplyMethods().put(
k, applyMethods == null ? "immediate" : applyMethods.getOrDefault(k, "immediate")));
}
putClusterParameterGroupForRegion(name, effectiveRegion, group);
return group;
@@ -7831,6 +7837,7 @@ public class RdsService implements Resettable, ResourceProvider {
DbClusterParameterGroup target = createDbClusterParameterGroup(
targetName, source.getDbParameterGroupFamily(), targetDescription, effectiveRegion);
target.getParameters().putAll(source.getParameters());
target.getApplyMethods().putAll(source.getApplyMethods());
putClusterParameterGroupForRegion(targetName, effectiveRegion, target);
return target;
}
@@ -7845,6 +7852,7 @@ public class RdsService implements Resettable, ResourceProvider {
}
DbClusterParameterGroup group = getDbClusterParameterGroup(name, effectiveRegion);
resetParameters(group.getParameters(), resetAllParameters, parameterNames);
resetParameters(group.getApplyMethods(), resetAllParameters, parameterNames);
putClusterParameterGroupForRegion(name, effectiveRegion, group);
return group;
}
@@ -16,6 +16,7 @@ public class DbClusterParameterGroup {
private String description;
private String region;
private Map<String, String> parameters = new HashMap<>();
private Map<String, String> applyMethods = new HashMap<>();
public DbClusterParameterGroup() {}
@@ -41,6 +42,13 @@ public class DbClusterParameterGroup {
public Map<String, String> getParameters() { return parameters; }
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
public Map<String, String> getApplyMethods() { return applyMethods; }
/** Normalizes null: a record persisted before apply methods were stored deserializes without them. */
public void setApplyMethods(Map<String, String> applyMethods) {
this.applyMethods = applyMethods == null ? new HashMap<>() : new HashMap<>(applyMethods);
}
public Map<String, String> getTags() { return tags; }
/** Normalizes null: a record persisted before tags were stored deserializes without them. */
@@ -16,6 +16,7 @@ public class DbParameterGroup {
private String description;
private String region;
private Map<String, String> parameters = new HashMap<>();
private Map<String, String> applyMethods = new HashMap<>();
public DbParameterGroup() {}
@@ -41,6 +42,13 @@ public class DbParameterGroup {
public Map<String, String> getParameters() { return parameters; }
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
public Map<String, String> getApplyMethods() { return applyMethods; }
/** Normalizes null: a record persisted before apply methods were stored deserializes without them. */
public void setApplyMethods(Map<String, String> applyMethods) {
this.applyMethods = applyMethods == null ? new HashMap<>() : new HashMap<>(applyMethods);
}
public Map<String, String> getTags() { return tags; }
/** Normalizes null: a record persisted before tags were stored deserializes without them. */
@@ -1,6 +1,7 @@
package io.github.hectorvent.floci.services.rds;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.path.xml.XmlPath;
import io.restassured.specification.RequestSpecification;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
@@ -10,6 +11,7 @@ import org.junit.jupiter.api.TestMethodOrder;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.URLENC;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* The RDS model declares the {@code Parameters} list with {@code locationName: Parameter}, so the
@@ -112,6 +114,150 @@ class RdsParameterGroupWireEncodingIntegrationTest {
.body(containsString("<ParameterValue>1</ParameterValue>"));
}
/** The provider skips parameters without Source and hashes ApplyMethod, so both must round-trip. */
private static void assertSourceAndApplyMethod(String describeAction, String nameKey, String group,
String immediateParam, String pendingParam) {
XmlPath xml = query(describeAction).formParam(nameKey, group)
.when().post("/").then().statusCode(200).extract().xmlPath();
for (String[] p : new String[][] {{immediateParam, "immediate"}, {pendingParam, "pending-reboot"}}) {
String find = "**.find { it.ParameterName == '" + p[0] + "' }.";
assertEquals("user", xml.getString(find + "Source"), p[0]);
assertEquals(p[1], xml.getString(find + "ApplyMethod"), p[0]);
}
}
@Test
@Order(3)
void describeDbParametersReturnsSourceAndApplyMethod() {
assertSourceAndApplyMethod("DescribeDBParameters", "DBParameterGroupName", PG,
"max_connections", "work_mem");
}
@Test
@Order(4)
void describeDbClusterParametersReturnsSourceAndApplyMethod() {
query("ModifyDBClusterParameterGroup")
.formParam("DBClusterParameterGroupName", CLUSTER_PG)
.formParam("Parameters.Parameter.1.ParameterName", "shared_preload_libraries")
.formParam("Parameters.Parameter.1.ParameterValue", "pg_stat_statements")
.formParam("Parameters.Parameter.1.ApplyMethod", "pending-reboot")
.when().post("/").then().statusCode(200);
assertSourceAndApplyMethod("DescribeDBClusterParameters", "DBClusterParameterGroupName", CLUSTER_PG,
"rds.force_ssl", "shared_preload_libraries");
}
private static String applyMethodOf(String describeAction, String nameKey, String group, String param) {
return query(describeAction).formParam(nameKey, group)
.when().post("/").then().statusCode(200).extract().xmlPath()
.getString("**.find { it.ParameterName == '" + param + "' }.ApplyMethod");
}
/**
* Copy carries a pending-reboot ApplyMethod to the copy; a selected reset and ResetAllParameters
* each leave no stale method behind, so a re-modify without ApplyMethod reads back immediate.
* Everything is read back through Describe, not the mutating call's own response.
*/
private static void assertApplyMethodLifecycle(String kind, String family, String param, String value) {
String groupKey = "DB" + kind + "ParameterGroupName";
String describe = "DescribeDB" + kind + "Parameters";
String src = "lifecycle-src" + kind.toLowerCase();
String copy = "lifecycle-copy" + kind.toLowerCase();
query("CreateDB" + kind + "ParameterGroup").formParam(groupKey, src)
.formParam("DBParameterGroupFamily", family).formParam("Description", "lifecycle")
.when().post("/").then().statusCode(200);
query("ModifyDB" + kind + "ParameterGroup").formParam(groupKey, src)
.formParam("Parameters.Parameter.1.ParameterName", param)
.formParam("Parameters.Parameter.1.ParameterValue", value)
.formParam("Parameters.Parameter.1.ApplyMethod", "pending-reboot")
.when().post("/").then().statusCode(200);
query("CopyDB" + kind + "ParameterGroup")
.formParam("SourceDB" + kind + "ParameterGroupIdentifier", src)
.formParam("TargetDB" + kind + "ParameterGroupIdentifier", copy)
.formParam("TargetDB" + kind + "ParameterGroupDescription", "lifecycle copy")
.when().post("/").then().statusCode(200);
assertEquals("pending-reboot", applyMethodOf(describe, groupKey, copy, param), "copy");
// Selected reset, then re-modify with no ApplyMethod.
query("ResetDB" + kind + "ParameterGroup").formParam(groupKey, copy)
.formParam("Parameters.Parameter.1.ParameterName", param)
.formParam("Parameters.Parameter.1.ApplyMethod", "pending-reboot")
.when().post("/").then().statusCode(200);
query("ModifyDB" + kind + "ParameterGroup").formParam(groupKey, copy)
.formParam("Parameters.Parameter.1.ParameterName", param)
.formParam("Parameters.Parameter.1.ParameterValue", value)
.when().post("/").then().statusCode(200);
assertEquals("immediate", applyMethodOf(describe, groupKey, copy, param), "after selected reset");
// ResetAllParameters from a pending-reboot state, then re-modify with no ApplyMethod.
query("ModifyDB" + kind + "ParameterGroup").formParam(groupKey, copy)
.formParam("Parameters.Parameter.1.ParameterName", param)
.formParam("Parameters.Parameter.1.ParameterValue", value)
.formParam("Parameters.Parameter.1.ApplyMethod", "pending-reboot")
.when().post("/").then().statusCode(200);
query("ResetDB" + kind + "ParameterGroup").formParam(groupKey, copy)
.formParam("ResetAllParameters", "true")
.when().post("/").then().statusCode(200);
query("ModifyDB" + kind + "ParameterGroup").formParam(groupKey, copy)
.formParam("Parameters.Parameter.1.ParameterName", param)
.formParam("Parameters.Parameter.1.ParameterValue", value)
.when().post("/").then().statusCode(200);
assertEquals("immediate", applyMethodOf(describe, groupKey, copy, param), "after reset all");
for (String g : new String[] {src, copy}) {
query("DeleteDB" + kind + "ParameterGroup").formParam(groupKey, g).when().post("/");
}
}
@Test
@Order(5)
void dbParameterGroupApplyMethodSurvivesCopyAndIsClearedByReset() {
assertApplyMethodLifecycle("", "postgres15", "work_mem", "65536");
}
@Test
@Order(6)
void dbClusterParameterGroupApplyMethodSurvivesCopyAndIsClearedByReset() {
assertApplyMethodLifecycle("Cluster", "aurora-postgresql15", "shared_preload_libraries", "pg_stat_statements");
}
/**
* The RDS model's ApplyMethod enum is {@code immediate | pending-reboot}; anything else, including
* a different case, is refused with InvalidParameterValue and leaves the stored parameter untouched.
*/
private static void assertInvalidApplyMethodRejected(String kind, String group, String prefix,
String param, String storedValue, String storedMethod) {
String groupKey = "DB" + kind + "ParameterGroupName";
String describe = "DescribeDB" + kind + "Parameters";
for (String bad : new String[] {"later", "Immediate", "PENDING-REBOOT", ""}) {
query("ModifyDB" + kind + "ParameterGroup").formParam(groupKey, group)
.formParam(prefix + ".1.ParameterName", param)
.formParam(prefix + ".1.ParameterValue", "999")
.formParam(prefix + ".1.ApplyMethod", bad)
.when().post("/")
.then()
.statusCode(400)
.body(containsString("<Code>InvalidParameterValue</Code>"));
}
XmlPath xml = query(describe).formParam(groupKey, group)
.when().post("/").then().statusCode(200).extract().xmlPath();
String find = "**.find { it.ParameterName == '" + param + "' }.";
assertEquals(storedValue, xml.getString(find + "ParameterValue"), param);
assertEquals(storedMethod, xml.getString(find + "ApplyMethod"), param);
}
@Test
@Order(7)
void modifyDbParameterGroupRejectsUnknownApplyMethod() {
assertInvalidApplyMethodRejected("", PG, "Parameters.Parameter", "work_mem", "65536", "pending-reboot");
}
@Test
@Order(8)
void modifyDbClusterParameterGroupRejectsUnknownApplyMethod() {
assertInvalidApplyMethodRejected("Cluster", CLUSTER_PG, "Parameters.member", "rds.force_ssl", "1", "immediate");
}
@Test
@Order(9)
void cleanUp() {
@@ -907,14 +907,14 @@ class RdsQueryHandlerTest {
when(service.getDbParameterGroup("pg1", "us-west-2"))
.thenReturn(parameterGroup);
when(service.modifyDbParameterGroup(
"pg1", Map.of("max_connections", "200"), "us-west-2"))
"pg1", Map.of("max_connections", "200"), Map.of(), "us-west-2"))
.thenReturn(parameterGroup);
when(service.listDbClusterParameterGroups(null, "us-west-2"))
.thenReturn(List.of(clusterParameterGroup));
when(service.getDbClusterParameterGroup("cpg1", "us-west-2"))
.thenReturn(clusterParameterGroup);
when(service.modifyDbClusterParameterGroup(
"cpg1", Map.of("log_statement", "all"), "us-west-2"))
"cpg1", Map.of("log_statement", "all"), Map.of(), "us-west-2"))
.thenReturn(clusterParameterGroup);
MultivaluedMap<String, String> subnetParams = params();
@@ -947,12 +947,12 @@ class RdsQueryHandlerTest {
verify(service).deleteDbSubnetGroup("custom-group", "us-west-2");
verify(service).listDbParameterGroups(null, "us-west-2");
verify(service).modifyDbParameterGroup(
"pg1", Map.of("max_connections", "200"), "us-west-2");
"pg1", Map.of("max_connections", "200"), Map.of(), "us-west-2");
verify(service).getDbParameterGroup("pg1", "us-west-2");
verify(service).deleteDbParameterGroup("pg1", "us-west-2");
verify(service).listDbClusterParameterGroups(null, "us-west-2");
verify(service).modifyDbClusterParameterGroup(
"cpg1", Map.of("log_statement", "all"), "us-west-2");
"cpg1", Map.of("log_statement", "all"), Map.of(), "us-west-2");
verify(service).getDbClusterParameterGroup("cpg1", "us-west-2");
verify(service).deleteDbClusterParameterGroup("cpg1", "us-west-2");
}
@@ -1385,7 +1385,7 @@ class RdsQueryHandlerTest {
void modifyDbParameterGroup_ignoresParametersWithoutValue() {
DbParameterGroup group = new DbParameterGroup("pg1", "postgres15", "test group");
when(service.modifyDbParameterGroup(
eq("pg1"), eq(Map.of("max_connections", "200")), isNull()))
eq("pg1"), eq(Map.of("max_connections", "200")), eq(Map.of()), isNull()))
.thenReturn(group);
MultivaluedMap<String, String> p = params();
@@ -1396,7 +1396,7 @@ class RdsQueryHandlerTest {
handler.handle("ModifyDBParameterGroup", p);
verify(service).modifyDbParameterGroup(
"pg1", Map.of("max_connections", "200"), null);
"pg1", Map.of("max_connections", "200"), Map.of(), null);
}
@Test
@@ -1469,7 +1469,7 @@ class RdsQueryHandlerTest {
void modifyDbClusterParameterGroup_ignoresParametersWithoutValue() {
DbClusterParameterGroup group = new DbClusterParameterGroup("cpg1", "aurora-postgresql16", "test group");
when(service.modifyDbClusterParameterGroup(
eq("cpg1"), eq(Map.of("log_statement", "all")), isNull()))
eq("cpg1"), eq(Map.of("log_statement", "all")), eq(Map.of()), isNull()))
.thenReturn(group);
MultivaluedMap<String, String> p = params();
@@ -1480,7 +1480,7 @@ class RdsQueryHandlerTest {
handler.handle("ModifyDBClusterParameterGroup", p);
verify(service).modifyDbClusterParameterGroup(
"cpg1", Map.of("log_statement", "all"), null);
"cpg1", Map.of("log_statement", "all"), Map.of(), null);
}
@Test
@@ -4610,6 +4610,26 @@ class RdsServiceTest {
assertEquals(404, exception.getHttpStatus());
}
/** Not observable through Describe (re-modify rewrites the method), so assert the stored map. */
@Test
void resetClearsStoredApplyMethods() {
Map<String, String> params = Map.of("a", "1", "b", "2");
Map<String, String> methods = Map.of("a", "pending-reboot", "b", "pending-reboot");
rdsService.createDbParameterGroup("reset-pg", "mysql8.0", "d");
rdsService.modifyDbParameterGroup("reset-pg", params, methods, "us-east-1");
assertEquals(Set.of("b"), rdsService.resetDbParameterGroup("reset-pg", false, List.of("a"), "us-east-1")
.getApplyMethods().keySet());
assertTrue(rdsService.resetDbParameterGroup("reset-pg", true, List.of(), "us-east-1")
.getApplyMethods().isEmpty());
rdsService.createDbClusterParameterGroup("reset-cpg", "aurora-mysql8.0", "d");
rdsService.modifyDbClusterParameterGroup("reset-cpg", params, methods, "us-east-1");
assertEquals(Set.of("b"), rdsService.resetDbClusterParameterGroup("reset-cpg", false, List.of("a"), "us-east-1")
.getApplyMethods().keySet());
assertTrue(rdsService.resetDbClusterParameterGroup("reset-cpg", true, List.of(), "us-east-1")
.getApplyMethods().isEmpty());
}
@Test
void createDbClusterRejectsIncompatibleClusterParameterGroupFamily() {
rdsService.createDbClusterParameterGroup("cpg1", "aurora-mysql8.0", "test group");
@@ -4694,9 +4714,9 @@ class RdsServiceTest {
rdsService.createDbParameterGroup("regional-pg", "postgres16", "east", "us-east-1");
rdsService.createDbParameterGroup("regional-pg", "postgres16", "west", "us-west-2");
rdsService.modifyDbParameterGroup(
"regional-pg", Map.of("application_name", "east"), "us-east-1");
"regional-pg", Map.of("application_name", "east"), null, "us-east-1");
rdsService.modifyDbParameterGroup(
"regional-pg", Map.of("application_name", "west"), "us-west-2");
"regional-pg", Map.of("application_name", "west"), null, "us-west-2");
assertEquals("east", rdsService.getDbParameterGroup(
"regional-pg", "us-east-1").getParameters().get("application_name"));
@@ -4708,9 +4728,9 @@ class RdsServiceTest {
rdsService.createDbClusterParameterGroup(
"regional-cpg", "aurora-postgresql16", "west", "us-west-2");
rdsService.modifyDbClusterParameterGroup(
"regional-cpg", Map.of("log_statement", "none"), "us-east-1");
"regional-cpg", Map.of("log_statement", "none"), null, "us-east-1");
rdsService.modifyDbClusterParameterGroup(
"regional-cpg", Map.of("log_statement", "all"), "us-west-2");
"regional-cpg", Map.of("log_statement", "all"), null, "us-west-2");
assertEquals("none", rdsService.getDbClusterParameterGroup(
"regional-cpg", "us-east-1").getParameters().get("log_statement"));
@@ -0,0 +1,48 @@
package io.github.hectorvent.floci.services.rds.model;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
/** A record persisted before apply methods were stored must reload with an empty map, not null. */
class ParameterGroupApplyMethodsPersistenceTest {
private static final ObjectMapper MAPPER = new ObjectMapper();
@Test
void parameterGroupWithoutApplyMethodsReloadsEmpty() throws Exception {
DbParameterGroup g = MAPPER.readValue(
"{\"dbParameterGroupName\":\"g\",\"parameters\":{\"a\":\"1\"}}", DbParameterGroup.class);
assertEquals(Map.of(), g.getApplyMethods());
assertEquals(Map.of(), MAPPER.readValue("{\"applyMethods\":null}", DbParameterGroup.class).getApplyMethods());
}
@Test
void parameterGroupApplyMethodsRoundTrip() throws Exception {
DbParameterGroup g = new DbParameterGroup("g", "postgres15", "d");
g.getApplyMethods().put("work_mem", "pending-reboot");
DbParameterGroup back = MAPPER.readValue(MAPPER.writeValueAsString(g), DbParameterGroup.class);
assertEquals(Map.of("work_mem", "pending-reboot"), back.getApplyMethods());
}
@Test
void clusterParameterGroupWithoutApplyMethodsReloadsEmpty() throws Exception {
DbClusterParameterGroup g = MAPPER.readValue(
"{\"dbClusterParameterGroupName\":\"g\",\"parameters\":{\"a\":\"1\"}}", DbClusterParameterGroup.class);
assertEquals(Map.of(), g.getApplyMethods());
assertEquals(Map.of(),
MAPPER.readValue("{\"applyMethods\":null}", DbClusterParameterGroup.class).getApplyMethods());
}
@Test
void clusterParameterGroupApplyMethodsRoundTrip() throws Exception {
DbClusterParameterGroup g = new DbClusterParameterGroup();
g.getApplyMethods().put("rds.force_ssl", "pending-reboot");
DbClusterParameterGroup back =
MAPPER.readValue(MAPPER.writeValueAsString(g), DbClusterParameterGroup.class);
assertEquals(Map.of("rds.force_ssl", "pending-reboot"), back.getApplyMethods());
}
}