Skip to content

Commit a3b910e

Browse files
authored
Merge pull request #6 from levkk/levkk-ci-tests
End-to-end CI tests
2 parents c6ccc6b + b9b89db commit a3b910e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

.circleci/config.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,31 @@ jobs:
1010
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
1111
docker:
1212
- image: cimg/rust:1.58.1
13+
- image: cimg/postgres:14.0
14+
auth:
15+
username: mydockerhub-user
16+
password: $DOCKERHUB_PASSWORD
17+
environment:
18+
POSTGRES_USER: postgres
19+
POSTGRES_DB: postgres
1320
# Add steps to the job
1421
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
1522
steps:
1623
- checkout
1724
- restore_cache:
1825
key: cargo-lock-2-{{ checksum "Cargo.lock" }}
26+
- run:
27+
name: "Install dependencies"
28+
command: "sudo apt-get update && sudo apt-get install -y postgresql-contrib-12 postgresql-client-12"
1929
- run:
2030
name: "Build"
2131
command: "cargo build"
2232
- run:
2333
name: "Test"
2434
command: "cargo test"
35+
- run:
36+
name: "Test end-to-end"
37+
command: "bash .circleci/run_tests.sh"
2538
- save_cache:
2639
key: cargo-lock-2-{{ checksum "Cargo.lock" }}
2740
paths:

.circleci/run_tests.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o xtrace
5+
6+
./target/debug/pgcat &
7+
8+
sleep 1
9+
10+
psql -e -h 127.0.0.1 -p 5432 -U postgres -f tests/sharding/query_routing_setup.sql
11+
12+
# Setup PgBench
13+
pgbench -i -h 127.0.0.1 -p 6432
14+
15+
# Run it
16+
pgbench -h 127.0.0.1 -p 6432 -t 500 -c 2
17+
18+
psql -e -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_insert.sql
19+
20+
psql -e -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_select.sql > /dev/null
21+
22+
# psql -f tests/sharding/query_routing_test_validate.sql
23+
24+
psql -e -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_primary_replica.sql > /dev/null

0 commit comments

Comments
 (0)