mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-26 12:12:13 +03:00
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:
committed by
Brian Behlendorf
parent
7a4500a101
commit
c1d9abf905
@@ -31,6 +31,7 @@
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
if is_linux; then
|
||||
DISK_ARRAY_NUM=2
|
||||
set_device_dir
|
||||
set_slice_prefix
|
||||
export SLICE0=1
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -49,7 +49,7 @@ function cleanup
|
||||
# Remove dump device.
|
||||
#
|
||||
if [[ -n $PREVDUMPDEV ]]; then
|
||||
log_must $DUMPADM -u -d $PREVDUMPDEV > /dev/null
|
||||
log_must dumpadm -u -d $PREVDUMPDEV > /dev/null
|
||||
fi
|
||||
|
||||
destroy_pool $TESTPOOL
|
||||
@@ -62,17 +62,17 @@ log_onexit cleanup
|
||||
typeset dumpdev=""
|
||||
typeset diskslice=""
|
||||
|
||||
PREVDUMPDEV=`$DUMPADM | $GREP "Dump device" | $AWK '{print $3}'`
|
||||
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
|
||||
|
||||
diskslice="${DEV_DSKDIR}/${FS_DISK0}${SLICE0}"
|
||||
log_note "Configuring $diskslice as dump device"
|
||||
log_must $DUMPADM -d $diskslice > /dev/null
|
||||
log_must dumpadm -d $diskslice > /dev/null
|
||||
|
||||
log_note "Confirm that dump device has been setup"
|
||||
dumpdev=`$DUMPADM | $GREP "Dump device" | $AWK '{print $3}'`
|
||||
dumpdev=`dumpadm | grep "Dump device" | awk '{print $3}'`
|
||||
[[ -z "$dumpdev" ]] && log_untested "No dump device has been configured"
|
||||
|
||||
[[ "$dumpdev" != "$diskslice" ]] && \
|
||||
@@ -80,7 +80,7 @@ dumpdev=`$DUMPADM | $GREP "Dump device" | $AWK '{print $3}'`
|
||||
|
||||
log_note "Attempt to zpool the dump device"
|
||||
unset NOINUSE_CHECK
|
||||
log_mustnot $ZPOOL create $TESTPOOL "$diskslice"
|
||||
log_mustnot zpool create $TESTPOOL "$diskslice"
|
||||
log_mustnot poolexists $TESTPOOL
|
||||
|
||||
log_pass "Unable to zpool a device in use by dumpadm"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -57,26 +57,26 @@ function cleanup
|
||||
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
|
||||
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`
|
||||
for all in `pgrep ufsdump`
|
||||
do
|
||||
$KILL -9 $all > /dev/null 2>&1
|
||||
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
|
||||
kill -0 $PIDUFSRESTORE > /dev/null 2>&1 && \
|
||||
log_must kill -9 $PIDUFSRESTORE > /dev/null 2>&1
|
||||
|
||||
ismounted $UFSMP ufs && log_must $UMOUNT $UFSMP
|
||||
ismounted $UFSMP ufs && log_must umount $UFSMP
|
||||
|
||||
$RM -rf $UFSMP
|
||||
$RM -rf $TESTDIR
|
||||
rm -rf $UFSMP
|
||||
rm -rf $TESTDIR
|
||||
|
||||
#
|
||||
# Tidy up the disks we used.
|
||||
@@ -103,23 +103,23 @@ for num in 0 1 2; do
|
||||
done
|
||||
|
||||
log_note "Make a ufs filesystem on source $rawdisk1"
|
||||
$ECHO "y" | $NEWFS -v $rawdisk1 > /dev/null 2>&1
|
||||
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_must mkdir -p $UFSMP
|
||||
|
||||
log_note "mount source $disk1 on $UFSMP"
|
||||
log_must $MOUNT $disk1 $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}
|
||||
log_must mkdir $bigdir${dirnum}
|
||||
while (( $filenum <= 2 )); do
|
||||
$FILE_WRITE -o create -f $bigdir${dirnum}/file${filenum} \
|
||||
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" \
|
||||
log_fail "file_write only wrote" \
|
||||
"<(( $dirnum * 3 + $filenum ))>" \
|
||||
"files, this is not enough"
|
||||
fi
|
||||
@@ -130,46 +130,46 @@ while (($dirnum <= 2)); do
|
||||
((dirnum = dirnum + 1))
|
||||
done
|
||||
|
||||
log_must $UMOUNT $UFSMP
|
||||
log_must umount $UFSMP
|
||||
|
||||
log_note "Start ufsdump in the background"
|
||||
log_note "$UFSDUMP 0bf 512 $rawdisk0 $disk1"
|
||||
$UFSDUMP 0bf 512 $rawdisk0 $disk1 &
|
||||
log_note "ufsdump 0bf 512 $rawdisk0 $disk1"
|
||||
ufsdump 0bf 512 $rawdisk0 $disk1 &
|
||||
PIDUFSDUMP=$!
|
||||
|
||||
unset NOINUSE_CHECK
|
||||
log_note "Attempt to zpool the source device in use by ufsdump"
|
||||
log_mustnot $ZPOOL create $TESTPOOL1 "$disk1"
|
||||
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 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"
|
||||
(($retval != 0)) && log_fail "ufsdump failed with error code $ret_val"
|
||||
|
||||
log_must $MOUNT $disk1 $UFSMP
|
||||
log_must mount $disk1 $UFSMP
|
||||
|
||||
log_must $RM -rf $UFSMP/*
|
||||
log_must $MKDIR $restored_files
|
||||
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 &
|
||||
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 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 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"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -52,12 +52,12 @@ function cleanup
|
||||
# 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
|
||||
log_must zfs umount $TESTPOOL/$TESTFS
|
||||
|
||||
$RM -rf $TESTDIR || \
|
||||
rm -rf $TESTDIR || \
|
||||
log_unresolved Could not remove $TESTDIR
|
||||
|
||||
log_must $ZFS destroy $TESTPOOL/$TESTFS
|
||||
log_must zfs destroy $TESTPOOL/$TESTFS
|
||||
destroy_pool $TESTPOOL
|
||||
}
|
||||
#
|
||||
@@ -69,13 +69,19 @@ function mini_format
|
||||
{
|
||||
typeset disk=$1
|
||||
|
||||
typeset format_file=/var/tmp/format_in.$$.1
|
||||
$ECHO "partition" > $format_file
|
||||
$ECHO "modify" >> $format_file
|
||||
if is_linux; then
|
||||
parted $disk -s -- mklabel gpt
|
||||
typeset -i retval=$?
|
||||
else
|
||||
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
|
||||
format -e -s -d $disk -f $format_file
|
||||
typeset -i retval=$?
|
||||
|
||||
rm -rf $format_file
|
||||
fi
|
||||
return $retval
|
||||
}
|
||||
|
||||
@@ -84,7 +90,7 @@ log_assert "format will disallow modification of a mounted zfs disk partition"\
|
||||
|
||||
log_onexit cleanup
|
||||
log_must default_setup_noexit $FS_DISK0
|
||||
log_must $ZPOOL add $TESTPOOL spare $FS_DISK1
|
||||
log_must zpool add $TESTPOOL spare $FS_DISK1
|
||||
|
||||
log_note "Attempt to format a ZFS disk"
|
||||
log_mustnot mini_format $FS_DISK0
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -59,7 +59,7 @@ function verify_assertion #slices
|
||||
typeset targets=$1
|
||||
|
||||
for t in $targets; do
|
||||
$ECHO "y" | $NEWFS -v $t > /dev/null 2>&1
|
||||
echo "y" | newfs -v $t > /dev/null 2>&1
|
||||
(( $? !=0 )) || \
|
||||
log_fail "newfs over active pool " \
|
||||
"unexpected return code of 0"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -47,7 +47,7 @@ verify_runnable "global"
|
||||
function cleanup
|
||||
{
|
||||
if [[ -n $PREVDUMPDEV ]]; then
|
||||
log_must $DUMPADM -u -d $PREVDUMPDEV
|
||||
log_must dumpadm -u -d $PREVDUMPDEV
|
||||
fi
|
||||
|
||||
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
||||
@@ -63,7 +63,7 @@ function verify_assertion #slices
|
||||
typeset targets=$1
|
||||
|
||||
for t in $targets; do
|
||||
log_mustnot $DUMPADM -d $t
|
||||
log_mustnot dumpadm -d $t
|
||||
done
|
||||
|
||||
return 0
|
||||
@@ -77,7 +77,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
|
||||
|
||||
typeset -i i=0
|
||||
|
||||
PREVDUMPDEV=`$DUMPADM | $GREP "Dump device" | $AWK '{print $3}'`
|
||||
PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'`
|
||||
|
||||
unset NOINUSE_CHECK
|
||||
while (( i < ${#vdevs[*]} )); do
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -48,10 +48,10 @@ verify_runnable "global"
|
||||
function cleanup
|
||||
{
|
||||
if [[ -n $PREVDUMPDEV ]]; then
|
||||
log_must $DUMPADM -u -d $PREVDUMPDEV
|
||||
log_must dumpadm -u -d $PREVDUMPDEV
|
||||
fi
|
||||
|
||||
poolexists $TESTPOOL1 || $ZPOOL import $TESTPOOL1 >/dev/null 2>&1
|
||||
poolexists $TESTPOOL1 || zpool import $TESTPOOL1 >/dev/null 2>&1
|
||||
|
||||
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
||||
|
||||
@@ -66,9 +66,9 @@ function verify_assertion #slices
|
||||
typeset targets=$1
|
||||
|
||||
for t in $targets; do
|
||||
log_must $DUMPADM -u -d $t
|
||||
log_must dumpadm -u -d $t
|
||||
|
||||
log_must $DUMPADM -u -d $PREVDUMPDEV
|
||||
log_must dumpadm -u -d $PREVDUMPDEV
|
||||
done
|
||||
|
||||
return 0
|
||||
@@ -82,7 +82,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
|
||||
|
||||
typeset -i i=0
|
||||
|
||||
PREVDUMPDEV=`$DUMPADM | $GREP "Dump device" | $AWK '{print $3}'`
|
||||
PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'`
|
||||
|
||||
while (( i < ${#vdevs[*]} )); do
|
||||
|
||||
@@ -99,9 +99,9 @@ while (( i < ${#vdevs[*]} )); do
|
||||
fi
|
||||
|
||||
create_pool $TESTPOOL1 ${vdevs[i]} $vslices spare $sslices
|
||||
log_must $ZPOOL export $TESTPOOL1
|
||||
log_must zpool export $TESTPOOL1
|
||||
verify_assertion "$disktargets"
|
||||
log_must $ZPOOL import $TESTPOOL1
|
||||
log_must zpool import $TESTPOOL1
|
||||
destroy_pool $TESTPOOL1
|
||||
|
||||
if [[ ( $FS_DISK0 == $FS_DISK2 ) && -n ${vdevs[i]} ]]; then
|
||||
@@ -115,9 +115,9 @@ while (( i < ${#vdevs[*]} )); do
|
||||
fi
|
||||
|
||||
create_pool $TESTPOOL1 ${vdevs[i]} $vdisks spare $sdisks
|
||||
log_must $ZPOOL export $TESTPOOL1
|
||||
log_must zpool export $TESTPOOL1
|
||||
verify_assertion "$disktargets"
|
||||
log_must $ZPOOL import $TESTPOOL1
|
||||
log_must zpool import $TESTPOOL1
|
||||
destroy_pool $TESTPOOL1
|
||||
|
||||
(( i = i + 1 ))
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -47,7 +47,7 @@ verify_runnable "global"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
poolexists $TESTPOOL1 || $ZPOOL import $TESTPOOL1 >/dev/null 2>&1
|
||||
poolexists $TESTPOOL1 || zpool import $TESTPOOL1 >/dev/null 2>&1
|
||||
|
||||
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
||||
|
||||
@@ -62,7 +62,7 @@ function verify_assertion #slices
|
||||
typeset targets=$1
|
||||
|
||||
for t in $targets; do
|
||||
$ECHO "y" | $NEWFS -v $t > /dev/null 2>&1
|
||||
echo "y" | newfs -v $t > /dev/null 2>&1
|
||||
(( $? !=0 )) && \
|
||||
log_fail "newfs over exported pool " \
|
||||
"failes unexpected."
|
||||
@@ -93,7 +93,7 @@ while (( i < ${#vdevs[*]} )); do
|
||||
fi
|
||||
|
||||
create_pool $TESTPOOL1 ${vdevs[i]} $vslices spare $sslices
|
||||
log_must $ZPOOL export $TESTPOOL1
|
||||
log_must zpool export $TESTPOOL1
|
||||
verify_assertion "$rawtargets"
|
||||
cleanup_devices $vslices $sslices
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -47,7 +47,7 @@ verify_runnable "global"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
poolexists $TESTPOOL1 || $ZPOOL import $TESTPOOL1 >/dev/null 2>&1
|
||||
poolexists $TESTPOOL1 || zpool import $TESTPOOL1 >/dev/null 2>&1
|
||||
|
||||
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
||||
|
||||
@@ -91,7 +91,7 @@ while (( i < ${#vdevs[*]} )); do
|
||||
fi
|
||||
|
||||
create_pool $TESTPOOL1 ${vdevs[i]} $vslices spare $sslices
|
||||
log_must $ZPOOL export $TESTPOOL1
|
||||
log_must zpool export $TESTPOOL1
|
||||
verify_assertion "$vdisks $sdisks"
|
||||
|
||||
if [[ ( $FS_DISK0 == $FS_DISK2 ) && -n ${vdevs[i]} ]]; then
|
||||
@@ -105,7 +105,7 @@ while (( i < ${#vdevs[*]} )); do
|
||||
fi
|
||||
|
||||
create_pool $TESTPOOL1 ${vdevs[i]} $vdisks spare $sdisks
|
||||
log_must $ZPOOL export $TESTPOOL1
|
||||
log_must zpool export $TESTPOOL1
|
||||
verify_assertion "$vdisks $sdisks"
|
||||
|
||||
(( i = i + 1 ))
|
||||
|
||||
Reference in New Issue
Block a user