1#!/bin/bash
2# Test for disk-only queue mode with v6+ config
3# This tests defines three rulesets, each one with its own queue. Then, it
4# sends data to them and checks the outcome. Note that we do need to
5# use some custom code as the test driver framework does not (yet?)
6# support multi-output-file operations.
7# added 2013-11-14 by Rgerhards
8# This file is part of the rsyslog project, released  under ASL 2.0
9. ${srcdir:=.}/diag.sh init
10skip_platform "SunOS" "This test does not work on Solaris. The overall queue
11size check in imdiag requires atomics or mutexes on this platform, which we
12do not use for performance reasons."
13export NUMMESSAGES=60000
14export QUEUE_EMPTY_CHECK_FUNC=wait_file_lines
15generate_conf
16add_conf '
17module(load="../plugins/imtcp/.libs/imtcp")
18
19# general definition
20$template outfmt,"%msg:F,58:2%\n"
21
22# create the individual rulesets
23$template dynfile1,"'$RSYSLOG_OUT_LOG'1.log" # trick to use relative path names!
24ruleset(name="file1" queue.type="linkedList") {
25	:msg, contains, "msgnum:" action(type="omfile" file="'$RSYSLOG_OUT_LOG'" template="outfmt")
26	:msg, contains, "msgnum:" ?dynfile1;outfmt
27}
28
29$template dynfile2,"'$RSYSLOG_OUT_LOG'2.log" # trick to use relative path names!
30ruleset(name="file2" queue.type="linkedList") {
31	:msg, contains, "msgnum:" action(type="omfile" file="'$RSYSLOG_OUT_LOG'" template="outfmt")
32	:msg, contains, "msgnum:" ?dynfile2;outfmt
33}
34
35$template dynfile3,"'$RSYSLOG_OUT_LOG'3.log" # trick to use relative path names!
36ruleset(name="file3" queue.type="linkedList") {
37	:msg, contains, "msgnum:" action(type="omfile" file="'$RSYSLOG_OUT_LOG'" template="outfmt")
38	:msg, contains, "msgnum:" ?dynfile3;outfmt
39}
40
41# start listeners and bind them to rulesets
42input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port" ruleset="file1")
43input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port2" ruleset="file2")
44input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port3" ruleset="file3")
45'
46startup
47assign_tcpflood_port2 "$RSYSLOG_DYNNAME.tcpflood_port2"
48assign_rs_port "$RSYSLOG_DYNNAME.tcpflood_port3"
49# now fill the three files (a bit sequentially, but they should
50# still get their share of concurrency - to increase the chance
51# we use three connections per set).
52tcpflood -c3 -p$TCPFLOOD_PORT -m20000 -i0
53tcpflood -c3 -p$TCPFLOOD_PORT2 -m20000 -i20000
54tcpflood -c3 -p$RS_PORT -m20000 -i40000
55shutdown_when_empty
56wait_shutdown
57# now consolidate all logs into a single one so that we can use the
58seq_check # do a check on the count file - doesn't hurt as we need it anyhow
59# regular check logic
60cat ${RSYSLOG_OUT_LOG}1.log ${RSYSLOG_OUT_LOG}2.log ${RSYSLOG_OUT_LOG}3.log > $RSYSLOG_OUT_LOG
61seq_check
62exit_test
63