mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-06-01 11:44:16 +03:00
Move some tests to cli_user/zpool_status
The tests in tests/functional/cli_root/zpool_status should all require root. However, linux.run has "user =" specified for those tests, which means they run as a normal user. When I removed that line to run them as root, the following tests did not pass: zpool_status_003_pos zpool_status_-c_disable zpool_status_-c_homedir zpool_status_-c_searchpath These tests need to be run as a normal user. To fix this, move these tests to a new tests/functional/cli_user/zpool_status directory. Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Giuseppe Di Natale <guss80@gmail.com> Signed-off-by: Tony Hutter <hutter2@llnl.gov> Closes #9057
This commit is contained in:
committed by
Brian Behlendorf
parent
7f31908913
commit
d84c5a120e
@@ -2,4 +2,5 @@ SUBDIRS = \
|
||||
misc \
|
||||
zfs_list \
|
||||
zpool_iostat \
|
||||
zpool_list
|
||||
zpool_list \
|
||||
zpool_status
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/zpool_status
|
||||
dist_pkgdata_SCRIPTS = \
|
||||
setup.ksh \
|
||||
cleanup.ksh \
|
||||
zpool_status_003_pos.ksh \
|
||||
zpool_status_-c_disable.ksh \
|
||||
zpool_status_-c_homedir.ksh \
|
||||
zpool_status_-c_searchpath.ksh
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/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.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
default_cleanup
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/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.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
DISK=${DISKS%% *}
|
||||
|
||||
default_setup $DISK
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#!/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 (c) 2017 by Lawrence Livermore National Security, LLC.
|
||||
#
|
||||
|
||||
# DESCRIPTION:
|
||||
# Verify zpool status command mode (-c) respects ZPOOL_SCRIPTS_ENABLED.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Set ZPOOL_SCRIPTS_ENABLED to 0, disabling zpool status -c
|
||||
# 2. zpool status -c must not run successfully
|
||||
# 3. Set ZPOOL_SCRIPTS_ENABLED to 1, enabling zpool status -c
|
||||
# 4. zpool status -c must run successfully
|
||||
# 5. Unset ZPOOL_SCRIPTS_ENABLED, enabling zpool status -c
|
||||
# 6. zpool status -c must run successfully
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/include/zpool_script.shlib
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
log_assert "zpool status -c properly handles ZPOOL_SCRIPTS_ENABLED"
|
||||
|
||||
export ZPOOL_SCRIPTS_ENABLED=0
|
||||
log_mustnot zpool status -c media
|
||||
|
||||
export ZPOOL_SCRIPTS_ENABLED=1
|
||||
log_must zpool status -c media
|
||||
|
||||
unset ZPOOL_SCRIPTS_ENABLED
|
||||
log_must zpool status -c media
|
||||
|
||||
log_pass "zpool status -c properly handles ZPOOL_SCRIPTS_ENABLED passed"
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
#!/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 (c) 2017 by Lawrence Livermore National Security, LLC.
|
||||
#
|
||||
|
||||
# DESCRIPTION:
|
||||
# Verify zpool status command mode (-c) works with scripts in user's
|
||||
# home directory.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Change HOME to /var/tmp
|
||||
# 2. Make a simple script that echos a key value pair
|
||||
# in /var/tmp/.zpool.d
|
||||
# 3. Make sure it can be run with -c
|
||||
# 4. Remove the script we created
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/include/zpool_script.shlib
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
# In tree testing sets this variable, we need to unset it
|
||||
# to restore zpool's search path.
|
||||
unset ZPOOL_SCRIPTS_PATH
|
||||
|
||||
# change HOME
|
||||
export HOME="$TEST_BASE_DIR"
|
||||
typeset USER_SCRIPT_FULL="$HOME/.zpool.d/userscript"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_must rm -rf "$HOME/.zpool.d"
|
||||
}
|
||||
|
||||
log_assert "zpool status -c can run scripts from ~/.zpool.d"
|
||||
|
||||
if [ -e "$USER_SCRIPT_FULL" ]; then
|
||||
log_fail "$USER_SCRIPT_FULL already exists."
|
||||
fi
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
# create simple script
|
||||
log_must mkdir -p "$HOME/.zpool.d"
|
||||
cat > "$USER_SCRIPT_FULL" << EOF
|
||||
#!/bin/sh
|
||||
echo "USRCOL=USRVAL"
|
||||
EOF
|
||||
log_must chmod +x "$USER_SCRIPT_FULL"
|
||||
|
||||
# test that we can run the script
|
||||
typeset USER_SCRIPT=$(basename "$USER_SCRIPT_FULL")
|
||||
test_zpool_script "$USER_SCRIPT" "$TESTPOOL" "zpool status -P -c"
|
||||
|
||||
log_pass "zpool status -c can run scripts from ~/.zpool.d passed"
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
#!/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 (c) 2017 by Lawrence Livermore National Security, LLC.
|
||||
#
|
||||
|
||||
# DESCRIPTION:
|
||||
# Verify zpool status command mode (-c) works with ZPOOL_SCRIPTS_PATH
|
||||
# defined.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Set ZPOOL_SCRIPTS_PATH to contain a couple of non-default dirs
|
||||
# 2. Make a simple script that echos a key value pair in each dir
|
||||
# 3. Make sure scripts can be run with -c
|
||||
# 4. Remove the scripts we created
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/include/zpool_script.shlib
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
typeset SCRIPT_1="$TEST_BASE_DIR/scripts1/test1"
|
||||
typeset SCRIPT_2="$TEST_BASE_DIR/scripts2/test2"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_must rm -rf $(dirname "$SCRIPT_1")
|
||||
log_must rm -rf $(dirname "$SCRIPT_2")
|
||||
}
|
||||
|
||||
log_assert "zpool status -c can run scripts from custom search path"
|
||||
|
||||
if [ -e "$SCRIPT_1" ]; then
|
||||
log_fail "$SCRIPT_1 already exists."
|
||||
fi
|
||||
|
||||
if [ -e "$SCRIPT_2" ]; then
|
||||
log_fail "$SCRIPT_2 already exists."
|
||||
fi
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
# change zpool status search path
|
||||
export ZPOOL_SCRIPTS_PATH="$(dirname $SCRIPT_1):$(dirname $SCRIPT_2)"
|
||||
|
||||
# create simple script in each dir
|
||||
log_must mkdir -p $(dirname "$SCRIPT_1")
|
||||
cat > "$SCRIPT_1" << EOF
|
||||
#!/bin/sh
|
||||
echo "USRCOL1=USRVAL1"
|
||||
EOF
|
||||
log_must chmod +x "$SCRIPT_1"
|
||||
|
||||
log_must mkdir -p $(dirname "$SCRIPT_2")
|
||||
cat > "$SCRIPT_2" << EOF
|
||||
#!/bin/sh
|
||||
echo "USRCOL2=USRVAL2"
|
||||
EOF
|
||||
log_must chmod +x "$SCRIPT_2"
|
||||
|
||||
# test that we can run the scripts
|
||||
typeset CMD_1=$(basename "$SCRIPT_1")
|
||||
typeset CMD_2=$(basename "$SCRIPT_2")
|
||||
test_zpool_script "$CMD_1" "$TESTPOOL" "zpool status -P -c"
|
||||
test_zpool_script "$CMD_2" "$TESTPOOL" "zpool status -P -c"
|
||||
test_zpool_script "$CMD_2,$CMD_1" "$TESTPOOL" "zpool status -P -c"
|
||||
|
||||
log_pass "zpool status -c can run scripts from custom search path passed"
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
#!/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.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2016-2017 by Lawrence Livermore National Security, LLC.
|
||||
#
|
||||
|
||||
# DESCRIPTION:
|
||||
# Verify zpool status command mode (-c) works for all pre-baked scripts.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Make sure each script creates at least one new column.
|
||||
# 2. Make sure the new column values exist.
|
||||
# 3. Make sure we can run multiple scripts in one -c line
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/include/zpool_script.shlib
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
typeset testpool
|
||||
if is_global_zone ; then
|
||||
testpool="$TESTPOOL"
|
||||
else
|
||||
testpool="${TESTPOOL%%/*}"
|
||||
fi
|
||||
|
||||
files="$(ls $ZPOOL_SCRIPT_DIR)"
|
||||
scripts=""
|
||||
for i in $files ; do
|
||||
if [ ! -x "$ZPOOL_SCRIPT_DIR/$i" ] ; then
|
||||
# Skip non-executables
|
||||
continue
|
||||
fi
|
||||
|
||||
# Collect executable script names
|
||||
scripts="$scripts $i"
|
||||
|
||||
# Run each one with -c
|
||||
test_zpool_script "$i" "$testpool" "zpool status -P -c"
|
||||
done
|
||||
|
||||
# Test that we can run multiple scripts separated with a commma by running
|
||||
# all the scripts in a single -c line.
|
||||
allscripts="$(echo $scripts | sed -r 's/[[:blank:]]+/,/g')"
|
||||
test_zpool_script "$allscripts" "$testpool" "zpool status -P -c"
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user