mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(rds): report LicenseModel on DB instances (#7232)
* fix(rds): report LicenseModel on DB instances DescribeDBInstances and the Create/Modify responses now carry LicenseModel. CreateDBInstance and ModifyDBInstance store a requested LicenseModel; when none was given the engine default is reported (postgresql-license for postgres, general-public-license for mysql/mariadb, license-included for sqlserver). * test(rds): reuse RdsRequests helpers in license model test
This commit is contained in:
1 parent
1fe8eae011
commit
9a1908ff25
4 files changed
+90
-7
No files matched your search
@@ -871,7 +871,8 @@ public class RdsQueryHandler {
|
||||
includeEncryption ? null : cloudwatchLogsExportChanges(params),
|
||||
optionalInt(params.getFirst("MaxAllocatedStorage")),
|
||||
params.getFirst("StorageType"),
|
||||
params.getFirst("CACertificateIdentifier"));
|
||||
params.getFirst("CACertificateIdentifier"),
|
||||
params.getFirst("LicenseModel"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1049,7 +1050,7 @@ public class RdsQueryHandler {
|
||||
if (engine != null && engine.regionMatches(true, 0, "sqlserver", 0, 9)) {
|
||||
return "license-included";
|
||||
}
|
||||
if (engine != null && engine.equalsIgnoreCase("aurora-mysql")) {
|
||||
if (engine != null && (engine.toLowerCase().contains("mysql") || engine.equalsIgnoreCase("mariadb"))) {
|
||||
return "general-public-license";
|
||||
}
|
||||
return "postgresql-license";
|
||||
@@ -3219,6 +3220,7 @@ public class RdsQueryHandler {
|
||||
.elem("DBInstanceStatus", statusStr)
|
||||
.elem("Engine", engineStr.toLowerCase())
|
||||
.elem("EngineVersion", i.getEngineVersion())
|
||||
.elem("LicenseModel", i.getLicenseModel() != null ? i.getLicenseModel() : licenseModel(engineStr))
|
||||
.elem("MasterUsername", i.getMasterUsername());
|
||||
if (i.getDbName() != null && !i.getDbName().isBlank()) {
|
||||
xml.elem("DBName", i.getDbName());
|
||||
|
||||
@@ -28,6 +28,8 @@ public class DbInstance {
|
||||
private String storageType;
|
||||
/** The RDS certificate authority for the instance; null on one stored before it was recorded. */
|
||||
private String caCertificateIdentifier;
|
||||
/** The license model the request named; null means the engine's default. */
|
||||
private String licenseModel;
|
||||
private DbInstanceStatus status;
|
||||
private DbEndpoint endpoint;
|
||||
private boolean iamDatabaseAuthenticationEnabled;
|
||||
@@ -141,6 +143,8 @@ public class DbInstance {
|
||||
public String getStorageType() { return storageType != null ? storageType : DEFAULT_STORAGE_TYPE; }
|
||||
public void setStorageType(String storageType) { this.storageType = storageType; }
|
||||
|
||||
public String getLicenseModel() { return licenseModel; }
|
||||
public void setLicenseModel(String licenseModel) { this.licenseModel = licenseModel; }
|
||||
public String getCaCertificateIdentifier() { return caCertificateIdentifier; }
|
||||
public void setCaCertificateIdentifier(String caCertificateIdentifier) {
|
||||
this.caCertificateIdentifier = caCertificateIdentifier;
|
||||
|
||||
+23
-5
@@ -28,7 +28,22 @@ public record DbInstanceSettings(Boolean storageEncrypted,
|
||||
LogExportChanges logExportChanges,
|
||||
Integer maxAllocatedStorage,
|
||||
String storageType,
|
||||
String caCertificateIdentifier) {
|
||||
String caCertificateIdentifier,
|
||||
String licenseModel) {
|
||||
public DbInstanceSettings(Boolean storageEncrypted, String kmsKeyId, Integer backupRetentionPeriod,
|
||||
String preferredBackupWindow, String preferredMaintenanceWindow,
|
||||
Boolean copyTagsToSnapshot, Integer monitoringInterval, String monitoringRoleArn,
|
||||
Boolean performanceInsightsEnabled, Integer performanceInsightsRetentionPeriod,
|
||||
String engineLifecycleSupport, List<String> enabledCloudwatchLogsExports,
|
||||
LogExportChanges logExportChanges, Integer maxAllocatedStorage, String storageType,
|
||||
String caCertificateIdentifier) {
|
||||
this(storageEncrypted, kmsKeyId, backupRetentionPeriod, preferredBackupWindow,
|
||||
preferredMaintenanceWindow, copyTagsToSnapshot, monitoringInterval, monitoringRoleArn,
|
||||
performanceInsightsEnabled, performanceInsightsRetentionPeriod, engineLifecycleSupport,
|
||||
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, storageType,
|
||||
caCertificateIdentifier, null);
|
||||
}
|
||||
|
||||
public DbInstanceSettings(Boolean storageEncrypted, String kmsKeyId, Integer backupRetentionPeriod,
|
||||
String preferredBackupWindow, String preferredMaintenanceWindow,
|
||||
Boolean copyTagsToSnapshot, Integer monitoringInterval, String monitoringRoleArn,
|
||||
@@ -201,7 +216,7 @@ public record DbInstanceSettings(Boolean storageEncrypted,
|
||||
monitoringInterval, monitoringRoleArn, performanceInsightsEnabled,
|
||||
performanceInsightsRetentionPeriod, engineLifecycleSupport,
|
||||
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, storageType,
|
||||
caCertificateIdentifier);
|
||||
caCertificateIdentifier, licenseModel);
|
||||
}
|
||||
|
||||
public DbInstanceSettings withKmsKeyId(String resolvedKmsKeyId) {
|
||||
@@ -210,7 +225,7 @@ public record DbInstanceSettings(Boolean storageEncrypted,
|
||||
monitoringInterval, monitoringRoleArn, performanceInsightsEnabled,
|
||||
performanceInsightsRetentionPeriod, engineLifecycleSupport,
|
||||
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, storageType,
|
||||
caCertificateIdentifier);
|
||||
caCertificateIdentifier, licenseModel);
|
||||
}
|
||||
|
||||
public DbInstanceSettings withStorageType(String resolvedStorageType) {
|
||||
@@ -219,7 +234,7 @@ public record DbInstanceSettings(Boolean storageEncrypted,
|
||||
monitoringInterval, monitoringRoleArn, performanceInsightsEnabled,
|
||||
performanceInsightsRetentionPeriod, engineLifecycleSupport,
|
||||
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, resolvedStorageType,
|
||||
caCertificateIdentifier);
|
||||
caCertificateIdentifier, licenseModel);
|
||||
}
|
||||
|
||||
/** The same settings with the CA certificate the service resolved. */
|
||||
@@ -229,7 +244,7 @@ public record DbInstanceSettings(Boolean storageEncrypted,
|
||||
monitoringInterval, monitoringRoleArn, performanceInsightsEnabled,
|
||||
performanceInsightsRetentionPeriod, engineLifecycleSupport,
|
||||
enabledCloudwatchLogsExports, logExportChanges, maxAllocatedStorage, storageType,
|
||||
resolvedCaCertificateIdentifier);
|
||||
resolvedCaCertificateIdentifier, licenseModel);
|
||||
}
|
||||
|
||||
public void validateStorageType() {
|
||||
@@ -290,5 +305,8 @@ public record DbInstanceSettings(Boolean storageEncrypted,
|
||||
if (caCertificateIdentifier != null && !caCertificateIdentifier.isBlank()) {
|
||||
instance.setCaCertificateIdentifier(caCertificateIdentifier);
|
||||
}
|
||||
if (licenseModel != null && !licenseModel.isBlank()) {
|
||||
instance.setLicenseModel(licenseModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
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.Response;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.github.hectorvent.floci.testing.RdsRequests.deleteInstance;
|
||||
import static io.github.hectorvent.floci.testing.RdsRequests.rds;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(RdsMockProfile.class)
|
||||
class RdsLicenseModelIntegrationTest {
|
||||
|
||||
private static RequestSpecification create(String id, String engine) {
|
||||
return rds("CreateDBInstance").formParam("DBInstanceIdentifier", id)
|
||||
.formParam("Engine", engine).formParam("DBInstanceClass", "db.t3.micro")
|
||||
.formParam("MasterUsername", "admin").formParam("MasterUserPassword", "password123")
|
||||
.formParam("AllocatedStorage", "20");
|
||||
}
|
||||
|
||||
private static String described(String id) {
|
||||
Response read = rds("DescribeDBInstances").formParam("DBInstanceIdentifier", id).post("/");
|
||||
assertEquals(200, read.statusCode(), read.asString());
|
||||
return read.xmlPath().getString(
|
||||
"DescribeDBInstancesResponse.DescribeDBInstancesResult.DBInstances.DBInstance.LicenseModel");
|
||||
}
|
||||
|
||||
@Test
|
||||
void omittedLicenseModelReportsTheEngineDefault() {
|
||||
try {
|
||||
create("license-default-pg", "postgres").post("/").then().statusCode(200);
|
||||
create("license-default-mysql", "mysql").post("/").then().statusCode(200);
|
||||
assertEquals("postgresql-license", described("license-default-pg"));
|
||||
assertEquals("general-public-license", described("license-default-mysql"));
|
||||
} finally {
|
||||
deleteInstance("license-default-pg");
|
||||
deleteInstance("license-default-mysql");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void requestedLicenseModelIsRetainedOnCreateAndModify() {
|
||||
String id = "license-requested";
|
||||
try {
|
||||
create(id, "postgres").formParam("LicenseModel", "bring-your-own-license")
|
||||
.post("/").then().statusCode(200);
|
||||
assertEquals("bring-your-own-license", described(id));
|
||||
rds("ModifyDBInstance").formParam("DBInstanceIdentifier", id)
|
||||
.formParam("LicenseModel", "postgresql-license").post("/").then().statusCode(200);
|
||||
assertEquals("postgresql-license", described(id));
|
||||
} finally {
|
||||
deleteInstance(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user