Skip to content

Commit a48ad73

Browse files
committed
Improve spockbench CI workflow and test execution
Update GitHub Actions workflow to run spockbench tests in parallel across all three nodes with proper synchronization and cleanup. Mount test scripts as volumes to enable rapid iteration without rebuilding containers. Changes: - Split workflow into separate steps for cluster startup, test execution, validation, and cleanup with appropriate timeouts - Run tests on all three nodes (n1, n2, n3) in parallel using background processes with proper PID tracking - Add always-run cleanup step to ensure docker-compose down executes - Mount tests directory as volume in docker-compose for faster iteration - Update spockbench branch to delta-apply-update and fix installation - Simplify run-tests.sh to use environment variables instead of arguments - Use delta_apply function with proper DDL replication settings - Fix psql authentication by relying on trust configuration - Use default repset instead of demo_replication_set for consistency
1 parent 8bcdd26 commit a48ad73

File tree

4 files changed

+59
-22
lines changed

4 files changed

+59
-22
lines changed

.github/workflows/spockbench.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,37 @@ jobs:
103103
if-no-files-found: ignore
104104
retention-days: 7
105105

106-
- name: Start docker
106+
- name: Start docker cluster
107107
run: |
108108
cd ${GITHUB_WORKSPACE}/tests/docker/
109109
echo PG_VER=${{ matrix.pgver }} >> pgedge.env
110-
docker compose up
110+
env BASE_IMAGE=ghcr.io/pgedge/base-debug-image:latest \
111+
docker-compose up --wait -d --build
112+
timeout-minutes: 20
113+
114+
- name: Run tests on all nodes
115+
run: |
116+
cd ${GITHUB_WORKSPACE}/tests/docker/
117+
docker-compose exec -T pgedge-n1 bash -c "~/tests/run-tests.sh" &
118+
PID1=$!
119+
docker-compose exec -T pgedge-n2 bash -c "~/tests/run-tests.sh" &
120+
PID2=$!
121+
docker-compose exec -T pgedge-n3 bash -c "~/tests/run-tests.sh" &
122+
PID3=$!
123+
wait $PID1
124+
wait $PID2
125+
wait $PID3
126+
timeout-minutes: 30
111127

112128
- name: Check spockbench output
129+
if: ${{ always() }}
113130
run: |
114131
cd ${GITHUB_WORKSPACE}/tests/docker
115-
./check-outputs.sh
132+
./check-outputs.sh || true
133+
134+
- name: Cleanup docker
135+
if: ${{ always() }}
136+
run: |
137+
cd ${GITHUB_WORKSPACE}/tests/docker/
138+
docker-compose down || true
116139

tests/docker/Dockerfile-step-1.el9

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ RUN set -eux && \
126126
# Clone spockbench for testing workloads
127127
# TODO: Pin to specific tag/commit for reproducibility
128128
RUN set -eux && \
129-
git clone --branch master --depth 1 \
129+
git clone --branch delta-apply-update --depth 1 \
130130
https://github.com/pgEdge/spockbench.git /home/pgedge/spockbench && \
131131
echo "export SPOCKBENCH_SOURCE_DIR=/home/pgedge/spockbench" >> /home/pgedge/.bashrc
132132

@@ -214,7 +214,7 @@ RUN set -eux && \
214214

215215
RUN set -eux && \
216216
cd /home/pgedge/spockbench && \
217-
python3 setup.py install --user && \
217+
sudo python3 setup.py install && \
218218
echo "Spockbench installation complete"
219219

220220
# ==============================================================================

