diff --git a/.circleci/config.yml b/.circleci/config.yml index 35826ec..bd5b396 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: diff --git a/.circleci/run_tests.sh b/.circleci/run_tests.sh new file mode 100644 index 0000000..4307e42 --- /dev/null +++ b/.circleci/run_tests.sh @@ -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 \ No newline at end of file