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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27# ident "@(#)zpool_import_006_pos.ksh 1.3 07/10/09 SMI" 28# 29 30. $STF_SUITE/include/libtest.kshlib 31 32################################################################################# 33# 34# __stc_assertion_start 35# 36# ID: zpool_import_006_pos 37# 38# DESCRIPTION: 39# For mirror, N-1 destroyed pools devices was removed or used by other 40# pool, it still can be imported correctly. 41# 42# STRATEGY: 43# 1. Create mirror with N disks. 44# 2. Destroy this mirror. 45# 3. Create another pool with N-1 disks which was used by this mirror. 46# 4. Verify import mirror can succeed. 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2006-06-12) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58verify_runnable "global" 59 60function cleanup 61{ 62 destroy_pool $TESTPOOL2 63 destroy_pool $TESTPOOL1 64 65 log_must $RM -rf $DEVICE_DIR/* 66 typeset i=0 67 while (( i < $MAX_NUM )); do 68 log_must create_vdevs ${DEVICE_DIR}/${DEVICE_FILE}$i 69 ((i += 1)) 70 done 71} 72 73log_assert "For mirror, N-1 destroyed pools devices was removed or used " \ 74 "by other pool, it still can be imported correctly." 75log_onexit cleanup 76 77function perform_test 78{ 79 typeset target=$1 80 81 assert_pool_in_cachefile $TESTPOOL1 82 log_must $ZPOOL destroy $TESTPOOL1 83 84 create_pool $TESTPOOL2 $VDEV0 $VDEV2 85 log_must $ZPOOL import -d $DEVICE_DIR -D -f $target 86 log_must $ZPOOL destroy $TESTPOOL1 87 88 log_must $ZPOOL destroy $TESTPOOL2 89 log_must $RM -rf $VDEV2 90 log_must $ZPOOL import -d $DEVICE_DIR -D -f $target 91 92 # Restore the vdev. 93 log_must create_vdevs $VDEV2 94} 95 96log_note "Testing import by name." 97create_pool $TESTPOOL1 mirror $VDEV0 $VDEV1 $VDEV2 98perform_test $TESTPOOL1 99 100log_note "Testing import by GUID." 101create_pool $TESTPOOL1 mirror $VDEV0 $VDEV1 $VDEV2 102typeset guid=$(get_config $TESTPOOL1 pool_guid) 103perform_test $guid 104 105log_pass "zpool import -D mirror passed." 106