blob: 53d9d7fa512c4e237db49cf76e297f2818f277d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/bin/bash
# This test injects a message and checks if it is received by
# imjournal. We use a special test string which we do not expect
# to be present in the regular log stream. So we do not expect that
# any other journal content matches our test message. We skip the
# test in case message does not make it even to journal which may
# sometimes happen in some environments.
# addd 2017-10-25 by RGerhards, released under ASL 2.0
. ${srcdir:=.}/diag.sh init
. $srcdir/diag.sh require-journalctl
generate_conf
add_conf '
module(load="../plugins/imjournal/.libs/imjournal" IgnorePreviousMessages="on"
RateLimit.Burst="1000000")
template(name="outfmt" type="string" string="%msg%\n")
action(type="omfile" template="outfmt" file="'$RSYSLOG_OUT_LOG'")
'
TESTMSG="TestBenCH-RSYSLog imjournal This is a test message - $(date +%s) - $RSYSLOG_DYNNAME"
startup
printf 'a quick glimpse at journal content at rsyslog startup:\n'
journalctl -n 20 --no-pager
printf '\n\n'
printf '++++++++++++++++++++++ Printing to the journal! +++++++++++++++++++++++++\n'
# inject message into journal and check that it is recorded
./journal_print "$TESTMSG"
journal_write_state=$?
if [ $journal_write_state -ne 0 ]; then
printf 'SKIP: journal_print returned state %d writing message: %s\n' "$journal_write_state" "$TESTMSG"
printf 'skipping test, journal probably not working\n'
exit 77
fi
# check state later - we must not terminate the test until we have terminated rsyslog
# give the journal ~5 minutes to forward the message, see
# https://github.com/rsyslog/rsyslog/issues/2564#issuecomment-435849660
content_check_with_count "$TESTMSG" 1 300
shutdown_when_empty # shut down rsyslogd when done processing messages
wait_shutdown
check_journal_testmsg_received
exit_test
|