2 machine
.wait_for_unit("ulogd.service")
3 machine
.wait_for_unit("network-online.target")
5 with
subtest("Ulogd is running"):
6 machine
.succeed("pgrep ulogd >&2")
8 # All packets show up twice in the logs
9 with
subtest("Logs are collected"):
10 machine
.succeed("ping -f 127.0.0.1 -c 5 >&2")
11 machine
.succeed("sleep 2")
12 machine
.wait_until_succeeds("du /var/log/ulogd.pcap")
13 _
, echo_request_packets
= machine
.execute("tcpdump -r /var/log/ulogd.pcap icmp[0] == 8 and host 127.0.0.1")
14 expected
, actual
= 5 * 2, len(echo_request_packets
.splitlines())
15 assert expected
== actual
, f
"Expected {expected} ICMP request packets from pcap, got: {actual}"
16 _
, echo_reply_packets
= machine
.execute("tcpdump -r /var/log/ulogd.pcap icmp[0] == 0 and host 127.0.0.1")
17 expected
, actual
= 5 * 2, len(echo_reply_packets
.splitlines())
18 assert expected
== actual
, f
"Expected {expected} ICMP reply packets from pcap, got: {actual}"
20 machine
.wait_until_succeeds("du /var/log/ulogd_pkts.log")
21 _
, echo_request_packets
= machine
.execute("grep TYPE=8 /var/log/ulogd_pkts.log")
22 expected
, actual
= 5 * 2, len(echo_request_packets
.splitlines())
23 assert expected
== actual
, f
"Expected {expected} ICMP request packets from logfile, got: {actual}"
24 _
, echo_reply_packets
= machine
.execute("grep TYPE=0 /var/log/ulogd_pkts.log")
25 expected
, actual
= 5 * 2, len(echo_reply_packets
.splitlines())
26 assert expected
== actual
, f
"Expected {expected} ICMP reply packets from logfile, got: {actual}"
28 with
subtest("Reloading service reopens log file"):
29 machine
.succeed("mv /var/log/ulogd.pcap /var/log/old_ulogd.pcap")
30 machine
.succeed("mv /var/log/ulogd_pkts.log /var/log/old_ulogd_pkts.log")
31 machine
.succeed("systemctl reload ulogd.service")
32 machine
.succeed("ping -f 127.0.0.1 -c 5 >&2")
33 machine
.succeed("sleep 2")
34 machine
.wait_until_succeeds("du /var/log/ulogd.pcap")
35 _
, echo_request_packets
= machine
.execute("tcpdump -r /var/log/ulogd.pcap icmp[0] == 8 and host 127.0.0.1")
36 expected
, actual
= 5 * 2, len(echo_request_packets
.splitlines())
37 assert expected
== actual
, f
"Expected {expected} packets, got: {actual}"
38 _
, echo_reply_packets
= machine
.execute("tcpdump -r /var/log/ulogd.pcap icmp[0] == 0 and host 127.0.0.1")
39 expected
, actual
= 5 * 2, len(echo_reply_packets
.splitlines())
40 assert expected
== actual
, f
"Expected {expected} packets, got: {actual}"
42 machine
.wait_until_succeeds("du /var/log/ulogd_pkts.log")
43 _
, echo_request_packets
= machine
.execute("grep TYPE=8 /var/log/ulogd_pkts.log")
44 expected
, actual
= 5 * 2, len(echo_request_packets
.splitlines())
45 assert expected
== actual
, f
"Expected {expected} ICMP request packets from logfile, got: {actual}"
46 _
, echo_reply_packets
= machine
.execute("grep TYPE=0 /var/log/ulogd_pkts.log")
47 expected
, actual
= 5 * 2, len(echo_reply_packets
.splitlines())
48 assert expected
== actual
, f
"Expected {expected} ICMP reply packets from logfile, got: {actual}"