]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: ceph-helpers.sh reduce kill_daemon verbosity
authorLoic Dachary <ldachary@redhat.com>
Sat, 30 May 2015 14:36:45 +0000 (16:36 +0200)
committerLoic Dachary <ldachary@redhat.com>
Wed, 8 Jul 2015 11:58:10 +0000 (13:58 +0200)
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>
qa/workunits/ceph-helpers.sh

index 4dcef3399c25810da01ae1067fc7dac0ded475ec..325754ad2077206a439163d86bdd147e421394cc 100755 (executable)
@@ -189,13 +189,15 @@ function test_teardown() {
 # @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
@@ -213,6 +215,7 @@ function kill_daemons() {
             status=1
         fi
     done
+    $trace && shopt -s -o xtrace
     return $status
 }