Add the ZFS Test Suite

Add the ZFS Test Suite and test-runner framework from illumos.
This is a continuation of the work done by Turbo Fredriksson to
port the ZFS Test Suite to Linux.  While this work was originally
conceived as a stand alone project integrating it directly with
the ZoL source tree has several advantages:

  * Allows the ZFS Test Suite to be packaged in zfs-test package.
    * Facilitates easy integration with the CI testing.
    * Users can locally run the ZFS Test Suite to validate ZFS.
      This testing should ONLY be done on a dedicated test system
      because the ZFS Test Suite in its current form is destructive.
  * Allows the ZFS Test Suite to be run directly in the ZoL source
    tree enabled developers to iterate quickly during development.
  * Developers can easily add/modify tests in the framework as
    features are added or functionality is changed.  The tests
    will then always be in sync with the implementation.

Full documentation for how to run the ZFS Test Suite is available
in the tests/README.md file.

Warning: This test suite is designed to be run on a dedicated test
system.  It will make modifications to the system including, but
not limited to, the following.

  * Adding new users
  * Adding new groups
  * Modifying the following /proc files:
    * /proc/sys/kernel/core_pattern
    * /proc/sys/kernel/core_uses_pid
  * Creating directories under /

Notes:
  * Not all of the test cases are expected to pass and by default
    these test cases are disabled.  The failures are primarily due
    to assumption made for illumos which are invalid under Linux.
  * When updating these test cases it should be done in as generic
    a way as possible so the patch can be submitted back upstream.
    Most existing library functions have been updated to be Linux
    aware, and the following functions and variables have been added.
    * Functions:
      * is_linux          - Used to wrap a Linux specific section.
      * block_device_wait - Waits for block devices to be added to /dev/.
    * Variables:            Linux          Illumos
      * ZVOL_DEVDIR         "/dev/zvol"    "/dev/zvol/dsk"
      * ZVOL_RDEVDIR        "/dev/zvol"    "/dev/zvol/rdsk"
      * DEV_DSKDIR          "/dev"         "/dev/dsk"
      * DEV_RDSKDIR         "/dev"         "/dev/rdsk"
      * NEWFS_DEFAULT_FS    "ext2"         "ufs"
  * Many of the disabled test cases fail because 'zfs/zpool destroy'
    returns EBUSY.  This is largely causes by the asynchronous nature
    of device handling on Linux and is expected, the impacted test
    cases will need to be updated to handle this.
  * There are several test cases which have been disabled because
    they can trigger a deadlock.  A primary example of this is to
    recursively create zpools within zpools.  These tests have been
    disabled until the root issue can be addressed.
  * Illumos specific utilities such as (mkfile) should be added to
    the tests/zfs-tests/cmd/ directory.  Custom programs required by
    the test scripts can also be added here.
  * SELinux should be either is permissive mode or disabled when
    running the tests.  The test cases should be updated to conform
    to a standard policy.
  * Redundant test functionality has been removed (zfault.sh).
  * Existing test scripts (zconfig.sh) should be migrated to use
    the framework for consistency and ease of testing.
  * The DISKS environment variable currently only supports loopback
    devices because of how the ZFS Test Suite expects partitions to
    be named (p1, p2, etc).  Support must be added to generate the
    correct partition name based on the device location and name.
  * The ZFS Test Suite is part of the illumos code base at:
    https://github.com/illumos/illumos-gate/tree/master/usr/src/test

