]> git.proxmox.com Git - mirror_zfs.git/blobdiff - tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh
ZTS: Make fault cleanup function more robust
[mirror_zfs.git] / tests / zfs-tests / tests / functional / fault / auto_online_001_pos.ksh
index 50f721c27f863e1f12c5143f77cbc34d5e1de9b8..bc925bc91c815080dc8f98c378db7db66d2069ac 100755 (executable)
@@ -21,6 +21,7 @@
 #
 #
 # Copyright (c) 2016, 2017 by Intel Corporation. All rights reserved.
+# Copyright (c) 2019 by Delphix. All rights reserved.
 #
 
 . $STF_SUITE/include/libtest.shlib
@@ -54,9 +55,17 @@ fi
 
 function cleanup
 {
-       #online last disk before fail
-       insert_disk $offline_disk $host
-       poolexists $TESTPOOL && destroy_pool $TESTPOOL
+       typeset disk
+
+       # Replace any disk that may have been removed at failure time.
+       for disk in $DISK1 $DISK2 $DISK3; do
+               # Skip loop devices and devices that currently exist.
+               is_loop_device $disk && continue
+               is_real_device $disk && continue
+               insert_disk $disk $(get_scsi_host $disk)
+       done
+       destroy_pool $TESTPOOL
+       unload_scsi_debug
 }
 
 log_assert "Testing automated auto-online FMA test"
@@ -65,8 +74,8 @@ log_onexit cleanup
 
 # If using the default loop devices, need a scsi_debug device for auto-online
 if is_loop_device $DISK1; then
-       SD=$(lsscsi | nawk '/scsi_debug/ {print $6; exit}')
-       SDDEVICE=$(echo $SD | nawk -F / '{print $3}')
+       load_scsi_debug $SDSIZE $SDHOSTS $SDTGTS $SDLUNS '512b'
+       SDDEVICE=$(get_debug_device)
        SDDEVICE_ID=$(get_persistent_disk_name $SDDEVICE)
        autoonline_disks="$SDDEVICE"
 else
@@ -111,7 +120,7 @@ do
        fi
 
        # Clear zpool events
-       zpool events -c $TESTPOOL
+       log_must zpool events -c
 
        # Online disk
        insert_disk $offline_disk $host