Skip to content

Commit 459bb1b

Browse files
committed
test: DBInstance PerformanceInsightsRetentionPeriod
1 parent 4fa6c23 commit 459bb1b

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

pkg/resource/db_instance/delta.go

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/db_instance/hooks.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ func instanceDeleting(r *resource) bool {
174174
return dbis == StatusDeleting
175175
}
176176

177+
func customPreCompare(delta *ackcompare.Delta, a *resource, b *resource) {
178+
if a.ko.Spec.PerformanceInsightsKMSKeyID == nil {
179+
a.ko.Spec.PerformanceInsightsKMSKeyID = b.ko.Spec.PerformanceInsightsKMSKeyID
180+
}
181+
182+
if a.ko.Spec.PerformanceInsightsRetentionPeriod == nil {
183+
a.ko.Spec.PerformanceInsightsRetentionPeriod = b.ko.Spec.PerformanceInsightsRetentionPeriod
184+
}
185+
}
186+
177187
// function to create restoreDbInstanceFromDbSnapshot payload and call restoreDbInstanceFromDbSnapshot API
178188
func (rm *resourceManager) restoreDbInstanceFromDbSnapshot(
179189
ctx context.Context,

templates/hooks/db_instance/delta_pre_compare.go.tpl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@
1919
*b.ko.Spec.NetworkType == ServiceDefaultNetworkType {
2020
a.ko.Spec.NetworkType = b.ko.Spec.NetworkType
2121
}
22-
if a.ko.Spec.PerformanceInsightsRetentionPeriod == nil &&
23-
b.ko.Spec.PerformanceInsightsRetentionPeriod != nil &&
24-
*b.ko.Spec.PerformanceInsightsRetentionPeriod == ServiceDefaultInsightsRetentionPeriod {
25-
a.ko.Spec.PerformanceInsightsRetentionPeriod = b.ko.Spec.PerformanceInsightsRetentionPeriod
26-
}
27-
if a.ko.Spec.PerformanceInsightsKMSKeyID == nil &&
28-
b.ko.Spec.PerformanceInsightsKMSKeyID != nil {
29-
a.ko.Spec.PerformanceInsightsKMSKeyID = b.ko.Spec.PerformanceInsightsKMSKeyID
22+
if a.ko.Spec.PerformanceInsightsEnabled == nil &&
23+
b.ko.Spec.PerformanceInsightsEnabled != nil {
24+
a.ko.Spec.PerformanceInsightsEnabled = func() *bool {a := false; return &a }()
3025
}
3126

3227
// RDS will choose preferred engine minor version if only

test/e2e/tests/test_db_instance.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,11 @@ def test_enable_pi_postgres14_t3_micro(
315315
assert latest is not None
316316
assert latest['PerformanceInsightsEnabled'] is True
317317

318-
# TODO: Ensure that the server side defaults
319-
# (PerformanceInsightsRetentionPeriod and PerformanceInsightsKMSKeyID)
320-
# are also persisted back into the spec. This currently does not work
318+
cr = k8s.get_resource(ref)
319+
assert 'performanceInsightsRetentionPeriod' in cr['spec']
320+
assert 'performanceInsightsKMSKeyID' in cr['spec']
321+
assert latest['PerformanceInsightsRetentionPeriod'] == cr['spec']['performanceInsightsRetentionPeriod']
322+
assert latest['PerformanceInsightsKMSKeyId'] == cr['spec']['performanceInsightsKMSKeyID']
321323

322324
def test_state_field_flapping(
323325
self,

0 commit comments

Comments
 (0)