summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-04 09:57:45 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-04 09:57:45 +0200
commit58e707b441aea88cd318762e6968e1db1211f949 (patch)
tree80271dac627000d5afed047a6372d633dd3fd068
parent4f742a8e32c43dc9b514ceaf80f4d17e697dfdf6 (diff)
downloadrsyslog-58e707b441aea88cd318762e6968e1db1211f949.tar.gz
rsyslog-58e707b441aea88cd318762e6968e1db1211f949.tar.xz
rsyslog-58e707b441aea88cd318762e6968e1db1211f949.zip
backported some of the v5 testbench
this permits us to keep a persistent test environment between v4 and v5, most importantly using the same tools. As far as the actual tests are concerned, some had issues. I had no time to check if that was an issue with the test or an actual issue with the v3/4 engine. Will do that at some later stage.
-rw-r--r--runtime/rsyslog.h5
-rw-r--r--tests/DiagTalker.java33
-rw-r--r--tests/Makefile.am26
-rw-r--r--tests/chkseq.c66
-rwxr-xr-xtests/diag.sh10
-rwxr-xr-xtests/diskqueue.sh3
-rw-r--r--tests/ourtail.c2
-rw-r--r--tests/rscript.c4
-rw-r--r--tests/tcpflood.c13
-rw-r--r--tests/testsuites/queue-persist.conf2
10 files changed, 123 insertions, 41 deletions
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index 293e559b..ea303a51 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -273,7 +273,10 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_ERR_FORK = -2118, /**< error during fork() */
RS_RET_ERR_WRITE_PIPE = -2119, /**< error writing to pipe */
RS_RET_RSCORE_TOO_OLD = -2120, /**< rsyslog core is too old for ... (eg this plugin) */
- RS_RET_NONFATAL_CONFIG_ERR = -2123, /**< non-fatal error during config processing */
+ RS_RET_DEFER_COMMIT = -2121, /**< output plugin status: not yet committed (an OK state!) */
+ RS_RET_PREVIOUS_COMMITTED = -2122, /**< output plugin status: previous record was committed (an OK state!) */
+ RS_RET_ACTION_FAILED = -2123, /**< action failed and is now suspended (consider this permanent for the time being) */
+ RS_RET_NONFATAL_CONFIG_ERR = -2124, /**< non-fatal error during config processing */
RS_RET_FILENAME_INVALID = -2140, /**< filename invalid, not found, no access, ... */
/* RainerScript error messages (range 1000.. 1999) */
diff --git a/tests/DiagTalker.java b/tests/DiagTalker.java
index e33a5867..04e12327 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.*;
@@ -13,6 +34,7 @@ public class DiagTalker {
try {
diagSocket = new Socket(host, port);
+ diagSocket.setSoTimeout(0); /* wait for lenghty operations */
out = new PrintWriter(diagSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
diagSocket.getInputStream()));
@@ -29,9 +51,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 402c1d83..a95139f2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,8 +1,13 @@
if ENABLE_TESTBENCH
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 \
- validation-run.sh
+TESTS = $(TESTRUNS) cfg.sh \
+ validation-run.sh \
+ imtcp-multiport.sh \
+ diskqueue.sh \
+ manytcp.sh \
+ queue-persist.sh
+
if ENABLE_OMSTDOUT
TESTS += omod-if-array.sh parsertest.sh inputname.sh fieldtest.sh
endif
@@ -32,25 +37,32 @@ 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 \
killrsyslog.sh \
parsertest.sh \
+ fieldtest.sh \
diskqueue.sh \
testsuites/diskqueue.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 \
@@ -58,6 +70,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/1.inputname_imtcp_12516 \
omod-if-array.sh \
diag.sh \
+ daqueue-persist.sh \
+ daqueue-persist-drvr.sh \
testsuites/diag-common.conf \
queue-persist.sh \
queue-persist-drvr.sh \
diff --git a/tests/chkseq.c b/tests/chkseq.c
index 3203c250..8c5fc61a 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,36 @@ int main(int argc, char *argv[])
}
/* read file */
- fp = fopen(argv[1], "r");
+ fp = fopen(file, "r");
if(fp == NULL) {
- perror(argv[1]);
+ printf("error opening file '%s'\n", file);
+ perror(file);
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/diag.sh b/tests/diag.sh
index ec2c1190..1ceca75b 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -5,8 +5,11 @@
# not always able to convey back states to the upper-level test driver
# begun 2009-05-27 by rgerhards
# This file is part of the rsyslog project, released under GPLv3
+#valgrind="valgrind --log-fd=1"
+#valgrind="valgrind --tool=drd --log-fd=1"
+#valgrind="valgrind --tool=helgrind --log-fd=1"
#set -o xtrace
-#export RSYSLOG_DEBUG="debug nostdout"
+#export RSYSLOG_DEBUG="debug nostdout printmutexaction"
#export RSYSLOG_DEBUGLOG="log"
case $1 in
'init') $srcdir/killrsyslog.sh # kill rsyslogd if it runs for some reason
@@ -22,7 +25,7 @@ case $1 in
;;
'startup') # start rsyslogd with default params. $2 is the config file name to use
# returns only after successful startup
- ../tools/rsyslogd -c4 -u2 -n -irsyslog.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/$2 &
+ $valgrind ../tools/rsyslogd -c4 -u2 -n -irsyslog.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/$2 &
$srcdir/diag.sh wait-startup
;;
'wait-startup') # wait for rsyslogd startup
@@ -72,9 +75,8 @@ 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"
exit 1
fi
diff --git a/tests/diskqueue.sh b/tests/diskqueue.sh
index bf1a46fd..2fe31db9 100755
--- a/tests/diskqueue.sh
+++ b/tests/diskqueue.sh
@@ -5,9 +5,6 @@
# added 2009-04-17 by Rgerhards
# This file is part of the rsyslog project, released under GPLv3
# uncomment for debugging support:
-#set -o xtrace
-#export RSYSLOG_DEBUG="debug nostdout"
-#export RSYSLOG_DEBUGLOG="tmp"
echo testing queue disk-only mode
source $srcdir/diag.sh init
source $srcdir/diag.sh startup diskqueue.conf
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/queue-persist.conf b/tests/testsuites/queue-persist.conf
index 81ee1be5..8903042d 100644
--- a/tests/testsuites/queue-persist.conf
+++ b/tests/testsuites/queue-persist.conf
@@ -9,8 +9,6 @@ $InputTCPServerRun 13514
$ModLoad ../plugins/omtesting/.libs/omtesting
-$ErrorMessagesToStderr off
-
# set spool locations and switch queue to disk-only mode
$WorkDirectory test-spool
$MainMsgQueueFilename mainq