forked from bitnami/charts
-
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.
[bitnami/postgresql] Revisit tests (bitnami#12945)
* [bitnami/postgresql] Revisit tests Signed-off-by: Jose Antonio Carmona <[email protected]> * Use a variable for Headless svc basename Signed-off-by: Jose Antonio Carmona <[email protected]> * Remove runtime params that we don't check in tests Signed-off-by: Jose Antonio Carmona <[email protected]> Signed-off-by: Jose Antonio Carmona <[email protected]>
- Loading branch information
Showing
4 changed files
with
71 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,49 @@ | ||
command: | ||
postgresql-connect: | ||
exec: PGPASSWORD="$POSTGRES_PASSWORD" psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" | ||
{{- $dbUser := .Vars.auth.username }} | ||
{{- $dbPassword := .Vars.auth.password }} | ||
{{- $dbName := .Vars.auth.database }} | ||
{{- $lb_port := .Vars.primary.service.ports.postgresql }} | ||
{{- $hl_svc_bn := printf "postgresql-%s" .Vars.readReplicas.name }} | ||
{{- $port := .Vars.containerPorts.postgresql }} | ||
{{- $replica_nodes := .Vars.readReplicas.replicaCount }} | ||
{{- $table := printf "test_%s" (randAlpha 5) }} | ||
postgresql-check-replication: | ||
exec: export PGPASSWORD='{{ $dbPassword }}' && psql -U '{{ $dbUser }}' -d '{{ $dbName }}' -p {{ $lb_port }} -h postgresql-{{ .Vars.primary.name }} -c "CREATE TABLE {{ $table }} (id int, first_name VARCHAR(50));" && sleep 1 {{ range $e, $i := until $replica_nodes }} && psql -U '{{ $dbUser }}' -d '{{ $dbName }}' -p {{ $port }} -h {{ $hl_svc_bn }}-{{ $i }}.{{ $hl_svc_bn }}-hl -c "SELECT * FROM {{ $table }};"{{ end }} | ||
exit-status: 0 | ||
stderr: [ ] | ||
timeout: 20000 | ||
postgresql-create-table: | ||
exec: PGPASSWORD="$POSTGRES_PASSWORD" psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c 'CREATE TABLE new_table_created (id int, first_name VARCHAR(50));' | ||
{{ range $e, $i := until $replica_nodes }} | ||
postgresql-only-read-node-{{ $i }}: | ||
exec: PGPASSWORD='{{ $dbPassword }}' psql -U '{{ $dbUser }}' -d '{{ $dbName }}' -p {{ $port }} -h {{ $hl_svc_bn }}-{{ $i }}.{{ $hl_svc_bn }}-hl -c "CREATE TABLE rep_table_test (id int);" | ||
exit-status: 1 | ||
stderr: | ||
- /.*read-only transaction.*/ | ||
{{ end }} | ||
cluster-size: | ||
exec: PGPASSWORD='{{ .Vars.auth.postgresPassword }}' psql -tA -U postgres -p {{ $port }} -h postgresql-{{ .Vars.primary.name }} -c "SELECT COUNT(*) FROM pg_stat_replication WHERE usename='{{ .Vars.auth.replicationUsername }}';" | ||
exit-status: 0 | ||
stdout: | ||
- 'CREATE TABLE' | ||
stderr: [ ] | ||
timeout: 2000 | ||
postgresql-check-connectivity-and-port: | ||
exec: pg_isready -d "$POSTGRES_DB" -h localhost -p "$POSTGRESQL_PORT_NUMBER" -U "$POSTGRES_USER" | ||
- '2' | ||
check-user-info: | ||
exec: id | ||
exit-status: 0 | ||
stdout: | ||
- {{ printf "localhost:%s - accepting connections" .Env.POSTGRESQL_PORT_NUMBER | quote }} | ||
stderr: [ ] | ||
timeout: 2000 | ||
user-id-test: | ||
exec: if [ "$(id -u)" -eq 0 ]; then exit 1; fi | ||
exit-status: 0 | ||
stdout: [] | ||
stderr: [] | ||
- uid={{ .Vars.primary.containerSecurityContext.runAsUser }} | ||
- /groups=.*{{ .Vars.primary.podSecurityContext.fsGroup }}/ | ||
file: | ||
/bitnami/postgresql/data: | ||
{{ .Vars.primary.persistence.mountPath }}: | ||
exists: true | ||
filetype: directory | ||
mode: "2775" | ||
owner: root | ||
/dev/shm: | ||
exists: true | ||
filetype: directory | ||
mode: "3777" | ||
owner: root | ||
/opt/bitnami/postgresql/conf/postgresql.conf: | ||
exists: true | ||
filetype: file | ||
mode: "0664" | ||
group: root | ||
contains: | ||
- /shared_preload_libraries.*{{ .Vars.postgresqlSharedPreloadLibraries }}/ | ||
- /port.*{{ $port }}/ |
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,23 @@ | ||
auth: | ||
postgresPassword: "ComplicatedPassword123!4" | ||
username: test_user | ||
password: test_password | ||
database: test_database | ||
replicationUsername: test_repl_user | ||
containerPorts: | ||
postgresql: 5433 | ||
postgresqlSharedPreloadLibraries: "pgaudit, pg_stat_statements" | ||
primary: | ||
name: ptest | ||
podSecurityContext: | ||
fsGroup: 1002 | ||
containerSecurityContext: | ||
runAsUser: 1002 | ||
service: | ||
ports: | ||
postgresql: 5433 | ||
persistence: | ||
mountPath: /bitnami/postgresql | ||
readReplicas: | ||
name: rtest | ||
replicaCount: 2 |
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