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,8 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cachefile
dist_pkgdata_SCRIPTS = \
cachefile.cfg \
cachefile.kshlib \
cachefile_001_pos.ksh \
cachefile_002_pos.ksh \
cachefile_003_pos.ksh \
cachefile_004_pos.ksh
@@ -0,0 +1,33 @@
#
# 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.
#
export CPATH="/etc/zfs/zpool.cache"
export CPATH1=/var/tmp/cachefile.$$
export CPATH2=$TEST_BASE_DIR/cachefile.$$
@@ -0,0 +1,47 @@
#!/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.
#
#
# A function to determine if a given pool name has an entry in cachefile
# returns 1 if the pool is not in the cache, 0 otherwise.
function pool_in_cache {
# checking for the pool name in the strings output of
# the given cachefile, default is /etc/zfs/zpool.cache
typeset cachefile=${2:-$CPATH}
RESULT=$($STRINGS $cachefile | $GREP -w $1)
if [ -z "$RESULT" ]
then
return 1
fi
return 0
}
@@ -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 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/cachefile/cachefile.cfg
. $STF_SUITE/tests/functional/cachefile/cachefile.kshlib
#
# DESCRIPTION:
#
# Creating a pool with "cachefile" set doesn't update zpool.cache
#
# STRATEGY:
# 1. Create a pool with the cachefile property set
# 2. Verify that the pool doesn't have an entry in zpool.cache
# 3. Verify the cachefile property is set
# 4. Create a pool without the cachefile property
# 5. Verify the cachefile property isn't set
# 6. Verify that zpool.cache contains an entry for the pool
#
function cleanup
{
typeset file
if poolexists $TESTPOOL ; then
destroy_pool $TESTPOOL
fi
for file in $CPATH1 $CPATH2 ; do
if [[ -f $file ]] ; then
log_must $RM $file
fi
done
}
verify_runnable "global"
log_assert "Creating a pool with \"cachefile\" set doesn't update zpool.cache"
log_onexit cleanup
set -A opts "none" "false" "none" \
"$CPATH" "true" "-" \
"$CPATH1" "true" "$CPATH1" \
"$CPATH2" "true" "$CPATH2"
typeset -i i=0
while (( i < ${#opts[*]} )); do
log_must $ZPOOL create -o cachefile=${opts[i]} $TESTPOOL $DISKS
case ${opts[((i+1))]} in
false) log_mustnot pool_in_cache $TESTPOOL
;;
true) log_must pool_in_cache $TESTPOOL ${opts[i]}
;;
esac
PROP=$(get_pool_prop cachefile $TESTPOOL)
if [[ $PROP != ${opts[((i+2))]} ]]; then
log_fail "cachefile property not set as expected. " \
"Expect: ${opts[((i+2))]}, Current: $PROP"
fi
log_must $ZPOOL destroy $TESTPOOL
(( i = i + 3 ))
done
log_pass "Creating a pool with \"cachefile\" set doesn't update zpool.cache"
@@ -0,0 +1,82 @@
#!/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/cachefile/cachefile.cfg
. $STF_SUITE/tests/functional/cachefile/cachefile.kshlib
#
# DESCRIPTION:
#
# Importing a pool with "cachefile" set doesn't update zpool.cache
#
# STRATEGY:
# 1. Create a pool with the cachefile property set
# 2. Verify the pool doesn't have an entry in zpool.cache
# 3. Export the pool
# 4. Import the pool
# 5. Verify the pool does have an entry in zpool.cache
# 6. Export the pool
# 7. Import the pool -o cachefile=<cachefile>
# 8. Verify the pool doesn't have an entry in zpool.cache
#
function cleanup
{
if poolexists $TESTPOOL ; then
destroy_pool $TESTPOOL
fi
}
verify_runnable "global"
log_assert "Importing a pool with \"cachefile\" set doesn't update zpool.cache"
log_onexit cleanup
log_must $ZPOOL create -o cachefile=none $TESTPOOL $DISKS
typeset DEVICEDIR=$(get_device_dir $DISKS)
log_mustnot pool_in_cache $TESTPOOL
log_must $ZPOOL export $TESTPOOL
log_must $ZPOOL import -d $DEVICEDIR $TESTPOOL
log_must pool_in_cache $TESTPOOL
log_must $ZPOOL export $TESTPOOL
log_must $ZPOOL import -o cachefile=none -d $DEVICEDIR $TESTPOOL
log_mustnot pool_in_cache $TESTPOOL
log_must $ZPOOL export $TESTPOOL
log_must $ZPOOL import -o cachefile=$CPATH -d $DEVICEDIR $TESTPOOL
log_must pool_in_cache $TESTPOOL
log_must $ZPOOL destroy $TESTPOOL
log_pass "Importing a pool with \"cachefile\" set doesn't update zpool.cache"
@@ -0,0 +1,100 @@
#!/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/cachefile/cachefile.cfg
. $STF_SUITE/tests/functional/cachefile/cachefile.kshlib
#
# DESCRIPTION:
#
# Setting altroot=<path> and cachefile=$CPATH for zpool create is succeed
#
# STRATEGY:
# 1. Attempt to create a pool with -o altroot=<path> -o cachefile=<value>
# 2. Verify the command succeed
#
#
TESTDIR=/altdir.$$
function cleanup
{
typeset file
if poolexists $TESTPOOL ; then
destroy_pool $TESTPOOL
fi
for file in $CPATH1 $CPATH2 ; do
if [[ -f $file ]] ; then
log_must $RM $file
fi
done
if [ -d $TESTDIR ]
then
$RMDIR $TESTDIR
fi
}
verify_runnable "global"
log_assert "Setting altroot=path and cachefile=$CPATH for zpool create succeed."
log_onexit cleanup
typeset -i i=0
set -A opts "none" "none" \
"$CPATH" "-" \
"$CPATH1" "$CPATH1" \
"$CPATH2" "$CPATH2"
while (( i < ${#opts[*]} )); do
log_must $ZPOOL create -o altroot=$TESTDIR -o cachefile=${opts[i]} \
$TESTPOOL $DISKS
if [[ ${opts[i]} != none ]]; then
log_must pool_in_cache $TESTPOOL ${opts[i]}
else
log_mustnot pool_in_cache $TESTPOOL
fi
PROP=$(get_pool_prop cachefile $TESTPOOL)
if [[ $PROP != ${opts[((i+1))]} ]]; then
log_fail "cachefile property not set as expected. " \
"Expect: ${opts[((i+1))]}, Current: $PROP"
fi
log_must $ZPOOL destroy $TESTPOOL
(( i = i + 2 ))
done
log_pass "Setting altroot=path and cachefile=$CPATH for zpool create succeed."
@@ -0,0 +1,124 @@
#!/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/cachefile/cachefile.cfg
. $STF_SUITE/tests/functional/cachefile/cachefile.kshlib
#
# DESCRIPTION:
# Verify set, export and destroy when cachefile is set on pool.
#
# STRATEGY:
# 1. Create two pools with one same cahcefile1.
# 2. Set cachefile of the two pools to another same cachefile2.
# 3. Verify cachefile1 not exist.
# 4. Export the two pools.
# 5. Verify cachefile2 not exist.
# 6. Import the two pools and set cachefile to cachefile2.
# 7. Destroy the two pools.
# 8. Verify cachefile2 not exist.
#
verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
poolexists $TESTPOOL2 && destroy_pool $TESTPOOL2
mntpnt=$(get_prop mountpoint $TESTPOOL)
typeset -i i=0
while ((i < 2)); do
if [[ -e $mntpnt/vdev$i ]]; then
log_must $RM -f $mntpnt/vdev$i
fi
((i += 1))
done
if poolexists $TESTPOOL ; then
destroy_pool $TESTPOOL
fi
for file in $CPATH1 $CPATH2 ; do
if [[ -f $file ]] ; then
log_must $RM $file
fi
done
}
log_assert "Verify set, export and destroy when cachefile is set on pool."
log_onexit cleanup
log_must $ZPOOL create $TESTPOOL $DISKS
mntpnt=$(get_prop mountpoint $TESTPOOL)
typeset -i i=0
while ((i < 2)); do
log_must $MKFILE 64M $mntpnt/vdev$i
eval vdev$i=$mntpnt/vdev$i
((i += 1))
done
log_must $ZPOOL create -o cachefile=$CPATH1 $TESTPOOL1 $vdev0
log_must pool_in_cache $TESTPOOL1 $CPATH1
log_must $ZPOOL create -o cachefile=$CPATH1 $TESTPOOL2 $vdev1
log_must pool_in_cache $TESTPOOL2 $CPATH1
log_must $ZPOOL set cachefile=$CPATH2 $TESTPOOL1
log_must pool_in_cache $TESTPOOL1 $CPATH2
log_must $ZPOOL set cachefile=$CPATH2 $TESTPOOL2
log_must pool_in_cache $TESTPOOL2 $CPATH2
if [[ -f $CPATH1 ]]; then
log_fail "Verify set when cachefile is set on pool."
fi
log_must $ZPOOL export $TESTPOOL1
log_must $ZPOOL export $TESTPOOL2
if [[ -f $CPATH2 ]]; then
log_fail "Verify export when cachefile is set on pool."
fi
log_must $ZPOOL import -d $mntpnt $TESTPOOL1
log_must $ZPOOL set cachefile=$CPATH2 $TESTPOOL1
log_must pool_in_cache $TESTPOOL1 $CPATH2
log_must $ZPOOL import -d $mntpnt $TESTPOOL2
log_must $ZPOOL set cachefile=$CPATH2 $TESTPOOL2
log_must pool_in_cache $TESTPOOL2 $CPATH2
log_must $ZPOOL destroy $TESTPOOL1
log_must $ZPOOL destroy $TESTPOOL2
if [[ -f $CPATH2 ]]; then
log_fail "Verify destroy when cachefile is set on pool."
fi
log_pass "Verify set, export and destroy when cachefile is set on pool."