Skip to content


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

# check for the latest version
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" \

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 src
$ cd src
$ git checkout VERSION

Then run:

test/ \
  primary_port \
  secondary_port \
  mod_pagespeed_dir \

For example:

$ test/ 8050 8051 /path/to/mod_pagespeed \

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.'

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 &

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/ ...

Testing with the native fetcher

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


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

TEST_NATIVE_FETCHER=true test/ ...

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/ ...
You can’t perform that action at this time.