From 096dca073d26ed8cf1db9da6801038c3aadbab37 Mon Sep 17 00:00:00 2001 From: NikitaUnisikhin Date: Tue, 12 Mar 2024 20:25:54 +0000 Subject: [PATCH] refactoring, change docker-compose-test --- Makefile | 2 +- docker-compose-test.yml | 12 ++++ docker/Dockerfile | 8 +-- docker/entrypoint.sh | 144 ++++++++++++++++++++-------------------- docker/gorm/test.sh | 5 +- 5 files changed, 88 insertions(+), 83 deletions(-) diff --git a/Makefile b/Makefile index 1ce2e43cf..6f4c19772 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ run_test_prep: build_asan copy_asan_bin build_dbg copy_dbg_bin build_release cop run_test: # change dir, test would not work with absolute path ./cleanup-docker.sh - docker-compose -f ./docker-compose-test.yml up --exit-code-from odyssey + docker-compose -f ./docker-compose-test.yml up --exit-code-from odyssey odyssey openldapr submit-cov: mkdir cov-build && cd cov-build diff --git a/docker-compose-test.yml b/docker-compose-test.yml index 86b88ca1a..0dfb0a0ff 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -23,6 +23,18 @@ services: networks: od_net: ipv4_address: 192.168.233.16 + + gorm-test: + build: + context: https://github.com/pg-sharding/gorm-spqr.git#main + environment: + DB_HOST: "odyssey" + DB_PORT: "6432" + DB_USER: "spqr-console" + DB_NAME: "spqr-console" + networks: + od_net: + ipv4_address: 192.168.233.17 networks: od_net: diff --git a/docker/Dockerfile b/docker/Dockerfile index b6aa858eb..a14a6ff86 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -49,16 +49,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libpq-dev \ vim \ postgresql-common \ - postgresql-server-dev-14 \ - git + postgresql-server-dev-14 RUN curl -fsSL https://get.docker.com -o get-docker.sh && \ sudo sh get-docker.sh -RUN mkdir /gorm -RUN git clone https://github.com/pg-sharding/gorm-spqr.git /gorm/gorm-spqr -COPY ./docker/gorm /gorm - COPY ./docker/pg/pg_hba-test.conf /etc/postgresql/14/main/pg_hba.conf RUN mkdir test_dir @@ -83,6 +78,7 @@ COPY ./docker/ldap /ldap COPY ./docker/lagpolling /lagpolling COPY ./docker/shell-test /shell-test COPY ./docker/tsa /tsa +COPY ./docker/gorm /gorm COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index e4ad9ee2b..16fc34ec3 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -2,69 +2,69 @@ set -ex -# cd /test_dir/test && /usr/bin/odyssey_test +cd /test_dir/test && /usr/bin/odyssey_test setup -# # odyssey rule-address test -# /rule-address/test.sh -# if [ $? -eq 1 ] -# then -# exit 1 -# fi - -# # odyssey target session attrs test -# /tsa/tsa.sh -# if [ $? -eq 1 ] -# then -# exit 1 -# fi - -# ody-start -# /config-validation -# ody-stop - -# #ldap -# /ldap/test_ldap.sh -# if [ $? -eq 1 ] -# then -# exit 1 -# fi - -# # scram -# /scram/test_scram.sh -# if [ $? -eq 1 ] -# then -# exit 1 -# fi - -# # auth query -# /auth_query/test_auth_query.sh -# if [ $? -eq 1 ] -# then -# exit 1 -# fi - -# # odyssey hba test -# /hba/test.sh -# if [ $? -eq 1 ] -# then -# exit 1 -# fi - -# #prepared statements in transaction pooling -# /usr/bin/odyssey /etc/odyssey/pstmts.conf -# sleep 1 -# /pstmts-test - -# ody-stop - -# # lag polling -# /lagpolling/test-lag.sh -# if [ $? -eq 1 ] -# then -# exit 1 -# fi +# odyssey rule-address test +/rule-address/test.sh +if [ $? -eq 1 ] +then + exit 1 +fi + +# odyssey target session attrs test +/tsa/tsa.sh +if [ $? -eq 1 ] +then + exit 1 +fi + +ody-start +/config-validation +ody-stop + +#ldap +/ldap/test_ldap.sh +if [ $? -eq 1 ] +then + exit 1 +fi + +# scram +/scram/test_scram.sh +if [ $? -eq 1 ] +then + exit 1 +fi + +# auth query +/auth_query/test_auth_query.sh +if [ $? -eq 1 ] +then + exit 1 +fi + +# odyssey hba test +/hba/test.sh +if [ $? -eq 1 ] +then + exit 1 +fi + +#prepared statements in transaction pooling +/usr/bin/odyssey /etc/odyssey/pstmts.conf +sleep 1 +/pstmts-test + +ody-stop + +# lag polling +/lagpolling/test-lag.sh +if [ $? -eq 1 ] +then + exit 1 +fi # gorm ody-start @@ -75,19 +75,19 @@ then fi ody-stop -# /usr/bin/odyssey-asan /etc/odyssey/odyssey.conf -# ody-stop +/usr/bin/odyssey-asan /etc/odyssey/odyssey.conf +ody-stop -# # TODO: rewrite -# #/shell-test/test.sh -# /shell-test/console_role_test.sh -# /shell-test/parse_pg_options_test.sh -# /shell-test/override_pg_options_test.sh -# /shell-test/pool_size_test.sh -# ody-stop +# TODO: rewrite +#/shell-test/test.sh +/shell-test/console_role_test.sh +/shell-test/parse_pg_options_test.sh +/shell-test/override_pg_options_test.sh +/shell-test/pool_size_test.sh +ody-stop -# ody-start -# /ody-integration-test -# ody-stop +ody-start +/ody-integration-test +ody-stop teardown \ No newline at end of file diff --git a/docker/gorm/test.sh b/docker/gorm/test.sh index 10c13dcb2..26f4df7e7 100755 --- a/docker/gorm/test.sh +++ b/docker/gorm/test.sh @@ -1,4 +1 @@ -docker network create gorm_test -docker network connect gorm_test odyssey_odyssey_1 -docker build -t gorm-tests /gorm/gorm-spqr -docker run -e DB_HOST='odyssey' -e DB_PORT=6432 -e DB_USER='spqr-console' -e DB_NAME='spqr-console' --network=gorm_test gorm-tests +docker run -e DB_HOST='odyssey' -e DB_PORT=6432 -e DB_USER='spqr-console' -e DB_NAME='spqr-console' --network=odyssey_od_net gorm-tests