d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Common Development and Distribution License (the "License").
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You may not use this file except in compliance with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Once a pool has been exported, and one or more devices are
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# move to other place, import should handle this kind of situation
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# as described:
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# - Regular, report error while any number of devices failing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# - Mirror could withstand (N-1) devices failing
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# before data integrity is compromised
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# - Raidz could withstand one devices failing
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# before data integrity is compromised
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Verify that is true.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 1. Create test pool upon device files using the various combinations.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# - Regular pool
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 2. Create necessary filesystem and test files.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 3. Export the test pool.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 4. Move one or more device files to other directory
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 5. Verify 'zpool import -d' with the new directory
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# will handle moved files successfullly.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Using the various combinations.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# - Regular import
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# - Alternate Root Specified
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy cd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must tar xf $DEVICE_DIR/$DEVICE_ARCHIVE
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zpool import -d $DEVICE_DIR $TESTPOOL1
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy typeset dev_file=${DEVICE_DIR}/${DEVICE_FILE}$i
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ ! -e ${dev_file} ]]; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must rm -f $DEVICE_DIR/$DEVICE_ARCHIVE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy cd $CWD || log_fail "Unable change directory to $CWD"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_assert "Verify that import could handle moving device."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedycd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must tar xf $DEVICE_DIR/$DEVICE_ARCHIVE
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must cp $MYTESTFILE $TESTDIR1/$TESTFILE0
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must tar xf $DEVICE_DIR/$DEVICE_ARCHIVE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Backup all device files while filesystem prepared.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -z $backup ]] ; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must tar cf $DEVICE_DIR/$DEVICE_ARCHIVE ${DEVICE_FILE}*
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_pass "Import could handle moving device."