Skip to content

Commit

Permalink
tcpflood: add -A option to NOT abort when sending fails
Browse files Browse the repository at this point in the history
Note: tcpflood is a testbench tool, not meant for production use

We add the -A option. If set, it does NOT abort tcpflood if
sending messages fails.

This is required for some tests which test connection closes.
If tcpflood terminates quickly before rsyslog could fully
initializes all sessions, the expected error message count is
not necessarily reached, which results in flakes. When tcpflood
contines to run, rsyslog has sufficient time (at least a race
is far less likely).
  • Loading branch information
rgerhards committed Jul 28, 2023
1 parent 27e1da2 commit bf58c35
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tests/tcpflood.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
* -z private key file for TLS mode
* -Z cert (public key) file for TLS mode
* -a Authentication Mode for relp-tls
* -A do NOT abort if an error occured during sending messages
* -E Permitted Peer for relp-tls
* -L loglevel to use for GnuTLS troubleshooting (0-off to 10-all, 0 default)
* -j format message in json, parameter is JSON cookie
Expand Down Expand Up @@ -208,6 +209,7 @@ static long long batchsize = 100000000ll;
static int waittime = 0;
static int runMultithreaded = 0; /* run tests in multithreaded mode */
static int numThrds = 1; /* number of threads to use */
static int abortOnSendFail = 1; /* abort run if sending fails? */
static char *tlsCAFile = NULL;
static char *tlsCertFile = NULL;
static char *tlsKeyFile = NULL;
Expand Down Expand Up @@ -793,13 +795,21 @@ int sendMessages(struct instdata *inst)
printf("\r%5.5u\n", i);
fflush(stdout);
test_rs_strerror_r(error_number, errStr, sizeof(errStr));
printf("send() failed \"%s\" at socket %d, index %u, msgNum %lld, "
"lenSend %zd, lenBuf %zd\n",
errStr, sockArray[socknum], i, inst->numSent, lenSend,
lenBuf);
if(lenSend == 0) {
printf("tcpflood: socket %d, index %u, msgNum %lld CLOSED REMOTELY\n",
sockArray[socknum], i, inst->numSent);
} else {
printf("tcpflood: send() failed \"%s\" at socket %d, index %u, "
"msgNum %lld, lenSend %zd, lenBuf %zd\n",
errStr, sockArray[socknum], i, inst->numSent, lenSend,
lenBuf);
}
fflush(stderr);

return(1);
if(abortOnSendFail) {
printf("tcpflood terminates due to send failure\n");
return(1);
}
}
if(i % show_progress_interval == 0) {
if(bShowProgress)
Expand Down Expand Up @@ -1629,7 +1639,7 @@ int main(int argc, char *argv[])

setvbuf(stdout, buf, _IONBF, 48);

while((opt = getopt(argc, argv, "a:Bb:c:C:d:DeE:f:F:i:I:j:k:l:L:m:M:n:OP:p:rR:sS:t:T:u:vW:x:XyYz:Z:")) != -1) {
while((opt = getopt(argc, argv, "a:ABb:c:C:d:DeE:f:F:i:I:j:k:l:L:m:M:n:OP:p:rR:sS:t:T:u:vW:x:XyYz:Z:")) != -1) {
switch (opt) {
case 'b': batchsize = atoll(optarg);
break;
Expand Down Expand Up @@ -1737,6 +1747,8 @@ int main(int argc, char *argv[])
break;
case 'a': relpAuthMode = optarg;
break;
case 'A': abortOnSendFail = 0;
break;
case 'E': relpPermittedPeer = optarg;
break;
case 'u':
Expand Down

0 comments on commit bf58c35

Please sign in to comment.