Files
wlan-cloud-helm/tip-wlan/charts/postgresql/templates/tests/test-postgres-record-insert-del.yaml
Max 83c14c6548 WIFI-1238 set all imagePullPolicies to Always (#38)
* set all imagePullPolicies to Always
* use chart-level and global image pull policy
* make images configurable
2020-12-23 12:13:09 +01:00

52 lines
1.7 KiB
YAML

{{- if .Values.testsEnabled -}}
# NOTE: For the test to work, make sure that the cluster-size remains the same
# if you are doing helm-del and then helm-install with existing pvc.
apiVersion: v1
kind: Pod
metadata:
name: {{ include "common.fullname" . }}-test-insertion-deletion
namespace: {{ include "common.namespace" . }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: {{ include "common.name" . }}-test-postgres-basic
image: {{ template "postgresql.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.pullPolicy }}
env:
- name: POSTGRES_USER
value: {{ include "postgresql.username" . | quote }}
{{- if .Values.usePasswordFile }}
- name: POSTGRES_PASSWORD_FILE
value: "/opt/bitnami/postgresql/secrets/postgresql-password"
{{- else }}
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "postgresql.secretName" . }}
key: postgresql-password
{{- end }}
command:
- sh
- -c
- |
PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ include "common.fullname" . }} -U $POSTGRES_USER << EOF
\l ;
DROP DATABASE IF EXISTS TEST;
CREATE DATABASE TEST;
\c test ;
CREATE TABLE IF NOT EXISTS TEST_TABLE (id int, name text);
\d ;
SELECT id,name FROM TEST_TABLE;
INSERT INTO TEST_TABLE VALUES (1, 'Test-user'), (2, 'User-2');
SELECT id,name FROM TEST_TABLE;
DELETE FROM TEST_TABLE where id=2;
SELECT id,name FROM TEST_TABLE;
DROP TABLE TEST_TABLE;
\c postgres;
DROP DATABASE test;
\l ;
\q
EOF
restartPolicy: Never
{{- end }}