Skip to content

Commit 27ba09c

Browse files
authored
Merge pull request #49 from devilbox/release-0.45
Ensure to test against timezone setting
2 parents b3196fb + 09ad80f commit 27ba09c

File tree

4 files changed

+132
-34
lines changed

4 files changed

+132
-34
lines changed

tests/00.sh tests/00-test-html.sh

+20-16
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ TAG="${4}"
1313
ARCH="${5}"
1414

1515

16+
HOST_PORT="8093"
17+
1618
###
1719
### Load Library
1820
###
@@ -26,15 +28,15 @@ ARCH="${5}"
2628
###
2729
RAND_DIR="$( mktemp -d )"
2830
RAND_NAME="$( get_random_name )"
29-
run "echo \"hello world\" > ${RAND_DIR}/index.html"
31+
run "echo \"hello world via html\" > ${RAND_DIR}/index.html"
3032

3133

3234
###
3335
### Startup container
3436
###
3537
run "docker run --rm --platform ${ARCH} \
3638
-v ${RAND_DIR}:/var/www/default/htdocs \
37-
-p 127.0.0.1:80:80 \
39+
-p 127.0.0.1:${HOST_PORT}:80 \
3840
-e DEBUG_ENTRYPOINT=2 \
3941
-e DEBUG_RUNTIME=1 \
4042
-e NEW_UID=$( id -u ) \
@@ -45,20 +47,22 @@ run "docker run --rm --platform ${ARCH} \
4547
###
4648
### Tests
4749
###
48-
run "sleep 20" # Startup-time is longer on cross-platform
49-
run "docker ps"
50-
if ! run "docker logs ${RAND_NAME}"; then
51-
exit 1
52-
fi
53-
if ! run "curl -sS localhost/index.html"; then
54-
run "docker stop ${RAND_NAME}"
55-
exit 1
56-
fi
57-
if ! run "curl -sS localhost/index.html | grep 'hello world'"; then
58-
run "docker stop ${RAND_NAME}"
59-
exit 1
60-
fi
61-
50+
WAIT=120
51+
INDEX=0
52+
printf "Testing connectivity"
53+
while ! curl -sS "http://localhost:${HOST_PORT}" 2>/dev/null | grep 'hello world via html'; do
54+
printf "."
55+
if [ "${INDEX}" = "${WAIT}" ]; then
56+
printf "\\n"
57+
run "docker logs ${RAND_NAME}" || true
58+
run "docker stop ${RAND_NAME}" || true
59+
echo "Error"
60+
exit 1
61+
fi
62+
INDEX=$(( INDEX + 1 ))
63+
sleep 1
64+
done
65+
printf "\\n[OK] Test success\\n"
6266

6367
###
6468
### Cleanup

tests/01-test-php.sh

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
8+
9+
IMAGE="${1}"
10+
#NAME="${2}"
11+
#VERSION="${3}"
12+
TAG="${4}"
13+
ARCH="${5}"
14+
15+
16+
HOST_PORT="8093"
17+
18+
###
19+
### Load Library
20+
###
21+
# shellcheck disable=SC1091
22+
. "${CWD}/.lib.sh"
23+
24+
25+
26+
###
27+
### Preparation
28+
###
29+
RAND_DIR="$( mktemp -d )"
30+
RAND_NAME1="$( get_random_name )"
31+
RAND_NAME2="$( get_random_name )"
32+
run "chmod 0755 ${RAND_DIR}"
33+
run "echo \"<?php echo 'hello world php';\" > ${RAND_DIR}/index.php"
34+
35+
36+
###
37+
### Startup container
38+
###
39+
run "docker run -d --rm --platform ${ARCH} \
40+
-v ${RAND_DIR}:/var/www/default/htdocs \
41+
--name ${RAND_NAME1} \
42+
devilbox/php-fpm-8.1"
43+
44+
run "docker run --rm --platform ${ARCH} \
45+
-v ${RAND_DIR}:/var/www/default/htdocs \
46+
-p 127.0.0.1:${HOST_PORT}:80 \
47+
-e DEBUG_ENTRYPOINT=2 \
48+
-e DEBUG_RUNTIME=1 \
49+
-e NEW_UID=$( id -u ) \
50+
-e NEW_GID=$( id -g ) \
51+
-e PHP_FPM_ENABLE=1 \
52+
-e PHP_FPM_SERVER_ADDR=${RAND_NAME1} \
53+
-e PHP_FPM_SERVER_PORT=9000 \
54+
--link ${RAND_NAME1} \
55+
--name ${RAND_NAME2} \
56+
${IMAGE}:${TAG} &"
57+
58+
59+
###
60+
### Tests
61+
###
62+
WAIT=120
63+
INDEX=0
64+
printf "Testing connectivity"
65+
while ! curl -sS "http://localhost:${HOST_PORT}" 2>/dev/null | grep 'hello world php'; do
66+
printf "."
67+
if [ "${INDEX}" = "${WAIT}" ]; then
68+
printf "\\n"
69+
run "docker logs ${RAND_NAME1}" || true
70+
run "docker logs ${RAND_NAME2}" || true
71+
run "docker stop ${RAND_NAME1}" || true
72+
run "docker stop ${RAND_NAME2}" || true
73+
echo "Error"
74+
exit 1
75+
fi
76+
INDEX=$(( INDEX + 1 ))
77+
sleep 1
78+
done
79+
printf "\\n[OK] Test success\\n"
80+
81+
###
82+
### Cleanup
83+
###
84+
run "docker stop ${RAND_NAME1}"
85+
run "docker stop ${RAND_NAME2}"

