forked from CrunchyData/postgres-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Select PostgresCluster by name for pgAdmin Server Group
This change adds the ability to select a PostgresCluster by name for a given pgAdmin ServerGroup in addition to selecting by label. Issue: PGO-1075
- Loading branch information
Showing
9 changed files
with
190 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
testing/kuttl/e2e-other/standalone-pgadmin-v8/10-invalid-pgadmin.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
# Check that invalid spec cannot be applied. | ||
commands: | ||
- script: | | ||
contains() { bash -ceu '[[ "$1" == *"$2"* ]]' - "$@"; } | ||
diff_comp() { bash -ceu 'diff <(echo "$1" ) <(echo "$2")' - "$@"; } | ||
data_expected='"pgadmin2" is invalid: spec.serverGroups[0]: Invalid value: "object": exactly one of "postgresClusterName" or "postgresClusterSelector" is required' | ||
data_actual=$(kubectl apply -f - 2>&1 <<EOF | ||
apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
kind: PGAdmin | ||
metadata: | ||
name: pgadmin2 | ||
spec: | ||
dataVolumeClaimSpec: | ||
accessModes: | ||
- "ReadWriteOnce" | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
serverGroups: | ||
- name: groupOne # can't have both a selector and name | ||
postgresClusterSelector: | ||
matchLabels: | ||
hello: world | ||
postgresClusterName: pgadmin4 | ||
EOF | ||
) | ||
{ | ||
contains "${data_actual}" "${data_expected}" | ||
} || { | ||
echo "Expected invalid error: got ${data_actual}" | ||
diff_comp "${data_actual}" "${data_expected}" | ||
exit 1 | ||
} |
7 changes: 7 additions & 0 deletions
7
testing/kuttl/e2e-other/standalone-pgadmin-v8/11--create-cluster.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- files/11-cluster.yaml | ||
- files/11-pgadmin.yaml | ||
error: | ||
- files/11-pgadmin-check.yaml |
80 changes: 80 additions & 0 deletions
80
testing/kuttl/e2e-other/standalone-pgadmin-v8/12-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
# Check the configmap is updated; | ||
# Check the file is updated on the pod; | ||
# Check the server dump is accurate. | ||
# Because we have to wait for the configmap reload, make sure we have enough time. | ||
timeout: 120 | ||
commands: | ||
- script: | | ||
contains() { bash -ceu '[[ "$1" == *"$2"* ]]' - "$@"; } | ||
diff_comp() { bash -ceu 'diff <(echo "$1" ) <(echo "$2")' - "$@"; } | ||
data_expected='"pgadmin-shared-clusters.json": "{\n \"Servers\": {\n \"1\": {\n \"Group\": \"groupOne\",\n \"Host\": \"named-cluster-primary.'${NAMESPACE}.svc'\",\n \"MaintenanceDB\": \"postgres\",\n \"Name\": \"named-cluster\",\n \"Port\": 5432,\n \"SSLMode\": \"prefer\",\n \"Shared\": true,\n \"Username\": \"named-cluster\"\n }\n }\n}\n"' | ||
data_actual=$(kubectl get cm -l postgres-operator.crunchydata.com/pgadmin=pgadmin2 -n "${NAMESPACE}" -o json | jq .items[0].data) | ||
{ | ||
contains "${data_actual}" "${data_expected}" | ||
} || { | ||
echo "Wrong configmap: got ${data_actual}" | ||
diff_comp "${data_actual}" "${data_expected}" | ||
exit 1 | ||
} | ||
pod_name=$(kubectl get pod -n "${NAMESPACE}" -l postgres-operator.crunchydata.com/pgadmin=pgadmin2 -o name) | ||
config_updated=$(kubectl exec -n "${NAMESPACE}" "${pod_name}" -- bash -c 'cat /etc/pgadmin/conf.d/~postgres-operator/pgadmin-shared-clusters.json') | ||
config_expected='{ | ||
"Servers": { | ||
"1": { | ||
"Group": "groupOne", | ||
"Host": "named-cluster-primary.'${NAMESPACE}.svc'", | ||
"MaintenanceDB": "postgres", | ||
"Name": "named-cluster", | ||
"Port": 5432, | ||
"SSLMode": "prefer", | ||
"Shared": true, | ||
"Username": "named-cluster" | ||
} | ||
} | ||
}' | ||
{ | ||
contains "${config_updated}" "${config_expected}" | ||
} || { | ||
echo "Wrong file mounted: got ${config_updated}" | ||
echo "Wrong file mounted: expected ${config_expected}" | ||
diff_comp "${config_updated}" "${config_expected}" | ||
sleep 10 | ||
exit 1 | ||
} | ||
clusters_actual=$(kubectl exec -n "${NAMESPACE}" "${pod_name}" -- bash -c "python3 /usr/local/lib/python3.11/site-packages/pgadmin4/setup.py dump-servers /tmp/dumped.json --user admin@pgadmin2.${NAMESPACE}.svc && cat /tmp/dumped.json") | ||
clusters_expected=' | ||
{ | ||
"Servers": { | ||
"1": { | ||
"Name": "named-cluster", | ||
"Group": "groupOne", | ||
"Host": "named-cluster-primary.'${NAMESPACE}.svc'", | ||
"Port": 5432, | ||
"MaintenanceDB": "postgres", | ||
"Username": "named-cluster", | ||
"Shared": true, | ||
"TunnelPort": "22", | ||
"KerberosAuthentication": false, | ||
"ConnectionParameters": { | ||
"sslmode": "prefer" | ||
} | ||
} | ||
} | ||
}' | ||
{ | ||
contains "${clusters_actual}" "${clusters_expected}" | ||
} || { | ||
echo "Wrong servers dumped: got ${clusters_actual}" | ||
echo "Wrong servers dumped: expected ${clusters_expected}" | ||
diff_comp "${clusters_actual}" "${clusters_expected}" | ||
exit 1 | ||
} |
15 changes: 15 additions & 0 deletions
15
testing/kuttl/e2e-other/standalone-pgadmin-v8/files/11-cluster.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
kind: PostgresCluster | ||
metadata: | ||
name: named-cluster | ||
spec: | ||
postgresVersion: ${KUTTL_PG_VERSION} | ||
instances: | ||
- name: instance1 | ||
dataVolumeClaimSpec: { accessModes: [ReadWriteOnce], resources: { requests: { storage: 1Gi } } } | ||
backups: | ||
pgbackrest: | ||
repos: | ||
- name: repo1 | ||
volume: | ||
volumeClaimSpec: { accessModes: [ReadWriteOnce], resources: { requests: { storage: 1Gi } } } |
4 changes: 4 additions & 0 deletions
4
testing/kuttl/e2e-other/standalone-pgadmin-v8/files/11-pgadmin-check.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
kind: PGAdmin | ||
metadata: | ||
name: named-cluster |
14 changes: 14 additions & 0 deletions
14
testing/kuttl/e2e-other/standalone-pgadmin-v8/files/11-pgadmin.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
kind: PGAdmin | ||
metadata: | ||
name: pgadmin2 | ||
spec: | ||
dataVolumeClaimSpec: | ||
accessModes: | ||
- "ReadWriteOnce" | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
serverGroups: | ||
- name: groupOne | ||
postgresClusterName: named-cluster |