From d1061273b0a8b1e489ca41e5bdb40991959ac518 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 23 Mar 2022 13:27:02 +0100 Subject: [PATCH] Fix prod/ tests --- tests/prod/01-test-env-timezone.sh | 27 +-- tests/prod/02-test-env-docker_logs-stdout.sh | 81 +++++---- tests/prod/03-test-env-docker_logs-file.sh | 154 +++++++++++------- tests/prod/04-test-env-enable_mail.sh | 28 ++-- .../05-test-env-forward_ports_to_localhost.sh | 64 +++++--- tests/prod/06-test-mount-custom_ini.sh | 86 +++++----- tests/prod/07-test-mount-custom_fpm_conf.sh | 73 +++++---- tests/prod/08-test-custom-user-scripts-1.sh | 22 ++- tests/prod/09-test-custom-user-scripts-2.sh | 23 ++- 9 files changed, 335 insertions(+), 223 deletions(-) diff --git a/tests/prod/01-test-env-timezone.sh b/tests/prod/01-test-env-timezone.sh index 668cd72..21f2769 100755 --- a/tests/prod/01-test-env-timezone.sh +++ b/tests/prod/01-test-env-timezone.sh @@ -23,25 +23,28 @@ FLAVOUR="${4}" ### ### Europe/Berlin ### -did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e TIMEZONE=Europe/Berlin" )" +print_h2 "-e DEBUG_ENTRYPOINT=2 -e TIMEZONE=Europe/Berlin" +if ! name="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e TIMEZONE=Europe/Berlin" )"; then + exit 1 +fi -if ! run "docker logs ${did} 2>&1 | grep -q 'Europe/Berlin'"; then - docker_logs "${did}" || true - docker_stop "${did}" || true +if ! run "docker logs ${name} 2>&1 | grep -q 'Europe/Berlin'"; then + docker_logs "${name}" || true + docker_stop "${name}" || true echo "Failed" exit 1 fi -if ! docker_exec "${did}" "date | grep -E 'CE(S)*T'"; then - docker_exec "${did}" "date" - docker_logs "${did}" || true - docker_stop "${did}" || true +if ! docker_exec "${name}" "date | grep -E 'CE(S)*T'"; then + docker_exec "${name}" "date" + docker_logs "${name}" || true + docker_stop "${name}" || true echo "Failed" exit 1 fi -if ! docker_exec "${did}" "php -i | grep -E 'date\.timezone' | grep 'Europe/Berlin'"; then - docker_logs "${did}" || true - docker_stop "${did}" || true +if ! docker_exec "${name}" "php -i | grep -E 'date\.timezone' | grep 'Europe/Berlin'"; then + docker_logs "${name}" || true + docker_stop "${name}" || true echo "Failed" exit 1 fi -docker_stop "${did}" +docker_stop "${name}" diff --git a/tests/prod/02-test-env-docker_logs-stdout.sh b/tests/prod/02-test-env-docker_logs-stdout.sh index e36fabc..fefbaaa 100755 --- a/tests/prod/02-test-env-docker_logs-stdout.sh +++ b/tests/prod/02-test-env-docker_logs-stdout.sh @@ -40,7 +40,9 @@ chmod 0777 -R "${LOG_DIR_HOST}" chmod 0777 -R "${CFG_DIR_HOST}" chmod 0777 -R "${WWW_DIR_HOST}" + # Pull Image +print_h2 "Pulling Nginx" run "until docker pull --platform ${ARCH} ${CONTAINER}; do sleep 1; done" ### @@ -48,8 +50,10 @@ run "until docker pull --platform ${ARCH} ${CONTAINER}; do sleep 1; done" ### # Start PHP-FPM -did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e DOCKER_LOGS=1 -v ${WWW_DIR_HOST}:${WWW_DIR_CONT} -v ${LOG_DIR_HOST}:/var/log/php" )" -name="$( docker_name "${did}" )" +print_h2 "Starting PHP-FPM" +if ! name="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e DOCKER_LOGS=1 -v ${WWW_DIR_HOST}:${WWW_DIR_CONT} -v ${LOG_DIR_HOST}:/var/log/php" )"; then + exit 1 +fi # Nginx.conf { @@ -70,8 +74,11 @@ name="$( docker_name "${did}" )" # Start Nginx -ndid="$( docker_run "${CONTAINER}" "${ARCH}" "-v ${WWW_DIR_HOST}:${WWW_DIR_CONT} -v ${CFG_DIR_HOST}:${CFG_DIR_CONT} -p ${WWW_PORT}:80 --link ${name}" )" - +print_h2 "Starting Nginx" +if ! nginx_name="$( docker_run "${CONTAINER}" "${ARCH}" "-v ${WWW_DIR_HOST}:${WWW_DIR_CONT} -v ${CFG_DIR_HOST}:${CFG_DIR_CONT} -p ${WWW_PORT}:80 --link ${name}" )"; then + docker_stop "${name}" || true + exit 1 +fi # Wait for both containers to be up and running run "sleep 10" @@ -79,6 +86,7 @@ run "sleep 10" ### ### Fire positive and error generating request ### +print_h2 "Fire curl requests" run "curl http://localhost:${WWW_PORT}/ok.php" run "curl http://localhost:${WWW_PORT}/fail.php" @@ -86,10 +94,12 @@ run "curl http://localhost:${WWW_PORT}/fail.php" ### ### Run tests ### -if ! run "docker logs ${did} 2>&1 | grep -q 'DOCKER_LOGS'"; then - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true +print_h2 "Checking DOCKER_LOGS" +if ! run "docker logs ${name} 2>&1 | grep 'DOCKER_LOGS'"; then + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -97,13 +107,15 @@ if ! run "docker logs ${did} 2>&1 | grep -q 'DOCKER_LOGS'"; then exit 1 fi -if [ -f "${LOG_DIR_HOST}/php-fpm.access" ]; then +print_h2 "Ensure php-fpm.access does not exist" +if ! run_fail "test -f ${LOG_DIR_HOST}/php-fpm.access"; then echo "Access log should not exist: ${LOG_DIR_HOST}/php-fpm.access" ls -lap "${LOG_DIR_HOST}/" cat "${LOG_DIR_HOST}/php-fpm.access" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -111,13 +123,15 @@ if [ -f "${LOG_DIR_HOST}/php-fpm.access" ]; then exit 1 fi -if [ -f "${LOG_DIR_HOST}/php-fpm.error" ]; then +print_h2 "Ensure php-fpm.error does not exist" +if ! run_fail "test -f ${LOG_DIR_HOST}/php-fpm.error"; then echo "Error log should not exist: ${LOG_DIR_HOST}/php-fpm.error" ls -lap "${LOG_DIR_HOST}/" cat "${LOG_DIR_HOST}/php-fpm.error" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -129,33 +143,39 @@ fi ### PHP 5.2 still does not show any errors ### if [ "${VERSION}" != "5.2" ]; then - if ! run "docker logs ${did} 2>&1 | grep -q 'GET /ok.php'"; then + print_h2 "Ensure stderr access logging is enabled" + if ! run "docker logs ${name} 2>&1 | grep 'GET /ok.php'"; then echo "Error no access log string for 'GET /ok.php' found in stderr" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" echo "Failed" exit 1 fi - if ! run "docker logs ${did} 2>&1 | grep -q 'GET /fail.php'"; then + print_h2 "Ensure stderr access logging is enabled" + if ! run "docker logs ${name} 2>&1 | grep 'GET /fail.php'"; then echo "Error no access log string for 'GET /fail.php' found in stderr" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" echo "Failed" exit 1 fi - if ! run "docker logs ${did} 2>&1 | grep -q '/var/www/default/fail.php'"; then + print_h2 "Ensure errors are logged to stderr" + if ! run "docker logs ${name} 2>&1 | grep '/var/www/default/fail.php'"; then echo "Error no error message found in stderr" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -168,8 +188,9 @@ fi ### ### Shutdown ### -docker_stop "${ndid}" || true -docker_stop "${did}" +print_h2 "Cleanup" +docker_stop "${nginx_name}" || true +docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" diff --git a/tests/prod/03-test-env-docker_logs-file.sh b/tests/prod/03-test-env-docker_logs-file.sh index a23c84e..4d3f03b 100755 --- a/tests/prod/03-test-env-docker_logs-file.sh +++ b/tests/prod/03-test-env-docker_logs-file.sh @@ -40,7 +40,9 @@ chmod 0777 -R "${LOG_DIR_HOST}" chmod 0777 -R "${CFG_DIR_HOST}" chmod 0777 -R "${WWW_DIR_HOST}" + # Pull Image +print_h2 "Pulling Nginx" run "until docker pull --platform ${ARCH} ${CONTAINER}; do sleep 1; done" ### @@ -48,8 +50,10 @@ run "until docker pull --platform ${ARCH} ${CONTAINER}; do sleep 1; done" ### # Start PHP-FPM -did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e DOCKER_LOGS=0 -v ${WWW_DIR_HOST}:${WWW_DIR_CONT} -v ${LOG_DIR_HOST}:/var/log/php" )" -name="$( docker_name "${did}" )" +print_h2 "Starting PHP-FPM" +if ! name="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e DOCKER_LOGS=0 -v ${WWW_DIR_HOST}:${WWW_DIR_CONT} -v ${LOG_DIR_HOST}:/var/log/php" )"; then + exit 1 +fi # Nginx.conf { @@ -70,7 +74,11 @@ name="$( docker_name "${did}" )" # Start Nginx -ndid="$( docker_run "${CONTAINER}" "${ARCH}" "-v ${WWW_DIR_HOST}:${WWW_DIR_CONT} -v ${CFG_DIR_HOST}:${CFG_DIR_CONT} -p ${WWW_PORT}:80 --link ${name}" )" +print_h2 "Starting Nginx" +if ! nginx_name="$( docker_run "${CONTAINER}" "${ARCH}" "-v ${WWW_DIR_HOST}:${WWW_DIR_CONT} -v ${CFG_DIR_HOST}:${CFG_DIR_CONT} -p ${WWW_PORT}:80 --link ${name}" )"; then + docker_stop "${name}" || true + exit 1 +fi # Wait for both containers to be up and running run "sleep 10" @@ -79,6 +87,7 @@ run "sleep 10" ### ### Fire positive and error generating request ### +print_h2 "Fire curl requests" run "curl http://localhost:${WWW_PORT}/ok.php" run "curl http://localhost:${WWW_PORT}/fail.php" @@ -86,10 +95,11 @@ run "curl http://localhost:${WWW_PORT}/fail.php" ### ### Run tests ### -if ! run "docker logs ${did} 2>&1 | grep -q 'DOCKER_LOGS'"; then - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true +print_h2 "Checking DOCKER_LOGS" +if ! run "docker logs ${name} 2>&1 | grep 'DOCKER_LOGS'"; then + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -97,24 +107,29 @@ if ! run "docker logs ${did} 2>&1 | grep -q 'DOCKER_LOGS'"; then exit 1 fi -if [ ! -f "${LOG_DIR_HOST}/php-fpm.access" ]; then +print_h2 "Ensure php-fpm.access exists" +if ! run "test -f ${LOG_DIR_HOST}/php-fpm.access"; then echo "Access log does not exist: ${LOG_DIR_HOST}/php-fpm.access" ls -lap "${LOG_DIR_HOST}/" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" echo "Failed" exit 1 fi -if [ ! -r "${LOG_DIR_HOST}/php-fpm.access" ]; then + +print_h2 "Ensure php-fpm.access is readable" +if ! run "test -r ${LOG_DIR_HOST}/php-fpm.access"; then echo "Access log is not readable" ls -lap "${LOG_DIR_HOST}/" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -122,24 +137,14 @@ if [ ! -r "${LOG_DIR_HOST}/php-fpm.access" ]; then exit 1 fi -if [ ! -f "${LOG_DIR_HOST}/php-fpm.error" ]; then +print_h2 "Ensure php-fpm.error exists" +if ! run "test -f ${LOG_DIR_HOST}/php-fpm.error"; then echo "Error log does not exist: ${LOG_DIR_HOST}/php-fpm.error" ls -lap "${LOG_DIR_HOST}/" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true - rm -rf "${LOG_DIR_HOST}" - rm -rf "${CFG_DIR_HOST}" - rm -rf "${WWW_DIR_HOST}" - echo "Failed" - exit 1 -fi -if [ ! -r "${LOG_DIR_HOST}/php-fpm.error" ]; then - echo "Error log is not readable" - ls -lap "${LOG_DIR_HOST}/" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -147,40 +152,62 @@ if [ ! -r "${LOG_DIR_HOST}/php-fpm.error" ]; then exit 1 fi -# Ensure no access/error goes to stderr -if run "docker logs ${did} 2>&1 | grep -q 'GET /ok.php'"; then +print_h2 "Ensure php-fpm.error is readable" +if ! run "test -r ${LOG_DIR_HOST}/php-fpm.error"; then + echo "Error log is not readable" + ls -lap "${LOG_DIR_HOST}/" + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true + rm -rf "${LOG_DIR_HOST}" + rm -rf "${CFG_DIR_HOST}" + rm -rf "${WWW_DIR_HOST}" + echo "Failed" + exit 1 +fi + +print_h2 "Ensure no access/error logging exists in stderr (ok.php)" +if run "docker logs ${name} 2>&1 | grep 'GET /ok.php'"; then echo "Error access log string for 'GET /ok.php' found in stderr, but shold go to file" run "cat ${LOG_DIR_HOST}/php-fpm.access" run "cat ${LOG_DIR_HOST}/php-fpm.error" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" echo "Failed" exit 1 fi -if run "docker logs ${did} 2>&1 | grep -q 'GET /fail.php'"; then + +print_h2 "Ensure no access/error logging exists in stderr (fail.php)" +if run "docker logs ${name} 2>&1 | grep 'GET /fail.php'"; then echo "Error access log string for 'GET /fail.php' found in stderr, but should go to file" run "cat ${LOG_DIR_HOST}/php-fpm.access" run "cat ${LOG_DIR_HOST}/php-fpm.error" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" echo "Failed" exit 1 fi -if run "docker logs ${did} 2>&1 | grep -q '/var/www/default/fail.php'"; then + +print_h2 "Ensure no error message is present in stderr" +if run "docker logs ${name} 2>&1 | grep '/var/www/default/fail.php'"; then echo "Error error message found in stderr, but should go to file" run "cat ${LOG_DIR_HOST}/php-fpm.access" run "cat ${LOG_DIR_HOST}/php-fpm.error" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -191,26 +218,31 @@ fi # PHP-FPM 5.2 does not show access logs if [ "${VERSION}" != "5.2" ]; then # Test access and error file for correct content - if ! run "grep -q 'GET /ok.php' ${LOG_DIR_HOST}/php-fpm.access"; then + print_h2 "Test access logs in php-fpm.access (ok.php)" + if ! run "grep 'GET /ok.php' ${LOG_DIR_HOST}/php-fpm.access"; then echo "Error no access log string for 'GET /ok.php' found in: ${LOG_DIR_HOST}/php-fpm.access" run "cat ${LOG_DIR_HOST}/php-fpm.access" run "cat ${LOG_DIR_HOST}/php-fpm.error" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" echo "Failed" exit 1 fi - if ! run "grep -q 'GET /fail.php' ${LOG_DIR_HOST}/php-fpm.access"; then + + print_h2 "Test access logs in php-fpm.access (fail.php)" + if ! run "grep 'GET /fail.php' ${LOG_DIR_HOST}/php-fpm.access"; then echo "Error no access log string for 'GET /fail.php' found in: ${LOG_DIR_HOST}/php-fpm.access" run "cat ${LOG_DIR_HOST}/php-fpm.access" run "cat ${LOG_DIR_HOST}/php-fpm.error" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -218,13 +250,16 @@ if [ "${VERSION}" != "5.2" ]; then exit 1 fi fi -if ! run "grep -q '/var/www/default/fail.php' ${LOG_DIR_HOST}/php-fpm.error"; then + +print_h2 "Ensiure error message is present in php-fpm.error" +if ! run "grep '/var/www/default/fail.php' ${LOG_DIR_HOST}/php-fpm.error"; then echo "Error no error message found in: ${LOG_DIR_HOST}/php-fpm.error" run "cat ${LOG_DIR_HOST}/php-fpm.access" run "cat ${LOG_DIR_HOST}/php-fpm.error" - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_logs "${nginx_name}" || true + docker_logs "${name}" || true + docker_stop "${nginx_name}" || true + docker_stop "${name}" || true rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" @@ -236,12 +271,13 @@ fi ### ### Shutdown ### -docker_logs "${did}" || true +print_h2 "Cleanup" +docker_logs "${name}" || true run "ls -lap ${LOG_DIR_HOST}/" run "cat ${LOG_DIR_HOST}/php-fpm.access" run "cat ${LOG_DIR_HOST}/php-fpm.error" -docker_stop "${ndid}" || true -docker_stop "${did}" +docker_stop "${nginx_name}" || true +docker_stop "${name}" rm -rf "${LOG_DIR_HOST}" rm -rf "${CFG_DIR_HOST}" rm -rf "${WWW_DIR_HOST}" diff --git a/tests/prod/04-test-env-enable_mail.sh b/tests/prod/04-test-env-enable_mail.sh index 03466a0..ef71e52 100755 --- a/tests/prod/04-test-env-enable_mail.sh +++ b/tests/prod/04-test-env-enable_mail.sh @@ -24,12 +24,16 @@ FLAVOUR="${4}" ### Postfix ### MOUNTPOINT="$( mktemp --directory )" -did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e ENABLE_MAIL=2 -v ${MOUNTPOINT}:/var/mail" )" + +print_h2 "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e ENABLE_MAIL=2 -v ${MOUNTPOINT}:/var/mail" +if ! name="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -e ENABLE_MAIL=2 -v ${MOUNTPOINT}:/var/mail" )"; then + exit 1 +fi run "sleep 10" -if ! run "docker logs ${did} 2>&1 | grep -q 'ENABLE_MAIL'"; then - docker_logs "${did}" || true - docker_stop "${did}" || true +if ! run "docker logs ${name} 2>&1 | grep -q 'ENABLE_MAIL'"; then + docker_logs "${name}" || true + docker_stop "${name}" || true rm -rf "${MOUNTPOINT}" echo "Failed" exit 1 @@ -38,8 +42,8 @@ fi if [ ! -f "${MOUNTPOINT}/devilbox" ]; then echo "Mail file does not exist: ${MOUNTPOINT}/devilbox" ls -lap "${MOUNTPOINT}/" - docker_logs "${did}" || true - docker_stop "${did}" || true + docker_logs "${name}" || true + docker_stop "${name}" || true rm -rf "${MOUNTPOINT}" echo "Failed" exit 1 @@ -47,25 +51,25 @@ fi if [ ! -r "${MOUNTPOINT}/devilbox" ]; then echo "Mail file is not readable" ls -lap "${MOUNTPOINT}/" - docker_logs "${did}" || true - docker_stop "${did}" || true + docker_logs "${name}" || true + docker_stop "${name}" || true rm -rf "${MOUNTPOINT}" echo "Failed" exit 1 fi # Send test email -docker_exec "${did}" "php -r \"mail('mailtest@devilbox.org', 'the subject', 'the message');\"" +docker_exec "${name}" "php -r \"mail('mailtest@devilbox.org', 'the subject', 'the message');\"" run "sleep 5" if ! run "grep 'the subject' ${MOUNTPOINT}/devilbox"; then - docker_logs "${did}" || true - docker_stop "${did}" || true + docker_logs "${name}" || true + docker_stop "${name}" || true run "cat ${MOUNTPOINT}/devilbox" rm -rf "${MOUNTPOINT}" echo "Failed" exit 1 fi -docker_stop "${did}" +docker_stop "${name}" rm -rf "${MOUNTPOINT}" diff --git a/tests/prod/05-test-env-forward_ports_to_localhost.sh b/tests/prod/05-test-env-forward_ports_to_localhost.sh index cbe9921..efd8471 100755 --- a/tests/prod/05-test-env-forward_ports_to_localhost.sh +++ b/tests/prod/05-test-env-forward_ports_to_localhost.sh @@ -23,28 +23,39 @@ FLAVOUR="${4}" ### ### Socat forwarding ### -CONTAINER="mysql:5.6" +CONTAINER="mysql:8.0-oracle" # Pull Container +print_h2 "Pulling MySQL" run "until docker pull --platform ${ARCH} ${CONTAINER}; do sleep 1; done" # Start mysql container -mdid="$( docker_run "${CONTAINER}" "${ARCH}" "-e MYSQL_ALLOW_EMPTY_PASSWORD=yes" )" -mname="$( docker_name "${mdid}" )" -run "sleep 5" +print_h2 "Starting MySQL" +if ! name_mysql="$( docker_run "${CONTAINER}" "${ARCH}" "-e MYSQL_ALLOW_EMPTY_PASSWORD=yes" )"; then + exit 1 +fi +run "sleep 60" -did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e FORWARD_PORTS_TO_LOCALHOST=3306:${mname}:3306 --link ${mname}" )" -if ! run "docker logs ${did} 2>&1 | grep 'Forwarding ${mname}:3306'"; then - docker_logs "${did}" || true - docker_logs "${mdid}" || true - docker_stop "${did}" || true - docker_stop "${mdid}" || true + +# Start PHP-FPM +print_h2 "Start PHP-FPM" +if ! name="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e FORWARD_PORTS_TO_LOCALHOST=3306:${name_mysql}:3306 --link ${name_mysql}" )"; then + docker_stop "${name_mysql}" || true + exit 1 +fi +run "sleep 15" + + +print_h2 "Ensure forwarding info is present in docker logs" +if ! run "docker logs ${name} 2>&1 | grep 'Forwarding ${name_mysql}:3306'"; then + docker_logs "${name_mysql}" || true + docker_logs "${name}" || true + docker_stop "${name_mysql}" || true + docker_stop "${name}" || true echo "Failed" exit 1 fi -# Wait for both containers to come up -run "sleep 10" # Test connectivity #docker_exec "${did}" "ping -c 1 ${mname}" @@ -53,22 +64,27 @@ run "sleep 10" # Only work container has mysql binary installed if [ "${FLAVOUR}" = "work" ]; then - if ! docker_exec "${did}" "mysql --user=root --password= --host=${mname} -e 'SHOW DATABASES;'"; then - docker_logs "${did}" || true - docker_logs "${mdid}" || true - docker_stop "${did}" || true - docker_stop "${mdid}" || true + print_h2 "Test connectivity against hostname" + if ! docker_exec "${name}" "mysql --user=root --password= --host=${name_mysql} -e 'SHOW DATABASES;'"; then + docker_logs "${name_mysql}" || true + docker_logs "${name}" || true + docker_stop "${name_mysql}" || true + docker_stop "${name}" || true echo "Failed" exit 1 fi - if ! docker_exec "${did}" "mysql --user=root --password= --host=127.0.0.1 -e 'SHOW DATABASES;'"; then - docker_logs "${did}" || true - docker_logs "${mdid}" || true - docker_stop "${did}" || true - docker_stop "${mdid}" || true + print_h2 "Test connectivity against 127.0.0.1" + if ! docker_exec "${name}" "mysql --user=root --password= --host=127.0.0.1 -e 'SHOW DATABASES;'"; then + docker_logs "${name_mysql}" || true + docker_logs "${name}" || true + docker_stop "${name_mysql}" || true + docker_stop "${name}" || true echo "Failed" exit 1 fi fi -docker_stop "${mdid}" -docker_stop "${did}" + + +print_h2 "Cleanup" +docker_stop "${name_mysql}" +docker_stop "${name}" diff --git a/tests/prod/06-test-mount-custom_ini.sh b/tests/prod/06-test-mount-custom_ini.sh index 24e2035..96e0752 100755 --- a/tests/prod/06-test-mount-custom_ini.sh +++ b/tests/prod/06-test-mount-custom_ini.sh @@ -44,12 +44,16 @@ chmod 0777 "${PHP_INI_HOST}" chmod 0777 "${DOC_ROOT_HOST}" chmod 0644 "${DOC_ROOT_HOST}/index.php" + # Pull container +print_h2 "Pulling Nginx" run "until docker pull --platform ${ARCH} ${CONTAINER}; do sleep 1; done" # Start PHP-FPM -did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${PHP_INI_HOST}:${PHP_INI_CONT}" )" -name="$( docker_name "${did}" )" +print_h2 "Starting PHP-FPM" +if ! name="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${PHP_INI_HOST}:${PHP_INI_CONT}" )"; then + exit 1 +fi # Nginx.conf { @@ -70,17 +74,21 @@ name="$( docker_name "${did}" )" # Start Nginx -ndid="$( docker_run "${CONTAINER}" "${ARCH}" "-v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${CONFIG_HOST}:${CONFIG_CONT} -p ${WWW_PORT}:80 --link ${name}" )" - +print_h2 "Starting Nginx" +if ! name_nginx="$( docker_run "${CONTAINER}" "${ARCH}" "-v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${CONFIG_HOST}:${CONFIG_CONT} -p ${WWW_PORT}:80 --link ${name}" )"; then + docker_stop "${name}" || true + exit 1 +fi # Wait for both containers to be up and running run "sleep 10" # Check entrypoint -if ! run "docker logs ${did} | grep 'post.ini'"; then - docker_logs "${ndid}" || true - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true +print_h2 "Checking entrypoint" +if ! run "docker logs ${name} | grep 'post.ini'"; then + docker_logs "${name_nginx}" || true + docker_logs "${name}" || true + docker_stop "${name_nginx}" || true + docker_stop "${name}" || true rm -rf "${DOC_ROOT_HOST}" rm -rf "${CONFIG_HOST}" rm -rf "${PHP_INI_HOST}" @@ -89,31 +97,32 @@ if ! run "docker logs ${did} | grep 'post.ini'"; then fi # Check PHP connectivity +print_h2 "Checking connectivity" if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php >/dev/null 2>&1"; then # Info run "netstat -tuln" run "curl -4 http://127.0.0.1:${WWW_PORT}/index.php" || true run "curl -6 http://127.0.0.1:${WWW_PORT}/index.php" || true run "docker ps --no-trunc" - docker_exec "${ndid}" "nginx -t" + docker_exec "${name_nginx}" "nginx -t" # Show logs - docker_logs "${ndid}" || true - docker_logs "${did}" || true + docker_logs "${name_nginx}" || true + docker_logs "${name}" || true # Ensure file is available - docker_exec "${ndid}" "ls -la ${DOC_ROOT_CONT}/" - docker_exec "${did}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${name_nginx}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${name}" "ls -la ${DOC_ROOT_CONT}/" - docker_exec "${ndid}" "cat ${DOC_ROOT_CONT}/index.php" - docker_exec "${did}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${name_nginx}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${name}" "cat ${DOC_ROOT_CONT}/index.php" # Nginx configuration - docker_exec "${ndid}" "cat ${CONFIG_CONT}/php.conf" + docker_exec "${name_nginx}" "cat ${CONFIG_CONT}/php.conf" # Shutdown - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_stop "${name_nginx}" || true + docker_stop "${name}" || true rm -rf "${DOC_ROOT_HOST}" rm -rf "${CONFIG_HOST}" rm -rf "${PHP_INI_HOST}" @@ -122,17 +131,18 @@ if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php >/dev/null 2>&1"; th fi # Check modified php.ini -if ! docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\" | grep '17M'"; then +print_h2 "Checking modified php.ini" +if ! docker_exec "${name}" "php -r \"echo ini_get('post_max_size');\" | grep '17M'"; then # Info - docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\"" + docker_exec "${name}" "php -r \"echo ini_get('post_max_size');\"" # Show logs - docker_logs "${ndid}" || true - docker_logs "${did}" || true + docker_logs "${name_nginx}" || true + docker_logs "${name}" || true # Shutdown - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_stop "${name_nginx}" || true + docker_stop "${name}" || true rm -rf "${DOC_ROOT_HOST}" rm -rf "${CONFIG_HOST}" rm -rf "${PHP_INI_HOST}" @@ -141,31 +151,32 @@ if ! docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\" | grep '17M fi # Check modified php.ini +print_h2 "Checking modified php.ini" if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php 2>/dev/null | grep post_max_size | grep '17M'"; then # Info run "netstat -tuln" run "curl -4 http://127.0.0.1:${WWW_PORT}/index.php" || true run "curl -6 http://127.0.0.1:${WWW_PORT}/index.php" || true run "docker ps --no-trunc" - docker_exec "${ndid}" "nginx -t" + docker_exec "${name_nginx}" "nginx -t" # Show logs - docker_logs "${ndid}" || true - docker_logs "${did}" || true + docker_logs "${name_nginx}" || true + docker_logs "${name}" || true # Ensure file is available - docker_exec "${ndid}" "ls -la ${DOC_ROOT_CONT}/" - docker_exec "${did}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${name_nginx}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${name}" "ls -la ${DOC_ROOT_CONT}/" - docker_exec "${ndid}" "cat ${DOC_ROOT_CONT}/index.php" - docker_exec "${did}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${name_nginx}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${name}" "cat ${DOC_ROOT_CONT}/index.php" # Nginx configuration - docker_exec "${ndid}" "cat ${CONFIG_CONT}/php.conf" + docker_exec "${name_nginx}" "cat ${CONFIG_CONT}/php.conf" # Shutdown - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_stop "${name_nginx}" || true + docker_stop "${name}" || true rm -rf "${DOC_ROOT_HOST}" rm -rf "${CONFIG_HOST}" rm -rf "${PHP_INI_HOST}" @@ -175,8 +186,9 @@ fi # Cleanup -docker_stop "${did}" -docker_stop "${ndid}" +print_h2 "Cleanup" +docker_stop "${name}" +docker_stop "${name_nginx}" rm -rf "${DOC_ROOT_HOST}" rm -rf "${CONFIG_HOST}" rm -rf "${PHP_INI_HOST}" diff --git a/tests/prod/07-test-mount-custom_fpm_conf.sh b/tests/prod/07-test-mount-custom_fpm_conf.sh index 135ca69..fcc4800 100755 --- a/tests/prod/07-test-mount-custom_fpm_conf.sh +++ b/tests/prod/07-test-mount-custom_fpm_conf.sh @@ -50,11 +50,14 @@ chmod 0777 "${DOC_ROOT_HOST}" chmod 0644 "${DOC_ROOT_HOST}/index.php" # Pull container +print_h2 "Pulling Nginx" run "until docker pull --platform ${ARCH} ${CONTAINER}; do sleep 1; done" # Start PHP-FPM -did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${PHP_CNF_HOST}:${PHP_CNF_CONT}" )" -name="$( docker_name "${did}" )" +print_h2 "Starting PHP-FPM" +if ! name="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${PHP_CNF_HOST}:${PHP_CNF_CONT}" )"; then + exit 1 +fi # Nginx.conf { @@ -75,17 +78,21 @@ name="$( docker_name "${did}" )" # Start Nginx -ndid="$( docker_run "${CONTAINER}" "${ARCH}" "-v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${CONFIG_HOST}:${CONFIG_CONT} -p ${WWW_PORT}:80 --link ${name}" )" - +print_h2 "Starting Nginx" +if ! name_nginx="$( docker_run "${CONTAINER}" "${ARCH}" "-v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${CONFIG_HOST}:${CONFIG_CONT} -p ${WWW_PORT}:80 --link ${name}" )"; then + docker_stop "${name}" || true + exit 1 +fi # Wait for both containers to be up and running run "sleep 10" # Check entrypoint -if ! run "docker logs ${did} | grep 'post.conf'"; then - docker_logs "${ndid}" || true - docker_logs "${did}" || true - docker_stop "${ndid}" || true - docker_stop "${did}" || true +print_h2 "Checking entrypoint" +if ! run "docker logs ${name} | grep 'post.conf'"; then + docker_logs "${name_nginx}" || true + docker_logs "${name}" || true + docker_stop "${name_nginx}" || true + docker_stop "${name}" || true rm -rf "${DOC_ROOT_HOST}" rm -rf "${CONFIG_HOST}" rm -rf "${PHP_CNF_HOST}" @@ -94,31 +101,32 @@ if ! run "docker logs ${did} | grep 'post.conf'"; then fi # Check PHP connectivity +print_h2 "Checking connectivity" if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php >/dev/null 2>&1"; then # Info run "netstat -tuln" run "curl -4 http://127.0.0.1:${WWW_PORT}/index.php" || true run "curl -6 http://127.0.0.1:${WWW_PORT}/index.php" || true run "docker ps --no-trunc" - docker_exec "${ndid}" "nginx -t" + docker_exec "${name_nginx}" "nginx -t" # Show logs - docker_logs "${ndid}" || true - docker_logs "${did}" || true + docker_logs "${name_nginx}" || true + docker_logs "${name}" || true # Ensure file is available - docker_exec "${ndid}" "ls -la ${DOC_ROOT_CONT}/" - docker_exec "${did}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${name_nginx}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${name}" "ls -la ${DOC_ROOT_CONT}/" - docker_exec "${ndid}" "cat ${DOC_ROOT_CONT}/index.php" - docker_exec "${did}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${name_nginx}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${name}" "cat ${DOC_ROOT_CONT}/index.php" # Nginx configuration - docker_exec "${ndid}" "cat ${CONFIG_CONT}/php.conf" + docker_exec "${name_nginx}" "cat ${CONFIG_CONT}/php.conf" # Shutdown - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_stop "${name_nginx}" || true + docker_stop "${name}" || true rm -rf "${DOC_ROOT_HOST}" rm -rf "${CONFIG_HOST}" rm -rf "${PHP_CNF_HOST}" @@ -126,32 +134,32 @@ if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php >/dev/null 2>&1"; th exit 1 fi - # Check modified php-fpm.conf +print_h2 "Checking modified php-fpm.conf" if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php 2>/dev/null | grep memory_limit | grep '17M'"; then # Info run "netstat -tuln" run "curl -4 http://127.0.0.1:${WWW_PORT}/index.php | grep memory_limit" || true run "docker ps --no-trunc" - docker_exec "${ndid}" "nginx -t" + docker_exec "${name_nginx}" "nginx -t" # Show logs - docker_logs "${ndid}" || true - docker_logs "${did}" || true + docker_logs "${name_nginx}" || true + docker_logs "${name}" || true # Ensure file is available - docker_exec "${ndid}" "ls -la ${DOC_ROOT_CONT}/" - docker_exec "${did}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${name_nginx}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${name}" "ls -la ${DOC_ROOT_CONT}/" - docker_exec "${ndid}" "cat ${DOC_ROOT_CONT}/index.php" - docker_exec "${did}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${name_nginx}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${name}" "cat ${DOC_ROOT_CONT}/index.php" # Nginx configuration - docker_exec "${ndid}" "cat ${CONFIG_CONT}/php.conf" + docker_exec "${name_nginx}" "cat ${CONFIG_CONT}/php.conf" # Shutdown - docker_stop "${ndid}" || true - docker_stop "${did}" || true + docker_stop "${name_nginx}" || true + docker_stop "${name}" || true rm -rf "${DOC_ROOT_HOST}" rm -rf "${CONFIG_HOST}" rm -rf "${PHP_CNF_HOST}" @@ -161,8 +169,9 @@ fi # Cleanup -docker_stop "${did}" -docker_stop "${ndid}" +print_h2 "Cleanup" +docker_stop "${name}" +docker_stop "${name_nginx}" rm -rf "${DOC_ROOT_HOST}" rm -rf "${CONFIG_HOST}" rm -rf "${PHP_CNF_HOST}" diff --git a/tests/prod/08-test-custom-user-scripts-1.sh b/tests/prod/08-test-custom-user-scripts-1.sh index a9ede10..eac6d25 100755 --- a/tests/prod/08-test-custom-user-scripts-1.sh +++ b/tests/prod/08-test-custom-user-scripts-1.sh @@ -34,24 +34,29 @@ printf "#!/bin/bash\\necho 'abcdefghijklmnopq';\\n" > "${RUN_SH_HOST}/myscript1. chmod +x "${RUN_SH_HOST}/myscript1.sh" # Start PHP-FPM -did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${RUN_SH_HOST}:${RUN_SH_CONT}" )" +print_h2 "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${RUN_SH_HOST}:${RUN_SH_CONT}" +if ! name="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${RUN_SH_HOST}:${RUN_SH_CONT}" )"; then + exit 1 +fi # 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 +print_h2 "Check docker logs for script run" +if ! run "docker logs ${name} | grep 'myscript1.sh'"; then + docker_logs "${name}" || true + docker_stop "${name}" || 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 +print_h2 "Check docker logs for script output" +if ! run "docker logs ${name} | grep 'abcdefghijklmnopq'"; then + docker_logs "${name}" || true + docker_stop "${name}" || true rm -rf "${RUN_SH_HOST}" echo "Failed" exit 1 @@ -59,5 +64,6 @@ fi # Cleanup -docker_stop "${did}" +print_h2 "Cleanup" +docker_stop "${name}" rm -rf "${RUN_SH_HOST}" diff --git a/tests/prod/09-test-custom-user-scripts-2.sh b/tests/prod/09-test-custom-user-scripts-2.sh index e378032..6d62cf1 100755 --- a/tests/prod/09-test-custom-user-scripts-2.sh +++ b/tests/prod/09-test-custom-user-scripts-2.sh @@ -34,24 +34,28 @@ printf "#!/bin/bash\\necho 'abcdefghijklmnopq';\\n" > "${RUN_SH_HOST}/myscript1. chmod +x "${RUN_SH_HOST}/myscript1.sh" # Start PHP-FPM -did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${RUN_SH_HOST}:${RUN_SH_CONT}" )" - +print_h2 "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${RUN_SH_HOST}:${RUN_SH_CONT}" +if ! name="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "${ARCH}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${RUN_SH_HOST}:${RUN_SH_CONT}" )"; then + exit 1 +fi # 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 +print_h2 "Check docker logs for script run" +if ! run "docker logs ${name} | grep 'myscript1.sh'"; then + docker_logs "${name}" || true + docker_stop "${name}" || 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 +print_h2 "Check docker logs for script output" +if ! run "docker logs ${name} | grep 'abcdefghijklmnopq'"; then + docker_logs "${name}" || true + docker_stop "${name}" || true rm -rf "${RUN_SH_HOST}" echo "Failed" exit 1 @@ -59,5 +63,6 @@ fi # Cleanup -docker_stop "${did}" +print_h2 "Cleanup" +docker_stop "${name}" rm -rf "${RUN_SH_HOST}"