-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from devilbox/release-0.2
Release 0.2
- Loading branch information
Showing
4 changed files
with
167 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "# --------------------------------------------------------------------------------------------------" | ||
echo "# Testing MySQL server version" | ||
echo "# --------------------------------------------------------------------------------------------------" | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
IMAGE="devilbox/mysql" | ||
TYPE="${1}" | ||
VERSION="${2}" | ||
|
||
|
||
if [ "${TYPE}" = "mysql" ]; then | ||
docker run --rm -it "${IMAGE}:${TYPE}-${VERSION}" -V | grep 'MySQL' | grep "${VERSION/./\\.}" | ||
elif [ "${TYPE}" = "mariadb" ]; then | ||
docker run --rm -it "${IMAGE}:${TYPE}-${VERSION}" -V | grep 'MariaDB' | grep "${VERSION/./\\.}" | ||
elif [ "${TYPE}" = "percona" ]; then | ||
docker run --rm -it "${IMAGE}:${TYPE}-${VERSION}" -V | grep 'Percona' | grep "${VERSION/./\\.}" | ||
else | ||
>&2 echo "[ERROR] Wrong type: ${TYPE}" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "# --------------------------------------------------------------------------------------------------" | ||
echo "# Testing mysqli connectivity to MySQL" | ||
echo "# --------------------------------------------------------------------------------------------------" | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
IMAGE="devilbox/mysql" | ||
TYPE="${1}" | ||
VERSION="${2}" | ||
|
||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" | ||
|
||
# Start MySQL | ||
docker run \ | ||
-d \ | ||
-it \ | ||
--rm \ | ||
--hostname=mysql \ | ||
--name devilbox-test-mysql \ | ||
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \ | ||
"${IMAGE}:${TYPE}-${VERSION}" | ||
|
||
# Start PHP 7.2 | ||
docker run \ | ||
-d \ | ||
-it \ | ||
--rm \ | ||
--hostname=php \ | ||
--entrypoint=bash \ | ||
--name devilbox-test-php \ | ||
--volume="${SCRIPTPATH}:/tmp" \ | ||
--link devilbox-test-mysql php:7.2 | ||
|
||
# Install PHP mysqli module | ||
docker exec -it devilbox-test-php docker-php-ext-install mysqli | ||
|
||
# Test MySQL connectivity | ||
max=100 | ||
i=0 | ||
while ! docker exec -it devilbox-test-php php /tmp/mysql.php >/dev/null 2>&1; do | ||
sleep 1 | ||
i=$(( i + 1)) | ||
if [ "${i}" -ge "${max}" ]; then | ||
docker stop devilbox-test-php || true | ||
docker stop devilbox-test-mysql || true | ||
>&2 echo "Failed" | ||
exit 1 | ||
fi | ||
done | ||
|
||
docker stop devilbox-test-php || true | ||
docker stop devilbox-test-mysql || true | ||
echo "Success" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
ini_set('display_startup_errors', 1); | ||
ini_set('display_errors', 1); | ||
error_reporting(-1); | ||
|
||
|
||
$MY_HOST = 'mysql'; | ||
$MY_USER = 'root'; | ||
$MY_PASS = ''; | ||
|
||
$link = mysqli_connect($MY_HOST, $MY_USER, $MY_PASS, 'mysql'); | ||
|
||
if (mysqli_connect_errno()) { | ||
echo 'FAIL'; | ||
exit(1); | ||
} | ||
|
||
$query = "SELECT * FROM `user` WHERE `User` = 'root';"; | ||
if (!$result = mysqli_query($link, $query)) { | ||
echo 'FAIL'; | ||
exit(1); | ||
} | ||
|
||
while ($row = $result->fetch_array(MYSQLI_ASSOC)) { | ||
$data[] = $row; | ||
} | ||
mysqli_free_result($result); | ||
mysqli_close($link); | ||
|
||
if (!isset($data[0])) { | ||
echo 'FAIL'; | ||
exit(1); | ||
} | ||
if ($data[0]['User'] == 'root') { | ||
echo 'OK'; | ||
exit(0); | ||
} else { | ||
echo 'FAIL'; | ||
exit(1); | ||
} |