annotate access_log.t @ 1188:074e05b33b1a

Tests: added access_log test with long line in log_format.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 15 Jun 2017 16:01:08 +0300
parents 717030fd5a94
children 1c703303feee
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
1188
074e05b33b1a Tests: added access_log test with long line in log_format.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1175
diff changeset
24 my $t = Test::Nginx->new()->has(qw/http rewrite gzip/)->plan(11)
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";
1188
074e05b33b1a Tests: added access_log test with long line in log_format.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1175
diff changeset
38 log_format long "long line $uri:$status";
900
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
39 log_format binary $binary_remote_addr;
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
40
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
41 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
42 listen 127.0.0.1:8080;
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
43 server_name localhost;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
44
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
45 location /combined {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
46 access_log %%TESTDIR%%/combined.log;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
47 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
48
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
49 location /combined/off {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
50 access_log off;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
51 return 200 OK;
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 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
54
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
55 location /filtered {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
56 access_log %%TESTDIR%%/filtered.log test
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
57 if=$arg_logme;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
58 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
59 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
60
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
61 location /filtered/complex {
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
62 access_log %%TESTDIR%%/complex.log test
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
63 if=$arg_logme$arg_logmetoo;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
64 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
65 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
66
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
67 location /filtered/noreuse {
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_a;
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
70 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
71 if=$arg_b;
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
72 return 200 OK;
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
73 }
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
74
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
75 location /compressed {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
76 access_log %%TESTDIR%%/compressed.log test
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
77 gzip buffer=1m flush=100ms;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
78 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
79 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
80
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
81 location /multi {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
82 access_log %%TESTDIR%%/multi1.log test;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
83 access_log %%TESTDIR%%/multi2.log test;
1188
074e05b33b1a Tests: added access_log test with long line in log_format.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1175
diff changeset
84 access_log %%TESTDIR%%/long.log long;
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
85 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
86 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
87
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
88 location /varlog {
616
e9f48f1e905b Tests: avoid alert/crit error logs in access_log.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 568
diff changeset
89 access_log %%TESTDIR%%/varlog_${arg_logname} test;
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
90 return 200 OK;
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
91 }
900
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
92
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
93 location /binary {
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
94 access_log %%TESTDIR%%/binary.log binary;
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
95 }
394
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
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
99 EOF
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
100
568
907e89fba9c3 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 467
diff changeset
101 $t->run();
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
102
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
103 ###############################################################################
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
104
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
105 http_get('/combined');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
106 http_get('/combined/off');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
107
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
108 http_get('/filtered');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
109 http_get('/filtered/empty?logme=');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
110 http_get('/filtered/zero?logme=0');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
111 http_get('/filtered/good?logme=1');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
112 http_get('/filtered/work?logme=yes');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
113
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
114 http_get('/filtered/complex');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
115 http_get('/filtered/complex/one?logme=1');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
116 http_get('/filtered/complex/two?logmetoo=1');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
117 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
118 http_get('/filtered/complex/either2?logme=A');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
119 http_get('/filtered/complex/either3?logmetoo=B');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
120 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
121 http_get('/filtered/complex/neither?logme=&logmetoo=');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
122
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
123 http_get('/filtered/noreuse1/zero?a=0');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
124 http_get('/filtered/noreuse1/good?a=1');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
125 http_get('/filtered/noreuse2/zero?b=0');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
126 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
127
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
128 http_get('/compressed');
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 http_get('/multi');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
131
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
132 http_get('/varlog');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
133 http_get('/varlog?logname=');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
134 http_get('/varlog?logname=0');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
135 http_get('/varlog?logname=filename');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
136
900
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
137 http_get('/binary');
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
138
451
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
139 # 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
140
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
141 for (1 .. 10) {
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
142 last if -s $t->testdir() . '/compressed.log';
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
143 select undef, undef, undef, 0.1;
be98c162f8bc Tests: adjusted access_log test timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents: 394
diff changeset
144 }
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
145
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
146 # verify that "gzip" parameter turns on compression
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
147
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
148 my $log;
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 SKIP: {
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
151 eval { require IO::Uncompress::Gunzip; };
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
152 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
153
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
154 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
155 IO::Uncompress::Gunzip::gunzip(\$gzipped => \$log);
458
ae69f9bdba92 Tests: fixed access_log.t on win32.
Maxim Dounin <mdounin@mdounin.ru>
parents: 451
diff changeset
156 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
157 }
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
158
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
159 # now verify all other logs
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
160
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
161 $t->stop();
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
162
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 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
165
746
f75bc412e802 Tests: unbreak access_log tests in jails.
Sergey Kandaurov <pluknet@nginx.com>
parents: 616
diff changeset
166 my $addr = IO::Socket::INET->new(LocalAddr => '127.0.0.1')->sockhost();
f75bc412e802 Tests: unbreak access_log tests in jails.
Sergey Kandaurov <pluknet@nginx.com>
parents: 616
diff changeset
167
899
c0c2fc0e7208 Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 746
diff changeset
168 like($t->read_file('combined.log'),
746
f75bc412e802 Tests: unbreak access_log tests in jails.
Sergey Kandaurov <pluknet@nginx.com>
parents: 616
diff changeset
169 qr!^\Q$addr - - [\E .*
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
170 \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
171 'default log format');
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
172
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
173 # verify that log filtering works
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
174
467
43e05ac6c23c Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 463
diff changeset
175 $log = $t->read_file('filtered.log');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
176 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
177
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
178 # verify "if=" argument works with complex value
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
179
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
180 my $exp_complex = <<'EOF';
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
181 /filtered/complex/one:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
182 /filtered/complex/two:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
183 /filtered/complex/either1:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
184 /filtered/complex/either2:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
185 /filtered/complex/either3:200
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
186 /filtered/complex/either4:200
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
187 EOF
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
188
899
c0c2fc0e7208 Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 746
diff changeset
189 is($t->read_file('complex.log'), $exp_complex, 'if with complex value');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
190
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
191 # 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
192
908
adf5671391ac Tests: use read_file subroutine in several tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 900
diff changeset
193 $log = $t->read_file('noreuse.log');
463
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
194 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
195 'log filtering with buffering');
da1a459c9318 Tests: access_log "if=" tests with buffering.
Sergey Kandaurov <pluknet@nginx.com>
parents: 458
diff changeset
196
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
197 # multiple logs in a same location
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
198
899
c0c2fc0e7208 Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 746
diff changeset
199 is($t->read_file('multi1.log'), "/multi:200\n", 'multiple logs 1');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
200
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
201 # same content in the second log
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
202
899
c0c2fc0e7208 Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 746
diff changeset
203 is($t->read_file('multi2.log'), "/multi:200\n", 'multiple logs 2');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
204
1188
074e05b33b1a Tests: added access_log test with long line in log_format.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1175
diff changeset
205 is($t->read_file('long.log'), "long line /multi:200\n", 'long line format');
074e05b33b1a Tests: added access_log test with long line in log_format.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1175
diff changeset
206
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
207 # test log destinations with variables
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
208
899
c0c2fc0e7208 Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 746
diff changeset
209 is($t->read_file('varlog_0'), "/varlog:200\n", 'varlog literal zero name');
c0c2fc0e7208 Tests: style.
Sergey Kandaurov <pluknet@nginx.com>
parents: 746
diff changeset
210 is($t->read_file('varlog_filename'), "/varlog:200\n", 'varlog good name');
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
211
900
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
212 # binary data is escaped
980
d10ec0f0bb6d Tests: unbreak access_log tests in jails.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
213 # that's "\\x7F\\x00\\x00\\x01\n" in $binary_remote_addr for "127.0.0.1"
900
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
214
980
d10ec0f0bb6d Tests: unbreak access_log tests in jails.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
215 my $expected = join '', map { sprintf "\\x%02X", $_ } split /\./, $addr;
d10ec0f0bb6d Tests: unbreak access_log tests in jails.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
216
d10ec0f0bb6d Tests: unbreak access_log tests in jails.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
217 is($t->read_file('binary.log'), "$expected\n", 'binary');
900
257de77879e8 Tests: added access_log test with binary data.
Sergey Kandaurov <pluknet@nginx.com>
parents: 899
diff changeset
218
394
8d436291c09b Tests: added tests for the "access_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
diff changeset
219 ###############################################################################