diff --git a/pkg/resource/db_cluster/custom_update.go b/pkg/resource/db_cluster/custom_update.go index 4e6ed0db..5e602168 100644 --- a/pkg/resource/db_cluster/custom_update.go +++ b/pkg/resource/db_cluster/custom_update.go @@ -662,6 +662,16 @@ func (rm *resourceManager) newCustomUpdateRequestPayload( } res.SetCloudwatchLogsExportConfiguration(f24) } + if delta.DifferentAt("Spec.PerformanceInsightsEnabled") && desired.ko.Spec.EnablePerformanceInsights != nil { + res.SetEnablePerformanceInsights(*desired.ko.Spec.EnablePerformanceInsights) + } + if delta.DifferentAt("Spec.PerformanceInsightsKMSKeyID") && desired.ko.Spec.PerformanceInsightsKMSKeyID != nil { + res.SetPerformanceInsightsKMSKeyId(*desired.ko.Spec.PerformanceInsightsKMSKeyID) + } + if delta.DifferentAt("Spec.PerformanceInsightsRetentionPeriod") && desired.ko.Spec.PerformanceInsightsRetentionPeriod != nil { + res.SetPerformanceInsightsRetentionPeriod(*desired.ko.Spec.PerformanceInsightsRetentionPeriod) + } + return res, nil } diff --git a/test/e2e/tests/test_db_cluster.py b/test/e2e/tests/test_db_cluster.py index c95be4a1..e1510c95 100644 --- a/test/e2e/tests/test_db_cluster.py +++ b/test/e2e/tests/test_db_cluster.py @@ -15,6 +15,7 @@ """ import time +import logging import pytest from acktest.k8s import resource as k8s @@ -448,3 +449,39 @@ def test_restore_cluster_to_latest_point_in_time( pass db_cluster.wait_until_deleted(db_cluster_id) + + + def test_enable_performance_insight( + self, aurora_postgres_cluster_log_exports, + ): + ref, _, db_cluster_id = aurora_postgres_cluster_log_exports + db_cluster.wait_until( + db_cluster_id, + db_cluster.status_matches('available'), + ) + + current = db_cluster.get(db_cluster_id) + assert current is not None + + performanceInsightsEnabled = current.get("PerformanceInsightsEnabled", None) + assert performanceInsightsEnabled is None + + k8s.patch_custom_resource( + ref, + {"spec": {"performanceInsightsEnabled": True}}, + ) + + db_cluster.wait_until( + db_cluster_id, + db_cluster.status_matches("available"), + ) + + time.sleep(MODIFY_WAIT_AFTER_SECONDS) + + latest = db_cluster.get(db_cluster_id) + assert latest is not None + + logging.info("+++++") + logging.info(latest) + performanceInsightsEnabled = current.get("PerformanceInsightsEnabled", None) + assert performanceInsightsEnabled == True \ No newline at end of file