Whamcloud - gitweb
LU-8952 tests: handling test specific cleanup of ost pools
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index d27cb30..39a0990 100755 (executable)
@@ -6020,9 +6020,8 @@ _wait_osc_import_state() {
 
        if [[ $facet == client* ]]; then
                # During setup time, the osc might not be setup, it need wait
-               # until list_param can return valid value. And also if there
-               # are mulitple osc entries we should list all of them before
-               # go to wait.
+               # until list_param can return valid value.
+               param="osc.${ost%?}[^mM]*.ost_server_uuid"
                params=$($LCTL list_param $param 2>/dev/null || true)
                while [ -z "$params" ]; do
                        if [ $i -ge $maxtime ]; then
@@ -6234,6 +6233,7 @@ create_pool() {
        local fsname=${1%%.*}
        local poolname=${1##$fsname.}
 
+       trap "destroy_test_pools $fsname" EXIT
        do_facet mgs lctl pool_new $1
        local RC=$?
        # get param should return err unless pool is created
@@ -6313,22 +6313,22 @@ destroy_pool() {
 }
 
 destroy_pools () {
-    local fsname=${1:-$FSNAME}
-    local poolname
-    local listvar=${fsname}_CREATED_POOLS
+       local fsname=${1:-$FSNAME}
+       local poolname
+       local listvar=${fsname}_CREATED_POOLS
 
-    [ x${!listvar} = x ] && return 0
+       [ x${!listvar} = x ] && return 0
 
-    echo destroy the created pools: ${!listvar}
-    for poolname in ${!listvar//,/ }; do
-        destroy_pool $fsname.$poolname
-    done
+       echo "Destroy the created pools: ${!listvar}"
+       for poolname in ${!listvar//,/ }; do
+               destroy_pool $fsname.$poolname
+       done
 }
 
-cleanup_pools () {
-    local fsname=${1:-$FSNAME}
-    trap 0
-    destroy_pools $fsname
+destroy_test_pools () {
+       trap 0
+       local fsname=${1:-$FSNAME}
+       destroy_pools $fsname || true
 }
 
 gather_logs () {