Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gorm tests #592

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 5 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
250 changes: 129 additions & 121 deletions 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 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"
Expand All @@ -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
# }
Loading
Loading