args-dropped-sigterm-tls.pl revision 1.7
1# The client writes 300 messages to Sys::Syslog native method.
2# The syslogd writes it into a file and through a pipe.
3# The syslogd passes it via TLS to the loghost.
4# The server blocks the message on its TLS socket.
5# The server waits until the client as written all messages.
6# The server sends a SIGTERM to syslogd and reads messages from kernel.
7# The client waits until the server has read the first message.
8# Find the message in client, file, pipe, syslogd log.
9# Check that the 300 messages are in syslogd and file log.
10# Check that the dropped message is in file log.
11
12use strict;
13use warnings;
14use Socket;
15
16our %args = (
17    client => {
18	func => sub { write_between2logs(shift, sub {
19	    my $self = shift;
20	    write_message($self, get_secondlog());
21	    write_lines($self, 300, 1024);
22	    write_message($self, get_thirdlog());
23	    ${$self->{server}}->loggrep(get_secondlog(), 8)
24		or die ref($self), " server did not receive second log";
25	})},
26    },
27    syslogd => {
28	loghost => '@tls://localhost:$connectport',
29	loggrep => {
30	    get_charlog() => 300,
31	    qr/ \(dropped.*\)/ => '~42',
32	    qr/SSL3_WRITE_PENDING/ => 0,
33	},
34    },
35    server => {
36	listen => { domain => AF_UNSPEC, proto => "tls", addr => "localhost" },
37	redo => 0,
38	func => sub {
39	    my $self = shift;
40	    ${$self->{syslogd}}->loggrep(get_thirdlog(), 20)
41		or die ref($self), " syslogd did not receive third log";
42	    ${$self->{syslogd}}->kill_syslogd('TERM');
43	    ${$self->{syslogd}}->loggrep("syslogd: exiting", 5)
44		or die ref($self), " no 'syslogd: exiting' between logs";
45	    # syslogd has shut down, read from kernel socket buffer
46	    read_log($self);
47	},
48	loggrep => {
49	    get_firstlog() => 1,
50	    get_secondlog() => 1,
51	    get_thirdlog() => 0,
52	    get_testlog() => 0,
53	    qr/syslogd: start/ => 1,
54	    get_charlog() => '~40',
55	},
56    },
57    pipe => {
58	loggrep => {},
59    },
60    file => {
61	loggrep => {
62	    get_firstlog() => 1,
63	    get_secondlog() => 1,
64	    get_thirdlog() => 1,
65	    get_testlog() => 0,
66	    qr/syslogd: start/ => 1,
67	    get_charlog() => 300,
68	    qr/syslogd: dropped 2[56][0-9] messages to remote loghost/ => 1,
69	},
70    },
71);
72
731;
74