Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ check-kuttl: ## example command: make check-kuttl KUTTL_TEST='
--config testing/kuttl/kuttl-test.yaml

.PHONY: generate-kuttl
generate-kuttl: export KUTTL_PGCLUSTER_API_VERSION ?= v1
generate-kuttl: export KUTTL_PG_UPGRADE_FROM_VERSION ?= 16
generate-kuttl: export KUTTL_PG_UPGRADE_TO_VERSION ?= 17
generate-kuttl: export KUTTL_PG_VERSION ?= 16
Expand All @@ -211,6 +212,7 @@ generate-kuttl: ## Generate kuttl tests
[ ! -d testing/kuttl/e2e-generated ] || rm -r testing/kuttl/e2e-generated
bash -ceu ' \
render() { envsubst '"'"' \
$$KUTTL_PGCLUSTER_API_VERSION \
$$KUTTL_PG_UPGRADE_FROM_VERSION $$KUTTL_PG_UPGRADE_TO_VERSION \
$$KUTTL_PG_VERSION $$KUTTL_POSTGIS_VERSION $$KUTTL_PSQL_IMAGE \
$$KUTTL_TEST_DELETE_NAMESPACE'"'"'; }; \
Expand Down
118 changes: 38 additions & 80 deletions internal/crd/validation/postgrescluster/postgres_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,43 +71,24 @@ func TestPostgresConfigParametersV1beta1(t *testing.T) {
})
})

