Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaUnisikhin committed Mar 12, 2024
1 parent 8aa0a1a commit 33be10b
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 134 deletions.
254 changes: 127 additions & 127 deletions docker/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -58,82 +58,82 @@ 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

# # 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
# }
# 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 "create user \"spqr-console\";" >> $SETUP_LOG 2>&1 || {
Expand All @@ -143,54 +143,54 @@ psql -h localhost -p 5432 -U postgres -c "create user \"spqr-console\";" >> $SE
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
}
7 changes: 0 additions & 7 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ then
exit 1
fi

# copy
/copy/copy_test.sh
if [ $? -eq 1 ]
then
exit 1
fi

# gorm
ody-start
/gorm/test.sh
Expand Down

0 comments on commit 33be10b

Please sign in to comment.