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