Skip to content

Commit 65522dd

Browse files
authored
Add pure-sql comparison run to integration (#507)
* Add pure-sql comparison run to integration * rework sql to be a bit cleaner, one query per file * working sql suite, fully specified DSNs with gssenc disabled * CI rework * each integration in its own run * revert to shared suite, distributing artifacts is colossally slow * stub GSSEnc for psycopg * try draining and fixing out of sync errors * more draining * move python to restart the server before run, tweak logic change around errored connections * revert ensure_in_sync changes * ok I guess we dont get to keep it running
1 parent 347ddfa commit 65522dd

File tree

21 files changed

+641
-33
lines changed

21 files changed

+641
-33
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -138,48 +138,32 @@ jobs:
138138
fi
139139
echo "Using instrumented binary at $BIN_PATH"
140140
echo "PGDOG_BIN=$(realpath "$BIN_PATH")" >> "$GITHUB_ENV"
141-
- name: Load balancer
142-
run: bash integration/load_balancer/run.sh
143141
- name: pgbench
144142
run: bash integration/pgbench/run.sh
145-
- name: Verify coverage (pgbench)
146-
run: bash integration/verify_profiles.sh pgbench
147143
- name: Go
148144
run: bash integration/go/run.sh
149-
- name: Verify coverage (go)
150-
run: bash integration/verify_profiles.sh go
151145
- name: JavaScript
152146
run: bash integration/js/pg_tests/run.sh
153-
- name: Verify coverage (javascript)
154-
run: bash integration/verify_profiles.sh javascript
155-
- name: Toxi
156-
run: bash integration/toxi/run.sh
157-
- name: Verify coverage (toxi)
158-
run: bash integration/verify_profiles.sh toxi
159-
- name: Python
160-
run: bash integration/python/run.sh
161-
- name: Verify coverage (python)
162-
run: bash integration/verify_profiles.sh python
163147
- name: Ruby
164148
run: bash integration/ruby/run.sh
165-
- name: Verify coverage (ruby)
166-
run: bash integration/verify_profiles.sh ruby
167149
- name: Java
168150
run: bash integration/java/run.sh
169-
- name: Verify coverage (java)
170-
run: bash integration/verify_profiles.sh java
171-
- name: More complex stuff
172-
run: bash integration/complex/run.sh
173-
- name: Verify coverage (complex)
174-
run: bash integration/verify_profiles.sh complex
151+
- name: SQL
152+
run: bash integration/sql/run.sh
153+
- name: Toxi
154+
run: bash integration/toxi/run.sh
175155
- name: Rust
176156
run: bash integration/rust/run.sh
177-
- name: Verify coverage (rust)
178-
run: bash integration/verify_profiles.sh rust
157+
- name: Stop shared PgDog
158+
run: bash -lc 'source integration/common.sh; stop_pgdog'
159+
- name: Python
160+
run: bash integration/python/run.sh
161+
- name: Load balancer
162+
run: bash integration/load_balancer/run.sh
163+
- name: More complex stuff
164+
run: bash integration/complex/run.sh
179165
- name: Dry run
180166
run: bash integration/dry_run/run.sh
181-
- name: Verify coverage (dry_run)
182-
run: bash integration/verify_profiles.sh dry_run
183167
# - name: Plugins
184168
# run: bash integration/plugins/run.sh
185169
- name: Ensure PgDog stopped

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ CLAUDE.local.md
5353
pgdog-plugin/src/bindings.rs
5454
local/
5555
integration/log.txt
56+
.pycache

integration/common.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ function run_pgdog() {
5454
}
5555

5656
function stop_pgdog() {
57+
if [ "${PGDOG_KEEP_RUNNING:-0}" = "1" ]; then
58+
return
59+
fi
5760
local pid_file="${COMMON_DIR}/pgdog.pid"
5861
local config_file="${COMMON_DIR}/pgdog.config"
5962
if [ -f "${pid_file}" ]; then

integration/load_balancer/run.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,5 @@ popd
3737

3838
stop_pgdog
3939

40-
PGDOG_NO_RESTART=1 bash ${SCRIPT_DIR}/../verify_profiles.sh load_balancer
41-
4240
docker-compose down
4341
popd

integration/pgdog.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,33 @@ name = "sharded_uuid"
218218
column = "id_uuid"
219219
data_type = "uuid"
220220

221+
# ------------------------------------------------------------------------------
222+
# ----- SQL Regression Sample --------------------------------------------------
223+
224+
[[sharded_tables]]
225+
database = "pgdog_sharded"
226+
name = "sql_regression_sample"
227+
column = "id"
228+
data_type = "bigint"
229+
230+
[[sharded_mappings]]
231+
database = "pgdog_sharded"
232+
table = "sql_regression_sample"
233+
column = "id"
234+
kind = "range"
235+
start = 0
236+
end = 100
237+
shard = 0
238+
239+
[[sharded_mappings]]
240+
database = "pgdog_sharded"
241+
table = "sql_regression_sample"
242+
column = "id"
243+
kind = "range"
244+
start = 100
245+
end = 200
246+
shard = 1
247+
221248
# ------------------------------------------------------------------------------
222249
# ----- Range Sharded :: BIGINT ------------------------------------------------
223250

integration/python/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -e
2+
set -euo pipefail
33
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
44
source ${SCRIPT_DIR}/../common.sh
55

integration/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ pushd ${SCRIPT_DIR}
55
bash python/run.sh
66
bash ruby/run.sh
77
bash java/run.sh
8+
bash sql/run.sh
89
popd

integration/sql/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# SQL Regression Suite
2+
3+
This directory hosts the pure-SQL regression harness used to ensure PgDog matches the behaviour of direct PostgreSQL connections.
4+
5+
## Layout
6+
7+
- `cases/` – numbered SQL scenarios using the `00x_slug_(setup|case|teardown).sql` convention.
8+
- `global_setup.sql` / `global_teardown.sql` – optional hooks that run before/after every case.
9+
- `lib.py` – harness logic plus in-code definitions for the six comparison targets (DSNs disable GSS encryption so PgDog can proxy them).
10+
- `run.sh` / `dev.sh` – integration entrypoints matching the other language suites.
11+
- `test_sql_regression.py` – pytest runner that executes every case against all registered targets.
12+
13+
## Workflow
14+
15+
1. `run.sh` builds PgDog, starts the proxy, runs the suite, then shuts PgDog down.
16+
2. For each scenario the harness:
17+
- runs `global_setup.sql` (if present) and the scenario’s `*_setup.sql` through every distinct DSN used by the targets (shared once for baseline/pgdog, once for the sharded pool),
18+
- executes the `*_case.sql` statements against all six variants (baseline Postgres, PgDog, PgDog sharded × text/binary),
19+
- asserts that statement status, column names, column types, row counts, and row payloads are identical for every target,
20+
- runs the scenario’s `*_teardown.sql` and then `global_teardown.sql` (if present) across the same DSNs to leave databases clean.
21+
22+
Add more scenarios by dropping files into `cases/`:
23+
24+
```
25+
cases/
26+
002_select_edge_case_setup.sql # optional
27+
002_select_edge_case_case.sql # required
28+
002_select_edge_case_teardown.sql # optional
29+
```
30+
31+
Metadata lives in SQL comments at the top of the `*_case.sql` file:
32+
33+
```
34+
-- description: Exercise numeric encoding edge cases
35+
-- tags: standard sharded
36+
-- transactional: true
37+
-- skip-targets: pgdog_sharded_binary
38+
-- only-targets: postgres_standard_text pgdog_standard_text
39+
```
40+
41+
Tags are informative only. Use `skip-targets` to drop one or more target names, or `only-targets` to pin a case to a specific subset (order-sensitive). Set `transactional: false` when the statements must commit.

integration/sql/__init__.py

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- description: Simple smoke test ensuring identical behaviour for constants and table data
2+
-- tags: standard
3+
-- transactional: true
4+
5+
SELECT id, val, created_at FROM sql_regression_sample ORDER BY id;

0 commit comments

Comments
 (0)