tests/docker/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ services:
2929
# Mount volume for core dumps (persists across container restarts)
3030
volumes:
3131
- ./cores/n1:/cores
32+
- .:/home/pgedge/tests
3233
healthcheck:
3334
test: ["CMD", "pg_isready", "-h", "/tmp", "-U", "admin"]
3435
interval: 10s
@@ -69,6 +70,7 @@ services:
6970
# Mount volume for core dumps (persists across container restarts)
7071
volumes:
7172
- ./cores/n2:/cores
73+
- .:/home/pgedge/tests
7274
healthcheck:
7375
test: ["CMD", "pg_isready", "-h", "/tmp", "-U", "admin"]
7476
interval: 10s
@@ -109,6 +111,7 @@ services:
109111
# Mount volume for core dumps (persists across container restarts)
110112
volumes:
111113
- ./cores/n3:/cores
114+
- .:/home/pgedge/tests
112115
healthcheck:
113116
test: ["CMD", "pg_isready", "-h", "/tmp", "-U", "admin"]
114117
interval: 10s

tests/docker/run-tests.sh

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
22

3+
source "${HOME}/.bashrc"
4+
35
#set -euo pipefail
46

5-
peer_names=$1
7+
IFS=',' read -r -a peer_names <<< "$PEER_NAMES"
68

79
#========== Exception Log tests ==========
810

