annotate access_log.t @ 570:f7bc1f74970a

Tests: avoid send errors in syslog tests with mail error_log. Use a separate mail server block for syslog parsing tests to make sure that syslog messages are always read by the receiver on the remote side. Otherwise, syslog message might not be sent due to a pending socket error.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 07 May 2015 14:28:44 +0300
parents 907e89fba9c3
children e9f48f1e905b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
2
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
3 # (C) Nginx, Inc.
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
4
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
5 # Tests for access_log.
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
6
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
7 ###############################################################################
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
8
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
9 use warnings;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
10 use strict;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
11
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
12 use Test::More;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
13
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
15
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
16 use lib 'lib';
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
17 use Test::Nginx;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
18
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
19 ###############################################################################
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
20
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
21 select STDERR; $| = 1;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
22 select STDOUT; $| = 1;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
23
568
907e89fba9c3 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 467
diff changeset
24 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(9)
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
25 ->write_file_expand('nginx.conf', <<'EOF');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
26
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
27 %%TEST_GLOBALS%%
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
28
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
29 daemon off;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
30
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
31 events {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
32 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
33
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
34 http {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
35 %%TEST_GLOBALS_HTTP%%
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
36
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
37 log_format test "$uri:$status";
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
38
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
39 server {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
40 listen 127.0.0.1:8080;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
41 server_name localhost;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
42
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
43 location /combined {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
44 access_log %%TESTDIR%%/combined.log;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
45 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
46
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
47 location /combined/off {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
48 access_log off;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
49 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
50 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
51 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
52
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
53 location /filtered {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
54 access_log %%TESTDIR%%/filtered.log test
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
55 if=$arg_logme;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
56 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
57 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
58
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
59 location /filtered/complex {
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
60 access_log %%TESTDIR%%/complex.log test
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
61 if=$arg_logme$arg_logmetoo;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
62 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
63 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
64
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
65 location /filtered/noreuse {
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
66 access_log %%TESTDIR%%/noreuse.log test buffer=16k
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
67 if=$arg_a;
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
68 access_log %%TESTDIR%%/noreuse.log test buffer=16k
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
69 if=$arg_b;
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
70 return 200 OK;
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
71 }
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
72
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
73 location /compressed {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
74 access_log %%TESTDIR%%/compressed.log test
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
75 gzip buffer=1m flush=100ms;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
76 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
77 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
78
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
79 location /multi {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
80 access_log %%TESTDIR%%/multi1.log test;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
81 access_log %%TESTDIR%%/multi2.log test;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
82 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
83 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
84
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
85 location /varlog {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
86 access_log %%TESTDIR%%/${arg_logname} test;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
87 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
88 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
89 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
90 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
91
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
92 EOF
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
93
568
907e89fba9c3 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 467
diff changeset
94 $t->run();
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
95
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
96 ###############################################################################
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
97
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
98 http_get('/combined');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
99 http_get('/combined/off');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
100
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
101 http_get('/filtered');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
102 http_get('/filtered/empty?logme=');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
103 http_get('/filtered/zero?logme=0');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
104 http_get('/filtered/good?logme=1');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
105 http_get('/filtered/work?logme=yes');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
106
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
107 http_get('/filtered/complex');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
108 http_get('/filtered/complex/one?logme=1');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
109 http_get('/filtered/complex/two?logmetoo=1');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
110 http_get('/filtered/complex/either1?logme=A&logmetoo=B');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
111 http_get('/filtered/complex/either2?logme=A');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
112 http_get('/filtered/complex/either3?logmetoo=B');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
113 http_get('/filtered/complex/either4?logme=0&logmetoo=0');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
114 http_get('/filtered/complex/neither?logme=&logmetoo=');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
115
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
116 http_get('/filtered/noreuse1/zero?a=0');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
117 http_get('/filtered/noreuse1/good?a=1');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
118 http_get('/filtered/noreuse2/zero?b=0');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
119 http_get('/filtered/noreuse2/good?b=1');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
120
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
121 http_get('/compressed');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
122
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
123 http_get('/multi');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
124
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
125 http_get('/varlog');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
126 http_get('/varlog?logname=');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
127 http_get('/varlog?logname=0');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
128 http_get('/varlog?logname=filename');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
129
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
130
451
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
131 # wait for file to appear with nonzero size thanks to the flush parameter
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
132
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
133 for (1 .. 10) {
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
134 last if -s $t->testdir() . '/compressed.log';
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
135 select undef, undef, undef, 0.1;
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
136 }
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
137
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
138 # verify that "gzip" parameter turns on compression
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
139
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
140 my $log;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
141
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
142 SKIP: {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
143 eval { require IO::Uncompress::Gunzip; };
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
144 skip("IO::Uncompress::Gunzip not installed", 1) if $@;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
145
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
146 my $gzipped = $t->read_file('compressed.log');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
147 IO::Uncompress::Gunzip::gunzip(\$gzipped => \$log);
458
ae69f9bdba92 Tests: fixed access_log.t on win32.
Maxim Dounin <mdounin@mdounin.ru>
parents: 451
diff changeset
148 like($log, qr!^/compressed:200!s, 'compressed log - flush time');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
149 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
150
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
151 # now verify all other logs
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
152
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
153 $t->stop();
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
154
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
155
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
156 # verify that by default, 'combined' format is used, 'off' disables logging
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
157
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
158 $log = $t->read_file('combined.log');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
159 like($log,
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
160 qr!^\Q127.0.0.1 - - [\E .*
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
161 \Q] "GET /combined HTTP/1.0" 200 2 "-" "-"\E$!x,
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
162 'default log format');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
163
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
164 # verify that log filtering works
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
165
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
166 $log = $t->read_file('filtered.log');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
167 is($log, "/filtered/good:200\n/filtered/work:200\n", 'log filtering');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
168
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
169
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
170 # verify "if=" argument works with complex value
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
171
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
172 my $exp_complex = <<'EOF';
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
173 /filtered/complex/one:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
174 /filtered/complex/two:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
175 /filtered/complex/either1:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
176 /filtered/complex/either2:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
177 /filtered/complex/either3:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
178 /filtered/complex/either4:200
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
179 EOF
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
180
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
181 $log = $t->read_file('complex.log');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
182 is($log, $exp_complex, 'if with complex value');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
183
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
184
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
185 # buffer created with false "if" is not reused among multiple access_log
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
186
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
187 $log = $t->read_file('/noreuse.log');
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
188 is($log, "/filtered/noreuse1/good:200\n/filtered/noreuse2/good:200\n",
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
189 'log filtering with buffering');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
190
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
191
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
192 # multiple logs in a same location
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
193
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
194 $log = $t->read_file('multi1.log');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
195 is($log, "/multi:200\n", 'multiple logs 1');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
196
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
197 # same content in the second log
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
198
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
199 $log = $t->read_file('multi2.log');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
200 is($log, "/multi:200\n", 'multiple logs 2');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
201
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
202
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
203 # test log destinations with variables
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
204
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
205 $log = $t->read_file('0');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
206 is($log, "/varlog:200\n", 'varlog literal zero name');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
207
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
208 $log = $t->read_file('filename');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
209 is($log, "/varlog:200\n", 'varlog good name');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
210
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
211 ###############################################################################