summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-11-11 11:44:24 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2009-11-11 11:44:24 +0100
commit7077420d58a56a29995e7930bd7943bb7f9b5bdf (patch)
treebc3e9ae7abcc4b4a01d9accf8ab8c24922846133
parentb4dd4ef83a51bc91a5861c0dd2809263e60cd05d (diff)
downloadrsyslog-7077420d58a56a29995e7930bd7943bb7f9b5bdf.tar.gz
rsyslog-7077420d58a56a29995e7930bd7943bb7f9b5bdf.tar.xz
rsyslog-7077420d58a56a29995e7930bd7943bb7f9b5bdf.zip
added support for dual-rsyslogd-instance test cases to testbench
... plus a simple initial test of the tcp forwarding capability.
-rw-r--r--tests/DiagTalker.java5
-rwxr-xr-xtests/diag.sh53
-rwxr-xr-xtests/killrsyslog.sh6
-rwxr-xr-xtests/tcpsndrcv.sh32
-rw-r--r--tests/testsuites/tcpsndrcv_rcvr.conf11
-rw-r--r--tests/testsuites/tcpsndrcv_sender.conf8
6 files changed, 98 insertions, 17 deletions
diff --git a/tests/DiagTalker.java b/tests/DiagTalker.java
index 04e12327..5a6f7dd5 100644
--- a/tests/DiagTalker.java
+++ b/tests/DiagTalker.java
@@ -30,7 +30,10 @@ public class DiagTalker {
PrintWriter out = null;
BufferedReader in = null;
final String host = "127.0.0.1";
- final int port = 13500;
+ int port = 13500;
+ if(args.length > 1) {
+ port = Integer.parseInt(args[1]);
+ }
try {
diagSocket = new Socket(host, port);
diff --git a/tests/diag.sh b/tests/diag.sh
index 60a56f07..f3d75a15 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -14,41 +14,50 @@
case $1 in
'init') $srcdir/killrsyslog.sh # kill rsyslogd if it runs for some reason
cp $srcdir/testsuites/diag-common.conf diag-common.conf
+ cp $srcdir/testsuites/diag-common2.conf diag-common2.conf
rm -f rsyslogd.started work-*.conf
+ rm -f rsyslogd2.started work-*.conf
rm -f work rsyslog.out.log rsyslog.out.log.save # common work files
rm -rf test-spool
rm -f core.* vgcore.*
mkdir test-spool
;;
'exit') rm -f rsyslogd.started work-*.conf diag-common.conf
+ rm -f rsyslogd2.started diag-common2.conf
rm -f work rsyslog.out.log rsyslog.out.log.save # common work files
rm -rf test-spool
;;
'startup') # start rsyslogd with default params. $2 is the config file name to use
- # returns only after successful startup
- $valgrind ../tools/rsyslogd -c4 -u2 -n -irsyslog.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/$2 &
- $srcdir/diag.sh wait-startup
+ # returns only after successful startup, $3 is the instance (blank or 2!)
+ $valgrind ../tools/rsyslogd -c4 -u2 -n -irsyslog$3.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/$2 &
+ $srcdir/diag.sh wait-startup $3
;;
- 'wait-startup') # wait for rsyslogd startup
- while test ! -f rsyslogd.started; do
+ 'wait-startup') # wait for rsyslogd startup ($2 is the instance)
+ while test ! -f rsyslogd$2.started; do
true
done
- echo "rsyslogd started with pid " `cat rsyslog.pid`
+ echo "rsyslogd$2 started with pid " `cat rsyslog$2.pid`
;;
- 'wait-shutdown') # actually, we wait for rsyslog.pid to be deleted
- while test -f rsyslog.pid; do
+ 'wait-shutdown') # actually, we wait for rsyslog.pid to be deleted. $2 is the
+ # instance
+ while test -f rsyslog$2.pid; do
true
done
;;
- 'wait-queueempty') # wait for main message queue to be empty
- echo WaitMainQueueEmpty | java -classpath $abs_top_builddir DiagTalker
+ 'wait-queueempty') # wait for main message queue to be empty. $2 is the instance.
+ if [ "$2" == "2" ]
+ then
+ echo WaitMainQueueEmpty | java -classpath $abs_top_builddir DiagTalker
+ else
+ echo WaitMainQueueEmpty | java -classpath $abs_top_builddir DiagTalker 13501
+ fi
;;
- 'shutdown-when-empty') # shut rsyslogd down when main queue is empty
- $srcdir/diag.sh wait-queueempty
- kill `cat rsyslog.pid`
+ 'shutdown-when-empty') # shut rsyslogd down when main queue is empty. $2 is the instance.
+ $srcdir/diag.sh wait-queueempty $2
+ kill `cat rsyslog$2.pid`
# note: we do not wait for the actual termination!
;;
- 'shutdown-immediate') # shut rsyslogd down without emptying the queue
+ 'shutdown-immediate') # shut rsyslogd down without emptying the queue. $2 is the instance.
kill `cat rsyslog.pid`
# note: we do not wait for the actual termination!
;;
@@ -65,7 +74,7 @@ case $1 in
echo injectmsg $2 $3 $4 $5 | java -classpath $abs_top_builddir DiagTalker
# TODO: some return state checking? (does it really make sense here?)
;;
- 'check-mainq-spool') # check if mainqueue spool files exist, if not abort (we just check .qi)
+ 'check-mainq-spool') # check if mainqueue spool files exist, if not abort (we just check .qi).
echo There must exist some files now:
ls -l test-spool
if test ! -f test-spool/mainq.qi; then
@@ -74,7 +83,7 @@ case $1 in
exit 1
fi
;;
- 'seq-check') # do the usual sequence check to see if everything was properly received
+ 'seq-check') # do the usual sequence check to see if everything was properly received. $2 is the instance.
rm -f work
sort < rsyslog.out.log > work
# $4... are just to have the abilit to pass in more options...
@@ -84,6 +93,18 @@ case $1 in
exit 1
fi
;;
+ 'seq-check2') # do the usual sequence check to see if everything was properly received. This is
+ # a duplicateof seq-check, but we could not change its calling conventions without
+ # breaking a lot of exitings test cases, so we preferred to duplicate the code here.
+ rm -f work2
+ sort < rsyslog2.out.log > work2
+ # $4... are just to have the abilit to pass in more options...
+ ./chkseq -fwork2 -v -s$2 -e$3 $4 $5 $6 $7
+ if [ "$?" -ne "0" ]; then
+ echo "sequence error detected"
+ exit 1
+ fi
+ ;;
'nettester') # perform nettester-based tests
# use -v for verbose output!
./nettester -t$2 -i$3
diff --git a/tests/killrsyslog.sh b/tests/killrsyslog.sh
index c9b6e0ac..aa342c1c 100755
--- a/tests/killrsyslog.sh
+++ b/tests/killrsyslog.sh
@@ -5,3 +5,9 @@ then
kill -9 `cat rsyslog.pid`
sleep 1
fi
+if [ -e "rsyslog2.pid" ]
+then
+ echo rsyslog2.pid exists, trying to shut down rsyslogd process `cat rsyslog.pid`.
+ kill -9 `cat rsyslog2.pid`
+ sleep 1
+fi
diff --git a/tests/tcpsndrcv.sh b/tests/tcpsndrcv.sh
new file mode 100755
index 00000000..69a2d79d
--- /dev/null
+++ b/tests/tcpsndrcv.sh
@@ -0,0 +1,32 @@
+# This is the first-ever test for two rsyslog instances. It can
+# probably be used as a copy-template for all those tests, and it
+# is thus kept very simple.
+# Besides that, it is useful. It tests two rsyslog instances. Instance
+# TWO sends data to instance ONE. A number of messages is injected into
+# the instance 2 and we finally check if all those messages
+# arrived at instance 1.
+# added 2009-11-11 by Rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+# uncomment for debugging support:
+echo ===============================================================================
+echo \[tcpsndrcv.sh\]: testing sending and receiving via tcp
+source $srcdir/diag.sh init
+# start up the instances
+source $srcdir/diag.sh startup tcpsndrcv_sender.conf 2
+source $srcdir/diag.sh startup tcpsndrcv_rcvr.conf
+source $srcdir/diag.sh wait-startup2
+source $srcdir/diag.sh wait-startup
+
+# now inject the messages into instance 2. It will connect to instance 1,
+# and that instance will record the data.
+source $srcdir/diag.sh tcpflood 127.0.0.1 13515 1 50000
+# shut down sender when everything is sent, receiver continues to run concurrently
+source $srcdir/diag.sh shutdown-when-empty 2
+source $srcdir/diag.sh wait-shutdown 2
+# now it is time to stop the receiver as well
+source $srcdir/diag.sh shutdown-when-empty
+source $srcdir/diag.sh wait-shutdown
+
+# do the final check
+source $srcdir/diag.sh seq-check 0 49999
+source $srcdir/diag.sh exit
diff --git a/tests/testsuites/tcpsndrcv_rcvr.conf b/tests/testsuites/tcpsndrcv_rcvr.conf
new file mode 100644
index 00000000..6bfb97b3
--- /dev/null
+++ b/tests/testsuites/tcpsndrcv_rcvr.conf
@@ -0,0 +1,11 @@
+# see tcpsndrcv.h for details
+# rgerhards, 2009-11-11
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imtcp/.libs/imtcp
+# then SENDER sends to this port (not tcpflood!)
+$InputTCPServerRun 13515
+
+$template outfmt,"%msg:F,58:2%\n"
+$template dynfile,"rsyslog.out.log" # trick to use relative path names!
+:msg, contains, "msgnum:" ?dynfile;outfmt
diff --git a/tests/testsuites/tcpsndrcv_sender.conf b/tests/testsuites/tcpsndrcv_sender.conf
new file mode 100644
index 00000000..c874c068
--- /dev/null
+++ b/tests/testsuites/tcpsndrcv_sender.conf
@@ -0,0 +1,8 @@
+# see tcpsndrcv.sh for details
+# rgerhards, 2009-11-11
+$IncludeConfig diag-common2.conf
+
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$InputTCPServerRun 13514
+
+*.* @@127.0.0.1:13515