12fae26bdSAlan Somers#!/usr/local/bin/ksh93 -p 22fae26bdSAlan Somers# 32fae26bdSAlan Somers# CDDL HEADER START 42fae26bdSAlan Somers# 52fae26bdSAlan Somers# The contents of this file are subject to the terms of the 62fae26bdSAlan Somers# Common Development and Distribution License (the "License"). 72fae26bdSAlan Somers# You may not use this file except in compliance with the License. 82fae26bdSAlan Somers# 92fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 102fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing. 112fae26bdSAlan Somers# See the License for the specific language governing permissions 122fae26bdSAlan Somers# and limitations under the License. 132fae26bdSAlan Somers# 142fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each 152fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 162fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the 172fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying 182fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner] 192fae26bdSAlan Somers# 202fae26bdSAlan Somers# CDDL HEADER END 212fae26bdSAlan Somers# 222fae26bdSAlan Somers 232fae26bdSAlan Somers# 242fae26bdSAlan Somers# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 252fae26bdSAlan Somers# Use is subject to license terms. 262fae26bdSAlan Somers 272fae26bdSAlan Somers. $STF_SUITE/include/libtest.kshlib 282fae26bdSAlan Somers 292fae26bdSAlan Somers################################################################################# 302fae26bdSAlan Somers# 312fae26bdSAlan Somers# __stc_assertion_start 322fae26bdSAlan Somers# 332fae26bdSAlan Somers# ID: zpool_import_007_pos 342fae26bdSAlan Somers# 352fae26bdSAlan Somers# DESCRIPTION: 362fae26bdSAlan Somers# For raidz, one destroyed pools devices was removed or used by other 372fae26bdSAlan Somers# pool, it still can be imported correctly. 382fae26bdSAlan Somers# 392fae26bdSAlan Somers# STRATEGY: 402fae26bdSAlan Somers# 1. Create a raidz pool A with N disks. 412fae26bdSAlan Somers# 2. Destroy this pool A. 422fae26bdSAlan Somers# 3. Create another pool B with 1 disk which was used by pool A. 432fae26bdSAlan Somers# 4. Verify import this raidz pool can succeed. 442fae26bdSAlan Somers# 452fae26bdSAlan Somers# TESTABILITY: explicit 462fae26bdSAlan Somers# 472fae26bdSAlan Somers# TEST_AUTOMATION_LEVEL: automated 482fae26bdSAlan Somers# 492fae26bdSAlan Somers# CODING_STATUS: COMPLETED (2006-06-12) 502fae26bdSAlan Somers# 512fae26bdSAlan Somers# __stc_assertion_end 522fae26bdSAlan Somers# 532fae26bdSAlan Somers################################################################################ 542fae26bdSAlan Somers 552fae26bdSAlan Somersverify_runnable "global" 562fae26bdSAlan Somers 572fae26bdSAlan Somersfunction cleanup 582fae26bdSAlan Somers{ 592fae26bdSAlan Somers destroy_pool $TESTPOOL2 602fae26bdSAlan Somers destroy_pool $TESTPOOL1 612fae26bdSAlan Somers 622fae26bdSAlan Somers log_must $RM -rf $DEVICE_DIR/* 632fae26bdSAlan Somers typeset i=0 642fae26bdSAlan Somers while (( i < $MAX_NUM )); do 652fae26bdSAlan Somers log_must create_vdevs ${DEVICE_DIR}/${DEVICE_FILE}$i 662fae26bdSAlan Somers ((i += 1)) 672fae26bdSAlan Somers done 682fae26bdSAlan Somers} 692fae26bdSAlan Somers 702fae26bdSAlan Somerslog_assert "For raidz, one destroyed pools devices was removed or used by " \ 712fae26bdSAlan Somers "other pool, it still can be imported correctly." 722fae26bdSAlan Somerslog_onexit cleanup 732fae26bdSAlan Somers 742fae26bdSAlan Somersfunction perform_test 752fae26bdSAlan Somers{ 762fae26bdSAlan Somers typeset target=$1 772fae26bdSAlan Somers 782fae26bdSAlan Somers assert_pool_in_cachefile $TESTPOOL1 792fae26bdSAlan Somers log_must $ZPOOL destroy $TESTPOOL1 802fae26bdSAlan Somers 812fae26bdSAlan Somers log_must $ZPOOL create $TESTPOOL2 $VDEV0 822fae26bdSAlan Somers log_must $ZPOOL import -d $DEVICE_DIR -D -f $target 832fae26bdSAlan Somers log_must $ZPOOL destroy $TESTPOOL1 842fae26bdSAlan Somers 852fae26bdSAlan Somers log_must $ZPOOL destroy $TESTPOOL2 862fae26bdSAlan Somers log_must $RM -rf $VDEV0 872fae26bdSAlan Somers log_must $ZPOOL import -d $DEVICE_DIR -D -f $target 882fae26bdSAlan Somers log_must $ZPOOL destroy $TESTPOOL1 892fae26bdSAlan Somers 902fae26bdSAlan Somers log_note "For raidz, two destroyed pool's devices were used, import failed." 912fae26bdSAlan Somers log_must create_vdevs $VDEV0 922fae26bdSAlan Somers log_must $ZPOOL create $TESTPOOL2 $VDEV0 $VDEV1 932fae26bdSAlan Somers log_mustnot $ZPOOL import -d $DEVICE_DIR -D -f $target 942fae26bdSAlan Somers log_must $ZPOOL destroy $TESTPOOL2 952fae26bdSAlan Somers} 962fae26bdSAlan Somers 972fae26bdSAlan Somerslog_note "Testing import by name." 982fae26bdSAlan Somerslog_must $ZPOOL create $TESTPOOL1 raidz $VDEV0 $VDEV1 $VDEV2 $VDEV3 992fae26bdSAlan Somersperform_test $TESTPOOL1 1002fae26bdSAlan Somers 1012fae26bdSAlan Somerslog_note "Testing import by GUID." 1022fae26bdSAlan Somerslog_must $ZPOOL create $TESTPOOL1 raidz $VDEV0 $VDEV1 $VDEV2 $VDEV3 1032fae26bdSAlan Somerstypeset guid=$(get_config $TESTPOOL1 pool_guid) 1042fae26bdSAlan Somersperform_test $guid 1052fae26bdSAlan Somers 1062fae26bdSAlan Somerslog_pass "zpool import -D raidz passed." 107