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
@@ -37,8 +37,8 @@
verify_runnable "global"
log_must $ZPOOL destroy $TESTPOOL
log_must zpool destroy $TESTPOOL
log_must $RM /tmp/zpool_upgrade_test.dat
log_must rm /tmp/zpool_upgrade_test.dat
default_cleanup
@@ -38,7 +38,7 @@
verify_runnable "global"
# create a pool without any features
log_must $MKFILE 128m /tmp/zpool_upgrade_test.dat
log_must $ZPOOL create -d -m $TESTDIR $TESTPOOL /tmp/zpool_upgrade_test.dat
log_must mkfile 128m /tmp/zpool_upgrade_test.dat
log_must zpool create -d -m $TESTDIR $TESTPOOL /tmp/zpool_upgrade_test.dat
log_pass
@@ -42,8 +42,8 @@
function cleanup
{
datasetexists $TESTPOOL/fs1 && log_must $ZFS destroy $TESTPOOL/fs1
datasetexists $TESTPOOL/fs2 && log_must $ZFS destroy $TESTPOOL/fs2
datasetexists $TESTPOOL/fs1 && log_must zfs destroy $TESTPOOL/fs1
datasetexists $TESTPOOL/fs2 && log_must zfs destroy $TESTPOOL/fs2
}
verify_runnable "global"
@@ -51,48 +51,48 @@ verify_runnable "global"
log_assert "pool upgrade for userobj accounting should work"
log_onexit cleanup
log_must $MKFILES $TESTDIR/tf $((RANDOM % 1000 + 1))
log_must $ZFS create $TESTPOOL/fs1
log_must $MKFILES $TESTDIR/fs1/tf $((RANDOM % 1000 + 1))
log_must $ZFS create $TESTPOOL/fs2
log_must $MKFILES $TESTDIR/fs2/tf $((RANDOM % 1000 + 1))
log_must $ZFS umount $TESTPOOL/fs2
log_must mkfiles $TESTDIR/tf $((RANDOM % 1000 + 1))
log_must zfs create $TESTPOOL/fs1
log_must mkfiles $TESTDIR/fs1/tf $((RANDOM % 1000 + 1))
log_must zfs create $TESTPOOL/fs2
log_must mkfiles $TESTDIR/fs2/tf $((RANDOM % 1000 + 1))
log_must zfs umount $TESTPOOL/fs2
# Make sure userobj accounting is disabled
$ZFS userspace -o objused -H $TESTPOOL | $HEAD -n 1 | $GREP -q "-" ||
zfs userspace -o objused -H $TESTPOOL | head -n 1 | grep -q "-" ||
log_fail "userobj accounting should be disabled initially"
# Upgrade zpool to support all features
log_must $ZPOOL upgrade $TESTPOOL
log_must zpool upgrade $TESTPOOL
# Make sure userobj accounting is disabled again
$ZFS userspace -o objused -H $TESTPOOL | $HEAD -n 1 | $GREP -q "-" ||
zfs userspace -o objused -H $TESTPOOL | head -n 1 | grep -q "-" ||
log_fail "userobj accounting should be disabled after pool upgrade"
# Create a file in fs1 should trigger dataset upgrade
log_must $MKFILE 1m $TESTDIR/fs1/tf
log_must mkfile 1m $TESTDIR/fs1/tf
sync_pool
# Make sure userobj accounting is working for fs1
$ZFS userspace -o objused -H $TESTPOOL/fs1 | $HEAD -n 1 | $GREP -q "-" &&
zfs userspace -o objused -H $TESTPOOL/fs1 | head -n 1 | grep -q "-" &&
log_fail "userobj accounting should be enabled for $TESTPOOL/fs1"
# Mount a dataset should trigger upgrade
log_must $ZFS mount $TESTPOOL/fs2
log_must zfs mount $TESTPOOL/fs2
sync_pool
# Make sure userobj accounting is working for fs2
$ZFS userspace -o objused -H $TESTPOOL/fs2 | $HEAD -n 1 | $GREP -q "-" &&
zfs userspace -o objused -H $TESTPOOL/fs2 | head -n 1 | grep -q "-" &&
log_fail "userobj accounting should be enabled for $TESTPOOL/fs2"
# All in all, after having been through this, the dataset for testpool
# still shouldn't be upgraded
$ZFS userspace -o objused -H $TESTPOOL | $HEAD -n 1 | $GREP -q "-" ||
zfs userspace -o objused -H $TESTPOOL | head -n 1 | grep -q "-" ||
log_fail "userobj accounting should be disabled for $TESTPOOL"
# Manual upgrade root dataset
log_must $ZFS set version=current $TESTPOOL
$ZFS userspace -o objused -H $TESTPOOL | $HEAD -n 1 | $GREP -q "-" &&
log_must zfs set version=current $TESTPOOL
zfs userspace -o objused -H $TESTPOOL | head -n 1 | grep -q "-" &&
log_fail "userobj accounting should be enabled for $TESTPOOL"
log_pass "all tests passed - what a lucky day!"