diff --git a/docker/Dockerfile b/docker/Dockerfile index b8cea896..80d8e16b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -80,6 +80,7 @@ COPY ./docker/lagpolling /lagpolling COPY ./docker/shell-test /shell-test COPY ./docker/tsa /tsa COPY ./docker/xproto /xproto +COPY ./docker/copy /copy COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh diff --git a/docker/bin/setup b/docker/bin/setup index ca9bfeee..40e58698 100755 --- a/docker/bin/setup +++ b/docker/bin/setup @@ -135,6 +135,22 @@ psql -h localhost -p 5432 -U postgres -c "create user user_addr_correct passwor exit 1 } +# Create users +psql -h localhost -p 5432 -U postgres -c "create role xproto SUPERUSER LOGIN" -d xproto_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 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 @@ -171,20 +187,6 @@ psql -h localhost -p 5432 -U postgres -c "set password_encryption TO 'md5'; crea exit 1 } -psql -h localhost -p 5432 -U postgres -c "create role xproto SUPERUSER LOGIN" -d xproto_db >> $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 "create user \"spqr-console\"" -d "spqr-console" >> $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 || { diff --git a/docker/copy/config.conf b/docker/copy/config.conf new file mode 100644 index 00000000..a1ed7112 --- /dev/null +++ b/docker/copy/config.conf @@ -0,0 +1,86 @@ +pid_file "/tmp/odyssey.pid" +daemonize yes + +unix_socket_dir "/tmp" +unix_socket_mode "0644" + +log_format "%p %t %l [%i %s] (%c) %m\n" + +log_to_stdout no + +log_syslog no +log_syslog_ident "odyssey" +log_syslog_facility "daemon" + +log_debug no +log_config yes +log_session yes +log_query no +log_stats yes +stats_interval 60 +log_general_stats_prom yes +log_route_stats_prom no +promhttp_server_port 7777 + +workers "auto" +resolvers 1 + +readahead 8192 + +cache_coroutine 0 + +coroutine_stack_size 16 + +nodelay yes + +keepalive 15 +keepalive_keep_interval 75 +keepalive_probes 9 + +keepalive_usr_timeout 0 + +listen { + host "*" + port 6432 + backlog 128 + compression yes + tls "disable" +} + + +storage "postgres_server" { + type "remote" + host "[localhost]:5432,localhost" + port 5550 +} + +database "db" { + user "postgres" { + authentication "none" + storage "postgres_server" + pool "transaction" + pool_discard no + pool_reserve_prepared_statement yes + client_fwd_error yes + } +} + +storage "local" { + type "local" +} + +database "console" { + user default { + authentication "none" + role "admin" + pool "session" + storage "local" + } +} + + +locks_dir "/tmp/odyssey" + +graceful_die_on_errors yes +enable_online_restart no +bindwith_reuseport yes diff --git a/docker/copy/copy_test.sh b/docker/copy/copy_test.sh new file mode 100755 index 00000000..ab50f756 --- /dev/null +++ b/docker/copy/copy_test.sh @@ -0,0 +1,47 @@ +#!/bin/bash -x + +set -ex + +test_successful() { + (for i in {1..1000}; do + echo "run_id_${i},task_id_${i},Some random ${i}th text"; + done | psql postgresql://postgres@localhost:6432/db -c "COPY copy_test FROM STDIN (FORMAT csv);";) > /dev/null 2>&1 || { + echo 1 + return + } + echo 0 +} + +/usr/bin/odyssey /copy/config.conf +with_pstmts_test_successful=$(test_successful) +ody-stop + +sed -i '/pool_reserve_prepared_statement yes/d' /copy/config.conf + +/usr/bin/odyssey /copy/config.conf +without_pstmts_test_successful=$(test_successful) +ody-stop + +if [ $with_pstmts_test_successful -eq 1 -a $without_pstmts_test_successful -eq 0 ]; then { + echo "ERROR: copy bug when pool_reserve_prepared_statement setting to yes" + + cat /var/log/odyssey.log + echo " + + " + cat /var/log/postgresql/postgresql-14-main.log + + exit 1 +} fi + +if [ $with_pstmts_test_successful -eq 1 -o $without_pstmts_test_successful -eq 1 ]; then { + echo "ERROR: copy bug" + + cat /var/log/odyssey.log + echo " + + " + cat /var/log/postgresql/postgresql-14-main.log + + exit 1 +} fi diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index d2a7c20b..1639c131 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -6,11 +6,23 @@ cd /test_dir/test && /usr/bin/odyssey_test setup +# gorm +ody-start +/gorm/test.sh +ody-stop + # proto ody-start /xproto/test.sh ody-stop +# copy +/copy/copy_test.sh +if [ $? -eq 1 ] +then + exit 1 +fi + # odyssey rule-address test /rule-address/test.sh if [ $? -eq 1 ] @@ -86,4 +98,4 @@ ody-start /ody-integration-test ody-stop -teardown \ No newline at end of file +teardown diff --git a/docker/gorm/test.sh b/docker/gorm/test.sh new file mode 100755 index 00000000..2537647e --- /dev/null +++ b/docker/gorm/test.sh @@ -0,0 +1,4 @@ +git clone https://github.com/pg-sharding/gorm-spqr.git /gorm/gorm-spqr +docker build -t gorm-tests /gorm/gorm-spqr +rm -rf /gorm/gorm-spqr +docker run -e DB_HOST='odyssey' -e DB_PORT=6432 -e DB_USER='spqr-console' -e DB_NAME='spqr-console' -e EXTRA_PARAMS='client_encoding=UTF8' --network=odyssey_od_net gorm-tests \ No newline at end of file diff --git a/docker/odyssey.conf b/docker/odyssey.conf index 45a8d5a5..ad696b02 100644 --- a/docker/odyssey.conf +++ b/docker/odyssey.conf @@ -58,4 +58,4 @@ database "console" { pool "session" storage "local" } -} +} \ No newline at end of file