When a test fails, the script returns immediately and kill_daemon
function is called to cleanup. It is quite verbose and requires
scrolling hundreds of lines back to find the actual error
message. Turn off the shell trace to reduce the verbosity and improve
error output readability.
The kill_daemon cannot just turn off set -x because it may be called by
a test, not just at the end of the run. Instead the kill_daemon function
checks if tracing is activated and temporarily disables it.
Also get rid of the find standard error that commonly happens when
kill_daemon is called to verify there are no leftovers and the test
directory does not exist.
Signed-off-by: Loic Dachary <ldachary@redhat.com>
# @return 0 on success, 1 on error
#
function kill_daemons() {
+ local trace=$(shopt -q -o xtrace && echo true || echo false)
+ $trace && shopt -u -o xtrace
local dir=$1
local signal=${2:-KILL}
local name_prefix=$3 # optional, osd, mon, osd.1
local delays=${4:-0 0 1 1 1 2 3 5 5 5 10 10 20 60}
local status=0
- for pidfile in $(find $dir | grep $name_prefix'[^/]*\.pid') ; do
+ for pidfile in $(find $dir 2>/dev/null | grep $name_prefix'[^/]*\.pid') ; do
pid=$(cat $pidfile)
local send_signal=$signal
local kill_complete=false
status=1
fi
done
+ $trace && shopt -s -o xtrace
return $status
}