4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
15 # Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
18 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_reopen
/zpool_reopen.shlib
22 # Test zpool reopen -n while scrub is running.
23 # Checks if re-plugged device is NOT resilvered.
28 # 3. Write test file to pool.
30 # 5. "Plug back" disk.
31 # 6. Reopen a pool with an -n flag.
32 # 7. Check if scrub scan is NOT replaced by resilver.
33 # 8. Check if trying to put device to offline fails because of no valid
37 # A 125ms delay is added to make sure that the scrub is running while
38 # the reopen is invoked.
41 verify_runnable
"global"
45 log_must zinject
-c all
46 # bring back removed disk online for further tests
47 insert_disk
$REMOVED_DISK $scsi_host
48 poolexists
$TESTPOOL && destroy_pool
$TESTPOOL
51 log_assert
"Testing zpool reopen with pool name as argument"
55 scsi_host
=$
(get_scsi_host
$REMOVED_DISK)
58 default_mirror_setup_noexit
$REMOVED_DISK_ID $DISK2
60 remove_disk
$REMOVED_DISK
61 log_must zpool reopen
-n $TESTPOOL
62 log_must check_state
$TESTPOOL "$REMOVED_DISK_ID" "unavail"
63 # 3. Write test file to pool.
64 log_must generate_random_file
/$TESTPOOL/data
$LARGE_FILE_SIZE
66 # add delay to I/O requests for remaining disk in pool
67 log_must zinject
-d $DISK2 -D125:1 $TESTPOOL
68 log_must zpool scrub
$TESTPOOL
69 # 5. "Plug back" disk.
70 insert_disk
$REMOVED_DISK $scsi_host
71 # 6. Reopen a pool with an -n flag.
72 log_must zpool reopen
-n $TESTPOOL
73 log_must check_state
$TESTPOOL "$REMOVED_DISK_ID" "online"
74 # remove delay from disk
75 log_must zinject
-c all
76 # 7. Check if scrub scan is NOT replaced by resilver.
77 log_must wait_for_scrub_end
$TESTPOOL $MAXTIMEOUT
78 log_mustnot is_scan_restarted
$TESTPOOL
80 # 8. Check if trying to put device to offline fails because of no valid
82 log_mustnot zpool offline
$TESTPOOL $DISK2
85 log_must zpool destroy
$TESTPOOL
87 log_pass
"Zpool reopen test successful"