From 12011be3ec81fe0c6a43efebd7ab6a9cccd765bf Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 11:08:57 -0800 Subject: [PATCH] tests --- .circleci/config.yml | 14 +++++++------- .circleci/run_tests.sh | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 .circleci/run_tests.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index e66f1d7..bd5b396 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,28 +15,28 @@ jobs: username: mydockerhub-user password: $DOCKERHUB_PASSWORD environment: - POSTGRES_USER: sharding_user - POSTGRES_DB: shard0 + 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-3-{{ checksum "Cargo.lock" }} + 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 --release" + command: "cargo build" - run: name: "Test" command: "cargo test" - run: - name: "Launch in background" - command: "./target/release/pgcat & pgbench -i -h 127.0.0.1 -p 6432 & pgbench -h 127.0.0.1 -p 6432 --protocol extended -t 100 -c 2" + name: "Test end-to-end" + command: "bash .circleci/run_tests.sh" - save_cache: - key: cargo-lock-3-{{ checksum "Cargo.lock" }} + key: cargo-lock-2-{{ checksum "Cargo.lock" }} paths: - target - ~/.cargo diff --git a/.circleci/run_tests.sh b/.circleci/run_tests.sh new file mode 100644 index 0000000..fe27634 --- /dev/null +++ b/.circleci/run_tests.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +./target/debug/pgcat & + +sleep 1 + +psql -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 -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_insert.sql + +psql -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_select.sql + +# psql -f tests/sharding/query_routing_test_validate.sql + +psql -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_primary_replica.sql \ No newline at end of file