From 765317d54ec5658dd0c598170d0fc0824f751265 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 10 Mar 2011 15:13:31 +0100 Subject: improved tcpflood test tool to support many more connections even on platforms that place a low limit on the number of file descriptors per processes. The tool now increases the fd limit as required. --- tests/tcpflood.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/tcpflood.c b/tests/tcpflood.c index d8c3f038..138706aa 100644 --- a/tests/tcpflood.c +++ b/tests/tcpflood.c @@ -62,6 +62,7 @@ #include #include #include +#include #define EXIT_FAILURE 1 #define INVALID_SOCKET -1 @@ -377,6 +378,7 @@ int main(int argc, char *argv[]) int ret = 0; int opt; struct sigaction sigAct; + struct rlimit maxFiles; static char buf[1024]; srand(time(NULL)); /* seed is good enough for our needs */ @@ -439,6 +441,18 @@ int main(int argc, char *argv[]) } } + if(numConnections > 100) { + maxFiles.rlim_cur = numConnections + 50; + maxFiles.rlim_max = numConnections + 50; + if(setrlimit(RLIMIT_NOFILE, &maxFiles) < 0) { + perror("set number of open files"); + fprintf(stderr, + "could net set sufficiently large number of " + "open files for required connection count!\n"); + exit(1); + } + } + if(dataFile != NULL) { if((dataFP = fopen(dataFile, "r")) == NULL) { perror(dataFile); -- cgit From 4195f9cb08cddaeae37dc88c5e879d84391b4359 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 11 Mar 2011 10:58:07 +0100 Subject: added new test for imfile to testbench --- tests/Makefile.am | 11 ++++++++++- tests/diag.sh | 2 ++ tests/imfile-basic.sh | 14 ++++++++++++++ tests/inputfilegen.c | 23 +++++++++++++++++++++++ tests/random.sh | 4 +--- tests/testsuites/imfile-basic.conf | 12 ++++++++++++ 6 files changed, 62 insertions(+), 4 deletions(-) create mode 100755 tests/imfile-basic.sh create mode 100644 tests/inputfilegen.c create mode 100644 tests/testsuites/imfile-basic.conf diff --git a/tests/Makefile.am b/tests/Makefile.am index 0045f00a..a438a926 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ if ENABLE_TESTBENCH TESTRUNS = rt_init rscript -check_PROGRAMS = $(TESTRUNS) ourtail nettester tcpflood chkseq randomgen +check_PROGRAMS = $(TESTRUNS) ourtail nettester tcpflood chkseq randomgen inputfilegen TESTS = $(TESTRUNS) cfg.sh \ validation-run.sh \ imtcp-multiport.sh \ @@ -44,6 +44,10 @@ if ENABLE_EXTENDED_TESTS TESTS += random.sh endif +if ENABLE_IMFILE +TESTS += imfile-basic.sh +endif + check_JAVA = DiagTalker.java endif # if ENABLE_TESTBENCH @@ -187,6 +191,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \ testsuites/complex1.conf \ random.sh \ testsuites/random.conf \ + imfile-basic.sh \ + testsuites/imfile-basic.conf \ dynfile_invld_async.sh \ dynfile_invld_sync.sh \ dynfile_cachemiss.sh \ @@ -213,6 +219,9 @@ tcpflood_LDADD = $(SOL_LIBS) randomgen_SOURCES = randomgen.c randomgen_LDADD = $(SOL_LIBS) +inputfilegen_SOURCES = inputfilegen.c +inputfilegen_LDADD = $(SOL_LIBS) + nettester_SOURCES = nettester.c getline.c nettester_LDADD = $(SOL_LIBS) diff --git a/tests/diag.sh b/tests/diag.sh index 51ad5f6a..806edf80 100755 --- a/tests/diag.sh +++ b/tests/diag.sh @@ -22,6 +22,7 @@ case $1 in rm -f work rsyslog.out.log rsyslog.out.log.save # common work files rm -f rsyslog.out.*.log work-presort rm -rf test-spool + rm -f rsyslog.input rm -f core.* vgcore.* mkdir test-spool ;; @@ -30,6 +31,7 @@ case $1 in rm -f work rsyslog.out.log rsyslog.out.log.save # common work files rm -f rsyslog.out.*.log rsyslog.random.data work-presort rm -rf test-spool + rm -f rsyslog.input ;; 'startup') # start rsyslogd with default params. $2 is the config file name to use # returns only after successful startup, $3 is the instance (blank or 2!) diff --git a/tests/imfile-basic.sh b/tests/imfile-basic.sh new file mode 100755 index 00000000..ca6a5d3a --- /dev/null +++ b/tests/imfile-basic.sh @@ -0,0 +1,14 @@ +# This is part of the rsyslog testbench, licensed under GPLv3 +echo [imfile-basic.sh] +source $srcdir/diag.sh init +# generate input file first. Note that rsyslog processes it as +# soon as it start up (so the file should exist at that point). +./inputfilegen 50000 > rsyslog.input +ls -l rsyslog.input +source $srcdir/diag.sh startup imfile-basic.conf +# sleep a little to give rsyslog a chance to begin processing +sleep 1 +source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages +source $srcdir/diag.sh wait-shutdown # we need to wait until rsyslogd is finished! +source $srcdir/diag.sh seq-check 0 49999 +source $srcdir/diag.sh exit diff --git a/tests/inputfilegen.c b/tests/inputfilegen.c new file mode 100644 index 00000000..26fb79af --- /dev/null +++ b/tests/inputfilegen.c @@ -0,0 +1,23 @@ +/* generate an input file suitable for use by the testbench + * Copyright (C) 2011 by Rainer Gerhards and Adiscon GmbH. + * Part of rsyslog, licensed under GPLv3 + */ +#include +#include + +int main(int argc, char* argv[]) +{ + int nmsgs; + int i; + + if(argc != 2) { + fprintf(stderr, "usage: inputfilegen num-messages\n"); + return 1; + } + + nmsgs = atoi(argv[1]); + for(i = 0 ; i < nmsgs ; ++i) { + printf("msgnum:%8.8d:\n", i); + } + return 0; +} diff --git a/tests/random.sh b/tests/random.sh index d1f392d3..969d720c 100755 --- a/tests/random.sh +++ b/tests/random.sh @@ -5,9 +5,6 @@ echo =============================================================================== echo TEST: \[random.sh\]: testing random data source $srcdir/diag.sh init -# uncomment for debugging support: -#export RSYSLOG_DEBUG="debug nostdout noprintmutexaction" -#export RSYSLOG_DEBUGLOG="log" source $srcdir/diag.sh startup random.conf # generate random data ./randomgen -f rsyslog.random.data -s 100000 @@ -17,4 +14,5 @@ source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done proces source $srcdir/diag.sh wait-shutdown # and wait for it to terminate # we do not check anything yet, the point is if rsyslog survived ;) # TODO: check for exit message, but we'll notice an abort anyhow, so not that important +rm -f random.data source $srcdir/diag.sh exit diff --git a/tests/testsuites/imfile-basic.conf b/tests/testsuites/imfile-basic.conf new file mode 100644 index 00000000..9fb9b5ca --- /dev/null +++ b/tests/testsuites/imfile-basic.conf @@ -0,0 +1,12 @@ +$IncludeConfig diag-common.conf + +$ModLoad ../plugins/imfile/.libs/imfile +$InputFileName ./rsyslog.input +$InputFileTag file: +$InputFileStateFile stat-file1 +$InputFileSeverity error +$InputFileFacility local7 +$InputRunFileMonitor + +$template outfmt,"%msg:F,58:2%\n" +:msg, contains, "msgnum:" ./rsyslog.out.log;outfmt -- cgit