Skip to content

Commit

Permalink
test setupscript fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mringler committed Nov 17, 2022
1 parent 69dcd5c commit 5df70ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions tests/bin/setup.mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ "$mysql" = "" ]; then
fi

if [ "$mysql" = "" ]; then
echo "Can not find mysql binary. Is it installed?";
echo "Cannot find mysql binary. Is it installed?";
exit 1;
fi

Expand All @@ -21,28 +21,29 @@ if [ "$DB_PW" != "" ]; then
fi

DB_HOSTNAME=${DB_HOSTNAME-127.0.0.1};
DB_NAME=${DB_NAME-test};

"$mysql" --version;

retry_count=0
while true; do
"$mysql" --host="$DB_HOSTNAME" -u"$DB_USER" $pw_option -e '
"$mysql" --host="$DB_HOSTNAME" -u"$DB_USER" $pw_option -e "
SET FOREIGN_KEY_CHECKS = 0;
DROP DATABASE IF EXISTS test;
DROP DATABASE IF EXISTS $DB_NAME;
DROP SCHEMA IF EXISTS second_hand_books;
DROP SCHEMA IF EXISTS contest;
DROP SCHEMA IF EXISTS bookstore_schemas;
DROP SCHEMA IF EXISTS migration;
SET FOREIGN_KEY_CHECKS = 1;
'
"
if [ $? -eq 0 ] || [ $retry_count -ge 6 ]; then break; fi
retry_count=$((retry_count + 1))
sleep "$(awk "BEGIN{print 2 ^ $retry_count}")"
done

"$mysql" --host="$DB_HOSTNAME" -u"$DB_USER" $pw_option -e "
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
CREATE DATABASE test;
CREATE DATABASE $DB_NAME;
CREATE SCHEMA bookstore_schemas;
CREATE SCHEMA contest;
CREATE SCHEMA second_hand_books;
Expand Down
4 changes: 2 additions & 2 deletions tests/bin/setup.pgsql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ fi

"$psql" --version;

dropdb --host="$DB_HOSTNAME" --username="$DB_USER" "$NO_PWD" "$DB_NAME";
dropdb --host="$DB_HOSTNAME" --username="$DB_USER" $NO_PWD "$DB_NAME";

createdb --host="$DB_HOSTNAME" --username="$DB_USER" "$NO_PWD" "$DB_NAME";
createdb --host="$DB_HOSTNAME" --username="$DB_USER" $NO_PWD "$DB_NAME";

"$psql" --host="$DB_HOSTNAME" --username="$DB_USER" -c '
CREATE SCHEMA bookstore_schemas;
Expand Down

0 comments on commit 5df70ef

Please sign in to comment.