OpenZFS 7290 - ZFS test suite needs to control what utilities it can run

Authored by: John Wren Kennedy <john.kennedy@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Gordon Ross <gordon.w.ross@gmail.com>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: George Melikov <mail@gmelikov.ru>

Porting Notes:
- Utilities which aren't available under Linux have been removed.
- Because of sudo's default secure path behavior PATH must be
  explicitly reset at the top of libtest.shlib.  This avoids the
  need for all users to customize secure path on their system.
- Updated ZoL infrastructure to manage constrained path
- Updated all test cases
- Check permissions for usergroup tests
- When testing in-tree create links under bin/
- Update fault cleanup such that missing files during
  cleanup aren't fatal.
- Configure su environment with constrained path

OpenZFS-issue: https://www.illumos.org/issues/7290
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/1d32ba6
Closes #5903
This commit is contained in:
John Wren Kennedy
2017-04-05 20:18:22 -04:00
committed by Brian Behlendorf
parent 7a4500a101
commit c1d9abf905
797 changed files with 8038 additions and 7458 deletions
+9 -9
View File
@@ -25,7 +25,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -33,10 +33,10 @@
function cleanup
{
if datasetexists $TESTPOOL ; then
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
fi
if datasetexists $TESTPOOL2 ; then
log_must $ZPOOL destroy -f $TESTPOOL2
log_must zpool destroy -f $TESTPOOL2
fi
}
@@ -50,17 +50,17 @@ function display_status
typeset pool=$1
typeset -i ret=0
$ZPOOL status -xv $pool > /dev/null 2>&1
zpool status -xv $pool > /dev/null 2>&1
ret=$?
$ZPOOL iostat > /dev/null 2>&1
zpool iostat > /dev/null 2>&1
((ret |= $?))
typeset mntpnt=$(get_prop mountpoint $pool)
$DD if=/dev/random of=$mntpnt/testfile.$$ &
dd if=/dev/random of=$mntpnt/testfile.$$ &
typeset pid=$!
$ZPOOL iostat -v 1 3 > /dev/null
zpool iostat -v 1 3 > /dev/null
((ret |= $?))
kill -9 $pid
@@ -93,7 +93,7 @@ function verify_cache_device
#
# mirror:/disks/d ONLINE mirror:/disks/e ONLINE stripe:/disks/f ONLINE
#
set -A dev_stat_tab $($ZPOOL status -v $pool | $NAWK 'BEGIN {start=0} \
set -A dev_stat_tab $(zpool status -v $pool | nawk 'BEGIN {start=0} \
/\tcache/ {start=1}
/\tmirror/ || /\tspares/ || /^$/ {start=0}
(start==1) && /\t (\/|[a-zA-Z])/ \
@@ -148,6 +148,6 @@ function verify_cache_device
function verify_cache_support
{
$ZPOOL upgrade -v | $GREP "Cache devices" > /dev/null 2>&1
zpool upgrade -v | grep "Cache devices" > /dev/null 2>&1
return $?
}
+4 -4
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -49,17 +49,17 @@ log_onexit cleanup
for type in "" "mirror" "raidz" "raidz2"
do
log_must $ZPOOL create $TESTPOOL $type $VDEV \
log_must zpool create $TESTPOOL $type $VDEV \
cache $LDEV
log_must display_status $TESTPOOL
ldev=$(random_get $LDEV)
log_must verify_cache_device $TESTPOOL $ldev 'ONLINE'
log_must $ZPOOL remove $TESTPOOL $ldev
log_must zpool remove $TESTPOOL $ldev
log_must check_vdev_state $TESTPOOL $ldev ""
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
done
log_pass "Creating a pool with a cache device succeeds."
+5 -5
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -50,16 +50,16 @@ log_onexit cleanup
for type in "" "mirror" "raidz" "raidz2"
do
log_must $ZPOOL create $TESTPOOL $type $VDEV
log_must $ZPOOL add $TESTPOOL cache $LDEV
log_must zpool create $TESTPOOL $type $VDEV
log_must zpool add $TESTPOOL cache $LDEV
log_must display_status $TESTPOOL
typeset ldev=$(random_get $LDEV)
log_must verify_cache_device $TESTPOOL $ldev 'ONLINE'
log_must $ZPOOL remove $TESTPOOL $ldev
log_must zpool remove $TESTPOOL $ldev
log_must check_vdev_state $TESTPOOL $ldev ""
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
done
log_pass "Adding a cache device to normal pool works."
+5 -5
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -51,19 +51,19 @@ log_onexit cleanup
for type in "" "mirror" "raidz" "raidz2"
do
log_must $ZPOOL create $TESTPOOL $type $VDEV \
log_must zpool create $TESTPOOL $type $VDEV \
cache $LDEV
log_must $ZPOOL add $TESTPOOL \
log_must zpool add $TESTPOOL \
cache $LDEV2
log_must display_status $TESTPOOL
ldev=$(random_get $LDEV2)
log_must verify_cache_device $TESTPOOL $ldev 'ONLINE'
log_must $ZPOOL remove $TESTPOOL $ldev
log_must zpool remove $TESTPOOL $ldev
log_must check_vdev_state $TESTPOOL $ldev ""
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
done
log_pass "Adding an extra cache device works."
+4 -4
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -50,15 +50,15 @@ log_onexit cleanup
for type in "" "mirror" "raidz" "raidz2"
do
log_must $ZPOOL create $TESTPOOL $type $VDEV \
log_must zpool create $TESTPOOL $type $VDEV \
cache $LDEV
ldev=$(random_get $LDEV)
typeset ldev2=$(random_get $LDEV2)
log_mustnot $ZPOOL attach $TESTPOOL $ldev $ldev2
log_mustnot zpool attach $TESTPOOL $ldev $ldev2
log_must check_vdev_state $TESTPOOL $ldev2 ""
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
done
log_pass "Attaching a cache device fails for an existing cache device."
+4 -4
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -51,15 +51,15 @@ log_onexit cleanup
for type in "" "mirror" "raidz" "raidz2"
do
log_must $ZPOOL create $TESTPOOL $type $VDEV \
log_must zpool create $TESTPOOL $type $VDEV \
cache $LDEV
sdev=$(random_get $LDEV)
tdev=$(random_get $LDEV2)
log_mustnot $ZPOOL replace $TESTPOOL $sdev $tdev
log_mustnot zpool replace $TESTPOOL $sdev $tdev
log_must verify_cache_device $TESTPOOL $sdev 'ONLINE'
log_must check_vdev_state $TESTPOOL $tdev ""
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
done
log_pass "Replacing a cache device fails."
+7 -7
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -53,7 +53,7 @@ log_onexit cleanup
for type in "" "mirror" "raidz" "raidz2"
do
log_must $ZPOOL create $TESTPOOL $type $VDEV \
log_must zpool create $TESTPOOL $type $VDEV \
cache $LDEV $LDEV2
ldev=$(random_get $LDEV $LDEV2)
log_must verify_cache_device \
@@ -62,8 +62,8 @@ do
#
# Nomal export/import operating
#
log_must $ZPOOL export $TESTPOOL
log_must $ZPOOL import -d $VDIR $TESTPOOL
log_must zpool export $TESTPOOL
log_must zpool import -d $VDIR $TESTPOOL
log_must display_status $TESTPOOL
ldev=$(random_get $LDEV $LDEV2)
log_must verify_cache_device \
@@ -72,14 +72,14 @@ do
#
# Destroy the pool and import again
#
log_must $ZPOOL destroy $TESTPOOL
log_must $ZPOOL import -Df -d $VDIR $TESTPOOL
log_must zpool destroy $TESTPOOL
log_must zpool import -Df -d $VDIR $TESTPOOL
log_must display_status $TESTPOOL
ldev=$(random_get $LDEV $LDEV2)
log_must verify_cache_device \
$TESTPOOL $ldev 'ONLINE'
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
done
log_pass "Exporting and importing pool with cache devices passes."
+2 -2
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -51,7 +51,7 @@ for type in "" "mirror" "raidz" "raidz2"
do
for cachetype in "mirror" "raidz" "raidz1" "raidz2"
do
log_mustnot $ZPOOL create $TESTPOOL $type $VDEV \
log_mustnot zpool create $TESTPOOL $type $VDEV \
cache $cachetype $LDEV $LDEV2
ldev=$(random_get $LDEV $LDEV2)
log_mustnot verify_cache_device \
+4 -4
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -52,15 +52,15 @@ for type in "" "mirror" "raidz" "raidz2"
do
for cachetype in "mirror" "raidz" "raidz1" "raidz2"
do
log_must $ZPOOL create $TESTPOOL $type $VDEV \
log_must zpool create $TESTPOOL $type $VDEV \
cache $LDEV
log_mustnot $ZPOOL add $TESTPOOL cache $cachetype $LDEV2
log_mustnot zpool add $TESTPOOL cache $cachetype $LDEV2
ldev=$(random_get $LDEV2)
log_mustnot verify_cache_device \
$TESTPOOL $ldev 'ONLINE' $cachetype
log_must $ZPOOL destroy $TESTPOOL
log_must zpool destroy $TESTPOOL
done
done
+5 -5
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -51,19 +51,19 @@ log_onexit cleanup
for type in "" "mirror" "raidz" "raidz2"
do
log_must $ZPOOL create $TESTPOOL $type $VDEV \
log_must zpool create $TESTPOOL $type $VDEV \
cache $LDEV $LDEV2
ldev=$(random_get $LDEV $LDEV2)
log_must $ZPOOL offline $TESTPOOL $ldev
log_must zpool offline $TESTPOOL $ldev
log_must display_status $TESTPOOL
log_must verify_cache_device $TESTPOOL $ldev 'OFFLINE' ''
log_must $ZPOOL online $TESTPOOL $ldev
log_must zpool online $TESTPOOL $ldev
log_must display_status $TESTPOOL
log_must verify_cache_device $TESTPOOL $ldev 'ONLINE' ''
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
done
log_pass "Offline and online a cache device succeed."
+12 -12
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -48,7 +48,7 @@ function cleanup_testenv
{
cleanup
if [[ -n $lofidev ]]; then
log_must $LOFIADM -d $lofidev
log_must lofiadm -d $lofidev
fi
}
@@ -57,7 +57,7 @@ log_onexit cleanup_testenv
TESTVOL=testvol1$$
dsk1=${DISKS%% *}
log_must $ZPOOL create $TESTPOOL ${DISKS#$dsk1}
log_must zpool create $TESTPOOL ${DISKS#$dsk1}
if is_linux; then
SLICE="p1"
@@ -66,25 +66,25 @@ else
fi
# Add nomal ${DEV_RDSKDIR} device
log_mustnot $ZPOOL add $TESTPOOL cache ${DEV_RDSKDIR}/${dsk1}${SLICE}
log_mustnot zpool add $TESTPOOL cache ${DEV_RDSKDIR}/${dsk1}${SLICE}
#log_must verify_cache_device $TESTPOOL $dsk1 'ONLINE'
# Add nomal file
log_mustnot $ZPOOL add $TESTPOOL cache $VDEV2
log_mustnot zpool add $TESTPOOL cache $VDEV2
# Add /dev/rlofi device
lofidev=${VDEV2%% *}
log_must $LOFIADM -a $lofidev
lofidev=$($LOFIADM $lofidev)
log_mustnot $ZPOOL add $TESTPOOL cache "/dev/rlofi/${lofidev#/dev/lofi/}"
log_must lofiadm -a $lofidev
lofidev=$(lofiadm $lofidev)
log_mustnot zpool add $TESTPOOL cache "/dev/rlofi/${lofidev#/dev/lofi/}"
if [[ -n $lofidev ]]; then
log_must $LOFIADM -d $lofidev
log_must lofiadm -d $lofidev
lofidev=""
fi
# Add ${ZVOL_RDEVDIR} device
log_must $ZPOOL create $TESTPOOL2 $VDEV2
log_must $ZFS create -V $SIZE $TESTPOOL2/$TESTVOL
log_mustnot $ZPOOL add $TESTPOOL cache ${ZVOL_RDEVDIR}/$TESTPOOL2/$TESTVOL
log_must zpool create $TESTPOOL2 $VDEV2
log_must zfs create -V $SIZE $TESTPOOL2/$TESTVOL
log_mustnot zpool add $TESTPOOL cache ${ZVOL_RDEVDIR}/$TESTPOOL2/$TESTVOL
log_pass "Cache device can only be block devices."
+5 -5
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -47,7 +47,7 @@ verify_disk_count "$LDEV2"
function cleanup {
if datasetexists $TESTPOOL ; then
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
fi
}
@@ -56,13 +56,13 @@ log_onexit cleanup
for type in "" "mirror" "raidz" "raidz2"
do
log_must $ZPOOL create $TESTPOOL $type $VDEV \
log_must zpool create $TESTPOOL $type $VDEV \
cache $LDEV spare $LDEV2
log_must $ZPOOL remove $TESTPOOL $LDEV
log_must zpool remove $TESTPOOL $LDEV
log_must display_status $TESTPOOL
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
done
log_pass "Remove cache device from pool with spare device should succeed"
+4 -4
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -35,12 +35,12 @@
verify_runnable "global"
if datasetexists $TESTPOOL ; then
log_must $ZPOOL destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL
fi
if datasetexists $TESTPOOL2 ; then
log_must $ZPOOL destroy -f $TESTPOOL2
log_must zpool destroy -f $TESTPOOL2
fi
log_must $RM -rf $VDIR $VDIR2
log_must rm -rf $VDIR $VDIR2
log_pass
+4 -4
View File
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cache/cache.cfg
@@ -38,8 +38,8 @@ if ! is_physical_device $LDEV; then
log_unsupported "Only physical disk could be cache device"
fi
log_must $RM -rf $VDIR $VDIR2
log_must $MKDIR -p $VDIR $VDIR2
log_must $MKFILE $SIZE $VDEV $VDEV2
log_must rm -rf $VDIR $VDIR2
log_must mkdir -p $VDIR $VDIR2
log_must mkfile $SIZE $VDEV $VDEV2
log_pass