mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(rds): apply DBInstanceClass, AllocatedStorage and EngineVersion on ModifyDBInstance (#4214)
* fix(rds): apply DBInstanceClass, AllocatedStorage and EngineVersion on ModifyDBInstance ModifyDBInstance parsed the password, IAM auth, subnet group, option group, security groups and the backup and monitoring settings, but never read DBInstanceClass, AllocatedStorage or EngineVersion. A resize or an engine upgrade returned 200 while DescribeDBInstances kept reporting the values the instance was created with, so a caller that diffs its configuration against a read-back saw the same pending change on every run. The three members move into a DbInstanceScalingChanges record that the handler fills from the request and the service applies, with the rules the AWS API reference states for them: - AllocatedStorage below the current size fails with InvalidParameterCombination - an increase under 10% is rounded up to 10% greater on PostgreSQL, MySQL and MariaDB, and taken as given on SQL Server - the same size is not a change and is left alone - a different major EngineVersion needs AllowMajorVersionUpgrade Floci applies the change immediately rather than deferring it to the preferred maintenance window: it runs no maintenance window and models no PendingModifiedValues, so a deferred change would never be applied at all. * fix(rds): reject a ModifyDBInstance scaling change before applying any member The scaling members were validated as they were assigned: the class was set, then the storage was resolved, which can refuse a shrink, then the engine version was checked, which can refuse a major upgrade. The instance a modify works on is the stored object rather than a copy, so a request refused at the second or third step had already written the earlier ones, and a read-back reported a class the 400 said it never got. The checks now run in resolveFor, ahead of every setter in modifyDbInstance, including the password rotation that reaches the running container. applyTo is left as pure assignment of an already-resolved record.
This commit is contained in:
1 parent
daecc6da17
commit
f2d6710b24
10 files changed
+598
-16
No files matched your search
+142
@@ -0,0 +1,142 @@
|
||||
package io.github.hectorvent.floci.services.rds;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RdsMockProfile;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static io.restassured.http.ContentType.URLENC;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
* ModifyDBInstance read DBInstanceClass, AllocatedStorage and EngineVersion from the request and
|
||||
* threw them away, so a resize or an engine upgrade returned 200 while DescribeDBInstances kept
|
||||
* reporting the values the instance was created with. A caller that diffs its configuration
|
||||
* against a read-back, Terraform above all, saw the same pending change on every run.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(RdsMockProfile.class)
|
||||
class RdsInstanceScalingIntegrationTest {
|
||||
|
||||
private static final String ID = "scaling-db";
|
||||
private static final String RESULT =
|
||||
"DescribeDBInstancesResponse.DescribeDBInstancesResult.DBInstances.DBInstance.";
|
||||
|
||||
private static RequestSpecification rds(String action) {
|
||||
return given().header("Authorization",
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260615/us-east-1/rds/aws4_request, "
|
||||
+ "SignedHeaders=content-type;host, Signature=test")
|
||||
.contentType(URLENC)
|
||||
.formParam("Action", action)
|
||||
.formParam("Version", "2014-10-31");
|
||||
}
|
||||
|
||||
private static void create() {
|
||||
rds("CreateDBInstance")
|
||||
.formParam("DBInstanceIdentifier", ID)
|
||||
.formParam("Engine", "postgres")
|
||||
.formParam("EngineVersion", "13")
|
||||
.formParam("DBInstanceClass", "db.t3.micro")
|
||||
.formParam("MasterUsername", "adminuser")
|
||||
.formParam("MasterUserPassword", "secret123")
|
||||
.formParam("AllocatedStorage", "20")
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
private static RequestSpecification modify() {
|
||||
return rds("ModifyDBInstance").formParam("DBInstanceIdentifier", ID);
|
||||
}
|
||||
|
||||
private static ValidatableResponse describe() {
|
||||
return rds("DescribeDBInstances").formParam("DBInstanceIdentifier", ID)
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanUp() {
|
||||
rds("DeleteDBInstance").formParam("DBInstanceIdentifier", ID)
|
||||
.formParam("SkipFinalSnapshot", "true").when().post("/");
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDBInstance_roundTripsTheNewClassStorageAndEngineVersion() {
|
||||
create();
|
||||
|
||||
modify()
|
||||
.formParam("DBInstanceClass", "db.t3.large")
|
||||
.formParam("AllocatedStorage", "100")
|
||||
.formParam("EngineVersion", "13.7")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body(containsString("<DBInstanceClass>db.t3.large</DBInstanceClass>"))
|
||||
.body(containsString("<AllocatedStorage>100</AllocatedStorage>"))
|
||||
.body(containsString("<EngineVersion>13.7</EngineVersion>"));
|
||||
|
||||
describe()
|
||||
.body(RESULT + "DBInstanceClass", equalTo("db.t3.large"))
|
||||
.body(RESULT + "AllocatedStorage", equalTo("100"))
|
||||
.body(RESULT + "EngineVersion", equalTo("13.7"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDBInstance_roundsAnIncreaseUnderTenPercentUpTheWayAwsDoes() {
|
||||
create();
|
||||
|
||||
modify().formParam("AllocatedStorage", "21")
|
||||
.when().post("/").then().statusCode(200);
|
||||
|
||||
describe().body(RESULT + "AllocatedStorage", equalTo("22"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDBInstance_refusesToShrinkAllocatedStorage() {
|
||||
create();
|
||||
|
||||
modify().formParam("AllocatedStorage", "10")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>InvalidParameterCombination</Code>"));
|
||||
|
||||
describe().body(RESULT + "AllocatedStorage", equalTo("20"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDBInstance_refusesAMajorEngineVersionUpgradeWithoutTheFlag() {
|
||||
create();
|
||||
|
||||
modify().formParam("EngineVersion", "14")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>InvalidParameterCombination</Code>"));
|
||||
|
||||
describe().body(RESULT + "EngineVersion", equalTo("13"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDBInstance_appliesNothingWhenOneMemberIsRefused() {
|
||||
create();
|
||||
|
||||
modify()
|
||||
.formParam("DBInstanceClass", "db.t3.large")
|
||||
.formParam("AllocatedStorage", "10")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>InvalidParameterCombination</Code>"));
|
||||
|
||||
describe()
|
||||
.body(RESULT + "DBInstanceClass", equalTo("db.t3.micro"))
|
||||
.body(RESULT + "AllocatedStorage", equalTo("20"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDBInstance_upgradesAMajorEngineVersionWhenTheFlagIsPresent() {
|
||||
create();
|
||||
|
||||
modify().formParam("EngineVersion", "14")
|
||||
.formParam("AllowMajorVersionUpgrade", "true")
|
||||
.when().post("/").then().statusCode(200);
|
||||
|
||||
describe().body(RESULT + "EngineVersion", equalTo("14"));
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.services.rds.model.DbClusterParameterGroup;
|
||||
import io.github.hectorvent.floci.services.docdb.DocDbQueryHandler;
|
||||
import io.github.hectorvent.floci.services.neptune.NeptuneQueryHandler;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstance;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstanceScalingChanges;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstanceSettings;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstanceStatus;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbParameterGroup;
|
||||
@@ -121,7 +122,8 @@ class RdsQueryHandlerTest {
|
||||
@Test
|
||||
void modifyDbInstance_forwardsPubliclyAccessible() {
|
||||
when(service.modifyDbInstance(eq("mydb"), isNull(), isNull(), isNull(), any(), isNull(), any(),
|
||||
isNull(), any(DbInstanceSettings.class), eq(true))).thenReturn(makeInstance("mydb"));
|
||||
isNull(), any(DbInstanceSettings.class), eq(true), any(DbInstanceScalingChanges.class)))
|
||||
.thenReturn(makeInstance("mydb"));
|
||||
MultivaluedMap<String, String> p = params();
|
||||
p.putSingle("DBInstanceIdentifier", "mydb");
|
||||
p.putSingle("PubliclyAccessible", "true");
|
||||
@@ -129,7 +131,7 @@ class RdsQueryHandlerTest {
|
||||
handler.handle("ModifyDBInstance", p);
|
||||
|
||||
verify(service).modifyDbInstance(eq("mydb"), isNull(), isNull(), isNull(), any(), isNull(), any(),
|
||||
isNull(), any(DbInstanceSettings.class), eq(true));
|
||||
isNull(), any(DbInstanceSettings.class), eq(true), any(DbInstanceScalingChanges.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,7 +144,8 @@ class RdsQueryHandlerTest {
|
||||
|
||||
assertEquals(400, response.getStatus());
|
||||
assertTrue(((String) response.getEntity()).contains("<Code>InvalidParameterValue</Code>"));
|
||||
verify(service, never()).modifyDbInstance(any(), any(), any(), any(), any(), any(), any(), any(), any(), any());
|
||||
verify(service, never()).modifyDbInstance(any(), any(), any(), any(), any(), any(), any(),
|
||||
any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -337,7 +340,8 @@ class RdsQueryHandlerTest {
|
||||
when(service.listDbInstances(null, "us-west-2")).thenReturn(List.of());
|
||||
when(service.getDbInstance("mydb", "us-west-2")).thenReturn(instance);
|
||||
when(service.modifyDbInstance(
|
||||
eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(), eq("us-west-2"), isNull(), any(DbInstanceSettings.class), isNull()))
|
||||
eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(), eq("us-west-2"), isNull(),
|
||||
any(DbInstanceSettings.class), isNull(), any(DbInstanceScalingChanges.class)))
|
||||
.thenReturn(instance);
|
||||
when(service.rebootDbInstance("mydb", "us-west-2")).thenReturn(instance);
|
||||
when(service.listDbClusters(null, "us-west-2")).thenReturn(List.of());
|
||||
@@ -363,7 +367,8 @@ class RdsQueryHandlerTest {
|
||||
verify(service).getDbInstance("mydb", "us-west-2");
|
||||
verify(service).deleteDbInstance("mydb", "us-west-2");
|
||||
verify(service).modifyDbInstance(
|
||||
eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(), eq("us-west-2"), isNull(), any(DbInstanceSettings.class), isNull());
|
||||
eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(), eq("us-west-2"), isNull(),
|
||||
any(DbInstanceSettings.class), isNull(), any(DbInstanceScalingChanges.class));
|
||||
verify(service).rebootDbInstance("mydb", "us-west-2");
|
||||
verify(service).listDbClusters(null, "us-west-2");
|
||||
verify(service).getDbCluster("mycluster", "us-west-2");
|
||||
@@ -612,8 +617,8 @@ class RdsQueryHandlerTest {
|
||||
|
||||
assertEquals(400, response.getStatus());
|
||||
assertTrue(((String) response.getEntity()).contains("InvalidParameterValue"));
|
||||
verify(service, never()).modifyDbInstance(
|
||||
any(), any(), any(), any(), any(), any(), any());
|
||||
verify(service, never()).modifyDbInstance(any(), any(), any(), any(), any(), any(), any(),
|
||||
any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2827,7 +2832,8 @@ class RdsQueryHandlerTest {
|
||||
void modifyDbInstance_passesBackupSettingsToService() {
|
||||
DbInstance instance = makeInstance("mydb");
|
||||
when(service.modifyDbInstance(eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(),
|
||||
isNull(), isNull(), any(DbInstanceSettings.class), isNull())).thenReturn(instance);
|
||||
isNull(), isNull(), any(DbInstanceSettings.class), isNull(),
|
||||
any(DbInstanceScalingChanges.class))).thenReturn(instance);
|
||||
|
||||
MultivaluedMap<String, String> p = params();
|
||||
p.add("DBInstanceIdentifier", "mydb");
|
||||
@@ -2841,10 +2847,66 @@ class RdsQueryHandlerTest {
|
||||
|
||||
ArgumentCaptor<DbInstanceSettings> captor = ArgumentCaptor.forClass(DbInstanceSettings.class);
|
||||
verify(service).modifyDbInstance(eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(),
|
||||
isNull(), isNull(), captor.capture(), isNull());
|
||||
isNull(), isNull(), captor.capture(), isNull(), any(DbInstanceScalingChanges.class));
|
||||
assertEquals(new DbInstanceSettings(null, null, 3, "01:00-01:30", null, true), captor.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstance_passesScalingChangesToService() {
|
||||
DbInstance instance = makeInstance("mydb");
|
||||
when(service.modifyDbInstance(eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(),
|
||||
isNull(), isNull(), any(DbInstanceSettings.class), isNull(),
|
||||
any(DbInstanceScalingChanges.class))).thenReturn(instance);
|
||||
|
||||
MultivaluedMap<String, String> p = params();
|
||||
p.add("DBInstanceIdentifier", "mydb");
|
||||
p.add("DBInstanceClass", "db.t3.large");
|
||||
p.add("AllocatedStorage", "100");
|
||||
p.add("EngineVersion", "14.7");
|
||||
p.add("AllowMajorVersionUpgrade", "true");
|
||||
assertEquals(200, handler.handle("ModifyDBInstance", p).getStatus());
|
||||
|
||||
ArgumentCaptor<DbInstanceScalingChanges> captor =
|
||||
ArgumentCaptor.forClass(DbInstanceScalingChanges.class);
|
||||
verify(service).modifyDbInstance(eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(),
|
||||
isNull(), isNull(), any(DbInstanceSettings.class), isNull(), captor.capture());
|
||||
assertEquals(new DbInstanceScalingChanges("db.t3.large", 100, "14.7", true), captor.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstance_leavesScalingChangesUnsetWhenTheRequestOmitsThem() {
|
||||
DbInstance instance = makeInstance("mydb");
|
||||
when(service.modifyDbInstance(eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(),
|
||||
isNull(), isNull(), any(DbInstanceSettings.class), isNull(),
|
||||
any(DbInstanceScalingChanges.class))).thenReturn(instance);
|
||||
|
||||
MultivaluedMap<String, String> p = params();
|
||||
p.add("DBInstanceIdentifier", "mydb");
|
||||
p.add("BackupRetentionPeriod", "3");
|
||||
assertEquals(200, handler.handle("ModifyDBInstance", p).getStatus());
|
||||
|
||||
ArgumentCaptor<DbInstanceScalingChanges> captor =
|
||||
ArgumentCaptor.forClass(DbInstanceScalingChanges.class);
|
||||
verify(service).modifyDbInstance(eq("mydb"), isNull(), isNull(), isNull(), anyList(), isNull(),
|
||||
isNull(), isNull(), any(DbInstanceSettings.class), isNull(), captor.capture());
|
||||
assertEquals(DbInstanceScalingChanges.unchanged(), captor.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstance_rejectsMalformedAllocatedStorage() {
|
||||
MultivaluedMap<String, String> p = params();
|
||||
p.add("DBInstanceIdentifier", "mydb");
|
||||
p.add("AllocatedStorage", "not-a-number");
|
||||
|
||||
Response response = handler.handle("ModifyDBInstance", p);
|
||||
String body = (String) response.getEntity();
|
||||
|
||||
assertEquals(400, response.getStatus());
|
||||
assertTrue(body.contains("<Code>InvalidParameterValue</Code>"), body);
|
||||
verify(service, never()).modifyDbInstance(any(), any(), any(), any(), any(), any(), any(),
|
||||
any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void unhandledExceptionRendersXmlInternalFailure() {
|
||||
when(service.createDbInstance(any(), any(), any(), any(), any(), any(),
|
||||
|
||||
@@ -22,6 +22,7 @@ import io.github.hectorvent.floci.services.rds.model.DbEndpoint;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstance;
|
||||
import io.github.hectorvent.floci.services.kms.KmsService;
|
||||
import io.github.hectorvent.floci.services.kms.model.KmsKey;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstanceScalingChanges;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstanceSettings;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbInstanceStatus;
|
||||
import io.github.hectorvent.floci.services.rds.model.DbParameterGroup;
|
||||
@@ -332,6 +333,159 @@ class RdsServiceTest {
|
||||
assertFalse(rdsService.getDbInstance("pubdb").isPubliclyAccessible());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceAppliesInstanceClassStorageAndEngineVersion() {
|
||||
createScalingInstance("scaled", "postgres", "13", 20);
|
||||
|
||||
DbInstance modified = rdsService.modifyDbInstance("scaled", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
new DbInstanceScalingChanges("db.t3.large", 100, "13.7", null));
|
||||
|
||||
assertEquals("db.t3.large", modified.getDbInstanceClass());
|
||||
assertEquals(100, modified.getAllocatedStorage());
|
||||
assertEquals("13.7", modified.getEngineVersion());
|
||||
|
||||
DbInstance stored = rdsService.getDbInstance("scaled");
|
||||
assertEquals("db.t3.large", stored.getDbInstanceClass());
|
||||
assertEquals(100, stored.getAllocatedStorage());
|
||||
assertEquals("13.7", stored.getEngineVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceLeavesScalingMembersAloneWhenTheRequestOmitsThem() {
|
||||
createScalingInstance("untouched", "postgres", "13", 20);
|
||||
|
||||
DbInstance modified = rdsService.modifyDbInstance("untouched", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
DbInstanceScalingChanges.unchanged());
|
||||
|
||||
assertEquals("db.t3.micro", modified.getDbInstanceClass());
|
||||
assertEquals(20, modified.getAllocatedStorage());
|
||||
assertEquals("13", modified.getEngineVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceRoundsAllocatedStorageUpToTenPercentGreater() {
|
||||
createScalingInstance("rounded", "postgres", "13", 20);
|
||||
|
||||
DbInstance modified = rdsService.modifyDbInstance("rounded", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
new DbInstanceScalingChanges(null, 21, null, null));
|
||||
|
||||
assertEquals(22, modified.getAllocatedStorage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceKeepsSqlServerStorageExactlyAsAsked() {
|
||||
createScalingInstance("mssql", "sqlserver-se", "15.00", 20);
|
||||
|
||||
DbInstance modified = rdsService.modifyDbInstance("mssql", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
new DbInstanceScalingChanges(null, 21, null, null));
|
||||
|
||||
assertEquals(21, modified.getAllocatedStorage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceLeavesAllocatedStorageAloneWhenItIsUnchanged() {
|
||||
createScalingInstance("same-storage", "postgres", "13", 20);
|
||||
|
||||
DbInstance modified = rdsService.modifyDbInstance("same-storage", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
new DbInstanceScalingChanges(null, 20, null, null));
|
||||
|
||||
assertEquals(20, modified.getAllocatedStorage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceRejectsAllocatedStorageDecrease() {
|
||||
createScalingInstance("shrinking", "postgres", "13", 20);
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () ->
|
||||
rdsService.modifyDbInstance("shrinking", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
new DbInstanceScalingChanges(null, 10, null, null)));
|
||||
|
||||
assertEquals("InvalidParameterCombination", error.getErrorCode());
|
||||
assertEquals(400, error.getHttpStatus());
|
||||
assertEquals(20, rdsService.getDbInstance("shrinking").getAllocatedStorage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceRejectsMajorEngineVersionUpgradeWithoutTheFlag() {
|
||||
createScalingInstance("major", "postgres", "13", 20);
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () ->
|
||||
rdsService.modifyDbInstance("major", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
new DbInstanceScalingChanges(null, null, "14", null)));
|
||||
|
||||
assertEquals("InvalidParameterCombination", error.getErrorCode());
|
||||
assertEquals("13", rdsService.getDbInstance("major").getEngineVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceAppliesMajorEngineVersionUpgradeWithTheFlag() {
|
||||
createScalingInstance("major-allowed", "postgres", "13", 20);
|
||||
|
||||
DbInstance modified = rdsService.modifyDbInstance("major-allowed", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
new DbInstanceScalingChanges(null, null, "14", true));
|
||||
|
||||
assertEquals("14", modified.getEngineVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceLeavesInstanceClassAloneWhenTheStorageShrinkIsRejected() {
|
||||
createScalingInstance("rejected-shrink", "postgres", "13", 20);
|
||||
|
||||
assertThrows(AwsException.class, () ->
|
||||
rdsService.modifyDbInstance("rejected-shrink", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
new DbInstanceScalingChanges("db.t3.large", 10, null, null)));
|
||||
|
||||
DbInstance stored = rdsService.getDbInstance("rejected-shrink");
|
||||
assertEquals("db.t3.micro", stored.getDbInstanceClass());
|
||||
assertEquals(20, stored.getAllocatedStorage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceLeavesClassAndStorageAloneWhenTheMajorUpgradeIsRejected() {
|
||||
createScalingInstance("rejected-upgrade", "postgres", "13", 20);
|
||||
|
||||
assertThrows(AwsException.class, () ->
|
||||
rdsService.modifyDbInstance("rejected-upgrade", null, null, null,
|
||||
null, null, null, null, DbInstanceSettings.unchanged(), null,
|
||||
new DbInstanceScalingChanges("db.t3.large", 100, "14", null)));
|
||||
|
||||
DbInstance stored = rdsService.getDbInstance("rejected-upgrade");
|
||||
assertEquals("db.t3.micro", stored.getDbInstanceClass());
|
||||
assertEquals(20, stored.getAllocatedStorage());
|
||||
assertEquals("13", stored.getEngineVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceLeavesEveryOtherMemberAloneWhenAScalingChangeIsRejected() {
|
||||
createScalingInstance("rejected-whole", "postgres", "13", 20);
|
||||
|
||||
assertThrows(AwsException.class, () ->
|
||||
rdsService.modifyDbInstance("rejected-whole", null, null, null,
|
||||
null, null, null, false,
|
||||
new DbInstanceSettings(null, null, 7, null, null, null), null,
|
||||
new DbInstanceScalingChanges(null, 10, null, null)));
|
||||
|
||||
DbInstance stored = rdsService.getDbInstance("rejected-whole");
|
||||
assertTrue(stored.isAutoMinorVersionUpgrade());
|
||||
assertEquals(1, stored.getBackupRetentionPeriod());
|
||||
}
|
||||
|
||||
private void createScalingInstance(String id, String engine, String engineVersion, int storage) {
|
||||
String dbName = engine.startsWith("sqlserver") ? null : "dbname";
|
||||
rdsService.createDbInstance(id, engine, engineVersion,
|
||||
"admin", "Password123!", dbName, "db.t3.micro",
|
||||
storage, false, null, null, null, null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDbInstanceOmittedPubliclyAccessibleDefaultsTrueForNonAuroraWithNoSubnetGroup() {
|
||||
DbInstance instance = rdsService.createDbInstance("plain-db", "postgres", "13",
|
||||
|
||||
Reference in new issue
Block a user