From 43fc083df2ffca313b780c31342b9906ece05308 Mon Sep 17 00:00:00 2001 From: Christian Kuhn Date: Wed, 20 Apr 2016 15:37:47 +0200 Subject: [PATCH] [TASK] travis: Acceptance tests with nginx+fpm * Start a php-fpm server on port 9000 * Install nginx, configure and start on port 8000 for acceptance tests * Use phantomjs provided by composer directly without selenium Change-Id: Ie25c27d765437ed0a12d1df9b0c9b1a4355b1024 Resolves: #75837 Releases: master Reviewed-on: https://review.typo3.org/47815 Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn --- .travis.yml | 40 +++++-------- .../TravisNginxFpm/ConfigureStartNginxFpm.sh | 15 +++++ .../TravisNginxFpm/nginx.tpl.conf | 56 +++++++++++++++++++ .../Configuration/TravisNginxFpm/php-fpm.conf | 7 +++ typo3/sysext/core/Tests/Acceptance.suite.yml | 3 +- 5 files changed, 95 insertions(+), 26 deletions(-) create mode 100755 typo3/sysext/core/Build/Configuration/TravisNginxFpm/ConfigureStartNginxFpm.sh create mode 100644 typo3/sysext/core/Build/Configuration/TravisNginxFpm/nginx.tpl.conf create mode 100644 typo3/sysext/core/Build/Configuration/TravisNginxFpm/php-fpm.conf diff --git a/.travis.yml b/.travis.yml index 72d09859030a..8b0fde3adddd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ matrix: include: - php: 7 - env: UNIT_TESTS=yes FUNCTIONAL_TESTS=yes ACCEPTANCE_TESTS=no PHP_LINT=yes XLF_CHECK=yes SUBMODULE_TEST=yes EXCEPTIONCODE_TEST=yes + env: UNIT_TESTS=yes FUNCTIONAL_TESTS=yes ACCEPTANCE_TESTS=yes PHP_LINT=yes XLF_CHECK=yes SUBMODULE_TEST=yes EXCEPTIONCODE_TEST=yes sudo: false @@ -14,6 +14,8 @@ addons: packages: - parallel - ack-grep + - nginx + - realpath cache: directories: @@ -50,51 +52,41 @@ before_script: - phpenv config-rm xdebug.ini - if [ "$GITHUB_COMPOSER_AUTH" ]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi - composer install + - typo3/sysext/core/Build/Configuration/TravisNginxFpm/ConfigureStartNginxFpm.sh + - mkdir -p typo3temp/var/tests + - export typo3DatabaseName="typo3" + - export typo3DatabaseHost="localhost" + - export typo3DatabaseUsername="root" + - export typo3DatabasePassword="" script: - > if [[ "$UNIT_TESTS" == "yes" ]]; then - echo; - echo "Running unit tests"; ./bin/phpunit -c typo3/sysext/core/Build/UnitTests.xml fi + - > if [[ "$FUNCTIONAL_TESTS" == "yes" ]]; then - echo; - export typo3DatabaseName="typo3"; - export typo3DatabaseHost="localhost"; - export typo3DatabaseUsername="root"; - export typo3DatabasePassword=""; find . -wholename '*typo3/sysext/*/Tests/Functional/*Test.php' | parallel --jobs 6 --gnu 'echo; echo "Running functional test suite {}"; ./bin/phpunit -c typo3/sysext/core/Build/FunctionalTests.xml {}' fi + - > if [[ "$ACCEPTANCE_TESTS" == "yes" ]]; then - export _JAVA_OPTIONS="-Xms1024m -Xmx1024m"; - ./bin/selenium-server-standalone >/dev/null 2>&1 & - php -S 0.0.0.0:8000 >/dev/null 2>&1 & - sleep 5; - export typo3DatabaseName="typo3"; - export typo3DatabaseHost="localhost"; - export typo3DatabaseUsername="root"; - export typo3DatabasePassword=""; - ./bin/codecept run Acceptance -c typo3/sysext/core/Build/AcceptanceTests.yml --debug + ./bin/codecept run Acceptance -c typo3/sysext/core/Build/AcceptanceTests.yml fi + - > if [[ "$PHP_LINT" == "yes" ]]; then - echo; - echo "Running php lint"; find typo3/ -name \*.php -not -path "vendor/*" | parallel --jobs 6 --gnu php -d display_errors=stderr -l {} > /dev/null \; fi + - > if [[ "$XLF_CHECK" == "yes" ]]; then - echo; - echo "Running XLF checker"; ./typo3/sysext/core/Build/Scripts/xlfcheck.sh fi + - > if [[ "$SUBMODULE_TEST" == "yes" ]]; then - echo; - echo "Running git submodule check"; /bin/bash -c " if [[ `git submodule status 2>&1 | wc -l` -ne 0 ]]; then echo \"Found a submodule definition in repository\"; @@ -105,7 +97,5 @@ script: - > if [[ "$EXCEPTIONCODE_TEST" == "yes" ]]; then - echo; - echo "Running duplicate exception code checker"; ./typo3/sysext/core/Build/Scripts/duplicateExceptionCodeCheck.sh fi diff --git a/typo3/sysext/core/Build/Configuration/TravisNginxFpm/ConfigureStartNginxFpm.sh b/typo3/sysext/core/Build/Configuration/TravisNginxFpm/ConfigureStartNginxFpm.sh new file mode 100755 index 000000000000..28e990e3ff76 --- /dev/null +++ b/typo3/sysext/core/Build/Configuration/TravisNginxFpm/ConfigureStartNginxFpm.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +DIR=$(realpath $(dirname "$0")) +PHP_VERSION=$(phpenv version-name) +ROOT=$(realpath "$DIR/../../../../../..") +PHP_FPM_BIN="$HOME/.phpenv/versions/$PHP_VERSION/sbin/php-fpm" +PHP_FPM_CONF="$DIR/php-fpm.conf" + +# Start php-fpm +"$PHP_FPM_BIN" --fpm-config "$PHP_FPM_CONF" + +# Build nginx config file and start nginx +sed -e "s|{ROOT}|$ROOT|g" < "$DIR/nginx.tpl.conf" > "$ROOT/nginx.conf" +nginx -c "$ROOT/nginx.conf" \ No newline at end of file diff --git a/typo3/sysext/core/Build/Configuration/TravisNginxFpm/nginx.tpl.conf b/typo3/sysext/core/Build/Configuration/TravisNginxFpm/nginx.tpl.conf new file mode 100644 index 000000000000..41c9a1297351 --- /dev/null +++ b/typo3/sysext/core/Build/Configuration/TravisNginxFpm/nginx.tpl.conf @@ -0,0 +1,56 @@ +error_log /tmp/error.log; +pid /tmp/nginx.pid; +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + # Set an array of temp and cache file options that will otherwise default to restricted locations accessible only to root + client_body_temp_path /tmp/client_body; + fastcgi_temp_path /tmp/fastcgi_temp; + proxy_temp_path /tmp/proxy_temp; + scgi_temp_path /tmp/scgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + + # Basic Settings + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Logging Settings + access_log /tmp/access.log; + + # Gzip Settings + gzip on; + gzip_disable "msie6"; + + server { + listen 8000 default_server; + listen [::]:8000 default_server ipv6only=on; + + root {ROOT}; + + location / { + # First attempt to serve request as file, then as directory, then fall back to index.html + try_files $uri $uri/ /index.html; + } + + location ~* "\.php(/|$)" { + include /etc/nginx/fastcgi_params; + + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SERVER_NAME $host; + + fastcgi_pass 127.0.0.1:9000; + } + } +} \ No newline at end of file diff --git a/typo3/sysext/core/Build/Configuration/TravisNginxFpm/php-fpm.conf b/typo3/sysext/core/Build/Configuration/TravisNginxFpm/php-fpm.conf new file mode 100644 index 000000000000..73e173599f0a --- /dev/null +++ b/typo3/sysext/core/Build/Configuration/TravisNginxFpm/php-fpm.conf @@ -0,0 +1,7 @@ +[travis] +listen = 9000 +listen.mode = 0666 +pm = static +pm.max_children = 5 +request_terminate_timeout = 360s +php_admin_value[memory_limit] = 256M \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Acceptance.suite.yml b/typo3/sysext/core/Tests/Acceptance.suite.yml index fab19fba89fc..45cc3daa4ccc 100644 --- a/typo3/sysext/core/Tests/Acceptance.suite.yml +++ b/typo3/sysext/core/Tests/Acceptance.suite.yml @@ -8,7 +8,7 @@ modules: WebDriver: url: http://localhost:8000/typo3temp/var/tests/acceptance browser: phantomjs - port: 4444 + port: 4445 window_size: 1440x570 wait: 1 restart: true @@ -26,3 +26,4 @@ env: config: WebDriver: browser: firefox + port: 4444