args-server-tcp-reconnect.pl revision 1.2
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; 12 13our %args = ( 14 client => { 15 func => sub { write_between2logs(shift, sub { 16 my $self = shift; 17 ${$self->{syslogd}}->loggrep("Connection refused", 5) 18 or die "no connection refused in syslogd.log"; 19 })}, 20 }, 21 syslogd => { 22 loghost => '@tcp://127.0.0.1:$connectport', 23 loggrep => { 24 qr/Logging to FORWTCP \@tcp:\/\/127.0.0.1:\d+/ => '>=6', 25 qr/syslogd: connect .* Connection refused/ => '>=2', 26 get_between2loggrep(), 27 }, 28 }, 29 server => { 30 listen => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1" }, 31 redo => 0, 32 func => sub { read_between2logs(shift, sub { 33 my $self = shift; 34 if ($self->{redo}) { 35 $self->{redo}--; 36 return; 37 } 38 $self->close(); 39 shutdown(\*STDOUT, 1) 40 or die "shutdown write failed: $!"; 41 ${$self->{syslogd}}->loggrep("Connection refused", 5) 42 or die "no connection refused in syslogd.log"; 43 $self->listen(); 44 $self->{redo}++; 45 })}, 46 loggrep => { 47 qr/Accepted/ => 2, 48 qr/syslogd: loghost .* connection close/ => 1, 49 qr/syslogd: connect .* Connection refused/ => 1, 50 get_between2loggrep(), 51 }, 52 }, 53 file => { 54 loggrep => { 55 qr/syslogd: connect .* Connection refused/ => '>=1', 56 get_between2loggrep(), 57 }, 58 }, 59); 60 611; 62