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# $FreeBSD$ 24 25# 26# Copyright 2013 Spectra Logic Corp. All rights reserved. 27# Use is subject to license terms. 28# 29# 30. $STF_SUITE/include/libtest.kshlib 31 32################################################################################ 33# 34# __stc_assertion_start 35# 36# ID: zpool_import_missing_004_pos 37# 38# DESCRIPTION: 39# Once a pool has been exported and one or more devices are missing 40# "zpool import" with no pool argument should exit with error code 0. 41# 42# STRATEGY: 43# 1. Create test pool upon device files using the various combinations. 44# - Striped pool 45# - Mirror 46# - Raidz 47# 2. Export the test pool. 48# 3. Remove one or more devices 49# 4. Verify 'zpool import' will handle missing devices successfully. 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING_STATUS: COMPLETED (2013-07-02) 56# 57# __stc_assertion_end 58# 59################################################################################ 60 61verify_runnable "global" 62 63set -A vdevs "mirror" "raidz" "" 64 65function cleanup 66{ 67 destroy_pool $TESTPOOL1 68 log_must $RM -rf $DEVICE_DIR/* 69} 70 71function recreate_files 72{ 73 cleanup 74 typeset -i i=0 75 for (( ; $i < $GROUP_NUM; i += 1 )); do 76 log_must create_vdevs ${DEVICE_DIR}/${DEVICE_FILE}$i 77 done 78 log_must $SYNC 79} 80 81log_onexit cleanup 82 83log_assert "Verify that zpool import succeeds when devices are missing" 84 85typeset rootvdev 86typeset option 87log_must $MKDIR -p $DEVICE_DIR 88for rootvdev in "${vdevs[@]}"; do 89 recreate_files 90 poolexists $TESTPOOL1 || \ 91 create_pool $TESTPOOL1 "${rootvdev}" $DEVICE_FILES 92 93 # Remove all devices but the last, one at a time 94 for device in ${DEVICE_FILES% *} ; do 95 poolexists $TESTPOOL1 && log_must $ZPOOL export $TESTPOOL1 96 log_must $RM -f $device 97 log_must $ZPOOL import -d $DEVICE_DIR 98 done 99done 100 101log_pass "zpool import succeeded when devices were missing" 102