summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/DiagTalker.java32
-rw-r--r--tests/Makefile.am26
-rwxr-xr-xtests/arrayqueue.sh26
-rw-r--r--tests/chkseq.c63
-rwxr-xr-xtests/da-mainmsg-q.sh62
-rwxr-xr-xtests/diag.sh4
-rwxr-xr-xtests/linkedlistqueue.sh26
-rw-r--r--tests/ourtail.c2
-rw-r--r--tests/rscript.c4
-rw-r--r--tests/tcpflood.c13
-rw-r--r--tests/testsuites/arrayqueue.conf14
-rw-r--r--tests/testsuites/da-mainmsg-q.conf21
-rw-r--r--tests/testsuites/linkedlistqueue.conf14
13 files changed, 276 insertions, 31 deletions
diff --git a/tests/DiagTalker.java b/tests/DiagTalker.java
index e33a5867..85a6671e 100644
--- a/tests/DiagTalker.java
+++ b/tests/DiagTalker.java
@@ -1,3 +1,24 @@
+/* A yet very simple tool to talk to imdiag.
+ *
+ * Copyright 2009 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This file is part of rsyslog.
+ *
+ * Rsyslog is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Rsyslog is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
//package com.rsyslog.diag;
import java.io.*;
import java.net.*;
@@ -29,9 +50,14 @@ public class DiagTalker {
new InputStreamReader(System.in));
String userInput;
- while ((userInput = stdIn.readLine()) != null) {
- out.println(userInput);
- System.out.println("imdiag returns: " + in.readLine());
+ try {
+ while ((userInput = stdIn.readLine()) != null) {
+ out.println(userInput);
+ System.out.println("imdiag returns: " + in.readLine());
+ }
+ } catch (SocketException e) {
+ System.err.println("We had a socket exception and consider this to be OK: "
+ + e.getMessage());
}
out.close();
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 713c721e..279158cf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,9 @@
TESTRUNS = rt_init rscript
check_PROGRAMS = $(TESTRUNS) ourtail nettester tcpflood chkseq
-TESTS = $(TESTRUNS) cfg.sh manytcp.sh diskqueue.sh imtcp-multiport.sh queue-persist.sh
+TESTS = $(TESTRUNS) cfg.sh arrayqueue.sh linkedlistqueue.sh da-mainmsg-q.sh \
+ diskqueue.sh manytcp.sh \
+ queue-persist.sh
+
if ENABLE_OMSTDOUT
TESTS += omod-if-array.sh parsertest.sh inputname.sh fieldtest.sh
endif
@@ -23,25 +26,38 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
err1.rstest \
NoExistFile.cfgtest \
testsuites/parse1.conf \
+ testsuites/field1.conf \
testsuites/1.parse1 \
- testsuites/rfc3164.parse1 \
+ testsuites/2.parse1 \
+ testsuites/3.parse1 \
+ testsuites/date1.parse1 \
+ testsuites/date2.parse1 \
+ testsuites/date3.parse1 \
+ testsuites/date4.parse1 \
+ testsuites/date5.parse1 \
+ testsuites/rfc3164.parse1 \
testsuites/rfc5424-1.parse1 \
testsuites/rfc5424-2.parse1 \
testsuites/rfc5424-3.parse1 \
testsuites/rfc5424-4.parse1 \
testsuites/omod-if-array.conf \
testsuites/1.omod-if-array \
+ testsuites/1.field1-if-array \
killrsyslog.sh \
parsertest.sh \
+ fieldtest.sh \
diskqueue.sh \
testsuites/diskqueue.conf \
+ arrayqueue.sh \
+ testsuites/arrayqueue.conf \
+ linkedlistqueue.sh \
+ testsuites/linkedlistqueue.conf \
+ da-mainmsg-q.sh \
+ testsuites/da-mainmsg-q.conf \
imtcp-multiport.sh \
testsuites/imtcp-multiport.conf \
manytcp.sh \
testsuites/manytcp.conf \
- fieldtest.sh \
- testsuites/field1.conf \
- testsuites/1.field1 \
inputname.sh \
testsuites/inputname_imtcp.conf \
testsuites/1.inputname_imtcp_12514 \
diff --git a/tests/arrayqueue.sh b/tests/arrayqueue.sh
new file mode 100755
index 00000000..7791ed57
--- /dev/null
+++ b/tests/arrayqueue.sh
@@ -0,0 +1,26 @@
+# Test for fixedArray queue mode
+# added 2009-05-20 by rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+echo testing queue fixedArray queue mode
+rm -f work rsyslog.out.log
+# enable this, if you need debug output: export RSYSLOG_DEBUG="debug"
+../tools/rsyslogd -c4 -u2 -n -irsyslog.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/arrayqueue.conf &
+sleep 1
+echo "rsyslogd started with pid " `cat rsyslog.pid`
+# 40000 messages should be enough
+./tcpflood 127.0.0.1 13514 1 40000
+if [ "$?" -ne "0" ]; then
+ echo "error during tcpflood! see rsyslog.out.log.save for what was written"
+ cp rsyslog.out.log rsyslog.out.log.save
+fi
+sleep 4 # we need this so that rsyslogd can receive all outstanding messages
+kill `cat rsyslog.pid`
+rm -f work
+sort < rsyslog.out.log > work
+./chkseq -fwork -e 39999
+if [ "$?" -ne "0" ]; then
+ # rm -f work rsyslog.out.log
+ echo "sequence error detected"
+ exit 1
+fi
+rm -f work rsyslog.out.log
diff --git a/tests/chkseq.c b/tests/chkseq.c
index 3203c250..5ffe855c 100644
--- a/tests/chkseq.c
+++ b/tests/chkseq.c
@@ -3,9 +3,10 @@
* be set.
*
* Params
- * argv[1] file to check
- * argv[2] start number
- * argv[3] end number
+ * -f<filename> MUST be given!
+ * -s<starting number> -e<ending number>
+ * default for s is 0. -e should be given (else it is also 0)
+ * -d may be specified, in which case duplicate messages are permitted.
*
* Part of the testbench for rsyslog.
*
@@ -31,6 +32,7 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
+#include <getopt.h>
int main(int argc, char *argv[])
{
@@ -38,16 +40,36 @@ int main(int argc, char *argv[])
int val;
int i;
int ret = 0;
- int start, end;
+ int dupsPermitted = 0;
+ int start = 0, end = 0;
+ int opt;
+ int nDups = 0;
+ char *file = NULL;
- if(argc != 4) {
- printf("Invalid call of chkseq\n");
- printf("Usage: chkseq file start end\n");
+ while((opt = getopt(argc, argv, "e:f:ds:")) != EOF) {
+ switch((char)opt) {
+ case 'f':
+ file = optarg;
+ break;
+ case 'd':
+ dupsPermitted = 1;
+ break;
+ case 'e':
+ end = atoi(optarg);
+ break;
+ case 's':
+ start = atoi(optarg);
+ break;
+ default:printf("Invalid call of chkseq\n");
+ printf("Usage: chkseq file -sstart -eend -d\n");
+ exit(1);
+ }
+ }
+
+ if(file == NULL) {
+ printf("file must be given!\n");
exit(1);
}
-
- start = atoi(argv[2]);
- end = atoi(argv[3]);
if(start > end) {
printf("start must be less than or equal end!\n");
@@ -55,22 +77,35 @@ int main(int argc, char *argv[])
}
/* read file */
- fp = fopen(argv[1], "r");
+ fp = fopen(file, "r");
if(fp == NULL) {
perror(argv[1]);
exit(1);
}
- for(i = start ; i < end ; ++i) {
+ for(i = start ; i < end+1 ; ++i) {
if(fscanf(fp, "%d\n", &val) != 1) {
printf("scanf error in index i=%d\n", i);
exit(1);
}
if(val != i) {
- printf("read value %d, but expected value %d\n", val, i);
- exit(1);
+ if(val == i - 1 && dupsPermitted) {
+ --i;
+ ++nDups;
+ } else {
+ printf("read value %d, but expected value %d\n", val, i);
+ exit(1);
+ }
}
}
+ if(nDups != 0)
+ printf("info: had %d duplicates (this is no error)\n", nDups);
+
+ if(i - 1 != end) {
+ printf("only %d records in file, expected %d\n", i - 1, end);
+ exit(1);
+ }
+
exit(ret);
}
diff --git a/tests/da-mainmsg-q.sh b/tests/da-mainmsg-q.sh
new file mode 100755
index 00000000..fde9e06e
--- /dev/null
+++ b/tests/da-mainmsg-q.sh
@@ -0,0 +1,62 @@
+# Test for DA mode on the main message queue
+# This test checks if DA mode operates correctly. To do so,
+# it uses a small in-memory queue size, so that DA mode is initiated
+# rather soon, and disk spooling used. There is some uncertainty (based
+# on machine speeds), but in general the test should work rather well.
+# We add a few messages after the initial run, just so that we can
+# check everything recovers from DA mode correctly.
+# added 2009-04-22 by Rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+echo "testing main message queue in DA mode (going to disk)"
+rm -f work rsyslog.out.log
+rm -rf test-spool
+mkdir test-spool
+rm -f work rsyslog.out.log rsyslog.out.log.save # work files
+../tools/rsyslogd -c4 -u2 -n -irsyslog.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/da-mainmsg-q.conf &
+sleep 1
+echo "rsyslogd started with pid " `cat rsyslog.pid`
+#
+# part1: send first 50 messages (in memory, only)
+#
+./tcpflood 127.0.0.1 13514 1 50
+if [ "$?" -ne "0" ]; then
+ echo "error during tcpflood! see rsyslog.out.log.save for what was written"
+ cp rsyslog.out.log rsyslog.out.log.save
+fi
+ls -l test-spool
+sleep 2 # we need this so that rsyslogd can receive all outstanding messages
+#
+# part 2: send bunch of messages. This should trigger DA mode
+#
+# 20000 messages should be enough - the disk test is slow enough ;)
+./tcpflood 127.0.0.1 13514 2 20000 50
+if [ "$?" -ne "0" ]; then
+ echo "error during tcpflood! see rsyslog.out.log.save for what was written"
+ cp rsyslog.out.log rsyslog.out.log.save
+fi
+ls -l test-spool
+sleep 8 # we need this so that rsyslogd can receive all outstanding messages
+#
+# send another handful
+#
+ls -l test-spool
+./tcpflood 127.0.0.1 13514 1 50 20050
+if [ "$?" -ne "0" ]; then
+ echo "error during tcpflood! see rsyslog.out.log.save for what was written"
+ cp rsyslog.out.log rsyslog.out.log.save
+fi
+sleep 1 # we need this so that rsyslogd can receive all outstanding messages
+#
+# clean up and check test result
+#
+kill `cat rsyslog.pid`
+rm -f work
+sort < rsyslog.out.log > work
+./chkseq -fwork -e20099
+if [ "$?" -ne "0" ]; then
+ # rm -f work rsyslog.out.log
+ echo "sequence error detected"
+ exit 1
+fi
+rm -f work rsyslog.out.log
+rm -rf test-spool
diff --git a/tests/diag.sh b/tests/diag.sh
index 270b30d6..a8f9b1b4 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -7,7 +7,7 @@
# This file is part of the rsyslog project, released under GPLv3
#set -o xtrace
#export RSYSLOG_DEBUG="debug nostdout"
-#export RSYSLOG_DEBUGLOG="tmp"
+#export RSYSLOG_DEBUGLOG="log"
case $1 in
'init') $srcdir/killrsyslog.sh # kill rsyslogd if it runs for some reason
rm -f rsyslogd.started work-*.conf
@@ -71,7 +71,7 @@ case $1 in
'seq-check') # do the usual sequence check to see if everything was properly received
rm -f work
sort < rsyslog.out.log > work
- ./chkseq work $2 $3
+ ./chkseq -fwork -e$2 $3
if [ "$?" -ne "0" ]; then
rm -f work rsyslog.out.log
echo "sequence error detected"
diff --git a/tests/linkedlistqueue.sh b/tests/linkedlistqueue.sh
new file mode 100755
index 00000000..aa574bd1
--- /dev/null
+++ b/tests/linkedlistqueue.sh
@@ -0,0 +1,26 @@
+# Test for Linkedlist queue mode
+# added 2009-05-20 by rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+echo testing queue Linkedlist queue mode
+rm -f work rsyslog.out.log
+# enable this, if you need debug output: export RSYSLOG_DEBUG="debug"
+../tools/rsyslogd -c4 -u2 -n -irsyslog.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/arrayqueue.conf &
+sleep 1
+echo "rsyslogd started with pid " `cat rsyslog.pid`
+# 40000 messages should be enough
+./tcpflood 127.0.0.1 13514 1 40000
+if [ "$?" -ne "0" ]; then
+ echo "error during tcpflood! see rsyslog.out.log.save for what was written"
+ cp rsyslog.out.log rsyslog.out.log.save
+fi
+sleep 4 # we need this so that rsyslogd can receive all outstanding messages
+kill `cat rsyslog.pid`
+rm -f work
+sort < rsyslog.out.log > work
+./chkseq -fwork -e39999
+if [ "$?" -ne "0" ]; then
+ # rm -f work rsyslog.out.log
+ echo "sequence error detected"
+ exit 1
+fi
+rm -f work rsyslog.out.log
diff --git a/tests/ourtail.c b/tests/ourtail.c
index f2751c72..6781b5fe 100644
--- a/tests/ourtail.c
+++ b/tests/ourtail.c
@@ -28,7 +28,7 @@
*/
#include <stdio.h>
-int main(int argc, char *argv[])
+int main(int __attribute__((unused)) argc, char __attribute__((unused)) *argv[])
{
int c;
diff --git a/tests/rscript.c b/tests/rscript.c
index ce81491c..6361aec4 100644
--- a/tests/rscript.c
+++ b/tests/rscript.c
@@ -104,8 +104,8 @@ PerformTest(cstr_t *pstrIn, rsRetVal iRetExpected, cstr_t *pstrOut)
if(strcmp((char*)rsCStrGetSzStr(pstrPrg), (char*)rsCStrGetSzStr(pstrOut))) {
printf("error: compiled program different from expected result!\n");
- printf("generated vmprg (%d bytes):\n%s\n", strlen((char*)rsCStrGetSzStr(pstrPrg)), rsCStrGetSzStr(pstrPrg));
- printf("expected (%d bytes):\n%s\n", strlen((char*)rsCStrGetSzStr(pstrOut)), rsCStrGetSzStr(pstrOut));
+ printf("generated vmprg (%d bytes):\n%s\n", (int)strlen((char*)rsCStrGetSzStr(pstrPrg)), rsCStrGetSzStr(pstrPrg));
+ printf("expected (%d bytes):\n%s\n", (int)strlen((char*)rsCStrGetSzStr(pstrOut)), rsCStrGetSzStr(pstrOut));
ABORT_FINALIZE(RS_RET_ERR);
}
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
index c3c9c871..2ca796ca 100644
--- a/tests/tcpflood.c
+++ b/tests/tcpflood.c
@@ -6,6 +6,7 @@
* argv[2] target port
* argv[3] number of connections
* argv[4] number of messages to send (connection is random)
+ * argv[5] initial message number (optional)
*
* Part of the testbench for rsyslog.
*
@@ -51,6 +52,7 @@ static int targetPort;
static int numMsgsToSend; /* number of messages to send */
static int numConnections; /* number of connections to create */
static int *sockArray; /* array of sockets to use */
+static int msgNum = 0; /* initial message number to start with */
/* open a single tcp connection
@@ -166,19 +168,20 @@ int sendMessages(void)
socknum = i - (numMsgsToSend - numConnections);
else
socknum = rand() % numConnections;
- lenBuf = sprintf(buf, "<167>Mar 1 01:00:00 172.20.245.8 tag msgnum:%8.8d:\n", i);
+ lenBuf = sprintf(buf, "<167>Mar 1 01:00:00 172.20.245.8 tag msgnum:%8.8d:\n", msgNum);
lenSend = send(sockArray[socknum], buf, lenBuf, 0);
if(lenSend != lenBuf) {
printf("\r%5.5d\n", i);
fflush(stdout);
perror("send test data");
- printf("send() failed at socket %d, index %d\n", socknum, i);
+ printf("send() failed at socket %d, index %d, msgNum %d\n", socknum, i, msgNum);
fflush(stderr);
return(1);
}
if(i % 100 == 0) {
printf("\r%5.5d", i);
}
+ ++msgNum;
}
printf("\r%5.5d messages sent\n", i);
@@ -260,9 +263,9 @@ int main(int argc, char *argv[])
setvbuf(stdout, buf, _IONBF, 48);
- if(argc != 5) {
+ if(argc != 5 && argc != 6) {
printf("Invalid call of tcpflood\n");
- printf("Usage: tcpflood target-host target-port num-connections num-messages\n");
+ printf("Usage: tcpflood target-host target-port num-connections num-messages [initial msgnum]\n");
exit(1);
}
@@ -270,6 +273,8 @@ int main(int argc, char *argv[])
targetPort = atoi(argv[2]);
numConnections = atoi(argv[3]);
numMsgsToSend = atoi(argv[4]);
+ if(argc == 6)
+ msgNum = atoi(argv[5]);
if(openConnections() != 0) {
printf("error opening connections\n");
diff --git a/tests/testsuites/arrayqueue.conf b/tests/testsuites/arrayqueue.conf
new file mode 100644
index 00000000..7fdbc79b
--- /dev/null
+++ b/tests/testsuites/arrayqueue.conf
@@ -0,0 +1,14 @@
+# Test for queue fixedArray mode (see .sh file for details)
+# rgerhards, 2009-04-17
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$MainMsgQueueTimeoutShutdown 10000
+$InputTCPServerRun 13514
+
+$ErrorMessagesToStderr off
+
+# set spool locations and switch queue to disk-only mode
+$MainMsgQueueType FixedArray
+
+$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/da-mainmsg-q.conf b/tests/testsuites/da-mainmsg-q.conf
new file mode 100644
index 00000000..fbda27d4
--- /dev/null
+++ b/tests/testsuites/da-mainmsg-q.conf
@@ -0,0 +1,21 @@
+# Test for DA mode in main message queue (see .sh file for details)
+# rgerhards, 2009-04-22
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$MainMsgQueueTimeoutShutdown 10000
+$InputTCPServerRun 13514
+
+$ErrorMessagesToStderr off
+
+# set spool locations and switch queue to disk assisted mode
+$WorkDirectory test-spool
+$MainMsgQueueSize 200 # this *should* trigger moving on to DA mode...
+# note: we must set QueueSize sufficiently high, so that 70% (light delay mark)
+# is high enough above HighWatermark!
+$MainMsgQueueHighWatermark 80
+$MainMsgQueueLowWatermark 40
+$MainMsgQueueFilename mainq
+$MainMsgQueueType linkedlist
+
+$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/linkedlistqueue.conf b/tests/testsuites/linkedlistqueue.conf
new file mode 100644
index 00000000..ecfc7a26
--- /dev/null
+++ b/tests/testsuites/linkedlistqueue.conf
@@ -0,0 +1,14 @@
+# Test for queue LinkedList mode (see .sh file for details)
+# rgerhards, 2009-04-17
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$MainMsgQueueTimeoutShutdown 10000
+$InputTCPServerRun 13514
+
+$ErrorMessagesToStderr off
+
+# set spool locations and switch queue to disk-only mode
+$MainMsgQueueType LinkedList
+
+$template outfmt,"%msg:F,58:2%\n"
+$template dynfile,"rsyslog.out.log" # trick to use relative path names!
+:msg, contains, "msgnum:" ?dynfile;outfmt