Original-patch-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #6
Closes #1534
This commit is contained in:
Brian Behlendorf
2015-07-01 15:23:09 -07:00
parent 887d1e60ef
commit 6bb24f4dc7
1243 changed files with 89497 additions and 1042 deletions
@@ -0,0 +1,12 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/inuse
dist_pkgdata_SCRIPTS = \
inuse.cfg \
setup.ksh \
inuse_001_pos.ksh \
inuse_003_pos.ksh \
inuse_004_pos.ksh \
inuse_005_pos.ksh \
inuse_006_pos.ksh \
inuse_007_pos.ksh \
inuse_008_pos.ksh \
inuse_009_pos.ksh
@@ -0,0 +1,135 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
if is_linux; then
export SLICE_PREFIX="p"
export SLICE0=1
export SLICE1=2
else
export SLICE_PREFIX="s"
export SLICE0=0
export SLICE1=1
fi
verify_disk_count "$DISKS" 2
set -A disk_array $(find_disks $DISKS)
case "${#disk_array[@]}" in
2)
FS_DISK0=${disk_array[0]}
FS_DISK1=${disk_array[1]}
FS_DISK2=${disk_array[0]}
FS_DISK3=${disk_array[1]}
FS_SIDE0=${FS_DISK0}${SLICE_PREFIX}${SLICE0}
FS_SIDE1=${FS_DISK0}${SLICE_PREFIX}${SLICE1}
FS_SIDE2=${FS_DISK1}${SLICE_PREFIX}${SLICE0}
FS_SIDE3=${FS_DISK1}${SLICE_PREFIX}${SLICE1}
disk0="${DEV_DSKDIR}/$FS_SIDE0"
disk1="${DEV_DSKDIR}/$FS_SIDE1"
disk2="${DEV_DSKDIR}/$FS_SIDE2"
disk3="${DEV_DSKDIR}/$FS_SIDE3"
disktargets="$disk0 $disk2"
rawdisk0="${DEV_RDSKDIR}/$FS_SIDE0"
rawdisk1="${DEV_RDSKDIR}/$FS_SIDE1"
rawdisk2="${DEV_RDSKDIR}/$FS_SIDE2"
rawdisk3="${DEV_RDSKDIR}/$FS_SIDE3"
rawtargets="$rawdisk0 $rawdisk2"
vdisks="$FS_DISK0"
sdisks="$FS_DISK1"
vslices="$FS_SIDE0 $FS_SIDE1 $FS_SIDE2"
sslices="$FS_SIDE3"
;;
3)
FS_DISK0=${disk_array[0]}
FS_DISK1=${disk_array[1]}
FS_DISK2=${disk_array[2]}
FS_DISK3=${disk_array[0]}
FS_SIDE0=${FS_DISK0}${SLICE_PREFIX}${SLICE0}
FS_SIDE1=${FS_DISK0}${SLICE_PREFIX}${SLICE1}
FS_SIDE2=${FS_DISK1}${SLICE_PREFIX}${SLICE0}
FS_SIDE3=${FS_DISK2}${SLICE_PREFIX}${SLICE0}
disk0="${DEV_DSKDIR}/$FS_SIDE0"
disk1="${DEV_DSKDIR}/$FS_SIDE1"
disk2="${DEV_DSKDIR}/$FS_SIDE2"
disk3="${DEV_DSKDIR}/$FS_SIDE3"
disktargets="$disk0 $disk2 $disk3"
rawdisk0="${DEV_RDSKDIR}/$FS_SIDE0"
rawdisk1="${DEV_RDSKDIR}/$FS_SIDE1"
rawdisk2="${DEV_RDSKDIR}/$FS_SIDE2"
rawdisk3="${DEV_RDSKDIR}/$FS_SIDE3"
rawtargets="$rawdisk0 $rawdisk2 $rawdisk3"
vdisks="$FS_DISK0 $FS_DISK1"
sdisks="$FS_DISK2"
vslices="$FS_SIDE0 $FS_SIDE2 $FS_SIDE3"
sslices="$FS_SIDE1"
;;
*)
FS_DISK0=${disk_array[0]}
FS_DISK1=${disk_array[1]}
FS_DISK2=${disk_array[2]}
FS_DISK3=${disk_array[3]}
FS_SIDE0=${FS_DISK0}${SLICE_PREFIX}${SLICE0}
FS_SIDE1=${FS_DISK1}${SLICE_PREFIX}${SLICE0}
FS_SIDE2=${FS_DISK2}${SLICE_PREFIX}${SLICE0}
FS_SIDE3=${FS_DISK3}${SLICE_PREFIX}${SLICE0}
disk0="${DEV_DSKDIR}/$FS_SIDE0"
disk1="${DEV_DSKDIR}/$FS_SIDE1"
disk2="${DEV_DSKDIR}/$FS_SIDE2"
disk3="${DEV_DSKDIR}/$FS_SIDE3"
disktargets="$disk0 $disk1 $disk2 $disk3"
rawdisk0="${DEV_RDSKDIR}/$FS_SIDE0"
rawdisk1="${DEV_RDSKDIR}/$FS_SIDE1"
rawdisk2="${DEV_RDSKDIR}/$FS_SIDE2"
rawdisk3="${DEV_RDSKDIR}/$FS_SIDE3"
rawtargets="$rawdisk0 $rawdisk1 $rawdisk2 $rawdisk3"
vdisks="$FS_DISK0 $FS_DISK1 $FS_DISK2"
sdisks="$FS_DISK3"
vslices="$FS_SIDE0 $FS_SIDE1 $FS_SIDE2"
sslices="$FS_SIDE3"
;;
esac
export FS_DISK0 FS_DISK1 FS_DISK2 FS_DISK3 SINGLE_DISK
export FS_SIDE0 FS_SIDE1 FS_SIDE2 FS_SIDE3
export disk0 disk1 disk2 disk3 disktargets
export rawdisk0 rawdisk1 rawdisk2 rawdisk3 rawtargets
export vdisks sdisks vslices sslices
export UFSMP=$TESTDIR/testinuseufsdump
export FS_SIZE=1g
export PREVDUMPDEV=""
export PIDUFSDUMP=""
export PIDUFSRESTORE=""
# size of block to be written to test file - currently 1mb
export BLOCK_SIZE=$(( 1024 * 1024 ))
# number of blocks to write == size of file
export BLOCK_COUNT=100
export STF_TIMEOUT=1200 # 20 minutes max.
+90
View File
@@ -0,0 +1,90 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/inuse/inuse.cfg
#
# DESCRIPTION:
# ZFS will not interfere with devices that are in use by dumpadm.
#
# STRATEGY:
# 1. Create crash dump device using 'dumpadm'
# 2. Try to create a ZFS pool using the 'dumpadm' crash dump device.
#
verify_runnable "global"
function cleanup
{
#
# Remove dump device.
#
if [[ -n $PREVDUMPDEV ]]; then
log_must $DUMPADM -u -d $PREVDUMPDEV > /dev/null
fi
destroy_pool $TESTPOOL
}
log_assert "Ensure ZFS cannot use a device designated as a dump device"
log_onexit cleanup
typeset dumpdev=""
typeset diskslice=""
PREVDUMPDEV=`$DUMPADM | $GREP "Dump device" | $AWK '{print $3}'`
log_note "Zero $FS_DISK0 and place free space in to slice 0"
log_must cleanup_devices $FS_DISK0
if [[ $WRAPPER == *"smi"* ]]; then
diskslice="${DEV_DSKDIR}/${FS_DISK0}${SLICE_PREFIX}${SLICE2}"
else
diskslice="${DEV_DSKDIR}/${FS_DISK0}${SLICE_PREFIX}${SLICE0}"
fi
log_note "Configuring $diskslice as dump device"
log_must $DUMPADM -d $diskslice > /dev/null
log_note "Confirm that dump device has been setup"
dumpdev=`$DUMPADM | $GREP "Dump device" | $AWK '{print $3}'`
[[ -z "$dumpdev" ]] && log_untested "No dump device has been configured"
[[ "$dumpdev" != "$diskslice" ]] && \
log_untested "Dump device has not been been configured to $diskslice"
log_note "Attempt to zpool the dump device"
log_mustnot $ZPOOL create $TESTPOOL "$diskslice"
log_mustnot poolexists $TESTPOOL
log_pass "Unable to zpool a device in use by dumpadm"
+185
View File
@@ -0,0 +1,185 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2012 by Delphix. All rights reserved.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/inuse/inuse.cfg
#
# DESCRIPTION:
# ZFS will not interfere with devices that are in use by ufsdump or
# ufsrestore.
#
# STRATEGY:
# 1. newfs a disk
# 2. mount the disk
# 3. create files and dirs on disk
# 4. umount the disk
# 5. ufsdump this disk to a backup disk
# 6. Try to create a ZFS pool with same disk (also as a spare device)
# 7. ufsrestore the disk from backup
# 8. try to create a zpool during the ufsrestore
#
verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
poolexists $TESTPOOL2 && destroy_pool $TESTPOOL2
log_note "Kill off ufsdump process if still running"
$KILL -0 $PIDUFSDUMP > /dev/null 2>&1 && \
log_must $KILL -9 $PIDUFSDUMP > /dev/null 2>&1
#
# Note: It would appear that ufsdump spawns a number of processes
# which are not killed when the $PIDUFSDUMP is whacked. So best bet
# is to find the rest of the them and deal with them individually.
#
for all in `$PGREP ufsdump`
do
$KILL -9 $all > /dev/null 2>&1
done
log_note "Kill off ufsrestore process if still running"
$KILL -0 $PIDUFSRESTORE > /dev/null 2>&1 && \
log_must $KILL -9 $PIDUFSRESTORE > /dev/null 2>&1
ismounted $UFSMP ufs && log_must $UMOUNT $UFSMP
$RM -rf $UFSMP
$RM -rf $TESTDIR
#
# Tidy up the disks we used.
#
log_must cleanup_devices $vdisks $sdisks
}
log_assert "Ensure ZFS does not interfere with devices that are in use by " \
"ufsdump or ufsrestore"
log_onexit cleanup
typeset bigdir="${UFSMP}/bigdirectory"
typeset restored_files="${UFSMP}/restored_files"
typeset -i dirnum=0
typeset -i filenum=0
typeset cwd=""
for num in 0 1 2; do
eval typeset slice=\${FS_SIDE$num}
disk=${slice%${SLICE_PREFIX}*}
slice=${slice##*${SLICE_PREFIX}}
if [[ $WRAPPER == *"smi"* && $disk == ${saved_disk} ]]; then
cyl=$(get_endslice $disk ${saved_slice})
log_must set_partition $slice "$cyl" $FS_SIZE $disk
else
log_must set_partition $slice "" $FS_SIZE $disk
fi
saved_disk=$disk
saved_slice=$slice
done
log_note "Make a ufs filesystem on source $rawdisk1"
$ECHO "y" | $NEWFS -v $rawdisk1 > /dev/null 2>&1
(($? != 0)) && log_untested "Unable to create ufs filesystem on $rawdisk1"
log_must $MKDIR -p $UFSMP
log_note "mount source $disk1 on $UFSMP"
log_must $MOUNT $disk1 $UFSMP
log_note "Now create some directories and files to be ufsdump'ed"
while (($dirnum <= 2)); do
log_must $MKDIR $bigdir${dirnum}
while (( $filenum <= 2 )); do
$FILE_WRITE -o create -f $bigdir${dirnum}/file${filenum} \
-b $BLOCK_SIZE -c $BLOCK_COUNT
if [[ $? -ne 0 ]]; then
if [[ $dirnum -lt 3 ]]; then
log_fail "$FILE_WRITE only wrote" \
"<(( $dirnum * 3 + $filenum ))>" \
"files, this is not enough"
fi
fi
((filenum = filenum + 1))
done
filenum=0
((dirnum = dirnum + 1))
done
log_must $UMOUNT $UFSMP
log_note "Start ufsdump in the background"
log_note "$UFSDUMP 0bf 512 $rawdisk0 $disk1"
$UFSDUMP 0bf 512 $rawdisk0 $disk1 &
PIDUFSDUMP=$!
log_note "Attempt to zpool the source device in use by ufsdump"
log_mustnot $ZPOOL create $TESTPOOL1 "$disk1"
log_mustnot poolexists $TESTPOOL1
log_note "Attempt to take the source device in use by ufsdump as spare device"
log_mustnot $ZPOOL create $TESTPOOL1 "$FS_SIDE2" spare "$disk1"
log_mustnot poolexists $TESTPOOL1
wait $PIDUFSDUMP
typeset -i retval=$?
(($retval != 0)) && log_fail "$UFSDUMP failed with error code $ret_val"
log_must $MOUNT $disk1 $UFSMP
log_must $RM -rf $UFSMP/*
log_must $MKDIR $restored_files
cwd=$PWD
log_must cd $restored_files
log_note "Start ufsrestore in the background from the target device"
log_note "$UFSRESTORE rbf 512 $rawdisk0"
$UFSRESTORE rbf 512 $rawdisk0 &
PIDUFSRESTORE=$!
log_must cd $cwd
log_note "Attempt to zpool the restored device in use by ufsrestore"
log_mustnot $ZPOOL create -f $TESTPOOL2 "$disk1"
log_mustnot poolexists $TESTPOOL2
log_note "Attempt to take the restored device in use by ufsrestore as spare" \
"device"
log_mustnot $ZPOOL create -f $TESTPOOL2 "$FS_SIDE2" spare "$disk1"
log_mustnot poolexists $TESTPOOL2
log_pass "Unable to zpool over a device in use by ufsdump or ufsrestore"
+94
View File
@@ -0,0 +1,94 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/inuse/inuse.cfg
#
# DESCRIPTION:
# format will disallow modification of a mounted zfs disk partition or a spare
# device
#
# STRATEGY:
# 1. Create a ZFS filesystem
# 2. Add a spare device to the ZFS pool
# 3. Attempt to format the disk and the spare device.
#
verify_runnable "global"
function cleanup
{
#
# Essentailly this is the default_cleanup rountine but I cannot get it
# to work correctly. So its reproduced below. Still need to full
# understand why default_cleanup does not work correctly from here.
#
log_must $ZFS umount $TESTPOOL/$TESTFS
$RM -rf $TESTDIR || \
log_unresolved Could not remove $TESTDIR
log_must $ZFS destroy $TESTPOOL/$TESTFS
destroy_pool $TESTPOOL
}
#
# Currently, if a ZFS disk gets formatted things go horribly wrong, hence the
# mini_format function. If the modify option is reached, then we know format
# would happily continue - best to not go further.
#
function mini_format
{
typeset disk=$1
typeset format_file=/var/tmp/format_in.$$.1
$ECHO "partition" > $format_file
$ECHO "modify" >> $format_file
$FORMAT -e -s -d $disk -f $format_file
typeset -i retval=$?
$RM -rf $format_file
return $retval
}
log_assert "format will disallow modification of a mounted zfs disk partition"\
" or a spare device"
log_onexit cleanup
log_must default_setup_noexit $FS_DISK0
log_must $ZPOOL add $TESTPOOL spare $FS_DISK1
log_note "Attempt to format a ZFS disk"
log_mustnot mini_format $FS_DISK0
log_note "Attempt to format a ZFS spare device"
log_mustnot mini_format $FS_DISK1
log_pass "Unable to format a disk in use by ZFS"
+122
View File
@@ -0,0 +1,122 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/inuse/inuse.cfg
#
# DESCRIPTION:
# newfs will not interfere with devices and spare devices that are in use
# by active pool.
#
# STRATEGY:
# 1. Create a regular|mirror|raidz|raidz2 pool with the given disk
# 2. Try to newfs against the disk, verify it fails as expect.
#
verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
#
# Tidy up the disks we used.
#
cleanup_devices $vdisks $sdisks
}
function verify_assertion #slices
{
typeset targets=$1
for t in $targets; do
$ECHO "y" | $NEWFS -v $t > /dev/null 2>&1
(( $? !=0 )) || \
log_fail "newfs over active pool " \
"unexpected return code of 0"
done
return 0
}
log_assert "Verify newfs over active pool fails."
log_onexit cleanup
set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
typeset -i i=0
while (( i < ${#vdevs[*]} )); do
for num in 0 1 2 3 ; do
eval typeset slice=\${FS_SIDE$num}
disk=${slice%${SLICE_PREFIX}*}
slice=${slice##*${SLICE_PREFIX}}
if [[ $WRAPPER == *"smi"* && \
$disk == ${saved_disk} ]]; then
cyl=$(get_endslice $disk ${saved_slice})
log_must set_partition $slice "$cyl" $FS_SIZE $disk
else
log_must set_partition $slice "" $FS_SIZE $disk
fi
saved_disk=$disk
saved_slice=$slice
done
if [[ -n $SINGLE_DISK && -n ${vdevs[i]} ]]; then
(( i = i + 1 ))
continue
fi
create_pool $TESTPOOL1 ${vdevs[i]} $vslices spare $sslices
verify_assertion "$rawtargets"
destroy_pool $TESTPOOL1
if [[ ( $FS_DISK0 == $FS_DISK2 ) && -n ${vdevs[i]} ]]; then
(( i = i + 1 ))
continue
fi
if [[ ( $FS_DISK0 == $FS_DISK3 ) && ( ${vdevs[i]} == "raidz2" ) ]]; then
(( i = i + 1 ))
continue
fi
create_pool $TESTPOOL1 ${vdevs[i]} $vdisks spare $sdisks
verify_assertion "$rawtargets"
destroy_pool $TESTPOOL1
(( i = i + 1 ))
done
log_pass "Newfs over active pool fails."
+125
View File
@@ -0,0 +1,125 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/inuse/inuse.cfg
#
# DESCRIPTION:
# dumpadm will not interfere with devices and spare devices that are in use
# by active pool.
#
# STRATEGY:
# 1. Create a regular|mirror|raidz|raidz2 pool with the given disk
# 2. Try to dumpadm against the disk, verify it fails as expect.
#
verify_runnable "global"
function cleanup
{
if [[ -n $PREVDUMPDEV ]]; then
log_must $DUMPADM -u -d $PREVDUMPDEV
fi
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
#
# Tidy up the disks we used.
#
cleanup_devices $vdisks $sdisks
}
function verify_assertion #slices
{
typeset targets=$1
for t in $targets; do
log_mustnot $DUMPADM -d $t
done
return 0
}
log_assert "Verify dumpadm over active pool fails."
log_onexit cleanup
set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
typeset -i i=0
PREVDUMPDEV=`$DUMPADM | $GREP "Dump device" | $AWK '{print $3}'`
while (( i < ${#vdevs[*]} )); do
for num in 0 1 2 3 ; do
eval typeset slice=\${FS_SIDE$num}
disk=${slice%${SLICE_PREFIX}*}
slice=${slice##*${SLICE_PREFIX}}
if [[ $WRAPPER == *"smi"* && \
$disk == ${saved_disk} ]]; then
cyl=$(get_endslice $disk ${saved_slice})
log_must set_partition $slice "$cyl" $FS_SIZE $disk
else
log_must set_partition $slice "" $FS_SIZE $disk
fi
saved_disk=$disk
saved_slice=$slice
done
if [[ -n $SINGLE_DISK && -n ${vdevs[i]} ]]; then
(( i = i + 1 ))
continue
fi
create_pool $TESTPOOL1 ${vdevs[i]} $vslices spare $sslices
verify_assertion "$disktargets"
destroy_pool $TESTPOOL1
if [[ ( $FS_DISK0 == $FS_DISK2 ) && -n ${vdevs[i]} ]]; then
(( i = i + 1 ))
continue
fi
if [[ ( $FS_DISK0 == $FS_DISK3 ) && ( ${vdevs[i]} == "raidz2" ) ]]; then
(( i = i + 1 ))
continue
fi
create_pool $TESTPOOL1 ${vdevs[i]} $vdisks spare $sdisks
verify_assertion "$disktargets"
destroy_pool $TESTPOOL1
(( i = i + 1 ))
done
log_pass "Dumpadm over active pool fails."
+134
View File
@@ -0,0 +1,134 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/inuse/inuse.cfg
#
# DESCRIPTION:
# dumpadm will interfere with devices and spare devices that are in use
# by exported pool.
#
# STRATEGY:
# 1. Create a regular|mirror|raidz|raidz2 pool with the given disk
# 2. Export the pool
# 3. Try to dumpadm against the disk, verify it succeeds as expect.
#
verify_runnable "global"
function cleanup
{
if [[ -n $PREVDUMPDEV ]]; then
log_must $DUMPADM -u -d $PREVDUMPDEV
fi
poolexists $TESTPOOL1 || $ZPOOL import $TESTPOOL1 >/dev/null 2>&1
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
#
# Tidy up the disks we used.
#
cleanup_devices $vdisks $sdisks
}
function verify_assertion #slices
{
typeset targets=$1
for t in $targets; do
log_must $DUMPADM -u -d $t
log_must $DUMPADM -u -d $PREVDUMPDEV
done
return 0
}
log_assert "Verify dumpadm over exported pool succeed."
log_onexit cleanup
set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
typeset -i i=0
PREVDUMPDEV=`$DUMPADM | $GREP "Dump device" | $AWK '{print $3}'`
while (( i < ${#vdevs[*]} )); do
for num in 0 1 2 3 ; do
eval typeset slice=\${FS_SIDE$num}
disk=${slice%${SLICE_PREFIX}*}
slice=${slice##*${SLICE_PREFIX}}
if [[ $WRAPPER == *"smi"* && \
$disk == ${saved_disk} ]]; then
cyl=$(get_endslice $disk ${saved_slice})
log_must set_partition $slice "$cyl" $FS_SIZE $disk
else
log_must set_partition $slice "" $FS_SIZE $disk
fi
saved_disk=$disk
saved_slice=$slice
done
if [[ -n $SINGLE_DISK && -n ${vdevs[i]} ]]; then
(( i = i + 1 ))
continue
fi
create_pool $TESTPOOL1 ${vdevs[i]} $vslices spare $sslices
log_must $ZPOOL export $TESTPOOL1
verify_assertion "$disktargets"
log_must $ZPOOL import $TESTPOOL1
destroy_pool $TESTPOOL1
if [[ ( $FS_DISK0 == $FS_DISK2 ) && -n ${vdevs[i]} ]]; then
(( i = i + 1 ))
continue
fi
if [[ ( $FS_DISK0 == $FS_DISK3 ) && ( ${vdevs[i]} == "raidz2" ) ]]; then
(( i = i + 1 ))
continue
fi
create_pool $TESTPOOL1 ${vdevs[i]} $vdisks spare $sdisks
log_must $ZPOOL export $TESTPOOL1
verify_assertion "$disktargets"
log_must $ZPOOL import $TESTPOOL1
destroy_pool $TESTPOOL1
(( i = i + 1 ))
done
log_pass "Dumpadm over exported pool succeed."
+111
View File
@@ -0,0 +1,111 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/inuse/inuse.cfg
#
# DESCRIPTION:
# Newfs will interfere with devices and spare devices that are in use
# by exported pool.
#
# STRATEGY:
# 1. Create a regular|mirror|raidz|raidz2 pool with the given disk
# 2. Export the pool
# 3. Try to newfs against the disk, verify it succeeds as expect.
#
verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 || $ZPOOL import $TESTPOOL1 >/dev/null 2>&1
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
#
# Tidy up the disks we used.
#
cleanup_devices $vdisks $sdisks
}
function verify_assertion #slices
{
typeset targets=$1
for t in $targets; do
$ECHO "y" | $NEWFS -v $t > /dev/null 2>&1
(( $? !=0 )) && \
log_fail "newfs over exported pool " \
"failes unexpected."
done
return 0
}
log_assert "Verify newfs over exported pool succeed."
log_onexit cleanup
set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
typeset -i i=0
for num in 0 1 2 3 ; do
eval typeset slice=\${FS_SIDE$num}
disk=${slice%${SLICE_PREFIX}*}
slice=${slice##*${SLICE_PREFIX}}
if [[ $WRAPPER == *"smi"* && \
$disk == ${saved_disk} ]]; then
cyl=$(get_endslice $disk ${saved_slice})
log_must set_partition $slice "$cyl" $FS_SIZE $disk
else
log_must set_partition $slice "" $FS_SIZE $disk
fi
saved_disk=$disk
saved_slice=$slice
done
while (( i < ${#vdevs[*]} )); do
if [[ -n $SINGLE_DISK && -n ${vdevs[i]} ]]; then
(( i = i + 1 ))
continue
fi
create_pool $TESTPOOL1 ${vdevs[i]} $vslices spare $sslices
log_must $ZPOOL export $TESTPOOL1
verify_assertion "$rawtargets"
cleanup_devices $vslices $sslices
(( i = i + 1 ))
done
log_pass "Newfs over exported pool succeed."
+122
View File
@@ -0,0 +1,122 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/inuse/inuse.cfg
#
# DESCRIPTION:
# format command will interfere with devices and spare devices that are in use
# by exported pool.
#
# STRATEGY:
# 1. Create a regular|mirror|raidz|raidz2 pool with the given disk
# 2. Export the pool
# 3. Try to format against the disk, verify it succeeds as expect.
#
verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 || $ZPOOL import $TESTPOOL1 >/dev/null 2>&1
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
#
# Tidy up the disks we used.
#
cleanup_devices $vdisks $sdisks
}
function verify_assertion #disks
{
typeset targets=$1
for t in $targets; do
log_must set_partition 0 "" 0mb $t
done
return 0
}
log_assert "Verify format over exported pool succeed."
log_onexit cleanup
set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
typeset -i i=0
while (( i < ${#vdevs[*]} )); do
for num in 0 1 2 3 ; do
eval typeset slice=\${FS_SIDE$num}
disk=${slice%${SLICE_PREFIX}*}
slice=${slice##*${SLICE_PREFIX}}
if [[ $WRAPPER == *"smi"* && \
$disk == ${saved_disk} ]]; then
cyl=$(get_endslice $disk ${saved_slice})
log_must set_partition $slice "$cyl" $FS_SIZE $disk
else
log_must set_partition $slice "" $FS_SIZE $disk
fi
saved_disk=$disk
saved_slice=$slice
done
if [[ -n $SINGLE_DISK && -n ${vdevs[i]} ]]; then
(( i = i + 1 ))
continue
fi
create_pool $TESTPOOL1 ${vdevs[i]} $vslices spare $sslices
log_must $ZPOOL export $TESTPOOL1
verify_assertion "$vdisks $sdisks"
if [[ ( $FS_DISK0 == $FS_DISK2 ) && -n ${vdevs[i]} ]]; then
(( i = i + 1 ))
continue
fi
if [[ ( $FS_DISK0 == $FS_DISK3 ) && ( ${vdevs[i]} == "raidz2" ) ]]; then
(( i = i + 1 ))
continue
fi
create_pool $TESTPOOL1 ${vdevs[i]} $vdisks spare $sdisks
log_must $ZPOOL export $TESTPOOL1
verify_assertion "$vdisks $sdisks"
(( i = i + 1 ))
done
log_pass "Format over exported pool succeed."
+36
View File
@@ -0,0 +1,36 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
verify_runnable "global"
log_pass