Testing

Jeffrey Crowell edited this page Apr 11, 2016 · 17 revisions

To run the ngx_pagespeed tests you need to first have built it. You also need to add four modules that we use for testing: ngx_cache_purge, set-misc-nginx-module, ngx_devel_kit, and headers-more. This changes the installation process to look something like:

# at this point you've got nginx and ngx_pagespeed downloaded, including psol
git clone https://github.com/FRiCKLE/ngx_cache_purge.git
NGX_CACHE_PURGE=$PWD/ngx_cache_purge

# check http://openresty.org/#Download for the latest version
wget http://openresty.org/download/ngx_openresty-VERSION.tar.gz
tar xzvf ngx_openresty-*.tar.gz
cd ngx_openresty-*/
./configure --with-luajit
make # no need to "make install"
NGX_DEVEL_KIT=$(echo $WORKDIR/ngx_openresty-*/build/ngx_devel_kit-*/)
SET_MISC_MODULE=$(echo $WORKDIR/ngx_openresty-*/build/set-misc-nginx-module-*/)
HEADERS_MORE_MODULE=$(echo $WORKDIR/ngx_openresty-*/build/headers-more-nginx-module-*/)

cd nginx-whatever
./configure \
   --add-module="/path/to/ngx_pagespeed" \
   --add-module="$NGX_CACHE_PURGE" \
   --add-module="$NGX_DEVEL_KIT" \
   --add-module="$SET_MISC_MODULE" \
   --add-module="$HEADERS_MORE_MODULE" \
   --with-ipv6

Next, check out mod_pagespeed. We can take a shortcut and do this the easy way, without gyp, because we don't need any dependencies:

$ mkdir mod_pagespeed
$ cd mod_pagespeed
$ git clone https://github.com/pagespeed/mod_pagespeed src
$ cd src
$ git checkout VERSION

Then run:

test/run_tests.sh \
  primary_port \
  secondary_port \
  mod_pagespeed_dir \
  nginx_executable_path

For example:

$ test/run_tests.sh 8050 8051 /path/to/mod_pagespeed \
    /path/to/sbin/nginx

All of these paths need to be absolute.

This should print out a lot of lines like:

TEST: Make sure 404s aren't rewritten
      check_not fgrep /mod_pagespeed_beacon /dev/fd/63

and then eventually:

Failing Tests:
  ...
MOSTLY PASS.  Expected failures only.
With serf fetcher setup.

Each of these failed tests is a known issue.

If it fails with:

TEST: PHP is enabled.
...
in 'PHP is enabled.'
FAIL.

the problem is that the test expects a php server to be running on port 9000:

$ sudo apt-get install php5-cgi
$ php-cgi -b 127.0.0.1:9000 &

If it fails with some other error, that's a problem, and it would be helpful for you to submit a bug.

Log files are in test/tmp/error.log and test/tmp/access.log.

Testing with memcached

Start an memcached server:

$ memcached -p 11211

In ngx_pagespeed/test/pagespeed_test.conf.template uncomment:

pagespeed MemcachedServers "localhost:11211";
pagespeed MemcachedThreads 1;

Then run the system test as above.

Testing with valgrind

If you set the environment variable USE_VALGRIND=true then the tests will run with valgrind:

USE_VALGRIND=true test/nginx_system_test.sh ...

Testing with the native fetcher

You can run the whole system test with the native fetcher instead of the serf fetcher:

TEST_NATIVE_FETCHER=true TEST_SERF_FETCHER=false test/nginx_system_test.sh ...

You can also run all the tests twice, once for each fetcher, serf fetcher first:

TEST_NATIVE_FETCHER=true test/nginx_system_test.sh ...

Manual debugging

If you just want to run some wgets against the testing setup you can ask the testing script to quit before actually running any tests, leaving nginx up:

RUN_TESTS=false test/nginx_system_test.sh ...
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.