summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-10 11:07:26 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-10 11:07:26 +0100
commit4408d4137acfacef57bd2e088a0da83d25e34918 (patch)
tree705c34ee7b023ffb4a4795918acd2c0618f7cb29
parentee8bf6d6873b79a5b1ed5a2aae08adf0d4827ff3 (diff)
downloadrsyslog-4408d4137acfacef57bd2e088a0da83d25e34918.tar.gz
rsyslog-4408d4137acfacef57bd2e088a0da83d25e34918.tar.xz
rsyslog-4408d4137acfacef57bd2e088a0da83d25e34918.zip
testbench: new calling interface for tcpflood
this is a perquisite to support more flexible testing modes, which could not intelligently be implemented with the old interface
-rwxr-xr-xtests/asynwr_simple.sh2
-rwxr-xr-xtests/asynwr_small.sh2
-rwxr-xr-xtests/asynwr_timeout.sh2
-rwxr-xr-xtests/asynwr_tinybuf.sh2
-rwxr-xr-xtests/diskqueue-fsync.sh2
-rwxr-xr-xtests/diskqueue.sh2
-rwxr-xr-xtests/execonlyonce.sh4
-rwxr-xr-xtests/imtcp-multiport.sh6
-rwxr-xr-xtests/manytcp.sh2
-rwxr-xr-xtests/pipeaction.sh2
-rwxr-xr-xtests/sndrcv_drvr.sh2
-rw-r--r--tests/tcpflood.c41
-rwxr-xr-xtests/threadingmqaq.sh2
-rw-r--r--tools/zpipe.c7
14 files changed, 44 insertions, 34 deletions
diff --git a/tests/asynwr_simple.sh b/tests/asynwr_simple.sh
index 2e476b8f..c21f7893 100755
--- a/tests/asynwr_simple.sh
+++ b/tests/asynwr_simple.sh
@@ -11,7 +11,7 @@ source $srcdir/diag.sh init
source $srcdir/diag.sh startup asynwr_simple.conf
# send 35555 messages, make sure file size is not a multiple of
# 10K, the buffer size!
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 35555
+source $srcdir/diag.sh tcpflood -m35555
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh seq-check 0 35554
source $srcdir/diag.sh exit
diff --git a/tests/asynwr_small.sh b/tests/asynwr_small.sh
index 39dcd762..ee091935 100755
--- a/tests/asynwr_small.sh
+++ b/tests/asynwr_small.sh
@@ -19,7 +19,7 @@ source $srcdir/diag.sh init
#export RSYSLOG_DEBUGLOG="log"
source $srcdir/diag.sh startup asynwr_small.conf
# send 4000 messages
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 2
+source $srcdir/diag.sh tcpflood -m2
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh seq-check 0 1
source $srcdir/diag.sh exit
diff --git a/tests/asynwr_timeout.sh b/tests/asynwr_timeout.sh
index 746ee3f1..41b76ede 100755
--- a/tests/asynwr_timeout.sh
+++ b/tests/asynwr_timeout.sh
@@ -13,7 +13,7 @@ source $srcdir/diag.sh init
source $srcdir/diag.sh startup asynwr_timeout.conf
# send 35555 messages, make sure file size is not a multiple of
# 10K, the buffer size!
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 35555
+source $srcdir/diag.sh tcpflood -m 35555
sleep 4 # wait for output writer to write and empty buffer
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh seq-check 0 35554
diff --git a/tests/asynwr_tinybuf.sh b/tests/asynwr_tinybuf.sh
index a0915394..8eae1e26 100755
--- a/tests/asynwr_tinybuf.sh
+++ b/tests/asynwr_tinybuf.sh
@@ -13,7 +13,7 @@ source $srcdir/diag.sh init
#export RSYSLOG_DEBUGLOG="log"
source $srcdir/diag.sh startup asynwr_tinybuf.conf
# send 1000 messages, fairly enough to trigger problems
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 1000
+source $srcdir/diag.sh tcpflood -m1000
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh seq-check 0 999
source $srcdir/diag.sh exit
diff --git a/tests/diskqueue-fsync.sh b/tests/diskqueue-fsync.sh
index 0282202d..c7745930 100755
--- a/tests/diskqueue-fsync.sh
+++ b/tests/diskqueue-fsync.sh
@@ -9,7 +9,7 @@ echo testing queue disk-only mode, fsync case
source $srcdir/diag.sh init
source $srcdir/diag.sh startup diskqueue-fsync.conf
# 1000 messages should be enough - the disk fsync test is very slow!
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 1000
+source $srcdir/diag.sh tcpflood -m1000
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh wait-shutdown
source $srcdir/diag.sh seq-check 0 999
diff --git a/tests/diskqueue.sh b/tests/diskqueue.sh
index ad512ee8..7a50d82e 100755
--- a/tests/diskqueue.sh
+++ b/tests/diskqueue.sh
@@ -13,7 +13,7 @@ source $srcdir/diag.sh init
source $srcdir/diag.sh startup diskqueue.conf
# 20000 messages should be enough - the disk test is slow enough ;)
sleep 4
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 20000
+source $srcdir/diag.sh tcpflood -m20000
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh wait-shutdown
source $srcdir/diag.sh seq-check 0 19999
diff --git a/tests/execonlyonce.sh b/tests/execonlyonce.sh
index a9b9d932..b7f60849 100755
--- a/tests/execonlyonce.sh
+++ b/tests/execonlyonce.sh
@@ -10,11 +10,11 @@ echo ===========================================================================
echo \[execonlyonce.sh\]: test for the $ActionExecOnlyOnceEveryInterval directive
source $srcdir/diag.sh init
source $srcdir/diag.sh startup execonlyonce.conf
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 10 1
+source $srcdir/diag.sh tcpflood -m10 -i1
# now wait until the interval definitely expires
sleep 4 # one more than the once inerval!
# and inject another couple of messages
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 10 100
+source $srcdir/diag.sh tcpflood -m10 -i100
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
# now we need your custom logic to see if the result is equal to the
diff --git a/tests/imtcp-multiport.sh b/tests/imtcp-multiport.sh
index 47a33cb9..ad2b44f8 100755
--- a/tests/imtcp-multiport.sh
+++ b/tests/imtcp-multiport.sh
@@ -11,7 +11,7 @@ echo ===========================================================================
echo \[imtcp-multiport.sh\]: testing imtcp multiple listeners
source $srcdir/diag.sh init
source $srcdir/diag.sh startup imtcp-multiport.conf
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 10000
+source $srcdir/diag.sh tcpflood -p13514 -m10000
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh wait-shutdown
source $srcdir/diag.sh seq-check 0 9999
@@ -23,7 +23,7 @@ source $srcdir/diag.sh exit
#
source $srcdir/diag.sh init
source $srcdir/diag.sh startup imtcp-multiport.conf
-source $srcdir/diag.sh tcpflood 127.0.0.1 13515 1 10000
+source $srcdir/diag.sh tcpflood -p13515 -m10000
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh wait-shutdown
source $srcdir/diag.sh seq-check 0 9999
@@ -35,7 +35,7 @@ source $srcdir/diag.sh exit
#
source $srcdir/diag.sh init
source $srcdir/diag.sh startup imtcp-multiport.conf
-source $srcdir/diag.sh tcpflood 127.0.0.1 13516 1 10000
+source $srcdir/diag.sh tcpflood -p13516 -m10000
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh wait-shutdown
source $srcdir/diag.sh seq-check 0 9999
diff --git a/tests/manytcp.sh b/tests/manytcp.sh
index c55eb9c0..dbf1d961 100755
--- a/tests/manytcp.sh
+++ b/tests/manytcp.sh
@@ -2,7 +2,7 @@
source $srcdir/diag.sh init
source $srcdir/diag.sh startup manytcp.conf
# the config file specifies exactly 1100 connections
-source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1000 40000
+source $srcdir/diag.sh tcpflood -c1000 -m40000
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh seq-check 0 39999
source $srcdir/diag.sh exit
diff --git a/tests/pipeaction.sh b/tests/pipeaction.sh
index 26a4c22a..c2201011 100755
--- a/tests/pipeaction.sh
+++ b/tests/pipeaction.sh
@@ -17,7 +17,7 @@ echo background cp process id is $CPPROCESS
# now do the usual run
source $srcdir/diag.sh startup pipeaction.conf
# 20000 messages should be enough
-#source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 20000
+#source $srcdir/diag.sh tcpflood -m20000
source $srcdir/diag.sh injectmsg 0 20000
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh wait-shutdown
diff --git a/tests/sndrcv_drvr.sh b/tests/sndrcv_drvr.sh
index 63afd6b5..3d613069 100755
--- a/tests/sndrcv_drvr.sh
+++ b/tests/sndrcv_drvr.sh
@@ -34,7 +34,7 @@ source $srcdir/diag.sh wait-startup 2
# 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 13514 1 $2 1
+source $srcdir/diag.sh tcpflood -m$2 -i1
sleep 2 # make sure all data is received in input buffers
# shut down sender when everything is sent, receiver continues to run concurrently
# may be needed by TLS (once we do it): sleep 60
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
index 0439e33e..308495a5 100644
--- a/tests/tcpflood.c
+++ b/tests/tcpflood.c
@@ -2,11 +2,11 @@
* messages over them. This is used for stress-testing.
*
* Params
- * argv[1] target address
- * 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)
+ * -t target address (default 127.0.0.1)
+ * -p target port (default 13514)
+ * -c number of connections (default 1)
+ * -m number of messages to send (connection is random)
+ * -i initial message number (optional)
*
* Part of the testbench for rsyslog.
*
@@ -47,10 +47,10 @@
/* Name of input file, must match $IncludeConfig in test suite .conf files */
#define NETTEST_INPUT_CONF_FILE "nettest.input.conf" /* name of input file, must match $IncludeConfig in .conf files */
-static char *targetIP;
-static int targetPort;
+static char *targetIP = "127.0.0.1";
+static int targetPort = 13514;
static int numMsgsToSend; /* number of messages to send */
-static int numConnections; /* number of connections to create */
+static int numConnections = 1; /* number of connections to create */
static int *sockArray; /* array of sockets to use */
static int msgNum = 0; /* initial message number to start with */
@@ -259,6 +259,7 @@ tcpSend(char *buf, int lenBuf)
int main(int argc, char *argv[])
{
int ret = 0;
+ int opt;
struct sigaction sigAct;
static char buf[1024];
@@ -272,18 +273,20 @@ int main(int argc, char *argv[])
setvbuf(stdout, buf, _IONBF, 48);
- if(argc != 5 && argc != 6) {
- printf("Invalid call of tcpflood\n");
- printf("Usage: tcpflood target-host target-port num-connections num-messages [initial msgnum]\n");
- exit(1);
+ while((opt = getopt(argc, argv, "t:p:c:m:i:")) != -1) {
+ switch (opt) {
+ case 't': targetIP = optarg;
+ break;
+ case 'p': targetPort = atoi(optarg);
+ break;
+ case 'c': numConnections = atoi(optarg);
+ break;
+ case 'm': numMsgsToSend = atoi(optarg);
+ break;
+ case 'i': msgNum = atoi(optarg);
+ break;
+ }
}
-
- targetIP = argv[1];
- 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/threadingmqaq.sh b/tests/threadingmqaq.sh
index 9f2ea793..b7764821 100755
--- a/tests/threadingmqaq.sh
+++ b/tests/threadingmqaq.sh
@@ -9,7 +9,7 @@
echo TEST: threadingmqaq.sh - main/action queue concurrency
source $srcdir/diag.sh init
source $srcdir/diag.sh startup threadingmqaq.conf
-#source $srcdir/diag.sh tcpflood 127.0.0.1 13514 2 100000
+#source $srcdir/diag.sh tcpflood -c2 -m100000
#source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh injectmsg 0 100000
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
diff --git a/tools/zpipe.c b/tools/zpipe.c
index d2278359..38069425 100644
--- a/tools/zpipe.c
+++ b/tools/zpipe.c
@@ -4,6 +4,13 @@
Version 2.0 03 June 2009 Rainer Gerhards */
/* RSYSLOG NOTE:
+ * This file is primarily been used as a testing aid for rsyslog. We do NOT
+ * properly maintain it and it has been brought to our attention that it may
+ * have some security issues. However, we prefer not to remove the file as it
+ * may turn out to be useful for further testing. All users are advised NOT
+ * to base any development on this version here, but rather look for the
+ * original zpipe.c by the authors mentioned above.
+ *
* This file is beeing distributed as part of rsyslog, but is just an
* add-on. Most importantly, rsyslog's copyright does not apply but
* rather the (non-) copyright stated above.