zpool_import_006_pos.ksh revision d583b39bfb4e2571d3e41097c5c357ffe353ad45
6185db853e024a486ff8837e6784dd290d866112dougm#!/bin/ksh -p
6185db853e024a486ff8837e6784dd290d866112dougm#
6185db853e024a486ff8837e6784dd290d866112dougm# CDDL HEADER START
6185db853e024a486ff8837e6784dd290d866112dougm#
6185db853e024a486ff8837e6784dd290d866112dougm# The contents of this file are subject to the terms of the
6185db853e024a486ff8837e6784dd290d866112dougm# Common Development and Distribution License (the "License").
6185db853e024a486ff8837e6784dd290d866112dougm# You may not use this file except in compliance with the License.
6185db853e024a486ff8837e6784dd290d866112dougm#
6185db853e024a486ff8837e6784dd290d866112dougm# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6185db853e024a486ff8837e6784dd290d866112dougm# or http://www.opensolaris.org/os/licensing.
6185db853e024a486ff8837e6784dd290d866112dougm# See the License for the specific language governing permissions
6185db853e024a486ff8837e6784dd290d866112dougm# and limitations under the License.
6185db853e024a486ff8837e6784dd290d866112dougm#
6185db853e024a486ff8837e6784dd290d866112dougm# When distributing Covered Code, include this CDDL HEADER in each
6185db853e024a486ff8837e6784dd290d866112dougm# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6185db853e024a486ff8837e6784dd290d866112dougm# If applicable, add the following below this CDDL HEADER, with the
6185db853e024a486ff8837e6784dd290d866112dougm# fields enclosed by brackets "[]" replaced with your own identifying
6185db853e024a486ff8837e6784dd290d866112dougm# information: Portions Copyright [yyyy] [name of copyright owner]
6185db853e024a486ff8837e6784dd290d866112dougm#
6185db853e024a486ff8837e6784dd290d866112dougm# CDDL HEADER END
6185db853e024a486ff8837e6784dd290d866112dougm#
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza
6185db853e024a486ff8837e6784dd290d866112dougm#
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
6185db853e024a486ff8837e6784dd290d866112dougm# Use is subject to license terms.
6185db853e024a486ff8837e6784dd290d866112dougm#
6185db853e024a486ff8837e6784dd290d866112dougm
6185db853e024a486ff8837e6784dd290d866112dougm#
6185db853e024a486ff8837e6784dd290d866112dougm# Copyright (c) 2012 by Delphix. All rights reserved.
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza#
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza
6185db853e024a486ff8837e6784dd290d866112dougm. $STF_SUITE/include/libtest.shlib
6185db853e024a486ff8837e6784dd290d866112dougm. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
6185db853e024a486ff8837e6784dd290d866112dougm
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza#
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza# DESCRIPTION:
6185db853e024a486ff8837e6784dd290d866112dougm# For mirror, N-1 destroyed pools devices was removed or used by other
6185db853e024a486ff8837e6784dd290d866112dougm# pool, it still can be imported correctly.
6185db853e024a486ff8837e6784dd290d866112dougm#
6185db853e024a486ff8837e6784dd290d866112dougm# STRATEGY:
5359815feb11a102a85ff1b899512fa9553b8c25dougm# 1. Create mirror with N disks.
5359815feb11a102a85ff1b899512fa9553b8c25dougm# 2. Destroy this mirror.
6185db853e024a486ff8837e6784dd290d866112dougm# 3. Create another pool with N-1 disks which was used by this mirror.
6185db853e024a486ff8837e6784dd290d866112dougm# 4. Verify import mirror can succeed.
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe#
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Prazaverify_runnable "global"
6185db853e024a486ff8837e6784dd290d866112dougm
6185db853e024a486ff8837e6784dd290d866112dougmfunction cleanup
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza{
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza destroy_pool $TESTPOOL2
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza destroy_pool $TESTPOOL1
6185db853e024a486ff8837e6784dd290d866112dougm
6185db853e024a486ff8837e6784dd290d866112dougm log_must $RM -rf $DEVICE_DIR/*
6185db853e024a486ff8837e6784dd290d866112dougm typeset i=0
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza while (( i < $MAX_NUM )); do
6185db853e024a486ff8837e6784dd290d866112dougm log_must $MKFILE $FILE_SIZE ${DEVICE_DIR}/${DEVICE_FILE}$i
6185db853e024a486ff8837e6784dd290d866112dougm ((i += 1))
6185db853e024a486ff8837e6784dd290d866112dougm done
6185db853e024a486ff8837e6784dd290d866112dougm}
6185db853e024a486ff8837e6784dd290d866112dougm
549ec3fff108310966327d1dc9004551b63210b7dougmlog_assert "For mirror, N-1 destroyed pools devices was removed or used " \
6185db853e024a486ff8837e6784dd290d866112dougm "by other pool, it still can be imported correctly."
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Prazalog_onexit cleanup
6185db853e024a486ff8837e6784dd290d866112dougm
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Prazalog_must $ZPOOL create $TESTPOOL1 mirror $VDEV0 $VDEV1 $VDEV2
6185db853e024a486ff8837e6784dd290d866112dougmtypeset guid=$(get_config $TESTPOOL1 pool_guid)
6185db853e024a486ff8837e6784dd290d866112dougmtypeset target=$TESTPOOL1
6185db853e024a486ff8837e6784dd290d866112dougmif (( RANDOM % 2 == 0 )) ; then
6185db853e024a486ff8837e6784dd290d866112dougm target=$guid
6185db853e024a486ff8837e6784dd290d866112dougm log_note "Import by guid."
6185db853e024a486ff8837e6784dd290d866112dougmfi
6185db853e024a486ff8837e6784dd290d866112dougmlog_must $ZPOOL destroy $TESTPOOL1
6185db853e024a486ff8837e6784dd290d866112dougm
6185db853e024a486ff8837e6784dd290d866112dougmlog_must $ZPOOL create $TESTPOOL2 $VDEV0 $VDEV2
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Prazalog_must $ZPOOL import -d $DEVICE_DIR -D -f $target
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Prazalog_must $ZPOOL destroy $TESTPOOL1
ead1f93ee620d7580f7e53350fe5a884fc4f158aLiane Praza
6185db853e024a486ff8837e6784dd290d866112dougmlog_must $ZPOOL destroy $TESTPOOL2
6185db853e024a486ff8837e6784dd290d866112dougmlog_must $RM -rf $VDEV2
log_must $ZPOOL import -d $DEVICE_DIR -D -f $target
log_pass "zpool import -D mirror passed."