Skip to content

Commit

Permalink
ParadeDB Test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
itay-grudev committed Sep 3, 2024
1 parent 24fb8cc commit 251345e
Show file tree
Hide file tree
Showing 21 changed files with 498 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: batch/v1
kind: Job
metadata:
name: minio-cleanup
status:
succeeded: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: batch/v1
kind: Job
metadata:
name: minio-cleanup
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: minio-cleanup
image: minio/mc
command: ['sh', '-c']
args:
- |
mc alias set myminio https://minio.minio.svc.cluster.local minio minio123
mc rm --recursive --force myminio/mybucket/paradedb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: paradedb-cluster
status:
readyInstances: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type: paradedb
mode: standalone
cluster:
instances: 2
storage:
size: 256Mi

backups:
enabled: true
provider: s3
endpointURL: "https://minio.minio.svc.cluster.local"
endpointCA:
name: kube-root-ca.crt
key: ca.crt
wal:
encryption: ""
data:
encryption: ""
s3:
bucket: "mybucket"
path: "/paradedb/v1"
accessKey: "minio"
secretKey: "minio123"
region: "local"
scheduledBackups: []
retentionPolicy: "30d"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: batch/v1
kind: Job
metadata:
name: paradedb-write
status:
succeeded: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: batch/v1
kind: Job
metadata:
name: paradedb-write
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: data-write
env:
- name: DB_URI
valueFrom:
secretKeyRef:
name: paradedb-cluster-app
key: uri
image: alpine:3.19
command: ['sh', '-c']
args:
- |
apk --no-cache add postgresql-client
psql "$DB_URI" <<-EOSQL
CALL paradedb.create_bm25_test_table( schema_name => 'public', table_name => 'mock_items' );
CALL paradedb.create_bm25(
index_name => 'search_idx',
schema_name => 'public',
table_name => 'mock_items',
key_field => 'id',
text_fields => paradedb.field('description', tokenizer => paradedb.tokenizer('en_stem')) ||
paradedb.field('category'),
numeric_fields => paradedb.field('rating')
);
EOSQL
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: batch/v1
kind: Job
metadata:
name: paradedb-test
status:
succeeded: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: batch/v1
kind: Job
metadata:
name: paradedb-test
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: data-test
env:
- name: DB_URI
valueFrom:
secretKeyRef:
name: paradedb-cluster-app
key: uri
image: alpine:3.19
command: ['sh', '-c']
args:
- |
apk --no-cache add postgresql-client
RESULT=$(psql "$DB_URI" -t) <<-EOSQL
SELECT description
FROM search_idx.search('description:"bluetooth speaker"~1');
EOSQL
echo -$RESULT-
test "$RESULT" = " Bluetooth-enabled speaker"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: batch/v1
kind: Job
metadata:
name: data-write
status:
succeeded: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: batch/v1
kind: Job
metadata:
name: data-write
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: data-write
env:
- name: DB_URI
valueFrom:
secretKeyRef:
name: paradedb-cluster-superuser
key: uri
image: alpine:3.19
command: ['sh', '-c']
args:
- |
apk --no-cache add postgresql-client kubectl
DB_URI=$(echo $DB_URI | sed "s|/\*|/|" )
psql "$DB_URI" -c "CREATE TABLE mygoodtable (id serial PRIMARY KEY);"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
name: post-init-backup
spec:
method: barmanObjectStore
cluster:
name: paradedb-cluster
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
name: post-init-backup
spec:
cluster:
name: paradedb-cluster
method: barmanObjectStore
status:
phase: completed
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
name: post-init-backup
spec:
cluster:
name: paradedb-cluster
method: barmanObjectStore
status:
phase: running
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: batch/v1
kind: Job
metadata:
name: backup-checkpoint
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: create-checkpoint
env:
- name: DB_URI
valueFrom:
secretKeyRef:
name: paradedb-cluster-superuser
key: uri
image: alpine:3.19
command: ['sh', '-c']
args:
- |
apk --no-cache add postgresql-client
DB_URI=$(echo $DB_URI | sed "s|/\*|/|" )
END_TIME=$(( $(date +%s) + 30 ))
while [ $(date +%s) -lt $END_TIME ]; do
psql "$DB_URI" -c "SELECT pg_switch_wal();CHECKPOINT;"
sleep 5
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: batch/v1
kind: Job
metadata:
name: data-write-post-backup
status:
succeeded: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: configmap-creator-sa
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: configmap-creator
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: configmap-creator-binding
subjects:
- kind: ServiceAccount
name: configmap-creator-sa
roleRef:
kind: Role
name: configmap-creator
apiGroup: rbac.authorization.k8s.io
---
apiVersion: batch/v1
kind: Job
metadata:
name: data-write-post-backup
spec:
template:
spec:
serviceAccountName: configmap-creator-sa
restartPolicy: OnFailure
containers:
- name: data-write
env:
- name: DB_URI
valueFrom:
secretKeyRef:
name: paradedb-cluster-superuser
key: uri
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: alpine:3.19
command: ['sh', '-c']
args:
- |
apk --no-cache add postgresql-client kubectl coreutils
DB_URI=$(echo $DB_URI | sed "s|/\*|/|" )
DATE_NO_BAD_TABLE=$(date --rfc-3339=ns)
sleep 30
psql "$DB_URI" -c "CREATE TABLE mybadtable (id serial PRIMARY KEY);"
kubectl create configmap date-no-bad-table --from-literal=date="$DATE_NO_BAD_TABLE"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: recovery-backup-pitr-cluster
status:
readyInstances: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
type: paradedb
mode: recovery

cluster:
instances: 2
storage:
size: 256Mi

recovery:
method: backup
backupName: "post-init-backup"
provider: s3
endpointURL: "https://minio.minio.svc.cluster.local"
endpointCA:
name: kube-root-ca.crt
key: ca.crt
wal:
encryption: ""
data:
encryption: ""
s3:
bucket: "mybucket"
path: "/paradedb/v1"
accessKey: "minio"
secretKey: "minio123"
region: "local"
scheduledBackups: []
retentionPolicy: "30d"

backups:
enabled: true
provider: s3
endpointURL: "https://minio.minio.svc.cluster.local"
endpointCA:
name: kube-root-ca.crt
key: ca.crt
wal:
encryption: ""
data:
encryption: ""
s3:
bucket: "mybucket"
path: "/paradedb/v2"
accessKey: "minio"
secretKey: "minio123"
region: "local"
scheduledBackups: []
retentionPolicy: "30d"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: batch/v1
kind: Job
metadata:
name: data-test-backup-pitr
status:
succeeded: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: batch/v1
kind: Job
metadata:
name: data-test-backup-pitr
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: data-test
env:
- name: DB_URI
valueFrom:
secretKeyRef:
name: recovery-backup-pitr-cluster-superuser
key: uri
image: alpine:3.19
command: ['sh', '-c']
args:
- |
apk --no-cache add postgresql-client
DB_URI=$(echo $DB_URI | sed "s|/\*|/|" )
set -e
test "$(psql $DB_URI -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mygoodtable$$)' --csv -q 2>/dev/null)" = "t"
echo "Good table exists"
test "$(psql $DB_URI -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mybadtable$$)' --csv -q 2>/dev/null)" = "f"
echo "Bad table does not exist"
Loading

0 comments on commit 251345e

Please sign in to comment.