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,4 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/pool_names
dist_pkgdata_SCRIPTS = \
pool_names_001_pos.ksh \
pool_names_002_neg.ksh
@@ -0,0 +1,115 @@
#!/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 2007 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
#
# DESCRIPTION:
#
# Test that a set of valid names can be used to create pools. Further
# verify that the created pools can be destroyed.
#
# STRATEGY:
# 1) For each valid character in the character set, try to create
# and destroy the pool.
# 2) Given a list of valid pool names, try to create and destroy
# pools with the given names.
#
verify_runnable "global"
log_assert "Ensure that pool names can use the ASCII subset of UTF-8"
function cleanup
{
if [[ -n $name ]] && poolexists $name ; then
log_must $ZPOOL destroy $name
fi
if [[ -d $TESTDIR ]]; then
log_must $RM -rf $TESTDIR
fi
}
log_onexit cleanup
DISK=${DISKS%% *}
if [[ ! -e $TESTDIR ]]; then
log_must $MKDIR $TESTDIR
fi
log_note "Ensure letters of the alphabet are allowable"
typeset name=""
for name in A B C D E F G H I J K L M \
N O P Q R S T U V W X Y Z \
a b c d e f g h i j k l m \
n o p q r s t u v w x y z
do
log_must $ZPOOL create -m $TESTDIR $name $DISK
if ! poolexists $name; then
log_fail "Could not create a pool called '$name'"
fi
log_must $ZPOOL destroy $name
done
log_note "Ensure a variety of unusual names passes"
name=""
for name in "a.............................." "a_" "a-" "a:" \
"a." "a123456" "bc0t0d0" "m1rr0r_p00l" "ra1dz_p00l" \
"araidz2" "C0t2d0" "cc0t0" "raid2:-_." "mirr_:-." \
"m1rr0r-p00l" "ra1dz-p00l" "spar3_p00l" \
"spar3-p00l" "hiddenmirrorpool" "hiddenraidzpool" \
"hiddensparepool"
do
log_must $ZPOOL create -m $TESTDIR $name $DISK
if ! poolexists $name; then
log_fail "Could not create a pool called '$name'"
fi
#
# Since the naming convention applies to datasets too,
# create datasets with the same names as above.
#
log_must $ZFS create $name/$name
log_must $ZFS snapshot $name/$name@$name
log_must $ZFS clone $name/$name@$name $name/clone_$name
log_must $ZFS create -V 150m $name/$name/$name
log_must $ZPOOL destroy $name
done
log_pass "Valid pool names were accepted correctly."
@@ -0,0 +1,131 @@
#!/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
#
# DESCRIPTION:
#
# Ensure that a set of invalid names cannot be used to create pools.
#
# STRATEGY:
# 1) For each invalid character in the character set, try to create
# and destroy the pool. Verify it fails.
# 2) Given a list of invalid pool names, ensure the pools are not
# created.
#
verify_runnable "global"
log_assert "Ensure that a set of invalid names cannot be used to create pools."
# Global variable use to cleanup failures.
POOLNAME=""
function cleanup
{
if poolexists $POOLNAME; then
log_must $ZPOOL destroy $POOLNAME
fi
if [[ -d $TESTDIR ]]; then
log_must $RM -rf $TESTDIR
fi
}
log_onexit cleanup
typeset exclude=`eval $ECHO \"'(${KEEP})'\"`
for pool in $($ZPOOL list -H -o name | \
$EGREP -v "$exclude" | \
$GREP -v "$TESTPOOL" | \
$EGREP -v "$NO_POOLS"); do
log_must $ZPOOL destroy $pool
done
DISK=${DISKS%% *}
if [[ ! -e $TESTDIR ]]; then
log_must $MKDIR $TESTDIR
fi
log_note "Ensure invalid characters fail"
for POOLNAME in "!" "\"" "#" "$" "%" "&" "'" "(" ")" \
"\*" "+" "," "-" "\." "/" "\\" \
0 1 2 3 4 5 6 7 8 9 \
":" ";" "<" "=" ">" "\?" "@" \
"[" "]" "^" "_" "\`" "{" "|" "}" "~"
do
log_mustnot $ZPOOL create -m $TESTDIR $POOLNAME $DISK
if poolexists $POOLNAME; then
log_fail "Unexpectedly created pool: '$POOLNAME'"
fi
log_mustnot $ZPOOL destroy $POOLNAME
done
log_note "Check that invalid octal values fail"
for oct in "\000" "\001" "\002" "\003" "\004" "\005" "\006" "\007" \
"\010" "\011" "\012" "\013" "\014" "\015" "\017" \
"\020" "\021" "\022" "\023" "\024" "\025" "\026" "\027" \
"\030" "\031" "\032" "\033" "\034" "\035" "\036" "\037" \
"\040" "\177"
do
POOLNAME=`eval "echo x | tr 'x' '$oct'"`
log_mustnot $ZPOOL create -m $TESTDIR $POOLNAME $DISK
if poolexists $POOLNAME; then
log_fail "Unexpectedly created pool: '$POOLNAME'"
fi
log_mustnot $ZPOOL destroy $POOLNAME
done
log_note "Verify invalid pool names fail"
set -A POOLNAME "c0t0d0s0" "c0t0d0" "c0t0d19" "c0t50000E0108D279d0" \
"mirror" "raidz" ",," ",,,,,,,,,,,,,,,,,,,,,,,,," \
"2222222222222222222" "mirror_pool" "raidz_pool" \
"mirror-pool" "raidz-pool" "spare" "spare_pool" \
"spare-pool" "raidz1-" "raidz2:" ":aaa" "-bbb" "_ccc" ".ddd"
if verify_slog_support ; then
POOLNAME[${#POOLNAME[@]}]='log'
fi
typeset -i i=0
while ((i < ${#POOLNAME[@]})); do
log_mustnot $ZPOOL create -m $TESTDIR ${POOLNAME[$i]} $DISK
if poolexists ${POOLNAME[$i]}; then
log_fail "Unexpectedly created pool: '${POOLNAME[$i]}'"
fi
log_mustnot $ZPOOL destroy ${POOLNAME[$i]}
((i += 1))
done
log_pass "Invalid names and characters were caught correctly"