From 3eac0ecaef047baac8c2e7494b23b2654453462c Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Fri, 19 Feb 2016 19:33:47 -0500 Subject: [PATCH 2/3] Fix the tests to pass and handle conditions that should fail properly The tests now pass, and more importantly, they also check for the existence of the necessary configuration files before proceeding. This prevents tests from running when they can't actually configure (like for instance, if the fpm config file doesn't exist for the fpm test). There are also additional commands now to prevent conflicting configurations from being potentially present and active. Also, apache2 has been added as a requirement for the mod-php test so that /var/www/html will exist to write the test php file. --- debian/tests.in/cgi | 14 ++++++++------ debian/tests.in/control | 2 +- debian/tests.in/fpm | 17 ++++++++++++----- debian/tests.in/mod-php | 21 ++++++++++++++++++++- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/debian/tests.in/cgi b/debian/tests.in/cgi index b00eb42..937951f 100644 --- a/debian/tests.in/cgi +++ b/debian/tests.in/cgi @@ -3,9 +3,7 @@ set -e # Author: Robie Basak -# /etc/apache2/conf-available/php@PHP_VERSION@-cgi.conf should exist. If this is renamed -# to /etc/apache2/conf-available/php@PHP_VERSION@-cgi in the future, then this test needs -# to be updated. +# /etc/apache2/conf-available/php@PHP_VERSION@-cgi.conf should exist. if [ ! -f /etc/apache2/conf-available/php@PHP_VERSION@-cgi.conf ]; then echo "/etc/apache2/conf-available/php@PHP_VERSION@-cgi.conf not found" >&2 @@ -22,9 +20,13 @@ EOT # mode here. a2dismod php@PHP_VERSION@ 2>/dev/null || true -a2enmod actions -a2enmod cgi 2>/dev/null -a2enconf php@PHP_VERSION@-cgi +# Ensure that fpm is disabled, since we want to get CGI here +a2dismod proxy-fcgi 2>/dev/null || true +a2disconf php@PHP_VERSION@ 2>/dev/null || true + +a2enmod actions 2>/dev/null || true +a2enmod cgi 2>/dev/null || true +a2enconf php@PHP_VERSION@-cgi 2>/dev/null || true service apache2 restart 2>/dev/null result=`wget -O- http://localhost/hello.php 2>/dev/null` test "$result" = "Hello, world!" diff --git a/debian/tests.in/control b/debian/tests.in/control index 19af295..c2ea997 100644 --- a/debian/tests.in/control +++ b/debian/tests.in/control @@ -6,7 +6,7 @@ Depends: apache2, php@PHP_VERSION@-cgi Restrictions: needs-root Tests: mod-php -Depends: libapache2-mod-php@PHP_VERSION@ +Depends: apache2, libapache2-mod-php@PHP_VERSION@ Restrictions: needs-root Tests: fpm diff --git a/debian/tests.in/fpm b/debian/tests.in/fpm index 11b8a8b..dc77c20 100644 --- a/debian/tests.in/fpm +++ b/debian/tests.in/fpm @@ -4,22 +4,29 @@ set -e # PHP-FPM test based on mod-php test # Author: Neal Gompa +# /etc/apache2/conf-available/php@PHP_VERSION@-fpm.conf should exist. + +if [ ! -f /etc/apache2/conf-available/php@PHP_VERSION@-fpm.conf ]; then + echo "/etc/apache2/conf-available/php@PHP_VERSION@-fpm.conf not found" >&2 + exit 1 +fi + cat > /var/www/html/hello.php < EOT -# Make sure that any CGI mechanism is disabled, since we want to test mod_php -# mode here. +# Make sure that any CGI mechanism is disabled, since we want to test +# php-fpm here. a2dismod actions 2>/dev/null || true a2dismod cgi 2>/dev/null || true a2disconf php@PHP_VERSION@-cgi 2>/dev/null || true # Ensure that mod_php is disabled -a2dismod php@PHP_VERSION@ 2>/dev/null +a2dismod php@PHP_VERSION@ 2>/dev/null || true # php-fpm configuration requires mod_proxy_fcgi -a2enmod proxy_fcgi -a2enconf php@PHP_VERSION@-fpm +a2enmod proxy_fcgi 2>/dev/null || true +a2enconf php@PHP_VERSION@-fpm 2>/dev/null || true service apache2 restart 2>/dev/null result=`wget -O- http://localhost/hello.php 2>/dev/null` test "$result" = "Hello, world!" diff --git a/debian/tests.in/mod-php b/debian/tests.in/mod-php index 3529112..9b822d1 100644 --- a/debian/tests.in/mod-php +++ b/debian/tests.in/mod-php @@ -3,6 +3,20 @@ set -e # Author: Robie Basak + +# /etc/apache2/mods-available/php@PHP_VERSION@.{conf,load} should exist. + +if [ ! -f /etc/apache2/mods-available/php@PHP_VERSION@.conf ]; then + echo "/etc/apache2/mods-available/php@PHP_VERSION@.conf not found" >&2 + exit 1 +fi + +if [ ! -f /etc/apache2/mods-available/php@PHP_VERSION@.load ]; then + echo "/etc/apache2/mods-available/php@PHP_VERSION@.load not found" >&2 + exit 1 +fi + + cat > /var/www/html/hello.php < EOT @@ -13,7 +27,12 @@ a2dismod actions 2>/dev/null || true a2dismod cgi 2>/dev/null || true a2disconf php@PHP_VERSION@-cgi 2>/dev/null || true -a2enmod php@PHP_VERSION@ 2>/dev/null +# Make sure that fpm configuration is disabled for the same reasons we disabled +# CGI mechanisms +a2dismod proxy_fcgi 2>/dev/null || true +a2disconf php@PHP_VERSION@-fpm 2>/dev/null || true + +a2enmod php@PHP_VERSION@ 2>/dev/null || true service apache2 restart 2>/dev/null result=`wget -O- http://localhost/hello.php 2>/dev/null` test "$result" = "Hello, world!" -- 2.5.0