Merge pull request #6 from levkk/levkk-ci-tests

End-to-end CI tests
This commit is contained in:
Lev Kokotov
2022-02-10 11:23:10 -08:00
committed by GitHub
2 changed files with 37 additions and 0 deletions

View File

@@ -10,18 +10,31 @@ jobs:
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
- image: cimg/rust:1.58.1
- image: cimg/postgres:14.0
auth:
username: mydockerhub-user
password: $DOCKERHUB_PASSWORD
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- checkout
- restore_cache:
key: cargo-lock-2-{{ checksum "Cargo.lock" }}
- run:
name: "Install dependencies"
command: "sudo apt-get update && sudo apt-get install -y postgresql-contrib-12 postgresql-client-12"
- run:
name: "Build"
command: "cargo build"
- run:
name: "Test"
command: "cargo test"
- run:
name: "Test end-to-end"
command: "bash .circleci/run_tests.sh"
- save_cache:
key: cargo-lock-2-{{ checksum "Cargo.lock" }}
paths:

24
.circleci/run_tests.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
set -e
set -o xtrace
./target/debug/pgcat &
sleep 1
psql -e -h 127.0.0.1 -p 5432 -U postgres -f tests/sharding/query_routing_setup.sql
# Setup PgBench
pgbench -i -h 127.0.0.1 -p 6432
# Run it
pgbench -h 127.0.0.1 -p 6432 -t 500 -c 2
psql -e -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_insert.sql
psql -e -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_select.sql > /dev/null
# psql -f tests/sharding/query_routing_test_validate.sql
psql -e -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_primary_replica.sql > /dev/null