Mercurial > hg > nginx-tests
comparison access_log.t @ 899:c0c2fc0e7208
Tests: style.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 18 Apr 2016 13:56:13 +0300 |
parents | f75bc412e802 |
children | 257de77879e8 |
comparison
equal
deleted
inserted
replaced
898:3f453670bfac | 899:c0c2fc0e7208 |
---|---|
125 http_get('/varlog'); | 125 http_get('/varlog'); |
126 http_get('/varlog?logname='); | 126 http_get('/varlog?logname='); |
127 http_get('/varlog?logname=0'); | 127 http_get('/varlog?logname=0'); |
128 http_get('/varlog?logname=filename'); | 128 http_get('/varlog?logname=filename'); |
129 | 129 |
130 | |
131 # wait for file to appear with nonzero size thanks to the flush parameter | 130 # wait for file to appear with nonzero size thanks to the flush parameter |
132 | 131 |
133 for (1 .. 10) { | 132 for (1 .. 10) { |
134 last if -s $t->testdir() . '/compressed.log'; | 133 last if -s $t->testdir() . '/compressed.log'; |
135 select undef, undef, undef, 0.1; | 134 select undef, undef, undef, 0.1; |
155 | 154 |
156 # verify that by default, 'combined' format is used, 'off' disables logging | 155 # verify that by default, 'combined' format is used, 'off' disables logging |
157 | 156 |
158 my $addr = IO::Socket::INET->new(LocalAddr => '127.0.0.1')->sockhost(); | 157 my $addr = IO::Socket::INET->new(LocalAddr => '127.0.0.1')->sockhost(); |
159 | 158 |
160 $log = $t->read_file('combined.log'); | 159 like($t->read_file('combined.log'), |
161 like($log, | |
162 qr!^\Q$addr - - [\E .* | 160 qr!^\Q$addr - - [\E .* |
163 \Q] "GET /combined HTTP/1.0" 200 2 "-" "-"\E$!x, | 161 \Q] "GET /combined HTTP/1.0" 200 2 "-" "-"\E$!x, |
164 'default log format'); | 162 'default log format'); |
165 | 163 |
166 # verify that log filtering works | 164 # verify that log filtering works |
167 | 165 |
168 $log = $t->read_file('filtered.log'); | 166 $log = $t->read_file('filtered.log'); |
169 is($log, "/filtered/good:200\n/filtered/work:200\n", 'log filtering'); | 167 is($log, "/filtered/good:200\n/filtered/work:200\n", 'log filtering'); |
170 | |
171 | 168 |
172 # verify "if=" argument works with complex value | 169 # verify "if=" argument works with complex value |
173 | 170 |
174 my $exp_complex = <<'EOF'; | 171 my $exp_complex = <<'EOF'; |
175 /filtered/complex/one:200 | 172 /filtered/complex/one:200 |
178 /filtered/complex/either2:200 | 175 /filtered/complex/either2:200 |
179 /filtered/complex/either3:200 | 176 /filtered/complex/either3:200 |
180 /filtered/complex/either4:200 | 177 /filtered/complex/either4:200 |
181 EOF | 178 EOF |
182 | 179 |
183 $log = $t->read_file('complex.log'); | 180 is($t->read_file('complex.log'), $exp_complex, 'if with complex value'); |
184 is($log, $exp_complex, 'if with complex value'); | |
185 | |
186 | 181 |
187 # buffer created with false "if" is not reused among multiple access_log | 182 # buffer created with false "if" is not reused among multiple access_log |
188 | 183 |
189 $log = $t->read_file('/noreuse.log'); | 184 $log = $t->read_file('/noreuse.log'); |
190 is($log, "/filtered/noreuse1/good:200\n/filtered/noreuse2/good:200\n", | 185 is($log, "/filtered/noreuse1/good:200\n/filtered/noreuse2/good:200\n", |
191 'log filtering with buffering'); | 186 'log filtering with buffering'); |
192 | 187 |
193 | |
194 # multiple logs in a same location | 188 # multiple logs in a same location |
195 | 189 |
196 $log = $t->read_file('multi1.log'); | 190 is($t->read_file('multi1.log'), "/multi:200\n", 'multiple logs 1'); |
197 is($log, "/multi:200\n", 'multiple logs 1'); | |
198 | 191 |
199 # same content in the second log | 192 # same content in the second log |
200 | 193 |
201 $log = $t->read_file('multi2.log'); | 194 is($t->read_file('multi2.log'), "/multi:200\n", 'multiple logs 2'); |
202 is($log, "/multi:200\n", 'multiple logs 2'); | |
203 | |
204 | 195 |
205 # test log destinations with variables | 196 # test log destinations with variables |
206 | 197 |
207 $log = $t->read_file('varlog_0'); | 198 is($t->read_file('varlog_0'), "/varlog:200\n", 'varlog literal zero name'); |
208 is($log, "/varlog:200\n", 'varlog literal zero name'); | 199 is($t->read_file('varlog_filename'), "/varlog:200\n", 'varlog good name'); |
209 | 200 |
210 $log = $t->read_file('varlog_filename'); | 201 ############################################################################### |
211 is($log, "/varlog:200\n", 'varlog good name'); | |
212 | |
213 ############################################################################### |