t.Run("ssl_groups and ssl_ecdh_curve", func(t *testing.T) {
t.Run("ssl_groups not allowed for pg17", func(t *testing.T) {
t.Run("SSL Settings", func(t *testing.T) {
t.Run("Allowed", func(t *testing.T) {
for _, tt := range []struct {
key string
value any
key string
value any
postgresVersion int
}{
{key: "ssl_groups", value: "anything"},
} {
t.Run(tt.key, func(t *testing.T) {
cluster := u.DeepCopy()
require.UnmarshalIntoField(t, cluster,
require.Value(yaml.Marshal(17)),
"spec", "postgresVersion")
require.UnmarshalIntoField(t, cluster,
require.Value(yaml.Marshal(tt.value)),
"spec", "config", "parameters", tt.key)
// ssl_ecdh_curve is allowed for all supported Postgres versions
{key: "ssl_ecdh_curve", value: "anything", postgresVersion: 17},
{key: "ssl_ecdh_curve", value: "anything", postgresVersion: 18},

err := cc.Create(ctx, cluster, client.DryRunAll)
assert.Assert(t, apierrors.IsInvalid(err))

details := require.StatusErrorDetails(t, err)
assert.Assert(t, cmp.Len(details.Causes, 1))
})
}
})

t.Run("ssl_groups allowed for pg18", func(t *testing.T) {
for _, tt := range []struct {
key string
value any
}{
{key: "ssl_groups", value: "anything"},
// ssl_groups is only supported for Postgres 18 and greater
{key: "ssl_groups", value: "anything", postgresVersion: 18},
} {
t.Run(tt.key, func(t *testing.T) {
cluster := u.DeepCopy()
require.UnmarshalIntoField(t, cluster,
require.Value(yaml.Marshal(18)),
require.Value(yaml.Marshal(tt.postgresVersion)),
"spec", "postgresVersion")
require.UnmarshalIntoField(t, cluster,
require.Value(yaml.Marshal(tt.value)),
Expand All @@ -118,48 +99,39 @@ func TestPostgresConfigParametersV1beta1(t *testing.T) {
}
})

t.Run("ssl_ecdh_curve allowed for both", func(t *testing.T) {
t.Run("Not Allowed", func(t *testing.T) {
for _, tt := range []struct {
key string
value any
key string
value any
postgresVersion int
}{
{key: "ssl_ecdh_curve", value: "anything"},
// setting "ssl" is not allowed for any Postgres version
{key: "ssl", value: "anything", postgresVersion: 17},
{key: "ssl", value: "anything", postgresVersion: 18},

// setting any parameter with an "ssl_" prefix that is not
// "ssl_ecdh_curve" or "ssl_groups" is not allowed for any version
{key: "ssl_anything", value: "anything", postgresVersion: 17},
{key: "ssl_anything", value: "anything", postgresVersion: 18},

// setting "ssl_ecdh_curve" with any additional suffix is not
// allowed for any version
{key: "ssl_ecdh_curve_bad", value: "anything", postgresVersion: 17},
{key: "ssl_ecdh_curve_bad", value: "anything", postgresVersion: 18},

// setting "ssl_groups" is not allowed for Postgres versions 17
// or earlier
{key: "ssl_groups", value: "anything", postgresVersion: 17},

// setting "ssl_groups" with any additional suffix is not
// allowed for any version
{key: "ssl_groups_bad", value: "anything", postgresVersion: 17},
{key: "ssl_groups_bad", value: "anything", postgresVersion: 18},
} {
t.Run(tt.key, func(t *testing.T) {
cluster := u.DeepCopy()
require.UnmarshalIntoField(t, cluster,
require.Value(yaml.Marshal(17)),
"spec", "postgresVersion")
require.UnmarshalIntoField(t, cluster,
require.Value(yaml.Marshal(tt.value)),
"spec", "config", "parameters", tt.key)

assert.NilError(t, cc.Create(ctx, cluster, client.DryRunAll))

cluster2 := u.DeepCopy()
require.UnmarshalIntoField(t, cluster2,
require.Value(yaml.Marshal(18)),
"spec", "postgresVersion")
require.UnmarshalIntoField(t, cluster2,
require.Value(yaml.Marshal(tt.value)),
"spec", "config", "parameters", tt.key)

assert.NilError(t, cc.Create(ctx, cluster2, client.DryRunAll))
})
}
})

t.Run("other ssl_* parameters not allowed for any pg version", func(t *testing.T) {
for _, tt := range []struct {
key string
value any
}{
{key: "ssl_anything", value: "anything"},
} {
t.Run(tt.key, func(t *testing.T) {
cluster := u.DeepCopy()
require.UnmarshalIntoField(t, cluster,
require.Value(yaml.Marshal(17)),
require.Value(yaml.Marshal(tt.postgresVersion)),
"spec", "postgresVersion")
require.UnmarshalIntoField(t, cluster,
require.Value(yaml.Marshal(tt.value)),
Expand All @@ -170,20 +142,6 @@ func TestPostgresConfigParametersV1beta1(t *testing.T) {

details := require.StatusErrorDetails(t, err)
assert.Assert(t, cmp.Len(details.Causes, 1))

cluster1 := u.DeepCopy()
require.UnmarshalIntoField(t, cluster1,
require.Value(yaml.Marshal(18)),
"spec", "postgresVersion")
require.UnmarshalIntoField(t, cluster1,
require.Value(yaml.Marshal(tt.value)),
"spec", "config", "parameters", tt.key)

err = cc.Create(ctx, cluster1, client.DryRunAll)
assert.Assert(t, apierrors.IsInvalid(err))

details = require.StatusErrorDetails(t, err)
assert.Assert(t, cmp.Len(details.Causes, 1))
})
}
})
Expand Down
8 changes: 6 additions & 2 deletions testing/chainsaw/e2e/pgbackrest-restore/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ spec:
- name: volume
value: { accessModes: [ReadWriteOnce], resources: { requests: { storage: 1Gi } } }

- name: postgrescluster
value:
apiVersion: (join('', ['postgres-operator.crunchydata.com/', $values.versions.postgrescluster]))

steps:
- name: 'Create Cluster with replica, tablespace'
use:
Expand Down Expand Up @@ -85,7 +89,7 @@ spec:
deletionPropagationPolicy: Background
expect: [{ check: { (`true`): true } }]
ref:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
name: clone-one

Expand Down Expand Up @@ -162,7 +166,7 @@ spec:
deletionPropagationPolicy: Background
expect: [{ check: { (`true`): true } }]
ref:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
name: clone-two

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
Update the cluster with parameters that require attention during recovery
patch:
resource:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
metadata:
name: original
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
Clone the cluster using a pgBackRest restore
apply:
resource:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
metadata:
name: ($name)
Expand All @@ -39,7 +39,7 @@ spec:
Wait for the cluster to come online
assert:
resource:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
metadata:
name: ($name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
Annotate the cluster to trigger a backup
patch:
resource:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
metadata:
name: original
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
and some parameters that require attention during PostgreSQL recovery
apply:
resource:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
metadata:
name: original
Expand Down Expand Up @@ -40,7 +40,7 @@ spec:
Wait for the replica backup to complete
assert:
resource:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
metadata:
name: original
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
Trigger an in-place point-in-time restore (PITR)
patch:
resource:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
metadata:
name: original
Expand All @@ -46,7 +46,7 @@ spec:
Wait for the restore to complete and the cluster to come online
assert:
resource:
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: ($postgrescluster.apiVersion)
kind: PostgresCluster
metadata:
name: original
Expand Down
1 change: 1 addition & 0 deletions testing/chainsaw/e2e/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
versions:
postgres: '17'
postgrescluster: 'v1'

images:
psql: 'registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-17.6-2542'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: cluster-pause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: cluster-pause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: cluster-pause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: cluster-pause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: cluster-pause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: cluster-pause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: cluster-start
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: cluster-start
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete-namespace
Expand Down
2 changes: 1 addition & 1 deletion testing/kuttl/e2e/delete-namespace/files/00-created.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete-namespace
Expand Down
2 changes: 1 addition & 1 deletion testing/kuttl/e2e/delete-namespace/files/01-errors.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
namespace: ${KUTTL_TEST_DELETE_NAMESPACE}
Expand Down
2 changes: 1 addition & 1 deletion testing/kuttl/e2e/delete/files/00-cluster-created.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete
Expand Down
2 changes: 1 addition & 1 deletion testing/kuttl/e2e/delete/files/00-create-cluster.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete
Expand Down
2 changes: 1 addition & 1 deletion testing/kuttl/e2e/delete/files/01-cluster-deleted.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete-with-replica
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete-with-replica
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete-with-replica
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete-not-running
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
apiVersion: postgres-operator.crunchydata.com/${KUTTL_PGCLUSTER_API_VERSION}
kind: PostgresCluster
metadata:
name: delete-not-running
Expand Down
Loading
Loading