Nginx本地test
介绍
- https://github.com/iresty/programming-openresty-zh/blob/master/testing/README.adoc
- https://openresty.gitbooks.io/programming-openresty/content/
步骤
- 切换root用户或者sudo 执行相关命令
- nginx 启停更,或者读写文件需要。避免权限错误。所以后续操作统一用root级用户角色
- 本地安装好nginx
|
|
- 安装 test::Nginx
|
|
-
luacov 安装(不是必须的)
-
下载源码:https://github.com/lunarmodules/luacov/tree/v0.15.0/src
-
cp luacov 到对应的lua_package_path 下即可。 比如 net-cache/nginx/share_lua 下
-
chash动态库 mac 编译(也不是必须的,用到的话,linux和mac不同)
-
如果本地没有chash的C代码,可以参考 https://github.com/openresty/lua-resty-balancer/tree/master
-
下载.chash.c, chash.h, Makefile 到本地
-
make all 即可,生成libchash.dylib
-
mv libchash.dylib 到 nginx/for_test_lib 下
-
增加root用户组
|
|
- 新建测试目录t
|
|
- 新建自定义shell脚本
|
|
- 尝试运行下ut
|
|
- 如果出错,很多内容,不好分辨
- 可以尝试启动测试nginx,排除环境问题。如果nginx可以正常启动,那么就是测试文件 test/qtest_scheduler.t的问题,按照提示修正
|
|