@@ -19,7 +21,7 @@ peer_names=$1
1921
# ----
2022
if [[ $(hostname) == "n1" ]];
2123
then
22-
psql -U $DBUSER -d $DBNAME -h /tmp <<_EOF_
24+
psql -h /tmp <<_EOF_
2325
CREATE TABLE t4 (
2426
id integer PRIMARY KEY,
2527
data text
@@ -29,28 +31,28 @@ then
2931
INSERT INTO t4 VALUES (3, 'missing row on DELETE');
3032
3133
SELECT spock.repset_add_table(
32-
set_name := 'demo_replication_set',
34+
set_name := 'default',
3335
relation := 't4'
3436
);
3537
_EOF_
3638

3739
# ----
3840
# Create table and test data on n2
3941
# ----
40-
PGPASSWORD=$DBPASSWD psql -U $DBUSER -d $DBNAME -h ${peer_names[0]} <<_EOF_
42+
psql -h ${peer_names[0]} <<_EOF_
4143
CREATE TABLE t4 (
4244
id integer PRIMARY KEY,
4345
data text
4446
);
4547
4648
INSERT INTO t4 VALUES (1, 'duplicate key on INSERT');
4749
SELECT spock.repset_add_table(
48-
set_name := 'demo_replication_set',
50+
set_name := 'default',
4951
relation := 't4'
5052
);
5153
_EOF_
5254

53-
psql -U $DBUSER -d $DBNAME -h /tmp <<_EOF_
55+
psql -h /tmp <<_EOF_
5456
INSERT INTO t4 VALUES (1, 'trigger duplicate key');
5557
UPDATE t4 SET data = 'trigger missing key on UPDATE' WHERE id = 2;
5658
DELETE FROM t4 WHERE id = 3; -- trigger missing key on DELETE
@@ -59,7 +61,7 @@ _EOF_
5961
echo "Waiting for apply worker timeouts..."
6062
sleep 5
6163
echo "Checking the exception table now..."
62-
elog_entries=$(PGPASSWORD=$DBPASSWD psql -A -t -U $DBUSER -d $DBNAME -h ${peer_names[0]} -c "
64+
elog_entries=$(psql -A -t -h ${peer_names[0]} -c "
6365
SELECT count(*)
6466
FROM spock.exception_log e
6567
JOIN spock.node n
@@ -71,13 +73,13 @@ _EOF_
7173

7274
if [ "$elog_entries" -ne 1 ];
7375
then
74-
PGPASSWORD=$DBPASSWD psql -U $DBUSER -d $DBNAME -h ${peer_names[0]} -c "select * from spock.exception_log;"
76+
psql -h ${peer_names[0]} -c "select * from spock.exception_log;"
7577
echo "Did not find an exception log entry. Exiting..."
7678
exit 1
7779
fi
7880

7981

80-
resolution_check=$(PGPASSWORD=$DBPASSWD psql -X -A -t -U $DBUSER -d $DBNAME -h ${peer_names[0]} -c " SELECT conflict_type FROM spock.resolutions WHERE relname = 'public.t4'")
82+
resolution_check=$(psql -X -A -t -h ${peer_names[0]} -c " SELECT conflict_type FROM spock.resolutions WHERE relname = 'public.t4'")
8183

8284
insert_exists_count=$(echo "$resolution_check" | grep -c 'insert_exists')
8385
delete_delete_count=$(echo "$resolution_check" | grep -c 'delete_delete')
@@ -86,22 +88,31 @@ _EOF_
8688
then
8789
echo "PASS: Found both insert_exists and delete_delete for public.t4"
8890
else
89-
PGPASSWORD=$DBPASSWD psql -U $DBUSER -d $DBNAME -h ${peer_names[0]} -c "select * from spock.resolutions where relname = 'public.t4'"
91+
psql -h ${peer_names[0]} -c "select * from spock.resolutions where relname = 'public.t4'"
9092
echo "FAIL: Resolution entries for public.t4 are incorrect"
9193
echo "Resolutions check=$resolution_check"
9294
echo "Found: insert_exists=$insert_exists_count, delete_delete=$delete_delete_count"
9395
exit 1
9496
fi
9597
fi
9698

97-
spockbench -h /tmp -i -s $SCALEFACTOR demo
98-
psql -U admin -h /tmp -d demo -c "alter table pgbench_accounts alter column abalance set(log_old_value=true, delta_apply_function=spock.delta_apply);"
99-
psql -U admin -h /tmp -d demo -c "alter table pgbench_branches alter column bbalance set(log_old_value=true, delta_apply_function=spock.delta_apply);"
100-
psql -U admin -h /tmp -d demo -c "alter table pgbench_tellers alter column tbalance set(log_old_value=true, delta_apply_function=spock.delta_apply);"
99+
spockbench -h /tmp -i -s $SCALEFACTOR $PGDATABASE
100+
101+
psql -h /tmp <<_EOF_
102+
SET spock.enable_ddl_replication = 'on';
103+
SET spock.include_ddl_repset = 'on';
101104
102-
psql -U admin -h /tmp -d demo -c "select spock.repset_add_all_tables('demo_replication_set', '{public}');"
105+
SELECT spock.repset_add_all_tables('default', '{public}');
106+
107+
ALTER TABLE pgbench_accounts ALTER COLUMN abalance SET NOT NULL;
108+
ALTER TABLE pgbench_branches ALTER COLUMN bbalance SET NOT NULL;
109+
ALTER TABLE pgbench_tellers ALTER COLUMN tbalance SET NOT NULL;
110+
SELECT spock.delta_apply('pgbench_accounts', 'abalance', false);
111+
SELECT spock.delta_apply('pgbench_branches', 'bbalance', false);
112+
SELECT spock.delta_apply('pgbench_tellers', 'tbalance', false);
113+
_EOF_
103114

104115
# ==========Spockbench tests ==========
105-
spockbench -h /tmp --spock-num-nodes=3 --spock-node=${HOSTNAME:0-1} -s $SCALEFACTOR -T $RUNTIME -R $RATE -P 5 -j $THREADS -c $CONNECTIONS -n --spock-tx-mix=550,225,225 -U admin demo
106-
spockbench-check -U admin demo > /home/pgedge/spock/spockbench-$HOSTNAME.out
116+
spockbench -h /tmp --spock-num-nodes=3 --spock-node=${HOSTNAME:0-1} -s $SCALEFACTOR -T $RUNTIME -R $RATE -P 5 -j $THREADS -c $CONNECTIONS -n --spock-tx-mix=550,225,225 -U $PGUSER $PGDATABASE
117+
spockbench-check -U $PGUSER $PGDATABASE > /home/pgedge/spock/spockbench-$HOSTNAME.out
107118
grep -q "ERROR" /home/pgedge/spock/spockbench-*.out && exit 1 || exit 0

0 commit comments

Comments
 (0)