comparison syslog.t @ 1326:fda0bf1cc601

Tests: syslog send error handling test added.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 21 May 2018 13:05:27 +0300
parents e4974af3fb12
children 0f2dd1f239ba
comparison
equal deleted inserted replaced
1325:f80176242a7e 1326:fda0bf1cc601
24 select STDERR; $| = 1; 24 select STDERR; $| = 1;
25 select STDOUT; $| = 1; 25 select STDOUT; $| = 1;
26 26
27 plan(skip_all => 'win32') if $^O eq 'MSWin32'; 27 plan(skip_all => 'win32') if $^O eq 'MSWin32';
28 28
29 my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(59); 29 my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(61);
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
229 ([ \d]\d)\s(\d{2}):(\d{2}):(\d{2})\s # date 229 ([ \d]\d)\s(\d{2}):(\d{2}):(\d{2})\s # date
230 (\w{1,32}):\s # tag 230 (\w{1,32}):\s # tag
231 (.*)/x, # MSG 231 (.*)/x, # MSG
232 'nohostname'); 232 'nohostname');
233 233
234 # send error handling
235
236 ok(get_syslog('/a'), 'send success');
237
238 close $s;
239
240 get_syslog('/a');
241 get_syslog('/a');
242
243 $s = IO::Socket::INET->new(
244 Proto => 'udp',
245 LocalAddr => '127.0.0.1:' . port(8984)
246 )
247 or die "Can't open syslog socket: $!";
248
249 ok(get_syslog('/a'), 'send error - recover');
250
251 # broken in fa0e093b64d7
252
253 $t->todo_alerts() if $t->has_version('1.15.0');
254
234 ############################################################################### 255 ###############################################################################
235 256
236 sub syslog_lines { 257 sub syslog_lines {
237 my ($uri, $pattern, $port) = @_; 258 my ($uri, $pattern, $port) = @_;
238 return map { $_ =~ /\Q$pattern\E/g } (get_syslog($uri)); 259 return map { $_ =~ /\Q$pattern\E/g } (get_syslog($uri));