fix(rds): preserve configured database images (#2035)

This commit is contained in:
Aniket Shukla authored and GitHub committed 2026-08-13 15:05:02 -04:00
1 parent 45bb37f1fb
commit 9e7cdad29a
6 files changed
+59 -24

No files matched your search

@@ -74,6 +74,7 @@ class RdsServiceTest {
private Ec2Service ec2Service;
private RegionResolver regionResolver;
private EmulatorConfig config;
private EmulatorConfig.RdsServiceConfig rdsConfig;
@BeforeEach
void setUp() {
@@ -83,15 +84,15 @@ class RdsServiceTest {
regionResolver = new RegionResolver("us-east-1", "123456789012");
config = mock(EmulatorConfig.class);
EmulatorConfig.ServicesConfig servicesConfig = mock(EmulatorConfig.ServicesConfig.class);
EmulatorConfig.RdsServiceConfig rdsConfig = mock(EmulatorConfig.RdsServiceConfig.class);
rdsConfig = mock(EmulatorConfig.RdsServiceConfig.class);
when(config.services()).thenReturn(servicesConfig);
when(servicesConfig.rds()).thenReturn(rdsConfig);
when(rdsConfig.proxyBasePort()).thenReturn(7000);
when(rdsConfig.proxyMaxPort()).thenReturn(7099);
when(rdsConfig.defaultPostgresImage()).thenReturn("postgres:16-alpine");
when(rdsConfig.defaultMysqlImage()).thenReturn("mysql:8.0");
when(rdsConfig.defaultMariadbImage()).thenReturn("mariadb:11");
when(rdsConfig.defaultPostgresImage()).thenReturn(Optional.empty());
when(rdsConfig.defaultMysqlImage()).thenReturn(Optional.empty());
when(rdsConfig.defaultMariadbImage()).thenReturn(Optional.empty());
rdsService = newService(containerManager, proxyManager,
new InMemoryStorage<>(), new InMemoryStorage<>(),
@@ -165,6 +166,30 @@ class RdsServiceTest {
eq("postgres:18.1-alpine"), eq("admin"), eq("password"), eq("dbname"));
}
@Test
void configuredPostgresImageIsNotRewrittenForRequestedEngineVersion() {
when(rdsConfig.defaultPostgresImage()).thenReturn(Optional.of("postgres:16.14-alpine3.23"));
rdsService.createDbCluster("cluster1", "postgres", "16.3",
"admin", "password", "dbname", false, null);
verify(containerManager).start(eq("cluster1"), any(), eq(DatabaseEngine.POSTGRES),
eq("postgres:16.14-alpine3.23"), eq("admin"), eq("password"), eq("dbname"));
}
@Test
void explicitlyConfiguredDefaultPostgresImageIsNotRewritten() {
when(rdsConfig.defaultPostgresImage())
.thenReturn(Optional.of(EmulatorConfig.RdsServiceConfig.DEFAULT_POSTGRES_IMAGE));
rdsService.createDbCluster("cluster1", "postgres", "18.1",
"admin", "password", "dbname", false, null);
verify(containerManager).start(eq("cluster1"), any(), eq(DatabaseEngine.POSTGRES),
eq(EmulatorConfig.RdsServiceConfig.DEFAULT_POSTGRES_IMAGE),
eq("admin"), eq("password"), eq("dbname"));
}
@Test
void dbInstanceTagsRoundTripAndMutateByArn() {
DbInstance instance = rdsService.createDbInstance("mydb", "postgres", "13",