diff --git a/docker-compose-test.yml b/docker-compose-test.yml index 117640d89..86b88ca1a 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -12,6 +12,8 @@ services: context: . environment: CMAKE_BUILD_TYPE: "${CMAKE_BUILD_TYPE:-Debug}" + volumes: + - /var/run/docker.sock:/var/run/docker.sock networks: od_net: ipv4_address: 192.168.233.15 diff --git a/docker/Dockerfile b/docker/Dockerfile index 43bd6397f..12357da09 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -49,7 +49,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libpq-dev \ vim \ postgresql-common \ - postgresql-server-dev-14 + postgresql-server-dev-14 \ + git COPY ./docker/pg/pg_hba-test.conf /etc/postgresql/14/main/pg_hba.conf @@ -59,6 +60,9 @@ RUN cd /test_dir && make run_test_prep && cp /test_dir/docker/bin/* /usr/bin/ RUN mkdir /tmp/odyssey +WORKDIR /gorm-tests +RUN git clone https://github.com/pg-sharding/gorm-spqr.git + COPY ./docker/odyssey.conf /etc/odyssey/odyssey.conf COPY ./docker/lagpolling/lag-conf.conf /etc/odyssey/lag-conf.conf COPY ./docker/prep_stmts/pstmts.conf /etc/odyssey/pstmts.conf diff --git a/docker/bin/setup b/docker/bin/setup index 5dfa81268..ebf4ce055 100755 --- a/docker/bin/setup +++ b/docker/bin/setup @@ -49,7 +49,7 @@ sudo -u postgres /usr/bin/pg_basebackup -D /var/lib/postgresql/14/repl -R -h loc sudo -u postgres /usr/lib/postgresql/14/bin/pg_ctl -D /var/lib/postgresql/14/repl/ -o '-p 5433' start # Create databases -for database_name in db scram_db ldap_db auth_query_db db1 hba_db tsa_db addr_db; do +for database_name in db scram_db ldap_db auth_query_db db1 hba_db tsa_db addr_db "spqr-console"; do sudo -u postgres createdb $database_name >> "$SETUP_LOG" 2>&1 || { echo "ERROR: 'createdb $database_name' failed, examine the log" cat "$SETUP_LOG" @@ -58,131 +58,139 @@ for database_name in db scram_db ldap_db auth_query_db db1 hba_db tsa_db addr_db } done -# pgbench initialization -mkdir /var/cores -sudo sysctl -w kernel.core_pattern=/var/cores/core.%p.%e -pgbench -i -h localhost -p 5432 -U postgres postgres +# # pgbench initialization +# mkdir /var/cores +# sudo sysctl -w kernel.core_pattern=/var/cores/core.%p.%e +# pgbench -i -h localhost -p 5432 -U postgres postgres + +# # Create users +# psql -h localhost -p 5432 -U postgres -c "set password_encryption = 'scram-sha-256'; create user scram_user password 'scram_user_password';" -d scram_db >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# # Create users +# psql -h localhost -p 5432 -U postgres -c "create role user1 with login;create role user_ro with login;create role user_rw with login;" -d ldap_db >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# # Create users +# psql -h localhost -p 5432 -U postgres -c "set password_encryption TO 'md5'; create user auth_query_user_md5 with password 'passwd'" -d postgres >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# # Create users +# psql -h localhost -p 5432 -U postgres -c "set password_encryption = 'scram-sha-256'; create user auth_query_user_scram_sha_256 with password 'passwd'" -d postgres >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# # Create users +# psql -h localhost -p 5432 -U postgres -c "GRANT ALL ON DATABASE db1 TO user1" -d postgres >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# # Create users +# psql -h localhost -p 5432 -U postgres -c "alter user user1 with connection limit 1000" -d postgres >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# # Create users +# psql -h localhost -p 5432 -U user1 -d db1 -c "CREATE SCHEMA sh1" >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# # Create users +# psql -h localhost -p 5432 -U postgres -c "create user user_allow password 'correct_password'; create user user_reject password 'correct_password'; create user user_unknown password 'correct_password';" >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# # Create users +# psql -h localhost -p 5432 -U postgres -c "create user user_addr_correct password 'correct_password'; create user user_addr_incorrect password 'correct_password'; create user user_addr_default password 'correct_password'; create user user_addr_empty password 'correct_password'; create user user_addr_hostname_localhost password 'correct_password';" >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } # Create users -psql -h localhost -p 5432 -U postgres -c "set password_encryption = 'scram-sha-256'; create user scram_user password 'scram_user_password';" -d scram_db >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -# Create users -psql -h localhost -p 5432 -U postgres -c "create role user1 with login;create role user_ro with login;create role user_rw with login;" -d ldap_db >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -# Create users -psql -h localhost -p 5432 -U postgres -c "set password_encryption TO 'md5'; create user auth_query_user_md5 with password 'passwd'" -d postgres >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -# Create users -psql -h localhost -p 5432 -U postgres -c "set password_encryption = 'scram-sha-256'; create user auth_query_user_scram_sha_256 with password 'passwd'" -d postgres >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -# Create users -psql -h localhost -p 5432 -U postgres -c "GRANT ALL ON DATABASE db1 TO user1" -d postgres >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -# Create users -psql -h localhost -p 5432 -U postgres -c "alter user user1 with connection limit 1000" -d postgres >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -# Create users -psql -h localhost -p 5432 -U user1 -d db1 -c "CREATE SCHEMA sh1" >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -# Create users -psql -h localhost -p 5432 -U postgres -c "create user user_allow password 'correct_password'; create user user_reject password 'correct_password'; create user user_unknown password 'correct_password';" >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -# Create users -psql -h localhost -p 5432 -U postgres -c "create user user_addr_correct password 'correct_password'; create user user_addr_incorrect password 'correct_password'; create user user_addr_default password 'correct_password'; create user user_addr_empty password 'correct_password'; create user user_addr_hostname_localhost password 'correct_password';" >> $SETUP_LOG 2>&1 || { +psql -h localhost -p 5432 -U postgres -c "create user \"spqr-console\";" >> $SETUP_LOG 2>&1 || { echo "ERROR: users creation failed, examine the log" cat "$SETUP_LOG" cat "$PG_LOG" exit 1 } -for i in `seq 0 9` -do - # Create tables - psql -h localhost -p 5432 -U user1 -d db1 -c "CREATE TABLE sh1.foo$i (i int)" >> $SETUP_LOG 2>&1 || { - echo "ERROR: tables creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 - } -done - -# Create databases for ldap_storage_credentials -for database_name in ldap_db1 ldap_db2; do - sudo -u postgres createdb $database_name >> "$SETUP_LOG" 2>&1 || { - echo "ERROR: 'createdb $database_name' failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 - } -done - -# Create users for ldap_storage_credentials -psql -h localhost -p 5432 -U postgres -c "create user ldap_readonly with password 'ldap_pass_readonly'" -d ldap_db1 >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -psql -h localhost -p 5432 -U postgres -c "set password_encryption TO 'md5'; create user ldap_rw with password 'ldap_pass_rw'" -d ldap_db2 >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -# Grant access for ldap_storage_credentials - -psql -h localhost -p 5432 -U postgres -c "GRANT ALL ON DATABASE ldap_db1 TO ldap_readonly" -d postgres >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} - -psql -h localhost -p 5432 -U postgres -c "GRANT ALL ON DATABASE ldap_db2 TO ldap_rw" -d postgres >> $SETUP_LOG 2>&1 || { - echo "ERROR: users creation failed, examine the log" - cat "$SETUP_LOG" - cat "$PG_LOG" - exit 1 -} +# for i in `seq 0 9` +# do +# # Create tables +# psql -h localhost -p 5432 -U user1 -d db1 -c "CREATE TABLE sh1.foo$i (i int)" >> $SETUP_LOG 2>&1 || { +# echo "ERROR: tables creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } +# done + +# # Create databases for ldap_storage_credentials +# for database_name in ldap_db1 ldap_db2; do +# sudo -u postgres createdb $database_name >> "$SETUP_LOG" 2>&1 || { +# echo "ERROR: 'createdb $database_name' failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } +# done + +# # Create users for ldap_storage_credentials +# psql -h localhost -p 5432 -U postgres -c "create user ldap_readonly with password 'ldap_pass_readonly'" -d ldap_db1 >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# psql -h localhost -p 5432 -U postgres -c "set password_encryption TO 'md5'; create user ldap_rw with password 'ldap_pass_rw'" -d ldap_db2 >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# # Grant access for ldap_storage_credentials + +# psql -h localhost -p 5432 -U postgres -c "GRANT ALL ON DATABASE ldap_db1 TO ldap_readonly" -d postgres >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } + +# psql -h localhost -p 5432 -U postgres -c "GRANT ALL ON DATABASE ldap_db2 TO ldap_rw" -d postgres >> $SETUP_LOG 2>&1 || { +# echo "ERROR: users creation failed, examine the log" +# cat "$SETUP_LOG" +# cat "$PG_LOG" +# exit 1 +# } diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index fe4004f37..0cd30b6b2 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -2,83 +2,102 @@ 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 - +# # 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 + +# # copy +# /copy/copy_test.sh +# if [ $? -eq 1 ] +# then +# exit 1 +# fi + +# gorm 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 +curl -fsSL https://get.docker.com -o get-docker.sh +sudo sh get-docker.sh +docker build -t gorm-tests /gorm-tests/gorm-spqr +docker run -e DB_HOST='localhost' -e DB_PORT=6432 -e DB_USER='spqr-console' -e DB_NAME='spqr-console' --network=host gorm-tests 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 +# /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 +teardown