1#!/bin/ksh -p 2# SPDX-License-Identifier: CDDL-1.0 3# 4# CDDL HEADER START 5# 6# The contents of this file are subject to the terms of the 7# Common Development and Distribution License (the "License"). 8# You may not use this file except in compliance with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or https://opensource.org/licenses/CDDL-1.0. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23 24# 25# Copyright (c) 2016 by Delphix. All rights reserved. 26# 27. $STF_SUITE/include/libtest.shlib 28. $STF_SUITE/tests/functional/cli_root/zpool_initialize/zpool_initialize.kshlib 29 30# 31# DESCRIPTION: 32# Suspending and resuming initializing works. 33# 34# STRATEGY: 35# 1. Create a one-disk pool. 36# 2. Start initializing and verify that initializing is active. 37# 3. Wait 3 seconds, then suspend initializing and verify that the progress 38# reporting says so. 39# 4. Wait 5 seconds and ensure initializing progress doesn't advance. 40# 5. Restart initializing and verify that the progress doesn't regress. 41# 42 43DISK1=${DISKS%% *} 44 45log_must zpool create -f $TESTPOOL $DISK1 46log_must zpool initialize $TESTPOOL 47 48[[ -z "$(initialize_progress $TESTPOOL $DISK1)" ]] && \ 49 log_fail "Initializing did not start" 50 51sleep 5 52log_must zpool initialize -s $TESTPOOL 53log_must eval "initialize_prog_line $TESTPOOL $DISK1 | grep suspended" 54progress="$(initialize_progress $TESTPOOL $DISK1)" 55 56sleep 3 57[[ "$progress" -eq "$(initialize_progress $TESTPOOL $DISK1)" ]] || \ 58 log_fail "Initializing progress advanced while suspended" 59 60log_must zpool initialize $TESTPOOL $DISK1 61[[ "$progress" -le "$(initialize_progress $TESTPOOL $DISK1)" ]] || 62 log_fail "Initializing progress regressed after resuming" 63 64log_pass "Suspend + resume initializing works as expected" 65