Skip to content

Commit 01c5b67

Browse files
authored
Merge pull request #611 from vshn/master
🔀 Merge master into develop (sync hotfixes)
2 parents d37461d + a19f5e0 commit 01c5b67

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

pkg/comp-functions/functions/vshnpostgrescnpg/deploy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func createCnpgHelmValues(ctx context.Context, svc *runtime.ServiceRuntime, comp
208208
"fullnameOverride": "postgresql",
209209
"cluster": map[string]any{
210210
"instances": instances,
211+
"enablePDB": instances > 1,
211212
"annotations": map[string]string{
212213
"cnpg.io/hibernation": hibernation,
213214
},

pkg/comp-functions/functions/vshnpostgrescnpg/deploy_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,35 @@ func Test_hibernation(t *testing.T) {
7373
})
7474
}
7575

76+
func Test_enablePDB(t *testing.T) {
77+
svc, comp := getSvcCompCnpg(t)
78+
ctx := context.TODO()
79+
80+
t.Run("PDB disabled for single instance", func(t *testing.T) {
81+
comp.Spec.Parameters.Instances = 1
82+
83+
values, err := createCnpgHelmValues(ctx, svc, comp)
84+
assert.NoError(t, err)
85+
assert.Equal(t, false, values["cluster"].(map[string]any)["enablePDB"])
86+
})
87+
88+
t.Run("PDB enabled for multiple instances", func(t *testing.T) {
89+
comp.Spec.Parameters.Instances = 2
90+
91+
values, err := createCnpgHelmValues(ctx, svc, comp)
92+
assert.NoError(t, err)
93+
assert.Equal(t, true, values["cluster"].(map[string]any)["enablePDB"])
94+
})
95+
96+
t.Run("PDB disabled for paused instance", func(t *testing.T) {
97+
comp.Spec.Parameters.Instances = 0
98+
99+
values, err := createCnpgHelmValues(ctx, svc, comp)
100+
assert.NoError(t, err)
101+
assert.Equal(t, false, values["cluster"].(map[string]any)["enablePDB"])
102+
})
103+
}
104+
76105
func Test_version(t *testing.T) {
77106
svc, comp := getSvcCompCnpg(t)
78107
ctx := context.TODO()

0 commit comments

Comments
 (0)