Skip to content

Commit

Permalink
Update install-package-tests to wait until MySQL is ready to accept c…
Browse files Browse the repository at this point in the history
…onnections (#167)

* wait until MySQL accepts connections

* Bail after 60 seconds

* Increase to 3 minutes

---------

Co-authored-by: Daniel Bachhuber <daniel.bachhuber@automattic.com>
  • Loading branch information
wojsmol and danielbachhuber committed Apr 12, 2023
1 parent 740af0d commit a8513f9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bin/install-package-tests
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ if [ -n "${WP_CLI_TEST_DBPASS}" ]; then
TEST_PASSWORD="${WP_CLI_TEST_DBPASS}"
fi

echo 'Checking if MySQL is ready...'
while ! mysql --user="${USER}" "${PASSWORD_STRING}" --execute="SHOW DATABASES;" | grep 'information_schema' >/dev/null;
do
echo 'Waiting for MySQL...'
sleep 5
let "i+=1"
if [ $i -gt 36 ]; then
echo 'MySQL failed to start. Aborting.'
exit 1
fi
done

# Prepare the database for running the tests with a MySQL version 8.0 or higher.
install_mysql_db_8_0_plus() {
set -ex
Expand Down

0 comments on commit a8513f9

Please sign in to comment.