1*094e47e9SGeorge Wilson#!/bin/ksh -p 2*094e47e9SGeorge Wilson# 3*094e47e9SGeorge Wilson# CDDL HEADER START 4*094e47e9SGeorge Wilson# 5*094e47e9SGeorge Wilson# The contents of this file are subject to the terms of the 6*094e47e9SGeorge Wilson# Common Development and Distribution License (the "License"). 7*094e47e9SGeorge Wilson# You may not use this file except in compliance with the License. 8*094e47e9SGeorge Wilson# 9*094e47e9SGeorge Wilson# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*094e47e9SGeorge Wilson# or http://www.opensolaris.org/os/licensing. 11*094e47e9SGeorge Wilson# See the License for the specific language governing permissions 12*094e47e9SGeorge Wilson# and limitations under the License. 13*094e47e9SGeorge Wilson# 14*094e47e9SGeorge Wilson# When distributing Covered Code, include this CDDL HEADER in each 15*094e47e9SGeorge Wilson# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*094e47e9SGeorge Wilson# If applicable, add the following below this CDDL HEADER, with the 17*094e47e9SGeorge Wilson# fields enclosed by brackets "[]" replaced with your own identifying 18*094e47e9SGeorge Wilson# information: Portions Copyright [yyyy] [name of copyright owner] 19*094e47e9SGeorge Wilson# 20*094e47e9SGeorge Wilson# CDDL HEADER END 21*094e47e9SGeorge Wilson# 22*094e47e9SGeorge Wilson 23*094e47e9SGeorge Wilson# 24*094e47e9SGeorge Wilson# Copyright (c) 2016 by Delphix. All rights reserved. 25*094e47e9SGeorge Wilson# 26*094e47e9SGeorge Wilson. $STF_SUITE/include/libtest.shlib 27*094e47e9SGeorge Wilson. $STF_SUITE/tests/functional/cli_root/zpool_initialize/zpool_initialize.kshlib 28*094e47e9SGeorge Wilson 29*094e47e9SGeorge Wilson# 30*094e47e9SGeorge Wilson# DESCRIPTION: 31*094e47e9SGeorge Wilson# Initializing automatically resumes across offline/online. 32*094e47e9SGeorge Wilson# 33*094e47e9SGeorge Wilson# STRATEGY: 34*094e47e9SGeorge Wilson# 1. Create a pool with a two-way mirror. 35*094e47e9SGeorge Wilson# 2. Start initializing one of the disks and verify that initializing is active. 36*094e47e9SGeorge Wilson# 3. Offline the disk. 37*094e47e9SGeorge Wilson# 4. Online the disk. 38*094e47e9SGeorge Wilson# 5. Verify that initializing resumes and progress does not regress. 39*094e47e9SGeorge Wilson# 6. Suspend initializing. 40*094e47e9SGeorge Wilson# 7. Repeat steps 3-4 and verify that initializing does not resume. 41*094e47e9SGeorge Wilson# 42*094e47e9SGeorge Wilson 43*094e47e9SGeorge WilsonDISK1=${DISKS%% *} 44*094e47e9SGeorge WilsonDISK2="$(echo $DISKS | cut -d' ' -f2)" 45*094e47e9SGeorge Wilson 46*094e47e9SGeorge Wilsonlog_must zpool create -f $TESTPOOL mirror $DISK1 $DISK2 47*094e47e9SGeorge Wilsonlog_must zpool initialize $TESTPOOL $DISK1 48*094e47e9SGeorge Wilson 49*094e47e9SGeorge Wilsonlog_must zpool offline $TESTPOOL $DISK1 50*094e47e9SGeorge Wilson 51*094e47e9SGeorge Wilsonprogress="$(initialize_progress $TESTPOOL $DISK1)" 52*094e47e9SGeorge Wilson[[ -z "$progress" ]] && log_fail "Initializing did not start" 53*094e47e9SGeorge Wilson 54*094e47e9SGeorge Wilsonlog_must zpool online $TESTPOOL $DISK1 55*094e47e9SGeorge Wilson 56*094e47e9SGeorge Wilsonnew_progress="$(initialize_progress $TESTPOOL $DISK1)" 57*094e47e9SGeorge Wilson[[ -z "$new_progress" ]] && \ 58*094e47e9SGeorge Wilson log_fail "Initializing did not restart after onlining" 59*094e47e9SGeorge Wilson[[ "$progress" -le "$new_progress" ]] || \ 60*094e47e9SGeorge Wilson log_fail "Initializing lost progress after onlining" 61*094e47e9SGeorge Wilsonlog_mustnot eval "initialize_prog_line $TESTPOOL $DISK1 | grep suspended" 62*094e47e9SGeorge Wilson 63*094e47e9SGeorge Wilsonlog_must zpool initialize -s $TESTPOOL $DISK1 64*094e47e9SGeorge Wilsonaction_date="$(initialize_prog_line $TESTPOOL $DISK1 | \ 65*094e47e9SGeorge Wilson sed 's/.*ed at \(.*\)).*/\1/g')" 66*094e47e9SGeorge Wilsonlog_must zpool offline $TESTPOOL $DISK1 67*094e47e9SGeorge Wilsonlog_must zpool online $TESTPOOL $DISK1 68*094e47e9SGeorge Wilsonnew_action_date=$(initialize_prog_line $TESTPOOL $DISK1 | \ 69*094e47e9SGeorge Wilson sed 's/.*ed at \(.*\)).*/\1/g') 70*094e47e9SGeorge Wilson[[ "$action_date" != "$new_action_date" ]] && \ 71*094e47e9SGeorge Wilson log_fail "Initializing action date did not persist across offline/online" 72*094e47e9SGeorge Wilsonlog_must eval "initialize_prog_line $TESTPOOL $DISK1 | grep suspended" 73*094e47e9SGeorge Wilson 74*094e47e9SGeorge Wilsonlog_pass "Initializing performs as expected across offline/online" 75