Skip to content

Latest commit

 

History

History
113 lines (80 loc) · 5.27 KB

test-suite.md

File metadata and controls

113 lines (80 loc) · 5.27 KB

测试套件

为了运行测试套件,依赖下面这些条件:

configure时添加的这些模块顺序是非常重要的。因为在filter链中不同的过滤模块位置决定最终输出。正确的添加顺序如上所示。

  • 第三方 Lua 库:

  • 应用:

    • mysql: 创建数据库 'ngx_test', 对用户'ngx_test'赋予所有权限,密码也是'ngx_test'。
    • memcached: 监听默认端口,11211.
    • redis: 监听默认端口, 6379.

查看developer build script内容,在搭建测试环境时确定更多细节。

在默认的测试模式下启动测试套件:

cd /path/to/lua-nginx-module
export PATH=/path/to/your/nginx/sbin:$PATH
prove -I/path/to/test-nginx/lib -r t

运行指定的测试文件:

cd /path/to/lua-nginx-module
export PATH=/path/to/your/nginx/sbin:$PATH
prove -I/path/to/test-nginx/lib t/002-content.t t/003-errors.t

在一个特别的测试文件中,运行指定的测试块,对你需要进行块测试部分添加一行--- ONLY信息,并使用prove工具运行这个.t文件。

此外,还有其他各种测试方式,基于mockeagain, valgrind 等。参考Test::Nginx documentation,有更多不同高级测试方式的资料。也可以看看在Amazon EC2的Nginx集群测试报告 http://qa.openresty.org.

返回目录

English source: Test Suite ==========

The following dependencies are required to run the test suite:

The order in which these modules are added during configuration is important because the position of any filter module in the filtering chain determines the final output, for example. The correct adding order is shown above.

  • 3rd-party Lua libraries:

  • Applications:

    • mysql: create database 'ngx_test', grant all privileges to user 'ngx_test', password is 'ngx_test'
    • memcached: listening on the default port, 11211.
    • redis: listening on the default port, 6379.

See also the developer build script for more details on setting up the testing environment.

To run the whole test suite in the default testing mode:

cd /path/to/lua-nginx-module
export PATH=/path/to/your/nginx/sbin:$PATH
prove -I/path/to/test-nginx/lib -r t

To run specific test files:

cd /path/to/lua-nginx-module
export PATH=/path/to/your/nginx/sbin:$PATH
prove -I/path/to/test-nginx/lib t/002-content.t t/003-errors.t

To run a specific test block in a particular test file, add the line --- ONLY to the test block you want to run, and then use the prove utility to run that .t file.

There are also various testing modes based on mockeagain, valgrind, and etc. Refer to the Test::Nginx documentation for more details for various advanced testing modes. See also the test reports for the Nginx test cluster running on Amazon EC2: http://qa.openresty.org.

Back to TOC