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# Initializing automatically resumes across import/export. 33# 34# STRATEGY: 35# 1. Create a one-disk pool. 36# 2. Start initializing and verify that initializing is active. 37# 3. Export the pool. 38# 4. Import the pool. 39# 5. Verify that initializing resumes and progress does not regress. 40# 6. Suspend initializing. 41# 7. Repeat steps 3-4. 42# 8. Verify that progress does not regress but initializing is still suspended. 43# 44 45DISK1=${DISKS%% *} 46 47log_must zpool create -f $TESTPOOL $DISK1 48log_must zpool initialize $TESTPOOL 49 50sleep 2 51 52progress="$(initialize_progress $TESTPOOL $DISK1)" 53[[ -z "$progress" ]] && log_fail "Initializing did not start" 54 55log_must zpool export $TESTPOOL 56log_must zpool import $TESTPOOL 57 58new_progress="$(initialize_progress $TESTPOOL $DISK1)" 59[[ -z "$new_progress" ]] && log_fail "Initializing did not restart after import" 60[[ "$progress" -le "$new_progress" ]] || \ 61 log_fail "Initializing lost progress after import" 62log_mustnot eval "initialize_prog_line $TESTPOOL $DISK1 | grep suspended" 63 64log_must zpool initialize -s $TESTPOOL $DISK1 65action_date="$(initialize_prog_line $TESTPOOL $DISK1 | \ 66 sed 's/.*ed at \(.*\)).*/\1/g')" 67log_must zpool export $TESTPOOL 68log_must zpool import $TESTPOOL 69new_action_date=$(initialize_prog_line $TESTPOOL $DISK1 | \ 70 sed 's/.*ed at \(.*\)).*/\1/g') 71[[ "$action_date" != "$new_action_date" ]] && \ 72 log_fail "Initializing action date did not persist across export/import" 73 74[[ "$new_progress" -le "$(initialize_progress $TESTPOOL $DISK1)" ]] || \ 75 log_fail "Initializing lost progress after import" 76 77log_must eval "initialize_prog_line $TESTPOOL $DISK1 | grep suspended" 78 79log_pass "Initializing retains state as expected across export/import" 80