Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ commands:
set -o xtrace

source ../../functions

kubectl -n ${NAMESPACE} patch perconapgcluster/${test_name} --type=json -p '[{"op":"add", "path":"/spec/autoCreateUserSchema","value":true},{"op":"add", "path":"/spec/users","value":[{"name":"chico","databases":["spain"],"password":{"type":"ASCII"},"secretName":"chico-credentials", "grantPublicSchemaAccess": true}]}]'
sleep 10
if [[ $PG_VER < 15 ]]; then
# grantPublicSchemaAccess is not supported before PPG15. Checking that applying patch fails."
set +o errexit
patch_output=$(kubectl -n ${NAMESPACE} patch perconapgcluster/${test_name} --type=json -p '[{"op":"add", "path":"/spec/autoCreateUserSchema","value":true},{"op":"add", "path":"/spec/users","value":[{"name":"chico","databases":["spain"],"password":{"type":"ASCII"},"secretName":"chico-credentials", "grantPublicSchemaAccess": true}]}]' 2>&1)
set -o errexit
if [[ $patch_output != 'The PerconaPGCluster "users" is invalid: spec: Invalid value: "object": PostgresVersion must be >= 15 if grantPublicSchemaAccess exists and is true' ]]; then
echo "grantPublicSchemaAccess is not supported before PPG15. Current PG_VER = $PG_VER but the patch was applied"
exit 1
fi
else
kubectl -n ${NAMESPACE} patch perconapgcluster/${test_name} --type=json -p '[{"op":"add", "path":"/spec/autoCreateUserSchema","value":true},{"op":"add", "path":"/spec/users","value":[{"name":"chico","databases":["spain"],"password":{"type":"ASCII"},"secretName":"chico-credentials", "grantPublicSchemaAccess": true}]}]'
sleep 10
fi
27 changes: 15 additions & 12 deletions e2e-tests/tests/users/14-write-data-to-custom-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ commands:

source ../../functions

password=$(get_psql_user_pass chico-credentials)
user='chico'
db_name='spain'
schema='public'
hostname=$(get_pgbouncer_host chico-credentials)
if [[ $PG_VER < 15 ]]; then
echo "grantPublicSchemaAccess is not supported before PPG15. Current PG_VER = $PG_VER. Skipping check"
else
password=$(get_psql_user_pass chico-credentials)
user='chico'
db_name='spain'
schema='public'
hostname=$(get_pgbouncer_host chico-credentials)

run_psql \
'SET search_path TO public;CREATE TABLE IF NOT EXISTS customApp (id int PRIMARY KEY);' \
"-h $hostname -U $user -d $db_name" "$password"
run_psql \
"INSERT INTO $schema.customApp (id) VALUES (100500)" \
"-h $hostname -U $user -d $db_name" "$password"
run_psql \
'SET search_path TO public;CREATE TABLE IF NOT EXISTS customApp (id int PRIMARY KEY);' \
"-h $hostname -U $user -d $db_name" "$password"
run_psql \
"INSERT INTO $schema.customApp (id) VALUES (100500)" \
"-h $hostname -U $user -d $db_name" "$password"
fi
20 changes: 12 additions & 8 deletions e2e-tests/tests/users/15-read-from-primary-custom-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ commands:
set -o xtrace

source ../../functions
if [[ $PG_VER < 15 ]]; then
echo "grantPublicSchemaAccess is not supported before PPG15. Current PG_VER = $PG_VER. Creating dummy configmap to pass check"
kubectl create configmap -n "${NAMESPACE}" 10-read-from-primary-custom-db --from-literal=data=' 100500'
else
password=$(get_psql_user_pass chico-credentials)
user='chico'
db_name='spain'
schema='public'
hostname=$(get_pgbouncer_host chico-credentials)

password=$(get_psql_user_pass chico-credentials)
user='chico'
db_name='spain'
schema='public'
hostname=$(get_pgbouncer_host chico-credentials)
data=$(run_psql "SELECT * from $schema.customApp;" "-h $hostname -U $user -d $db_name" "$password")

data=$(run_psql "SELECT * from $schema.customApp;" "-h $hostname -U $user -d $db_name" "$password")

kubectl create configmap -n "${NAMESPACE}" 10-read-from-primary-custom-db --from-literal=data="${data}"
kubectl create configmap -n "${NAMESPACE}" 10-read-from-primary-custom-db --from-literal=data="${data}"
fi
6 changes: 5 additions & 1 deletion e2e-tests/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@

export IMAGE_BASE=${IMAGE_BASE:-"perconalab/percona-postgresql-operator"}
export IMAGE=${IMAGE:-"${IMAGE_BASE}:${VERSION}"}
export PG_VER="${PG_VER:-17}"
if [[ ! $PG_VER && $IMAGE_POSTGRESQL ]]; then
export PG_VER=$(echo "$IMAGE_POSTGRESQL" | sed -E 's/.*:(.*ppg)?([0-9]+).*/\2/')

Check warning on line 27 in e2e-tests/vars.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] e2e-tests/vars.sh#L27 <ShellCheck.SC2155>

Declare and assign separately to avoid masking return values.
Raw output
./e2e-tests/vars.sh:27:9: warning: Declare and assign separately to avoid masking return values. (ShellCheck.SC2155)
else
export PG_VER="${PG_VER:-17}"
fi
export IMAGE_PGBOUNCER=${IMAGE_PGBOUNCER:-"${IMAGE_BASE}:main-pgbouncer$PG_VER"}
export IMAGE_POSTGRESQL=${IMAGE_POSTGRESQL:-"perconalab/percona-distribution-postgresql:$PG_VER"}
export IMAGE_BACKREST=${IMAGE_BACKREST:-"${IMAGE_BASE}:main-pgbackrest$PG_VER"}
Expand All @@ -50,9 +54,9 @@
if [[ $var_value == percona/* || $var_value == perconalab/* ]]; then
new_value="${REGISTRY_NAME_FULL}${var_value}"
export "$var=$new_value"
echo $var=$new_value

Check notice on line 57 in e2e-tests/vars.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] e2e-tests/vars.sh#L57 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./e2e-tests/vars.sh:57:8: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)

Check notice on line 57 in e2e-tests/vars.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] e2e-tests/vars.sh#L57 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./e2e-tests/vars.sh:57:13: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
fi
echo $IMAGE

Check notice on line 59 in e2e-tests/vars.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] e2e-tests/vars.sh#L59 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./e2e-tests/vars.sh:59:7: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
done

# shellcheck disable=SC2034
Expand Down
Loading