Skip to content

Commit

Permalink
ci: fix docker replica mode test
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyang01 authored Dec 5, 2024
1 parent 7195cdb commit 69db038
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/replication-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ jobs:
- name: Verify initial replication
run: |
# Query source data & MyDuck data
# Query source data
SCHEMA=""
if [ "${{ matrix.source }}" = "mysql" ]; then
docker exec source-db mysql -uroot -proot test \
-e "SELECT * FROM items ORDER BY id;" | tee source_data.csv
docker exec myduck psql -U postgres -h 127.0.0.1 \
-c "\COPY (SELECT * FROM test.items ORDER BY id) TO STDOUT WITH CSV;" | tee myduck_data.csv
SCHEMA=test
else
docker exec source-db psql -U postgres -h 127.0.0.1 test \
-c "\COPY (SELECT * FROM items ORDER BY id) TO STDOUT WITH CSV;" | tee source_data.csv
docker exec myduck psql -U postgres -h 127.0.0.1 \
-c "\COPY (SELECT * FROM items ORDER BY id) TO STDOUT WITH CSV;" | tee myduck_data.csv
SCHEMA=public
fi
# Query MyDuck data
docker exec myduck psql -U postgres -h 127.0.0.1 \
-c "\COPY (SELECT * FROM ${SCHEMA}.items ORDER BY id) TO STDOUT WITH CSV;" | tee myduck_data.csv
# Compare data using DuckDB
duckdb --csv -c "
CREATE TABLE source AS FROM 'source_data.csv';
Expand All @@ -113,20 +113,23 @@ jobs:
- name: Test replication of new data
run: |
# Insert new data in source
SCHEMA=""
if [ "${{ matrix.source }}" = "mysql" ]; then
docker exec source-db mysql -uroot -proot test \
-e "INSERT INTO items VALUES (3, 'test3');"
SCHEMA=test
else
docker exec source-db psql -U postgres test \
-c "INSERT INTO items VALUES (3, 'test3');"
SCHEMA=public
fi
# Wait for replication
sleep 5
# Verify new data was replicated
docker exec myduck psql -t -U postgres -h 127.0.0.1 -c \
"SELECT COUNT(*) FROM items WHERE id = 3;" | tr -d ' ' | tee count.txt
"SELECT COUNT(*) FROM ${SCHEMA}.items WHERE id = 3;" | tr -d ' ' | tee count.txt
if grep -q '^1$' count.txt; then
echo 'Replication of new data verified successfully'
Expand All @@ -138,4 +141,4 @@ jobs:
- name: Cleanup
if: always()
run: |
docker rm -f source-db myduck || true
docker rm -f source-db myduck || true

0 comments on commit 69db038

Please sign in to comment.