Mercurial > hg > nginx-tests
comparison syslog.t @ 1237:e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Wed, 13 Sep 2017 19:04:25 +0300 |
parents | bef8be8a6224 |
children | fda0bf1cc601 |
comparison
equal
deleted
inserted
replaced
1236:93f749c1d5c5 | 1237:e4974af3fb12 |
---|---|
30 | 30 |
31 $t->write_file_expand('nginx.conf', <<'EOF'); | 31 $t->write_file_expand('nginx.conf', <<'EOF'); |
32 | 32 |
33 %%TEST_GLOBALS%% | 33 %%TEST_GLOBALS%% |
34 | 34 |
35 error_log syslog:server=127.0.0.1:%%PORT_8081_UDP%% info; | 35 error_log syslog:server=127.0.0.1:%%PORT_8981_UDP%% info; |
36 error_log %%TESTDIR%%/f_glob.log info; | 36 error_log %%TESTDIR%%/f_glob.log info; |
37 | 37 |
38 daemon off; | 38 daemon off; |
39 | 39 |
40 events { | 40 events { |
46 limit_req_zone $binary_remote_addr zone=one:1m rate=1r/m; | 46 limit_req_zone $binary_remote_addr zone=one:1m rate=1r/m; |
47 | 47 |
48 log_format empty ""; | 48 log_format empty ""; |
49 log_format logf "$uri:$status"; | 49 log_format logf "$uri:$status"; |
50 | 50 |
51 error_log syslog:server=127.0.0.1:%%PORT_8082_UDP%% info; | 51 error_log syslog:server=127.0.0.1:%%PORT_8982_UDP%% info; |
52 error_log %%TESTDIR%%/f_http.log info; | 52 error_log %%TESTDIR%%/f_http.log info; |
53 | 53 |
54 server { | 54 server { |
55 listen 127.0.0.1:8080; | 55 listen 127.0.0.1:8080; |
56 server_name localhost; | 56 server_name localhost; |
57 | 57 |
58 location /e { | 58 location /e { |
59 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 59 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
60 } | 60 } |
61 location /a { | 61 location /a { |
62 access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 62 access_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
63 } | 63 } |
64 location /ef { | 64 location /ef { |
65 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,facility=user; | 65 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%,facility=user; |
66 } | 66 } |
67 location /es { | 67 location /es { |
68 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,severity=alert; | 68 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%,severity=alert; |
69 } | 69 } |
70 location /et { | 70 location /et { |
71 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,tag=SEETHIS; | 71 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%,tag=SEETHIS; |
72 } | 72 } |
73 location /af { | 73 location /af { |
74 access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,facility=user; | 74 access_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%,facility=user; |
75 } | 75 } |
76 location /as { | 76 location /as { |
77 # put severity inside to catch possible parsing programming errors | 77 # put severity inside to catch possible parsing programming errors |
78 access_log syslog:severity=alert,server=127.0.0.1:%%PORT_8084_UDP%%; | 78 access_log syslog:severity=alert,server=127.0.0.1:%%PORT_8984_UDP%%; |
79 } | 79 } |
80 location /at { | 80 location /at { |
81 access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,tag=SEETHIS; | 81 access_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%,tag=SEETHIS; |
82 } | 82 } |
83 location /e2 { | 83 location /e2 { |
84 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 84 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
85 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 85 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
86 } | 86 } |
87 location /a2 { | 87 location /a2 { |
88 access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 88 access_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
89 access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 89 access_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
90 } | 90 } |
91 location /a_logf { | 91 location /a_logf { |
92 access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% logf; | 92 access_log syslog:server=127.0.0.1:%%PORT_8984_UDP%% logf; |
93 } | 93 } |
94 location /if { | 94 location /if { |
95 access_log syslog:server=127.0.0.1:%%PORT_8083_UDP%% logf | 95 access_log syslog:server=127.0.0.1:%%PORT_8983_UDP%% logf |
96 if=$arg_logme; | 96 if=$arg_logme; |
97 } | 97 } |
98 | 98 |
99 location /nohostname { | 99 location /nohostname { |
100 access_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%,nohostname; | 100 access_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%,nohostname; |
101 } | 101 } |
102 | 102 |
103 location /debug { | 103 location /debug { |
104 limit_req zone=one; | 104 limit_req zone=one; |
105 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% debug; | 105 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%% debug; |
106 } | 106 } |
107 location /info { | 107 location /info { |
108 limit_req zone=one; | 108 limit_req zone=one; |
109 limit_req_log_level info; | 109 limit_req_log_level info; |
110 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% info; | 110 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%% info; |
111 } | 111 } |
112 location /notice { | 112 location /notice { |
113 limit_req zone=one; | 113 limit_req zone=one; |
114 limit_req_log_level notice; | 114 limit_req_log_level notice; |
115 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% notice; | 115 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%% notice; |
116 } | 116 } |
117 location /warn { | 117 location /warn { |
118 limit_req zone=one; | 118 limit_req zone=one; |
119 limit_req_log_level warn; | 119 limit_req_log_level warn; |
120 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% warn; | 120 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%% warn; |
121 } | 121 } |
122 location /error { | 122 location /error { |
123 limit_req zone=one; | 123 limit_req zone=one; |
124 limit_req_log_level error; | 124 limit_req_log_level error; |
125 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 125 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
126 } | 126 } |
127 location /low { | 127 location /low { |
128 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% warn; | 128 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%% warn; |
129 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 129 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
130 } | 130 } |
131 location /dup { | 131 location /dup { |
132 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 132 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
133 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 133 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
134 } | 134 } |
135 location /high { | 135 location /high { |
136 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%% emerg; | 136 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%% emerg; |
137 error_log syslog:server=127.0.0.1:%%PORT_8084_UDP%%; | 137 error_log syslog:server=127.0.0.1:%%PORT_8984_UDP%%; |
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 EOF | 142 EOF |
143 | 143 |
144 $t->run_daemon(\&syslog_daemon, port(8081), $t, 's_glob.log'); | 144 $t->run_daemon(\&syslog_daemon, port(8981), $t, 's_glob.log'); |
145 $t->run_daemon(\&syslog_daemon, port(8082), $t, 's_http.log'); | 145 $t->run_daemon(\&syslog_daemon, port(8982), $t, 's_http.log'); |
146 $t->run_daemon(\&syslog_daemon, port(8083), $t, 's_if.log'); | 146 $t->run_daemon(\&syslog_daemon, port(8983), $t, 's_if.log'); |
147 | 147 |
148 $t->waitforfile($t->testdir . '/s_glob.log'); | 148 $t->waitforfile($t->testdir . '/s_glob.log'); |
149 $t->waitforfile($t->testdir . '/s_http.log'); | 149 $t->waitforfile($t->testdir . '/s_http.log'); |
150 $t->waitforfile($t->testdir . '/s_if.log'); | 150 $t->waitforfile($t->testdir . '/s_if.log'); |
151 | 151 |
153 | 153 |
154 ############################################################################### | 154 ############################################################################### |
155 | 155 |
156 my $s = IO::Socket::INET->new( | 156 my $s = IO::Socket::INET->new( |
157 Proto => 'udp', | 157 Proto => 'udp', |
158 LocalAddr => '127.0.0.1:' . port(8084) | 158 LocalAddr => '127.0.0.1:' . port(8984) |
159 ) | 159 ) |
160 or die "Can't open syslog socket: $!"; | 160 or die "Can't open syslog socket: $!"; |
161 | 161 |
162 parse_syslog_message('error_log', get_syslog('/e')); | 162 parse_syslog_message('error_log', get_syslog('/e')); |
163 parse_syslog_message('access_log', get_syslog('/a')); | 163 parse_syslog_message('access_log', get_syslog('/a')); |