args-sync-tcp.pl revision 1.4
1# The client writes 300 long messages to UDP socket. 2# The syslogd writes it into a file and through a pipe. 3# The syslogd does a TCP reconnect and passes it to loghost. 4# The server blocks the message on its TCP socket. 5# The server waits until the client has written all messages. 6# The server closes the TCP connection and accepts a new one. 7# The server receives the messages on its new accepted TCP socket. 8# This way the server receives a block of messages that is truncated 9# at the beginning and at the end. 10# Find the message in client, file, pipe, syslogd, server log. 11# Check that the server does not get lines that are cut in the middle. 12 13use strict; 14use warnings; 15use Socket; 16 17our %args = ( 18 client => { 19 connect => { domain => AF_UNSPEC, addr => "localhost", port => 514 }, 20 func => sub { write_between2logs(shift, sub { 21 my $self = shift; 22 write_message($self, get_secondlog()); 23 write_lines($self, 300, 2000); 24 write_message($self, get_thirdlog()); 25 ${$self->{server}}->loggrep("Accepted", 5, 2) 26 or die ref($self), " server did not receive second log"; 27 })}, 28 }, 29 syslogd => { 30 options => ["-u"], 31 loghost => '@tcp://127.0.0.1:$connectport', 32 loggrep => { 33 get_between2loggrep(), 34 get_charlog() => 300, 35 qr/dropped partial message/ => 1, 36 }, 37 }, 38 server => { 39 listen => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1" }, 40 redo => 0, 41 func => sub { read_between2logs(shift, sub { 42 my $self = shift; 43 if ($self->{redo}) { 44 $self->{redo}--; 45 return; 46 } 47 ${$self->{syslogd}}->loggrep(get_thirdlog(), 40) 48 or die ref($self), " syslogd did not receive third log"; 49 shutdown(\*STDOUT, 1) 50 or die "shutdown write failed: $!"; 51 $self->{redo}++; 52 })}, 53 loggrep => { 54 qr/Accepted/ => 2, 55 get_between2loggrep(), 56 get_secondlog() => 0, 57 get_thirdlog() => 0, 58 qr/>>> [0-9A-Za-z]{10}/ => 0, 59 }, 60 }, 61 file => { 62 loggrep => { 63 get_between2loggrep(), 64 get_secondlog() => 1, 65 get_thirdlog() => 1, 66 get_charlog() => 300, 67 }, 68 }, 69); 70 711; 72