Whamcloud - gitweb
LU-14789 tests: make sanity 133f and 133g working
[fs/lustre-release.git] / lustre / tests / racer / racer.sh
index 9fb4105..5f378bc 100755 (executable)
@@ -4,16 +4,27 @@
 DIR="$1"
 MAX_FILES=${MAX_FILES:-20}
 DURATION=${DURATION:-$((60*5))}
-MDSCOUNT=${MDSCOUNT:-1}
 
 NUM_THREADS=${NUM_THREADS:-$2}
 NUM_THREADS=${NUM_THREADS:-3}
 
+RACER_MAX_CLEANUP_WAIT=${RACER_MAX_CLEANUP_WAIT:-$DURATION}
+
 mkdir -p $DIR
 
-RACER_PROGS="file_create dir_create file_rm file_rename file_link file_symlink \
-file_list file_concat file_exec file_chown file_chmod file_mknod file_truncate \
-file_delxattr file_getxattr file_setxattr"
+RACER_PROGS=${RACER_PROGS:-"file_create dir_create file_rm file_rename \
+file_link file_symlink file_list file_concat file_exec file_chown \
+file_chmod file_mknod file_truncate file_delxattr file_getxattr \
+file_setxattr"}
+
+# allow e.g. RACER_EXTRA=dir_create:5,file_link:10 to launch extra tasks
+for PROG in ${RACER_EXTRA//,/ }; do
+       prog=(${PROG/:/ })
+       count=${prog[1]:-1}
+       for ((i = 0; i < count; i++)); do
+               RACER_PROGS+=" ${prog[0]}"
+       done
+done
 
 if $RACER_ENABLE_REMOTE_DIRS || $RACER_ENABLE_STRIPED_DIRS; then
        RACER_PROGS+=' dir_remote'
@@ -32,11 +43,10 @@ racer_cleanup()
        trap 0
 
        local TOT_WAIT=0
-       local MAX_WAIT=$DURATION
        local SHORT_WAIT=5
 
        local rc
-       while [[ $TOT_WAIT -le $MAX_WAIT ]]; do
+       while [[ $TOT_WAIT -le $RACER_MAX_CLEANUP_WAIT ]]; do
                rc=0
                echo sleeping $SHORT_WAIT sec ...
                sleep $SHORT_WAIT
@@ -45,14 +55,22 @@ racer_cleanup()
                        killall -0 $P.sh
                        [[ $? -eq 0 ]] && (( rc+=1 ))
                done
+
+               # Kill dd processes to speedup cleanup
+               local pids=$(ps uax | grep "$DIR" | grep dd | grep -v grep |
+                               awk '{print $2}')
+               for pid in $pids; do
+                       kill $pid
+               done
+
                if [[ $rc -eq 0 ]]; then
                        echo there should be NO racer processes:
                        ps uww -C "${RACER_PROGS// /.sh,}.sh"
                        return 0
                fi
-               echo -n "Waited $(( TOT_WAIT + SHORT_WAIT)), rc=$rc "
-               (( SHORT_WAIT+=SHORT_WAIT ))
                (( TOT_WAIT+=SHORT_WAIT ))
+               echo -n "Waited $TOT_WAIT, rc=$rc "
+               (( SHORT_WAIT+=SHORT_WAIT ))
        done
        ps uww -C "${RACER_PROGS// /.sh,}.sh"
        return 1