args-server-tcp-reconnect.pl revision 1.4
1# The TCP server closes the connection to syslogd. 2# The client writes a message to Sys::Syslog native method. 3# The syslogd writes it into a file and through a pipe. 4# The syslogd does a TCP reconnect and passes it to loghost. 5# The server receives the message on its new accepted TCP socket. 6# Find the message in client, pipe, syslogd, server log. 7# Check that syslogd and server close and reopen the connection. 8 9use strict; 10use warnings; 11use Socket; 12use Errno ':POSIX'; 13 14my @errors = (ECONNREFUSED); 15my $errors = "(". join("|", map { $! = $_ } @errors). ")"; 16 17our %args = ( 18 client => { 19 func => sub { write_between2logs(shift, sub { 20 my $self = shift; 21 ${$self->{syslogd}}->loggrep($errors, 5) 22 or die "no $errors in syslogd.log"; 23 })}, 24 }, 25 syslogd => { 26 loghost => '@tcp://127.0.0.1:$connectport', 27 loggrep => { 28 qr/Logging to FORWTCP \@tcp:\/\/127.0.0.1:\d+/ => '>=6', 29 qr/syslogd: (connect .*|.*connection error): $errors/ => '>=2', 30 get_between2loggrep(), 31 }, 32 }, 33 server => { 34 listen => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1" }, 35 redo => 0, 36 func => sub { read_between2logs(shift, sub { 37 my $self = shift; 38 if ($self->{redo}) { 39 $self->{redo}--; 40 return; 41 } 42 $self->close(); 43 shutdown(\*STDOUT, 1) 44 or die "shutdown write failed: $!"; 45 ${$self->{syslogd}}->loggrep($errors, 5) 46 or die "no $errors in syslogd.log"; 47 $self->listen(); 48 $self->{redo}++; 49 })}, 50 loggrep => { 51 qr/Accepted/ => 2, 52 qr/syslogd: loghost .* connection close/ => 1, 53 qr/syslogd: (connect .*|.*connection error): $errors/ => 1, 54 get_between2loggrep(), 55 }, 56 }, 57 file => { 58 loggrep => { 59 qr/syslogd: (connect .*|.*connection error): $errors/ => '>=1', 60 get_between2loggrep(), 61 }, 62 }, 63); 64 651; 66