-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for custom startup scripts
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" | ||
|
||
IMAGE="${1}" | ||
VERSION="${2}" | ||
FLAVOUR="${3}" | ||
|
||
# shellcheck disable=SC1090 | ||
. "${CWD}/../.lib.sh" | ||
|
||
|
||
|
||
############################################################ | ||
# Tests | ||
############################################################ | ||
|
||
### | ||
### Check if PHP still starts up with working scripts | ||
### | ||
RUN_SH_HOST="$( mktemp -d )" | ||
RUN_SH_CONT="/startup.d" | ||
|
||
# Fix mount permissions | ||
chmod 0777 "${RUN_SH_HOST}" | ||
|
||
# Add a startup script to execute | ||
printf "#!/bin/bash\\necho 'abcdefghijklmnopq';\\n" > "${RUN_SH_HOST}/myscript1.sh" | ||
chmod +x "${RUN_SH_HOST}/myscript1.sh" | ||
|
||
# Start PHP-FPM | ||
did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${RUN_SH_HOST}:${RUN_SH_CONT}" )" | ||
|
||
# Wait for both containers to be up and running | ||
run "sleep 10" | ||
|
||
# Check entrypoint for script run | ||
if ! run "docker logs ${did} | grep 'myscript1.sh'"; then | ||
docker_logs "${did}" || true | ||
docker_stop "${did}" || true | ||
rm -rf "${RUN_SH_HOST}" | ||
echo "Failed" | ||
exit 1 | ||
fi | ||
|
||
# Check entrypoint for script output | ||
if ! run "docker logs ${did} | grep 'abcdefghijklmnopq'"; then | ||
docker_logs "${did}" || true | ||
docker_stop "${did}" || true | ||
rm -rf "${RUN_SH_HOST}" | ||
echo "Failed" | ||
exit 1 | ||
fi | ||
|
||
|
||
# Cleanup | ||
docker_stop "${did}" | ||
rm -rf "${RUN_SH_HOST}" |