tests/01.sh tests/02-timezone.sh

+24-17
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ TAG="${4}"
1313
ARCH="${5}"
1414

1515

16+
HOST_PORT="8093"
17+
1618
###
1719
### Load Library
1820
###
@@ -38,37 +40,42 @@ run "docker run -d --rm --platform ${ARCH} \
3840
-v ${RAND_DIR}:/var/www/default/htdocs \
3941
--name ${RAND_NAME1} devilbox/php-fpm-8.1"
4042

41-
run "docker run -d --rm --platform ${ARCH} \
43+
run "docker run --rm --platform ${ARCH} \
4244
-v ${RAND_DIR}:/var/www/default/htdocs \
43-
-p 127.0.0.1:80:80 \
45+
-p 127.0.0.1:${HOST_PORT}:80 \
4446
-e DEBUG_ENTRYPOINT=2 \
4547
-e DEBUG_RUNTIME=1 \
48+
-e TIMEZONE=Europe/Berlin \
4649
-e NEW_UID=$( id -u ) \
4750
-e NEW_GID=$( id -g ) \
4851
-e PHP_FPM_ENABLE=1 \
4952
-e PHP_FPM_SERVER_ADDR=${RAND_NAME1} \
5053
-e PHP_FPM_SERVER_PORT=9000 \
5154
--link ${RAND_NAME1} \
52-
--name ${RAND_NAME2} ${IMAGE}:${TAG}"
55+
--name ${RAND_NAME2} ${IMAGE}:${TAG} &"
5356

5457

5558
###
5659
### Tests
5760
###
58-
run "sleep 20" # Startup-time is longer on cross-platform
59-
run "docker ps"
60-
run "docker logs ${RAND_NAME1}"
61-
run "docker logs ${RAND_NAME2}"
62-
if ! run "curl localhost"; then
63-
run "docker stop ${RAND_NAME1}"
64-
run "docker stop ${RAND_NAME2}"
65-
exit 1
66-
fi
67-
if ! run "curl localhost | grep 'hello world php'"; then
68-
run "docker stop ${RAND_NAME1}"
69-
run "docker stop ${RAND_NAME2}"
70-
exit 1
71-
fi
61+
WAIT=120
62+
INDEX=0
63+
printf "Testing connectivity"
64+
while ! curl -sS "http://localhost:${HOST_PORT}" 2>/dev/null | grep 'hello world php'; do
65+
printf "."
66+
if [ "${INDEX}" = "${WAIT}" ]; then
67+
printf "\\n"
68+
run "docker logs ${RAND_NAME1}" || true
69+
run "docker logs ${RAND_NAME2}" || true
70+
run "docker stop ${RAND_NAME1}" || true
71+
run "docker stop ${RAND_NAME2}" || true
72+
echo "Error"
73+
exit 1
74+
fi
75+
INDEX=$(( INDEX + 1 ))
76+
sleep 1
77+
done
78+
printf "\\n[OK] Test success\\n"
7279

7380
###
7481
### Cleanup

tests/start-ci.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ else
4343
echo "################################################################################"
4444
echo "# [${CWD}/${i}] ${IMAGE}:${TAG} ${NAME}-${VERSION} (${ARCH})"
4545
echo "################################################################################"
46-
sh -c "${i} ${IMAGE} ${NAME} ${VERSION} ${TAG} ${ARCH}"
46+
if ! sh -c "${i} ${IMAGE} ${NAME} ${VERSION} ${TAG} ${ARCH}"; then
47+
exit 1
48+
fi
4749
done
4850
fi

0 commit comments

Comments
 (0)