Skip to content

Commit

Permalink
Merge branch 'master' into add_groups
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaUnisikhin committed Mar 19, 2024
2 parents 79f6dc0 + bf05761 commit 1680276
Show file tree
Hide file tree
Showing 54 changed files with 1,576 additions and 613 deletions.
2 changes: 2 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ 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

RUN curl -fsSL https://get.docker.com -o get-docker.sh && \
sudo sh get-docker.sh

COPY ./docker/pg/pg_hba-test.conf /etc/postgresql/14/main/pg_hba.conf

Expand All @@ -69,12 +73,16 @@ COPY --from=base /prep_stmts/pkg/pstmts-test /pstmts-test
COPY --from=base /config-validation/pkg/config-validation /config-validation
COPY ./docker/scram /scram
COPY ./docker/hba /hba
COPY ./docker/rule-address /rule-address
COPY ./docker/auth_query /auth_query
COPY ./docker/ldap /ldap
COPY ./docker/lagpolling /lagpolling
COPY ./docker/shell-test /shell-test
COPY ./docker/tsa /tsa
COPY ./docker/group /group
COPY ./docker/xproto /xproto
COPY ./docker/copy /copy
COPY ./docker/gorm /gorm

COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh

Expand Down
1 change: 0 additions & 1 deletion docker/auth_query/test_auth_query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ PGPASSWORD=passwd psql -h localhost -p 6432 -U auth_query_user_md5 -c "SELECT 1"
exit 1
}


ody-stop
34 changes: 33 additions & 1 deletion docker/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -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 group_db; do
for database_name in db scram_db ldap_db auth_query_db db1 hba_db tsa_db group_db addr_db xproto_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"
Expand Down Expand Up @@ -135,6 +135,30 @@ psql -h localhost -p 5432 -U postgres -c "create user user_allow password 'corr
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 "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
Expand All @@ -146,6 +170,14 @@ do
}
done

# Create tables
psql -h localhost -p 5432 -U postgres -d db -c "CREATE TABLE copy_test(c1 VARCHAR(50), c2 VARCHAR(50), c3 VARCHAR(50))" >> $SETUP_LOG 2>&1 || {
echo "ERROR: tables creation failed, examine the log"
cat "$SETUP_LOG"
cat "$PG_LOG"
exit 1
}

# 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 || {
Expand Down
87 changes: 87 additions & 0 deletions docker/copy/config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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_file "/var/log/odyssey.log"
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
47 changes: 47 additions & 0 deletions docker/copy/copy_test.sh
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@ then
exit 1
fi

# 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 ]
then
exit 1
fi

# odyssey target session attrs test
/tsa/tsa.sh
if [ $? -eq 1 ]
Expand Down
4 changes: 4 additions & 0 deletions docker/gorm/test.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions docker/ody-integration-test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.14

require (
github.com/jackc/pgproto3 v1.1.0
github.com/jackc/pgx/v4 v4.7.1
github.com/jackc/pgx/v4 v4.18.2
github.com/jmoiron/sqlx v1.2.0
github.com/lib/pq v1.3.0
github.com/lib/pq v1.10.2
google.golang.org/appengine v1.6.6 // indirect
)
Loading

0 comments on commit 1680276

Please sign in to comment.