Skip to content

Commit 274256e

Browse files
spacewanderthibaultcha
authored andcommitted
tests: pipe.t: assert the behavior of ngx.pipe.spawn() when error_log is configured with syslog.
1 parent 4b6ad57 commit 274256e

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ env:
4545
- NGINX_VERSION=1.15.8 OPENSSL_VER=1.0.2n OPENSSL_PATCH_VER=1.0.2h
4646
- NGINX_VERSION=1.15.8 OPENSSL_VER=1.1.0h OPENSSL_PATCH_VER=1.1.0d
4747

48+
services:
49+
- memcache
50+
4851
before_install:
4952
- sudo luarocks install luacheck $LUACHECK_VER
5053
- luacheck -q .

t/TestCore.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use Test::Nginx::Socket::Lua -Base;
44
use Cwd qw(cwd);
55

66
$ENV{TEST_NGINX_HOTLOOP} ||= 10;
7+
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
78

89
our $pwd = cwd();
910

t/pipe.t

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,3 +1493,56 @@ timeout
14931493
[error]
14941494
--- error_log
14951495
lua pipe wait process:
1496+
1497+
1498+
1499+
=== TEST 43: spawn sub-process when error_log is configured with syslog
1500+
--- config
1501+
location = /t {
1502+
content_by_lua_block {
1503+
local function get_ngx_bin_path()
1504+
local ffi = require "ffi"
1505+
ffi.cdef[[char **ngx_argv;]]
1506+
return ffi.string(ffi.C.ngx_argv[0])
1507+
end
1508+
1509+
local conf_file = "$TEST_NGINX_HTML_DIR/nginx.conf"
1510+
local nginx = get_ngx_bin_path()
1511+
1512+
local cmd = nginx .. " -p $TEST_NGINX_HTML_DIR -c " .. conf_file
1513+
local ngx_pipe = require "ngx.pipe"
1514+
local ok, reason, status = ngx_pipe.spawn(cmd):wait()
1515+
ngx.say(ok)
1516+
ngx.say(reason)
1517+
ngx.say(status)
1518+
}
1519+
}
1520+
--- user_files
1521+
>>> nginx.conf
1522+
events {
1523+
worker_connections 64;
1524+
}
1525+
error_log syslog:server=127.0.0.1:$TEST_NGINX_MEMCACHED_PORT,facility=local1 info;
1526+
daemon off;
1527+
master_process off;
1528+
worker_processes 1;
1529+
http {
1530+
lua_package_path "$TEST_NGINX_LUA_PACKAGE_PATH";
1531+
init_worker_by_lua_block {
1532+
ngx.timer.at(0, function()
1533+
local ngx_pipe = require "ngx.pipe"
1534+
local ok, reason, status = ngx_pipe.spawn("echo"):wait()
1535+
if not ok then
1536+
os.exit(status)
1537+
end
1538+
os.exit(0)
1539+
end)
1540+
}
1541+
}
1542+
>>> logs/error.log
1543+
--- response_body
1544+
true
1545+
exit
1546+
0
1547+
--- no_error_log
1548+
[error]

0 commit comments

Comments
 (0)