Skip to content

Commit a8513f9

Browse files
Update install-package-tests to wait until MySQL is ready to accept connections (#167)
* wait until MySQL accepts connections * Bail after 60 seconds * Increase to 3 minutes --------- Co-authored-by: Daniel Bachhuber <[email protected]>
1 parent 740af0d commit a8513f9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bin/install-package-tests

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ if [ -n "${WP_CLI_TEST_DBPASS}" ]; then
4747
TEST_PASSWORD="${WP_CLI_TEST_DBPASS}"
4848
fi
4949

50+
echo 'Checking if MySQL is ready...'
51+
while ! mysql --user="${USER}" "${PASSWORD_STRING}" --execute="SHOW DATABASES;" | grep 'information_schema' >/dev/null;
52+
do
53+
echo 'Waiting for MySQL...'
54+
sleep 5
55+
let "i+=1"
56+
if [ $i -gt 36 ]; then
57+
echo 'MySQL failed to start. Aborting.'
58+
exit 1
59+
fi
60+
done
61+
5062
# Prepare the database for running the tests with a MySQL version 8.0 or higher.
5163
install_mysql_db_8_0_plus() {
5264
set -ex

0 commit comments

Comments
 (0)