From 89dc33f8aa3e02a081f31ad2e1e969a52b6249b4 Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 10:50:19 -0800 Subject: [PATCH 1/9] test ci --- .circleci/config.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 35826ec..75fdc09 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,20 +10,39 @@ 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: sharding_user + password: sharding_user + environment: + POSTGRES_USER: root + POSTGRES_DB: shard0 # 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" }} + key: cargo-lock-3-{{ checksum "Cargo.lock" }} + - run: + name: "Install dependencies" + command: "apt-get update && apt-get install postgresql-contrib-12 postgresql-client-12" - run: name: "Build" - command: "cargo build" + command: "cargo build --release" - run: name: "Test" command: "cargo test" + - run: + name: "Launch in background" + command: "./target/release/pgcat &" + - run: + name: "PgBench initialize" + command: "pgbench -i -h 127.0.0.1 -p 6432" + - run: + name: "PgBench run" + command: "pgbench -h 127.0.0.1 -p 6432 --protocol extended -t 100 -c 2" - save_cache: - key: cargo-lock-2-{{ checksum "Cargo.lock" }} + key: cargo-lock-3-{{ checksum "Cargo.lock" }} paths: - target - ~/.cargo From 17aed5dcee986d3d313673014a09067b6f8565ce Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 10:53:15 -0800 Subject: [PATCH 2/9] hmm --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75fdc09..df9968d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,10 +12,10 @@ jobs: - image: cimg/rust:1.58.1 - image: cimg/postgres:14.0 auth: - username: sharding_user - password: sharding_user + username: mydockerhub-user + password: $DOCKERHUB_PASSWORD environment: - POSTGRES_USER: root + POSTGRES_USER: sharding_user POSTGRES_DB: shard0 # Add steps to the job # See: https://circleci.com/docs/2.0/configuration-reference/#steps From 66c527145323feee0a734586cee19e10a971b9f6 Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 10:54:06 -0800 Subject: [PATCH 3/9] sudo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index df9968d..5de73fe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,7 +25,7 @@ jobs: key: cargo-lock-3-{{ checksum "Cargo.lock" }} - run: name: "Install dependencies" - command: "apt-get update && apt-get install postgresql-contrib-12 postgresql-client-12" + command: "sudo apt-get update && sudo apt-get install postgresql-contrib-12 postgresql-client-12" - run: name: "Build" command: "cargo build --release" From 86386c737761f9e96f295a9729f9f3f59102b56d Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 10:59:45 -0800 Subject: [PATCH 4/9] background --- .circleci/config.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5de73fe..e66f1d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,7 +25,7 @@ jobs: key: cargo-lock-3-{{ checksum "Cargo.lock" }} - run: name: "Install dependencies" - command: "sudo apt-get update && sudo apt-get install postgresql-contrib-12 postgresql-client-12" + command: "sudo apt-get update && sudo apt-get install -y postgresql-contrib-12 postgresql-client-12" - run: name: "Build" command: "cargo build --release" @@ -34,13 +34,7 @@ jobs: command: "cargo test" - run: name: "Launch in background" - command: "./target/release/pgcat &" - - run: - name: "PgBench initialize" - command: "pgbench -i -h 127.0.0.1 -p 6432" - - run: - name: "PgBench run" - command: "pgbench -h 127.0.0.1 -p 6432 --protocol extended -t 100 -c 2" + 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" - save_cache: key: cargo-lock-3-{{ checksum "Cargo.lock" }} paths: From 12011be3ec81fe0c6a43efebd7ab6a9cccd765bf Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 11:08:57 -0800 Subject: [PATCH 5/9] 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 From 9d51fe898522b991e11d2439cdef8309aaf8dfdf Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 11:11:56 -0800 Subject: [PATCH 6/9] print whats going on --- .circleci/run_tests.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/run_tests.sh b/.circleci/run_tests.sh index fe27634..2385644 100644 --- a/.circleci/run_tests.sh +++ b/.circleci/run_tests.sh @@ -1,12 +1,13 @@ #!/bin/bash set -e +set -o xtrace ./target/debug/pgcat & sleep 1 -psql -f tests/sharding/query_routing_setup.sql +psql -h 127.0.0.1 -p 5432 -f tests/sharding/query_routing_setup.sql # Setup PgBench pgbench -i -h 127.0.0.1 -p 6432 From 39028282b9d67dc3b5cb51bc03fb3fe20b992c9c Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 11:13:31 -0800 Subject: [PATCH 7/9] hmm --- .circleci/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/run_tests.sh b/.circleci/run_tests.sh index 2385644..2b752ab 100644 --- a/.circleci/run_tests.sh +++ b/.circleci/run_tests.sh @@ -7,7 +7,7 @@ set -o xtrace sleep 1 -psql -h 127.0.0.1 -p 5432 -f tests/sharding/query_routing_setup.sql +psql -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 From 604af32b9450c7ae54fb05fca59853e2216ea731 Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 11:16:08 -0800 Subject: [PATCH 8/9] print whats going on --- .circleci/run_tests.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/run_tests.sh b/.circleci/run_tests.sh index 2b752ab..1150862 100644 --- a/.circleci/run_tests.sh +++ b/.circleci/run_tests.sh @@ -7,7 +7,7 @@ set -o xtrace sleep 1 -psql -h 127.0.0.1 -p 5432 -U postgres -f tests/sharding/query_routing_setup.sql +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 @@ -15,10 +15,10 @@ 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 -e -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 -e -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 +psql -e -h 127.0.0.1 -p 6432 -f tests/sharding/query_routing_test_primary_replica.sql \ No newline at end of file From b9b89db708326e9d93b861183e93748d94990170 Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 10 Feb 2022 11:20:33 -0800 Subject: [PATCH 9/9] maybe were breaking the terminal? --- .circleci/run_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/run_tests.sh b/.circleci/run_tests.sh index 1150862..4307e42 100644 --- a/.circleci/run_tests.sh +++ b/.circleci/run_tests.sh @@ -17,8 +17,8 @@ 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 +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 \ No newline at end of file +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