1#!/bin/ksh -p 2# 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 6# 1.0 of the CDDL. 7# 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. 11# 12 13# 14# Copyright (c) 2018 by Delphix. All rights reserved. 15# 16 17. $STF_SUITE/include/libtest.shlib 18. $STF_SUITE/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib 19 20# 21# DESCRIPTION: 22# 'zpool wait' works when waiting for resilvering to complete. 23# 24# STRATEGY: 25# 1. Attach a device to the pool so that resilvering starts. 26# 2. Start 'zpool wait'. 27# 3. Monitor the waiting process to make sure it returns neither too soon nor 28# too late. 29# 4. Repeat 1-3, except using the '-w' flag with 'zpool attach' instead of using 30# 'zpool wait'. 31# 32 33function cleanup 34{ 35 remove_io_delay 36 kill_if_running $pid 37 get_disklist $TESTPOOL | grep $DISK2 >/dev/null && \ 38 log_must zpool detach $TESTPOOL $DISK2 39} 40 41typeset -r IN_PROGRESS_CHECK="is_pool_resilvering $TESTPOOL" 42typeset pid 43 44log_onexit cleanup 45 46add_io_delay $TESTPOOL 47 48# Test 'zpool wait -t resilver' 49log_must zpool attach $TESTPOOL $DISK1 $DISK2 50log_bkgrnd zpool wait -t resilver $TESTPOOL 51pid=$! 52check_while_waiting $pid "$IN_PROGRESS_CHECK" 53 54log_must zpool detach $TESTPOOL $DISK2 55 56# Test 'zpool attach -w' 57log_bkgrnd zpool attach -w $TESTPOOL $DISK1 $DISK2 58pid=$! 59while ! is_pool_resilvering $TESTPOOL && proc_exists $pid; do 60 log_must sleep .5 61done 62check_while_waiting $pid "$IN_PROGRESS_CHECK" 63 64log_pass "'zpool wait -t resilver' and 'zpool attach -w' work." 65