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

Add pooler tests (LOCAL router) #932

Merged
merged 3 commits into from
Jan 11, 2025
Merged
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
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ coordinator_run:
pooler_run:
./spqr-router run --config ./examples/localrouter.yaml

pooler_d_run:
./spqr-router run --config ./examples/localrouter.yaml -d

####################### TESTS #######################

unittest:
Expand All @@ -91,6 +94,12 @@ unittest:
regress_local: proxy_2sh_run
./script/regress_local.sh

regress_pooler_local: pooler_d_run
./script/regress_pooler_local.sh

regress_pooler: build_images
docker compose -f test/regress/docker-compose.yaml down && docker compose -f test/regress/docker-compose.yaml run --build regress

regress: build_images
docker compose -f test/regress/docker-compose.yaml down && docker compose -f test/regress/docker-compose.yaml run --build regress

Expand Down
2 changes: 1 addition & 1 deletion examples/localrouter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ frontend_rules:
auth_rule:
auth_method: ok
password: strong
- pool_mode: SESSION
- pool_mode: TRANSACTION
pool_default: true
pool_prepared_statement: false
auth_rule:
Expand Down
16 changes: 16 additions & 0 deletions script/regress_pooler_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -ex

for name in `ls -1 test/regress/tests/pooler/sql/`;
do
echo $name start
cat test/regress/tests/pooler/sql/$name | psql "host=localhost port=6432 dbname=db1" --echo-all --quiet > test/regress/tests/pooler/expected/$(basename $name .sql).out 2>&1;
RESULT=$?
if [ ! $RESULT -eq 0 ]; then
exit 1
fi
echo $name done
done

killall -9 spqr-router
50 changes: 50 additions & 0 deletions test/regress/conf/localrouter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
host: 'regress_pooler'
log_level: debug

router_port: '6432'
admin_console_port: '7433'
grpc_api_port: '7001'


with_jaeger: true
world_shard_fallback: true
router_mode: LOCAL
time_quantiles:
- 0.5

frontend_tls:
key_file: /etc/spqr/ssl/server.key
cert_file: /etc/spqr/ssl/server.crt
sslmode: require
frontend_rules:
- db: regress
usr: regress
pool_mode: TRANSACTION
auth_rule:
auth_method: ok
- pool_mode: TRANSACTION
pool_default: true
pool_prepared_statement: false
auth_rule:
auth_method: ok
shards:
sh1:
db: regress
usr: regress
pwd: 12345678
type: DATA
hosts:
- 'spqr_shard_1:6432'

backend_rules:
- db: regress
usr: regress
pool_discard: true
pool_rollback: true
auth_rules:
sh1:
auth_method: md5
password: 12345678
sh2:
auth_method: md5
password: 12345678
15 changes: 15 additions & 0 deletions test/regress/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ services:
interval: 10s
timeout: 3s
retries: 50
pooler:
build:
dockerfile: ./docker/router/Dockerfile
context: ../../
ports:
- "6433:6432"
environment:
- ROUTER_CONFIG=/spqr/test/regress/conf/localrouter.yaml
- ROUTER_LOG=/var/log/spqr-router.log
hostname: regress_pooler
container_name: regress_pooler
depends_on:
shard1:
condition: service_healthy
router:
build:
dockerfile: ./docker/router/Dockerfile
Expand Down Expand Up @@ -77,3 +91,4 @@ services:
depends_on:
- router
- coordinator
- pooler
1 change: 1 addition & 0 deletions test/regress/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ run_tests () {

run_tests "console" "regress_router" "7432"
run_tests "router" "regress_router" "6432"
run_tests "pooler" "regress_pooler" "6432"
run_tests "coordinator" "regress_coordinator" "7002"

# test if diffs are empty
Expand Down
2 changes: 2 additions & 0 deletions test/regress/schedule/pooler
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

test: copy
8 changes: 8 additions & 0 deletions test/regress/tests/pooler/expected/copy.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BEGIN;
CREATE TABLE copy_test(id INTEGER);
SELECT FROM copy_test WHERE id = 29;
--
(0 rows)

COPY copy_test(id) FROM STDIN;
ROLLBACK;
17 changes: 17 additions & 0 deletions test/regress/tests/pooler/sql/copy.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

BEGIN;

CREATE TABLE copy_test(id INTEGER);

SELECT FROM copy_test WHERE id = 29;

COPY copy_test(id) FROM STDIN;
10
112
113
114
115
\.

ROLLBACK;

Loading