This repository was archived by the owner on Jan 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·54 lines (43 loc) · 1.31 KB
/
test.sh
File metadata and controls
executable file
·54 lines (43 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
set -o errexit
set -o nounset
HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# This just tests that we can connect to MySQL with an untrusted cert using the
# PHP image when MYSQL_ATTR_SSL_VERIFY_SERVER_CERT is set, which is what the
# patch we carry allows for.
IMG="$REGISTRY/$REPOSITORY:$TAG"
# NOTE: We use MySQL 5.7 because PHP cannot connect using MySQL's 8
# caching_sha2_password authentication.
MYSQL_IMG="quay.io/aptible/mysql:5.7"
MYSQL_CONTAINER='php-mysql-test'
PASSPHRASE="php-pass"
function cleanup {
echo "Cleaning up"
docker rm -f "$MYSQL_CONTAINER" >/dev/null 2>&1 || true
}
function wait_for_mysql {
for _ in $(seq 1 100); do
if docker exec -it "$MYSQL_CONTAINER" test -f /initialized && docker exec -it "$MYSQL_CONTAINER" mysqladmin ping >/dev/null 2>&1; then
return 0
fi
sleep 1
done
echo "MySQL never came online"
docker logs "$MYSQL_CONTAINER"
return 1
}
trap cleanup EXIT
cleanup
docker run -d \
-e "PASSPHRASE=${PASSPHRASE}" \
--name "$MYSQL_CONTAINER" \
--entrypoint bash \
"$MYSQL_IMG" \
-c 'run-database.sh --initialize && touch /initialized && exec run-database.sh'
wait_for_mysql
docker run --rm -it \
-e "PASSPHRASE=${PASSPHRASE}" \
-v "${HERE}/test.php:/test.php" \
--link "${MYSQL_CONTAINER}:mysql" \
"$IMG" \
php /test.php