3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
14 # Copyright (c) 2018 by Delphix. All rights reserved.
17 . $STF_SUITE/include/libtest.shlib
18 . $STF_SUITE/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib
22 # 'zpool wait' works when waiting for a device to be removed.
25 # 1. Create a pool with two disks and some data.
26 # 2. Modify a tunable to make sure removal doesn't make any progress.
27 # 3. Start removing one of the disks.
28 # 4. Start 'zpool wait'.
29 # 5. Sleep for a few seconds and check that the process is actually waiting.
30 # 6. Modify tunable to allow removal to complete.
31 # 7. Monitor the waiting process to make sure it returns neither too soon nor
33 # 8. Repeat 1-7, except using the '-w' flag for 'zpool remove' instead of using
40 log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 0
41 poolexists $TESTPOOL && destroy_pool $TESTPOOL
48 log_must zpool create -f $TESTPOOL $DISK1 $DISK2
49 log_must dd if=/dev/urandom of="/$TESTPOOL/testfile" bs=1k count=16k
51 # Start removal, but don't allow it to make any progress at first
52 log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 1
55 log_bkgrnd zpool remove -w $TESTPOOL $DISK1
58 while ! is_pool_removing $TESTPOOL && proc_exists $pid; do
62 log_must zpool remove $TESTPOOL $DISK1
63 log_bkgrnd zpool wait -t remove $TESTPOOL
67 # Make sure the 'zpool wait' is actually waiting
71 # Unpause removal, and wait for it to finish
72 log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 0
73 check_while_waiting $pid "is_pool_removing $TESTPOOL"
75 log_must zpool destroy $TESTPOOL
85 log_pass "'zpool wait -t remove' and 'zpool remove -w' work."