rsyslog/tests/omprog-cleanup-vg.sh
Janmejay Singh 4886df7232 Fixes a "Bug in test code" situation, which had to omprog child death racing with next input.
Reasoning:
- kill has delivered signal
- child is waiting on input
- child gets input appends it to file and exits the while-loop
- another signal comes
- another log-line is injected
- the process is not dead yet but is out of the while loop
- it wont read the input and will never flush it to file because it never read it
- it dies, new process is started, it gets next message, but the previous message is now lost

It can lead to multiple messages being lost too.

The fix is to reduce the number of messages we pass through this read-log, write-log and kill-process cycle so we can afford some sleep and then actually adding some sleep.
2016-11-03 23:48:43 +05:30

37 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# added 2016-09-20 by singh.janmejay
# This file is part of the rsyslog project, released under ASL 2.0
echo ===============================================================================
echo \[omprog-cleanup-vg.sh\]: test for cleanup in omprog with valgrind
. $srcdir/diag.sh init
. $srcdir/diag.sh startup-vg omprog-cleanup.conf
. $srcdir/diag.sh wait-startup
. $srcdir/diag.sh injectmsg 0 5
sleep 1
. $srcdir/diag.sh wait-queueempty
. $srcdir/diag.sh content-check "msgnum:00000000:"
. $srcdir/diag.sh getpid
old_fd_count=$(lsof -p $pid | wc -l)
for i in $(seq 5 10); do
pkill -USR1 omprog-test-bin
sleep .1
. $srcdir/diag.sh injectmsg $i 1
sleep .1
done
sleep .5
. $srcdir/diag.sh content-check "msgnum:00000009:"
new_fd_count=$(lsof -p $pid | wc -l)
echo OLD: $old_fd_count NEW: $new_fd_count
. $srcdir/diag.sh assert-equal $old_fd_count $new_fd_count 2
echo doing shutdown
. $srcdir/diag.sh shutdown-when-empty
echo wait on shutdown
. $srcdir/diag.sh wait-shutdown-vg
. $srcdir/diag.sh check-exit-vg
. $srcdir/diag.sh exit