Mercurial > hg > nginx-tests
comparison syslog.t @ 771:abe795720deb
Tests: added test for syslog nohostname parameter.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 29 Oct 2015 12:53:56 +0300 |
parents | 907e89fba9c3 |
children | 1f48ed26b49a |
comparison
equal
deleted
inserted
replaced
770:c35b071d4b47 | 771:abe795720deb |
---|---|
24 | 24 |
25 plan(skip_all => 'win32') if $^O eq 'MSWin32'; | 25 plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
26 | 26 |
27 my $t = Test::Nginx->new()->has(qw/http limit_req/); | 27 my $t = Test::Nginx->new()->has(qw/http limit_req/); |
28 | 28 |
29 $t->plan(58)->write_file_expand('nginx.conf', <<'EOF'); | 29 $t->write_file_expand('nginx.conf', <<'EOF'); |
30 | 30 |
31 %%TEST_GLOBALS%% | 31 %%TEST_GLOBALS%% |
32 | 32 |
33 error_log syslog:server=127.0.0.1:8083 info; | 33 error_log syslog:server=127.0.0.1:8083 info; |
34 error_log %%TESTDIR%%/f_glob.log info; | 34 error_log %%TESTDIR%%/f_glob.log info; |
90 } | 90 } |
91 location /if { | 91 location /if { |
92 access_log syslog:server=127.0.0.1:8085 logf if=$arg_logme; | 92 access_log syslog:server=127.0.0.1:8085 logf if=$arg_logme; |
93 } | 93 } |
94 | 94 |
95 location /nohostname { | |
96 access_log syslog:server=127.0.0.1:8080,nohostname; | |
97 } | |
98 | |
95 location /debug { | 99 location /debug { |
96 limit_req zone=one; | 100 limit_req zone=one; |
97 error_log syslog:server=127.0.0.1:8080 debug; | 101 error_log syslog:server=127.0.0.1:8080 debug; |
98 } | 102 } |
99 location /info { | 103 location /info { |
139 | 143 |
140 $t->waitforfile($t->testdir . '/s_glob.log'); | 144 $t->waitforfile($t->testdir . '/s_glob.log'); |
141 $t->waitforfile($t->testdir . '/s_http.log'); | 145 $t->waitforfile($t->testdir . '/s_http.log'); |
142 $t->waitforfile($t->testdir . '/s_if.log'); | 146 $t->waitforfile($t->testdir . '/s_if.log'); |
143 | 147 |
144 $t->run(); | 148 $t->try_run('no syslog nohostname')->plan(59); |
145 | 149 |
146 ############################################################################### | 150 ############################################################################### |
147 | 151 |
148 parse_syslog_message('error_log', get_syslog('/e')); | 152 parse_syslog_message('error_log', get_syslog('/e')); |
149 parse_syslog_message('access_log', get_syslog('/a')); | 153 parse_syslog_message('access_log', get_syslog('/a')); |
206 | 210 |
207 get_syslog('/a'); | 211 get_syslog('/a'); |
208 | 212 |
209 like($t->read_file('s_if.log'), qr/good:404.*work:404/s, 'syslog if success'); | 213 like($t->read_file('s_if.log'), qr/good:404.*work:404/s, 'syslog if success'); |
210 unlike($t->read_file('s_if.log'), qr/(if:|empty:|zero:)404/, 'syslog if fail'); | 214 unlike($t->read_file('s_if.log'), qr/(if:|empty:|zero:)404/, 'syslog if fail'); |
215 | |
216 like(get_syslog('/nohostname'), | |
217 qr/^<(\d{1,3})> # PRI | |
218 ([A-Z][a-z]{2})\s # mon | |
219 ([ \d]\d)\s(\d{2}):(\d{2}):(\d{2})\s # date | |
220 (\w{1,32}):\s # tag | |
221 (.*)/x, # MSG | |
222 'nohostname'); | |
211 | 223 |
212 ############################################################################### | 224 ############################################################################### |
213 | 225 |
214 sub syslog_lines { | 226 sub syslog_lines { |
215 my ($uri, $pattern, $port) = @_; | 227 my ($uri, $pattern, $port) = @_; |