/.idea
/build/*
-/tests/coverage/*
/vendor/*
/.phpunit.result.cache
/composer.lock
# Show as much info as we can to help developers
- sudo cat /var/log/privoxy/*
- - cat apache_error.log
- - cat apache_access.log
+ - sudo cat /var/log/apache2/error.log
+ - sudo cat /var/log/apache2/other_vhosts_access.log
- sudo cat /var/log/php*.log
after_script:
In any case, read carefully the docs in [doc/api_changes_v4.md](doc/api_changes_v4.md) and report back any undocumented
issue using GitHub.
+Running tests
+-------------
+
+The recommended way to run the library test suite is via the provided Docker containers.
+A handy shell script is available that simplifies usage of Docker.
+
+The full sequence of operations is:
+
+ ./tests/ci/vm.sh build
+ ./tests/ci/vm.sh start
+ ./tests/ci/vm.sh runtests
+ ./tests/ci/vm.sh stop
+
+ # and, once you have finished all testing related work:
+ ./tests/ci/vm.sh cleanup
+
+By default tests are run using php 7.0 in a Container based on Ubuntu 16 Xenial.
+You can change the version of PHP and Ubuntu in use by setting the environment variables PHP_VERSION and UBUNTU_VERSION
+before building the Container.
+
+To generate the code-coverage report, run `./tests/ci/vm.sh runcoverage`
+
License
-------
Use of this software is subject to the terms in the [license.txt](license.txt) file
-NB: All recent commits are available online.
+NB: This is an old changelog. All recent commits are available online at https://github.com/gggeek/phpxmlrpc/commits
This file will not be updated further.
-See https://github.com/gggeek/phpxmlrpc/commits/master
2014-05-26 - G. Giunta (giunta.gaetano@gmail.com)
EXPOSE 80 443 8080
-WORKDIR /home/test
+# @todo can we avoid hardcoding this here? We can f.e. get it passed down as ARG...
+WORKDIR /home/docker/build
ENTRYPOINT ["/root/entrypoint.sh"]
DocumentRoot ${TESTS_ROOT_DIR}
- ErrorLog "${TESTS_ROOT_DIR}/apache_error.log"
- CustomLog "${TESTS_ROOT_DIR}/apache_access.log" combined
+ #ErrorLog "${TESTS_ROOT_DIR}/apache_error.log"
+ #CustomLog "${TESTS_ROOT_DIR}/apache_access.log" combined
# Env vars used by the test code, which we get from the environment
SetEnv HTTPSERVER ${HTTPSERVER}
DocumentRoot ${TESTS_ROOT_DIR}
- ErrorLog "${TESTS_ROOT_DIR}/apache_error.log"
- CustomLog "${TESTS_ROOT_DIR}/apache_access.log" combined
+ #ErrorLog "${TESTS_ROOT_DIR}/apache_error.log"
+ #CustomLog "${TESTS_ROOT_DIR}/apache_access.log" combined
# Env vars used by the test code, which we get from the environment
SetEnv HTTPSERVER ${HTTPSERVER}
#!/bin/sh
-# @todo make username flexible
-
-USERNAME=test
+USERNAME="${1:-docker}"
echo "[$(date)] Bootstrapping the Test container..."
chown "${CONTAINER_USER_UID}":"${CONTAINER_USER_GID}" "${CONTAINER_USER_HOME}"
chown -R "${CONTAINER_USER_UID}":"${CONTAINER_USER_GID}" "${CONTAINER_USER_HOME}"/.*
fi
+# @todo do the same chmod for ${TESTS_ROOT_DIR}, if it's not within CONTAINER_USER_HOME
-echo "[$(date)] Fixing apache configuration..."
+echo "[$(date)] Fixing Apache configuration..."
sed -e "s?^export TESTS_ROOT_DIR=.*?export TESTS_ROOT_DIR=${TESTS_ROOT_DIR}?g" --in-place /etc/apache2/envvars
+sed -e "s?^export APACHE_RUN_USER=.*?export APACHE_RUN_USER=${USERNAME}?g" --in-place /etc/apache2/envvars
+sed -e "s?^export APACHE_RUN_GROUP=.*?export APACHE_RUN_GROUP=${USERNAME}?g" --in-place /etc/apache2/envvars
+
+echo "[$(date)] Fixing FPM configuration..."
-# @todo set as well php-fpm user/group ?
+FPMCONF="/etc/php/$(php -r 'echo implode(".",array_slice(explode(".",PHP_VERSION),0,2));' 2>/dev/null)/fpm/pool.d/www.conf"
+sed -e "s?^user =.*?user = ${USERNAME}?g" --in-place "${FPMCONF}"
+sed -e "s?^group =.*?group = ${USERNAME}?g" --in-place "${FPMCONF}"
+sed -e "s?^listen.owner =.*?listen.owner = ${USERNAME}?g" --in-place "${FPMCONF}"
+sed -e "s?^listen.group =.*?listen.group = ${USERNAME}?g" --in-place "${FPMCONF}"
echo "[$(date)] Running Composer..."
-sudo test -c "cd /home/test && composer install"
+sudo "${USERNAME}" -c "cd ${TESTS_ROOT_DIR} && composer install"
trap clean_up TERM
#!/bin/sh
-# @todo set up the same user for running tests as on travis (ie. 'travis'), or maybe user 'user' ?
# @todo make the GID & UID of the user variable (we picked 2000 as it is the one used by default by Travis)
set -e
-USERNAME="${1:-test}"
+USERNAME="${1:-docker}"
addgroup --gid 2000 "${USERNAME}"
adduser --system --uid=2000 --gid=2000 --home "/home/${USERNAME}" --shell /bin/bash "${USERNAME}"
#!/bin/sh
-# @todo support getting the 2 vars as cli args as well as via env vars?
+# @todo support getting the 2 vars as cli options as well as via env vars?
set -e
# We default to the same version we use on Travis
export UBUNTU_VERSION=${UBUNTU_VERSION:-xenial}
+CONTAINER_USER=docker
+CONTAINER_BUILD_DIR="/home/${CONTAINER_USER}/build"
+ROOT_DIR="$(dirname -- "$(dirname -- "$(dirname -- "$(readlink -f "$0")")")")"
IMAGE_NAME=phpxmlrpc:${UBUNTU_VERSION}-${PHP_VERSION}
CONTAINER_NAME=phpxmlrpc_${UBUNTU_VERSION}_${PHP_VERSION}
-ROOT_DIR="$(dirname -- "$(dirname -- "$(dirname -- "$(readlink -f "$0")")")")"
cd "$(dirname -- "$(readlink -f "$0")")"
Commands:
build build or rebuild the containers and set up the test env
+ cleanup removes the docker containers and their images
enter enter the test container
- #exec \$cmd execute a single shell command in the test container
- #runtests [\$suite] execute the test suite using the test container (or a single test scenario eg. Tests/1ParsingBugsTest.php)
+ inspect
+ logs
+ ps
+ runtests [\$suite] execute the test suite using the test container (or a single test scenario eg. tests/1ParsingBugsTest.php)
+ runcoverage execute the test suite and generate a code coverage report (in build/coverage)
start start the containers
- #status
stop stop containers
+ top
Options:
-h print help
+
+Environment variables: to be set before the 'build' action
+ PHP_VERSION default value: 'default', ie. the stock php version from the Ubuntu version in use. Other possible values: 7.0 .. 8.0
+ UBUNTU_VERSION default value: xenial. Other possible values: bionic, focal
"
}
docker run -d \
-p 80:80 -p 443:443 -p 8080:8080 \
--name "${CONTAINER_NAME}" \
- --env CONTAINER_USER_UID=$(id -u) --env CONTAINER_USER_GID=$(id -g) --env TESTS_ROOT_DIR=/home/test \
+ --env CONTAINER_USER_UID=$(id -u) --env CONTAINER_USER_GID=$(id -g) \
+ --env TESTS_ROOT_DIR=${CONTAINER_BUILD_DIR} \
--env HTTPSERVER=localhost \
--env HTTPURI=/demo/server/server.php \
--env HTTPSSERVER=localhost \
--env HTTPSIGNOREPEER=1 \
--env SSLVERSION=0 \
--env DEBUG=0 \
- -v "${ROOT_DIR}":/home/test "${IMAGE_NAME}"
+ -v "${ROOT_DIR}":"${CONTAINER_BUILD_DIR}" \
+ "${IMAGE_NAME}"
}
start() {
;;
enter | shell | cli)
- docker exec -it "${CONTAINER_NAME}" su test
+ # @todo allow login as root
+ docker exec -it "${CONTAINER_NAME}" su "${CONTAINER_USER}"
;;
+ # @todo implement
#exec)
# ;;
start
;;
- #runtests)
- # ;;
+ runcoverage)
+ # @todo clean up /tmp/phpxmlrpc and .phpunit.result.cache
+ if [ ! -d build ]; then mkdir build; fi
+ docker exec -t "${CONTAINER_NAME}" /home/${CONTAINER_USER}/build/tests/ci/setup/setup_code_coverage.sh enable
+ docker exec -it "${CONTAINER_NAME}" su "${CONTAINER_USER}" -c "./vendor/bin/phpunit --coverage-html build/coverage -v tests"
+ docker exec -t "${CONTAINER_NAME}" /home/${CONTAINER_USER}/build/tests/ci/setup/setup_code_coverage.sh disable
+ ;;
+
+ runtests)
+ docker exec -it "${CONTAINER_NAME}" su "${CONTAINER_USER}" -c "./vendor/bin/phpunit -v tests"
+ ;;
start)
start