Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add test for replication (rebased) #75

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -3,4 +3,4 @@ kind: Cluster
metadata:
name: paradedb-ncc-1701-d
status:
readyInstances: 1
readyInstances: 2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version:
major: "17"
paradedb: "0.13.2"
cluster:
instances: 1
instances: 2
storage:
size: 256Mi
imagePullSecrets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
schema_name => 'public',
table_name => 'mock_items_paradedb_enterprise'
);
CREATE INDEX search_idx_paradedb_enterprise_ ON mock_items_paradedb_enterprise
CREATE INDEX search_idx_paradedb_enterprise ON mock_items_paradedb_enterprise
USING bm25 (id, description, category, rating, in_stock, created_at, metadata, weight_range)
WITH (key_field='id');
EOSQL
Expand All @@ -35,4 +35,9 @@ spec:
LIMIT 1;
EOSQL
echo -$RESULT-
test "$RESULT" = " Bluetooth-enabled speaker"
if [ "$RESULT" = " Bluetooth-enabled speaker" ]; then
echo "Test for description search passed."
else
echo "Test for description search failed."
exit 1
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: batch/v1
kind: Job
metadata:
name: paradedb-enterprise-index-test
status:
succeeded: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: batch/v1
kind: Job
metadata:
name: paradedb-enterprise-index-test
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: data-test
env:
- name: DB_URI
valueFrom:
secretKeyRef:
name: paradedb-ncc-1701-d-app
key: uri
image: alpine:3.19
command: ['sh', '-c']
args:
- |
apk --no-cache add postgresql-client
DB_URI="${DB_URI/paradedb-ncc-1701-d-rw/paradedb-ncc-1701-d-ro}"
RESULT=$(psql "$DB_URI" -t) <<-EOSQL
SELECT description
FROM mock_items_paradedb_enterprise
WHERE description @@@ '"bluetooth speaker"~1'
LIMIT 1;
EOSQL
echo -$RESULT-
if [ "$RESULT" = " Bluetooth-enabled speaker" ]; then
echo "Test for description search on replicas passed."
else
echo "Test for description search on replicas failed."
exit 1
fi

SIZE_RESULT=$(psql "$DB_URI" -t) <<-EOSQL
SELECT pg_size_pretty(pg_relation_size('search_idx_paradedb_enterprise'));
EOSQL
echo -$SIZE_RESULT-
if [ "$SIZE_RESULT" != " 0 bytes" ]; then
echo "Test for index size on replicas passed."
else
echo "Test for index size on replicas failed."
exit 1
fi
19 changes: 19 additions & 0 deletions charts/paradedb/test/paradedb-enterprise/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ spec:
kind: Job
- podLogs:
selector: cnpg.io/cluster=paradedb-ncc-1701-d
- podLogs:
selector: batch.kubernetes.io/job-name=paradedb-enterprise-test
- name: Verify index replication
timeouts:
apply: 1s
assert: 30s
try:
- apply:
file: 03-paradedb_replication_test.yaml
- assert:
file: 03-paradedb_replication_test-assert.yaml
catch:
- describe:
apiVersion: batch/v1
kind: Job
- podLogs:
selector: cnpg.io/cluster=paradedb-ncc-1701-d
- podLogs:
selector: batch.kubernetes.io/job-name=paradedb-enterprise-index-test
- name: Cleanup
try:
- script:
Expand Down
Loading