1#!/usr/local/bin/ksh93 -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2013 Spectra Logic Corp. All rights reserved. 25# Use is subject to license terms. 26# 27# 28. $STF_SUITE/include/libtest.kshlib 29 30################################################################################ 31# 32# __stc_assertion_start 33# 34# ID: zpool_import_missing_004_pos 35# 36# DESCRIPTION: 37# Once a pool has been exported and one or more devices are missing 38# "zpool import" with no pool argument should exit with error code 0. 39# 40# STRATEGY: 41# 1. Create test pool upon device files using the various combinations. 42# - Striped pool 43# - Mirror 44# - Raidz 45# 2. Export the test pool. 46# 3. Remove one or more devices 47# 4. Verify 'zpool import' will handle missing devices successfully. 48# 49# TESTABILITY: explicit 50# 51# TEST_AUTOMATION_LEVEL: automated 52# 53# CODING_STATUS: COMPLETED (2013-07-02) 54# 55# __stc_assertion_end 56# 57################################################################################ 58 59verify_runnable "global" 60 61set -A vdevs "mirror" "raidz" "" 62 63function cleanup 64{ 65 destroy_pool $TESTPOOL1 66 log_must $RM -rf $DEVICE_DIR/* 67} 68 69function recreate_files 70{ 71 cleanup 72 typeset -i i=0 73 for (( ; $i < $GROUP_NUM; i += 1 )); do 74 log_must create_vdevs ${DEVICE_DIR}/${DEVICE_FILE}$i 75 done 76 log_must $SYNC 77} 78 79log_onexit cleanup 80 81log_assert "Verify that zpool import succeeds when devices are missing" 82 83typeset rootvdev 84typeset option 85log_must $MKDIR -p $DEVICE_DIR 86for rootvdev in "${vdevs[@]}"; do 87 recreate_files 88 poolexists $TESTPOOL1 || \ 89 create_pool $TESTPOOL1 "${rootvdev}" $DEVICE_FILES 90 91 # Remove all devices but the last, one at a time 92 for device in ${DEVICE_FILES% *} ; do 93 poolexists $TESTPOOL1 && log_must $ZPOOL export $TESTPOOL1 94 log_must $RM -f $device 95 log_must $ZPOOL import -d $DEVICE_DIR 96 done 97done 98 99log_pass "zpool import succeeded when devices were missing" 100