Skip to content

Commit

Permalink
[bitnami/postgresql] Revisit tests (bitnami#12945)
Browse files Browse the repository at this point in the history
* [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
joancafom authored Oct 21, 2022
1 parent 1ea11eb commit 9da60d8
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 26 deletions.
60 changes: 40 additions & 20 deletions .vib/postgresql/goss/goss.yaml
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 }}/
23 changes: 23 additions & 0 deletions .vib/postgresql/goss/vars.yaml
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
7 changes: 4 additions & 3 deletions .vib/postgresql/vib-publish.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"url": "{SHA_ARCHIVE}",
"path": "/bitnami/postgresql"
},
"runtime_parameters": "YXV0aDoKICB1c2VybmFtZTogdXNlcgogIHBhc3N3b3JkOiBDb21wbGljYXRlZFBhc3N3b3JkMTIzNAogIGRhdGFiYXNlOiB0ZXN0X2RhdGFiYXNlCnByaW1hcnk6CiAgc2VydmljZToKICAgIHBvcnRzOgogICAgICBwb3N0Z3Jlc3FsOiA4MAogICAgdHlwZTogTG9hZEJhbGFuY2Vy",
"runtime_parameters": "YXJjaGl0ZWN0dXJlOiByZXBsaWNhdGlvbgphdXRoOgogIGVuYWJsZVBvc3RncmVzVXNlcjogdHJ1ZQogIHBvc3RncmVzUGFzc3dvcmQ6ICJDb21wbGljYXRlZFBhc3N3b3JkMTIzITQiCiAgdXNlcm5hbWU6IHRlc3RfdXNlcgogIHBhc3N3b3JkOiB0ZXN0X3Bhc3N3b3JkCiAgZGF0YWJhc2U6IHRlc3RfZGF0YWJhc2UKICByZXBsaWNhdGlvblVzZXJuYW1lOiB0ZXN0X3JlcGxfdXNlcgpjb250YWluZXJQb3J0czoKICBwb3N0Z3Jlc3FsOiA1NDMzCnBvc3RncmVzcWxTaGFyZWRQcmVsb2FkTGlicmFyaWVzOiAicGdhdWRpdCwgcGdfc3RhdF9zdGF0ZW1lbnRzIgpzaG1Wb2x1bWU6CiAgZW5hYmxlZDogdHJ1ZQpwcmltYXJ5OgogIG5hbWU6IHB0ZXN0CiAgcG9kU2VjdXJpdHlDb250ZXh0OgogICAgZW5hYmxlZDogdHJ1ZQogICAgZnNHcm91cDogMTAwMgogIGNvbnRhaW5lclNlY3VyaXR5Q29udGV4dDoKICAgIGVuYWJsZWQ6IHRydWUKICAgIHJ1bkFzVXNlcjogMTAwMgogIHNlcnZpY2U6CiAgICB0eXBlOiBMb2FkQmFsYW5jZXIKICAgIHBvcnRzOgogICAgICBwb3N0Z3Jlc3FsOiA1NDMzCiAgcGVyc2lzdGVuY2U6CiAgICBlbmFibGVkOiB0cnVlCiAgICBtb3VudFBhdGg6IC9iaXRuYW1pL3Bvc3RncmVzcWwKcmVhZFJlcGxpY2FzOgogIG5hbWU6IHJ0ZXN0CiAgcmVwbGljYUNvdW50OiAyCiAgc2VydmljZToKICAgIHR5cGU6IExvYWRCYWxhbmNlcgogICAgcG9ydHM6CiAgICAgIHBvc3RncmVzcWw6IDgw",
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
Expand All @@ -34,7 +34,7 @@
{
"action_id": "health-check",
"params": {
"endpoint": "lb-postgresql-tcp-postgresql"
"endpoint": "lb-postgresql-rtest-tcp-postgresql"
}
},
{
Expand All @@ -43,8 +43,9 @@
"resources": {
"path": "/.vib/postgresql/goss"
},
"vars_file": "vars.yaml",
"remote": {
"workload": "sts-postgresql"
"workload": "sts-postgresql-ptest"
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions .vib/postgresql/vib-verify.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"url": "{SHA_ARCHIVE}",
"path": "/bitnami/postgresql"
},
"runtime_parameters": "YXV0aDoKICB1c2VybmFtZTogdXNlcgogIHBhc3N3b3JkOiBDb21wbGljYXRlZFBhc3N3b3JkMTIzNAogIGRhdGFiYXNlOiB0ZXN0X2RhdGFiYXNlCnByaW1hcnk6CiAgc2VydmljZToKICAgIHBvcnRzOgogICAgICBwb3N0Z3Jlc3FsOiA4MAogICAgdHlwZTogTG9hZEJhbGFuY2Vy",
"runtime_parameters": "YXJjaGl0ZWN0dXJlOiByZXBsaWNhdGlvbgphdXRoOgogIGVuYWJsZVBvc3RncmVzVXNlcjogdHJ1ZQogIHBvc3RncmVzUGFzc3dvcmQ6ICJDb21wbGljYXRlZFBhc3N3b3JkMTIzITQiCiAgdXNlcm5hbWU6IHRlc3RfdXNlcgogIHBhc3N3b3JkOiB0ZXN0X3Bhc3N3b3JkCiAgZGF0YWJhc2U6IHRlc3RfZGF0YWJhc2UKICByZXBsaWNhdGlvblVzZXJuYW1lOiB0ZXN0X3JlcGxfdXNlcgpjb250YWluZXJQb3J0czoKICBwb3N0Z3Jlc3FsOiA1NDMzCnBvc3RncmVzcWxTaGFyZWRQcmVsb2FkTGlicmFyaWVzOiAicGdhdWRpdCwgcGdfc3RhdF9zdGF0ZW1lbnRzIgpzaG1Wb2x1bWU6CiAgZW5hYmxlZDogdHJ1ZQpwcmltYXJ5OgogIG5hbWU6IHB0ZXN0CiAgcG9kU2VjdXJpdHlDb250ZXh0OgogICAgZW5hYmxlZDogdHJ1ZQogICAgZnNHcm91cDogMTAwMgogIGNvbnRhaW5lclNlY3VyaXR5Q29udGV4dDoKICAgIGVuYWJsZWQ6IHRydWUKICAgIHJ1bkFzVXNlcjogMTAwMgogIHNlcnZpY2U6CiAgICB0eXBlOiBMb2FkQmFsYW5jZXIKICAgIHBvcnRzOgogICAgICBwb3N0Z3Jlc3FsOiA1NDMzCiAgcGVyc2lzdGVuY2U6CiAgICBlbmFibGVkOiB0cnVlCiAgICBtb3VudFBhdGg6IC9iaXRuYW1pL3Bvc3RncmVzcWwKcmVhZFJlcGxpY2FzOgogIG5hbWU6IHJ0ZXN0CiAgcmVwbGljYUNvdW50OiAyCiAgc2VydmljZToKICAgIHR5cGU6IExvYWRCYWxhbmNlcgogICAgcG9ydHM6CiAgICAgIHBvc3RncmVzcWw6IDgw",
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
Expand All @@ -34,7 +34,7 @@
{
"action_id": "health-check",
"params": {
"endpoint": "lb-postgresql-tcp-postgresql"
"endpoint": "lb-postgresql-rtest-tcp-postgresql"
}
},
{
Expand All @@ -43,8 +43,9 @@
"resources": {
"path": "/.vib/postgresql/goss"
},
"vars_file": "vars.yaml",
"remote": {
"workload": "sts-postgresql"
"workload": "sts-postgresql-ptest"
}
}
}
Expand Down

0 comments on commit 9da60d8

Please sign in to comment.