args-dropped-sigterm-tls.pl revision 1.1
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	    foreach (1..300) {
22		write_char($self, [1024], $_);
23		# if client sends too fast, syslogd will not see everything
24		sleep .01;
25	    }
26	    write_message($self, get_thirdlog());
27	    ${$self->{server}}->loggrep(get_secondlog(), 8)
28		or die ref($self), " server did not receive second log";
29	})},
30    },
31    syslogd => {
32	loghost => '@tls://localhost:$connectport',
33	loggrep => {
34	    get_charlog() => 300,
35	},
36    },
37    server => {
38	listen => { domain => AF_UNSPEC, proto => "tls", addr => "localhost" },
39	redo => 0,
40	func => sub {
41	    my $self = shift;
42	    ${$self->{client}}->loggrep(get_thirdlog(), 5)
43		or die ref($self), " client did not send third log";
44	    ${$self->{syslogd}}->kill_syslogd('TERM');
45	    ${$self->{syslogd}}->loggrep("syslogd: exiting", 5)
46		or die ref($self), " no 'syslogd: exiting' between logs";
47	    # syslogd has shut down, read from kernel socket buffer
48	    read_log($self);
49	},
50	loggrep => {
51	    get_firstlog() => 1,
52	    get_secondlog() => 1,
53	    get_thirdlog() => 0,
54	    get_testlog() => 0,
55	    qr/syslogd: start/ => 1,
56	    get_charlog() => 42,
57	},
58    },
59    pipe => {
60	loggrep => {},
61    },
62    file => {
63	loggrep => {
64	    get_firstlog() => 1,
65	    get_secondlog() => 1,
66	    get_thirdlog() => 1,
67	    get_testlog() => 0,
68	    qr/syslogd: start/ => 1,
69	    get_charlog() => 300,
70	    qr/syslogd: dropped 260 messages to remote loghost/ => 1,
71	},
72    },
73);
74
751;
76