args-client-tcp-deferred.pl revision 1.3
1# The syslogd listens on 127.0.0.1 TCP socket. 2# The client creates connections to syslogd TCP socket until it blocks. 3# The client writes to all sockets and closes them. 4# Wait until syslogd has slots to accept all sockets. 5# Find the message in client, file, pipe, syslogd, server log. 6# Check the messages end up in the log file. 7 8use strict; 9use warnings; 10 11our %args = ( 12 client => { 13 connect => { domain => AF_INET, proto => "tcp", addr => "127.0.0.1", 14 port => 514 }, 15 func => sub { 16 my $self = shift; 17 local $| = 1; 18 my @s; 19 $s[0] = \*STDOUT; 20 # open additional connections until syslogd deferres 21 for (my $i = 1; $i <= 30; $i++) { 22 $s[$i] = IO::Socket::IP->new( 23 Domain => AF_INET, 24 Proto => "tcp", 25 PeerAddr => "127.0.0.1", 26 PeerPort => 514, 27 ) or die ref($self), " id $i tcp socket connect failed: $!"; 28 print STDERR "<<< id $i tcp connected\n"; 29 ${$self->{syslogd}}->loggrep("tcp logger .* accepted", 1, $i); 30 ${$self->{syslogd}}->loggrep("accept deferred") 31 and last; 32 } 33 write_tcp($self, \*STDOUT, 0); 34 for (my $i = 1; $i < @s; $i++) { 35 my $fh = $s[$i]; 36 write_tcp($self, $fh, $i); 37 # close connection so that others can be accepted 38 close($fh); 39 } 40 ${$self->{syslogd}}->loggrep(qr/tcp logger .* use \d+ bytes/, 10, 41 scalar @s) 42 or die ref($self), " syslogd did not use connections"; 43 write_shutdown($self); 44 }, 45 }, 46 syslogd => { 47 options => ["-T", "127.0.0.1:514"], 48 rlimit => { 49 RLIMIT_NOFILE => 30, 50 }, 51 loggrep => { 52 qr/tcp logger .* accepted/ => '>=10', 53 qr/tcp logger .* use \d+ bytes/ => '>=10', 54 qr/tcp logger .* connection close/ => '>=10', 55 }, 56 }, 57 file => { 58 loggrep => { 59 get_testgrep() => '>=10', 60 }, 61 }, 62); 63 641; 65