Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions tests/00.sh → tests/00-test-html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ TAG="${4}"
ARCH="${5}"


HOST_PORT="8093"

###
### Load Library
###
Expand All @@ -26,15 +28,15 @@ ARCH="${5}"
###
RAND_DIR="$( mktemp -d )"
RAND_NAME="$( get_random_name )"
run "echo \"hello world\" > ${RAND_DIR}/index.html"
run "echo \"hello world via html\" > ${RAND_DIR}/index.html"


###
### Startup container
###
run "docker run --rm --platform ${ARCH} \
-v ${RAND_DIR}:/var/www/default/htdocs \
-p 127.0.0.1:80:80 \
-p 127.0.0.1:${HOST_PORT}:80 \
-e DEBUG_ENTRYPOINT=2 \
-e DEBUG_RUNTIME=1 \
-e NEW_UID=$( id -u ) \
Expand All @@ -45,20 +47,22 @@ run "docker run --rm --platform ${ARCH} \
###
### Tests
###
run "sleep 20" # Startup-time is longer on cross-platform
run "docker ps"
if ! run "docker logs ${RAND_NAME}"; then
exit 1
fi
if ! run "curl -sS localhost/index.html"; then
run "docker stop ${RAND_NAME}"
exit 1
fi
if ! run "curl -sS localhost/index.html | grep 'hello world'"; then
run "docker stop ${RAND_NAME}"
exit 1
fi

WAIT=120
INDEX=0
printf "Testing connectivity"
while ! curl -sS "http://localhost:${HOST_PORT}" 2>/dev/null | grep 'hello world via html'; do
printf "."
if [ "${INDEX}" = "${WAIT}" ]; then
printf "\\n"
run "docker logs ${RAND_NAME}" || true
run "docker stop ${RAND_NAME}" || true
echo "Error"
exit 1
fi
INDEX=$(( INDEX + 1 ))
sleep 1
done
printf "\\n[OK] Test success\\n"

###
### Cleanup
Expand Down
85 changes: 85 additions & 0 deletions tests/01-test-php.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env bash

set -e
set -u
set -o pipefail

CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"

IMAGE="${1}"
#NAME="${2}"
#VERSION="${3}"
TAG="${4}"
ARCH="${5}"


HOST_PORT="8093"

###
### Load Library
###
# shellcheck disable=SC1091
. "${CWD}/.lib.sh"



###
### Preparation
###
RAND_DIR="$( mktemp -d )"
RAND_NAME1="$( get_random_name )"
RAND_NAME2="$( get_random_name )"
run "chmod 0755 ${RAND_DIR}"
run "echo \"<?php echo 'hello world php';\" > ${RAND_DIR}/index.php"


###
### Startup container
###
run "docker run -d --rm --platform ${ARCH} \
-v ${RAND_DIR}:/var/www/default/htdocs \
--name ${RAND_NAME1} \
devilbox/php-fpm-8.1"

run "docker run --rm --platform ${ARCH} \
-v ${RAND_DIR}:/var/www/default/htdocs \
-p 127.0.0.1:${HOST_PORT}:80 \
-e DEBUG_ENTRYPOINT=2 \
-e DEBUG_RUNTIME=1 \
-e NEW_UID=$( id -u ) \
-e NEW_GID=$( id -g ) \
-e PHP_FPM_ENABLE=1 \
-e PHP_FPM_SERVER_ADDR=${RAND_NAME1} \
-e PHP_FPM_SERVER_PORT=9000 \
--link ${RAND_NAME1} \
--name ${RAND_NAME2} \
${IMAGE}:${TAG} &"


###
### Tests
###
WAIT=120
INDEX=0
printf "Testing connectivity"
while ! curl -sS "http://localhost:${HOST_PORT}" 2>/dev/null | grep 'hello world php'; do
printf "."
if [ "${INDEX}" = "${WAIT}" ]; then
printf "\\n"
run "docker logs ${RAND_NAME1}" || true
run "docker logs ${RAND_NAME2}" || true
run "docker stop ${RAND_NAME1}" || true
run "docker stop ${RAND_NAME2}" || true
echo "Error"
exit 1
fi
INDEX=$(( INDEX + 1 ))
sleep 1
done
printf "\\n[OK] Test success\\n"

###
### Cleanup
###
run "docker stop ${RAND_NAME1}"
run "docker stop ${RAND_NAME2}"
41 changes: 24 additions & 17 deletions tests/01.sh → tests/02-timezone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ TAG="${4}"
ARCH="${5}"


HOST_PORT="8093"

###
### Load Library
###
Expand All @@ -38,37 +40,42 @@ run "docker run -d --rm --platform ${ARCH} \
-v ${RAND_DIR}:/var/www/default/htdocs \
--name ${RAND_NAME1} devilbox/php-fpm-8.1"

run "docker run -d --rm --platform ${ARCH} \
run "docker run --rm --platform ${ARCH} \
-v ${RAND_DIR}:/var/www/default/htdocs \
-p 127.0.0.1:80:80 \
-p 127.0.0.1:${HOST_PORT}:80 \
-e DEBUG_ENTRYPOINT=2 \
-e DEBUG_RUNTIME=1 \
-e TIMEZONE=Europe/Berlin \
-e NEW_UID=$( id -u ) \
-e NEW_GID=$( id -g ) \
-e PHP_FPM_ENABLE=1 \
-e PHP_FPM_SERVER_ADDR=${RAND_NAME1} \
-e PHP_FPM_SERVER_PORT=9000 \
--link ${RAND_NAME1} \
--name ${RAND_NAME2} ${IMAGE}:${TAG}"
--name ${RAND_NAME2} ${IMAGE}:${TAG} &"


###
### Tests
###
run "sleep 20" # Startup-time is longer on cross-platform
run "docker ps"
run "docker logs ${RAND_NAME1}"
run "docker logs ${RAND_NAME2}"
if ! run "curl localhost"; then
run "docker stop ${RAND_NAME1}"
run "docker stop ${RAND_NAME2}"
exit 1
fi
if ! run "curl localhost | grep 'hello world php'"; then
run "docker stop ${RAND_NAME1}"
run "docker stop ${RAND_NAME2}"
exit 1
fi
WAIT=120
INDEX=0
printf "Testing connectivity"
while ! curl -sS "http://localhost:${HOST_PORT}" 2>/dev/null | grep 'hello world php'; do
printf "."
if [ "${INDEX}" = "${WAIT}" ]; then
printf "\\n"
run "docker logs ${RAND_NAME1}" || true
run "docker logs ${RAND_NAME2}" || true
run "docker stop ${RAND_NAME1}" || true
run "docker stop ${RAND_NAME2}" || true
echo "Error"
exit 1
fi
INDEX=$(( INDEX + 1 ))
sleep 1
done
printf "\\n[OK] Test success\\n"

###
### Cleanup
Expand Down
4 changes: 3 additions & 1 deletion tests/start-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ else
echo "################################################################################"
echo "# [${CWD}/${i}] ${IMAGE}:${TAG} ${NAME}-${VERSION} (${ARCH})"
echo "################################################################################"
sh -c "${i} ${IMAGE} ${NAME} ${VERSION} ${TAG} ${ARCH}"
if ! sh -c "${i} ${IMAGE} ${NAME} ${VERSION} ${TAG} ${ARCH}"; then
exit 1
fi
done
fi