diff --git a/.gitignore b/.gitignore index 8d5457d38..020324563 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -test/pagespeed_test.conf +test/tmp diff --git a/README.md b/README.md index 85ca4833c..6fb7a5d8f 100644 --- a/README.md +++ b/README.md @@ -213,13 +213,12 @@ Then run: primary_port \ secondary_port \ mod_pagespeed_dir \ - file_cache_path \ nginx_executable_path For example: $ test/nginx_system_test.sh 8050 8051 /path/to/mod_pagespeed \ - /path/to/ngx_pagespeed_cache /path/to/sbin/nginx + /path/to/sbin/nginx This should print out a lot of lines like: diff --git a/test/nginx_system_test.sh b/test/nginx_system_test.sh index c86ccbfb7..b7af4368d 100755 --- a/test/nginx_system_test.sh +++ b/test/nginx_system_test.sh @@ -25,25 +25,21 @@ # Exits with status 2 if command line args are wrong. # # Usage: -# ./ngx_system_test.sh primary_port secondary_port \ -# mod_pagespeed_dir file_cache_path -# for example: -# ./ngx_system_test.sh 8050 8051 \ -# /path/to/mod_pagespeed \ -# /path.to/ngx_pagespeed_cache +# ./ngx_system_test.sh primary_port secondary_port mod_pagespeed_dir +# Example: +# ./ngx_system_test.sh 8050 8051 /path/to/mod_pagespeed # -if [ "$#" -ne 5 ] ; then +if [ "$#" -ne 4 ] ; then echo "Usage: $0 primary_port secondary_port mod_pagespeed_dir" - echo " file_cache_path nginx_executable" - exit 1 + echo " nginx_executable" + exit 2 fi PRIMARY_PORT="$1" SECONDARY_PORT="$2" MOD_PAGESPEED_DIR="$3" -FILE_CACHE_PATH="$4" -NGINX_EXECUTABLE="$5" +NGINX_EXECUTABLE="$4" PRIMARY_HOSTNAME="localhost:$PRIMARY_PORT" SECONDARY_HOSTNAME="localhost:$SECONDARY_PORT" @@ -54,7 +50,7 @@ SERVER_ROOT="$MOD_PAGESPEED_DIR/src/install/" # them. function handle_failure_simple() { echo "FAIL" - exit 2 + exit 1 } function check_simple() { echo " check" "$@" @@ -67,9 +63,19 @@ function check_not_simple() { this_dir="$( cd $(dirname "$0") && pwd)" +# stop nginx +killall nginx + +TEST_TMP="$this_dir/tmp" +rm -r "$TEST_TMP" +check_simple mkdir "$TEST_TMP" +FILE_CACHE="$TEST_TMP/file-cache/" +check_simple mkdir "$FILE_CACHE" + + # set up the config file for the test -PAGESPEED_CONF="$this_dir/pagespeed_test.conf" -PAGESPEED_CONF_TEMPLATE="$PAGESPEED_CONF.template" +PAGESPEED_CONF="$TEST_TMP/pagespeed_test.conf" +PAGESPEED_CONF_TEMPLATE="$this_dir/pagespeed_test.conf.template" # check for config file template check_simple test -e "$PAGESPEED_CONF_TEMPLATE" # create PAGESPEED_CONF by substituting on PAGESPEED_CONF_TEMPLATE @@ -78,7 +84,8 @@ This file is automatically generated from $PAGESPEED_CONF_TEMPLATE" by nginx_system_test.sh; don't edit here." EOF cat $PAGESPEED_CONF_TEMPLATE \ - | sed 's#@@FILE_CACHE_PATH@@#'"$FILE_CACHE_PATH/"'#' \ + | sed 's#@@TEST_TMP@@#'"$TEST_TMP/"'#' \ + | sed 's#@@FILE_CACHE@@#'"$FILE_CACHE/"'#' \ | sed 's#@@SERVER_ROOT@@#'"$SERVER_ROOT"'#' \ | sed 's#@@PRIMARY_PORT@@#'"$PRIMARY_PORT"'#' \ | sed 's#@@SECONDARY_PORT@@#'"$SECONDARY_PORT"'#' \ @@ -86,9 +93,7 @@ cat $PAGESPEED_CONF_TEMPLATE \ # make sure we substituted all the variables check_not_simple grep @@ $PAGESPEED_CONF -# restart nginx with new config -killall nginx -sleep .1 +# start nginx with new config check_simple "$NGINX_EXECUTABLE" -c "$PAGESPEED_CONF" # run generic system tests diff --git a/test/pagespeed_test.conf.template b/test/pagespeed_test.conf.template index 6f131466e..e976b1b68 100644 --- a/test/pagespeed_test.conf.template +++ b/test/pagespeed_test.conf.template @@ -1,20 +1,14 @@ -# nginx_system_test.sh makes a few substitutions to this file to generate -# pagespeed_test.conf +# nginx_system_test.sh makes a few substitutions to pagespeed_test.conf.template +# file to generate @@TEST_TMP@@/pagespeed_test.conf -#user nobody; worker_processes 1; # for debugging #daemon off; #master_process off; -#error_log logs/error.log; -#error_log logs/error.log notice; -#error_log logs/error.log info; -error_log logs/error.log debug; - -#pid logs/nginx.pid; - +error_log "@@TEST_TMP@@/error.log" debug; +pid "@@TEST_TMP@@/nginx.pid"; events { worker_connections 1024; @@ -22,13 +16,14 @@ events { http { + access_log "@@TEST_TMP@@/access.log"; root "@@SERVER_ROOT@@"; server { listen @@PRIMARY_PORT@@; server_name localhost; - pagespeed FileCachePath "@@FILE_CACHE_PATH@@"; + pagespeed FileCachePath "@@FILE_CACHE@@"; # uncomment the following two lines if you're testing memcached #pagespeed MemcachedServers "localhost:11211";