mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-27 11:29:36 +03:00
Add zconfig test for adding and removing vdevs
This test performs a sanity check of the zpool add and remove commands. It tests adding and removing both a cache disk and a log disk to and from a zpool. Usage of both a shorthand device path and a full path is covered. The test uses a scsi_debug device as the disk to be added and removed. This is done so that zpool will see it as a whole disk and partition it, which it does not currently done for loopback devices. We want to verify that the manipulation done to whole disks paths to hide the parition information does not break the add/remove interface. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
parent
4682b8c14e
commit
d4055aac3c
@ -65,6 +65,16 @@ if [ ${CLEANUP} ]; then
|
|||||||
rm -f /tmp/zpool.cache.*
|
rm -f /tmp/zpool.cache.*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if we need to skip the tests that require scsi_debug and lsscsi.
|
||||||
|
SCSI_DEBUG=0
|
||||||
|
${INFOMOD} scsi_debug &>/dev/null && SCSI_DEBUG=1
|
||||||
|
HAVE_LSSCSI=0
|
||||||
|
test -f ${LSSCSI} && HAVE_LSSCSI=1
|
||||||
|
if [ ${SCSI_DEBUG} -eq 0 ] || [ ${HAVE_LSSCSI} -eq 0 ]; then
|
||||||
|
echo "Skipping test 10 which requires the scsi_debug " \
|
||||||
|
"module and the ${LSSCSI} utility"
|
||||||
|
fi
|
||||||
|
|
||||||
zconfig_partition() {
|
zconfig_partition() {
|
||||||
local DEVICE=$1
|
local DEVICE=$1
|
||||||
local START=$2
|
local START=$2
|
||||||
@ -566,5 +576,96 @@ test_9() {
|
|||||||
}
|
}
|
||||||
run_test 9 "zpool events"
|
run_test 9 "zpool events"
|
||||||
|
|
||||||
|
zconfig_add_vdev() {
|
||||||
|
local POOL_NAME=$1
|
||||||
|
local TYPE=$2
|
||||||
|
local DEVICE=$3
|
||||||
|
local TMP_FILE1=`mktemp`
|
||||||
|
local TMP_FILE2=`mktemp`
|
||||||
|
local TMP_FILE3=`mktemp`
|
||||||
|
|
||||||
|
BASE_DEVICE=`basename ${DEVICE}`
|
||||||
|
|
||||||
|
${ZPOOL} status ${POOL_NAME} >${TMP_FILE1}
|
||||||
|
${ZPOOL} add -f ${POOL_NAME} ${TYPE} ${DEVICE} 2>/dev/null || return 1
|
||||||
|
${ZPOOL} status ${POOL_NAME} >${TMP_FILE2}
|
||||||
|
diff ${TMP_FILE1} ${TMP_FILE2} > ${TMP_FILE3}
|
||||||
|
|
||||||
|
[ `wc -l ${TMP_FILE3}|${AWK} '{print $1}'` -eq 3 ] || return 1
|
||||||
|
|
||||||
|
PARENT_VDEV=`tail -2 ${TMP_FILE3} | head -1 | ${AWK} '{print $NF}'`
|
||||||
|
case $TYPE in
|
||||||
|
cache)
|
||||||
|
[ "${PARENT_VDEV}" = "${TYPE}" ] || return 1
|
||||||
|
;;
|
||||||
|
log)
|
||||||
|
[ "${PARENT_VDEV}" = "logs" ] || return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if ! tail -1 ${TMP_FILE3} |
|
||||||
|
egrep -q "^>[[:space:]]+${BASE_DEVICE}[[:space:]]+ONLINE" ; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
rm -f ${TMP_FILE1} ${TMP_FILE2} ${TMP_FILE3}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# zpool add and remove sanity check
|
||||||
|
test_10() {
|
||||||
|
local POOL_NAME=tank
|
||||||
|
local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
|
||||||
|
local TMP_FILE1=`mktemp`
|
||||||
|
local TMP_FILE2=`mktemp`
|
||||||
|
|
||||||
|
if [ ${SCSI_DEBUG} -eq 0 ] || [ ${HAVE_LSSCSI} -eq 0 ] ; then
|
||||||
|
skip
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
test `${LSMOD} | grep -c scsi_debug` -gt 0 && \
|
||||||
|
(${RMMOD} scsi_debug || exit 1)
|
||||||
|
|
||||||
|
/sbin/modprobe scsi_debug dev_size_mb=128 ||
|
||||||
|
die "Error $? creating scsi_debug device"
|
||||||
|
udev_trigger
|
||||||
|
|
||||||
|
SDDEVICE=`${LSSCSI}|${AWK} '/scsi_debug/ { print $6; exit }'`
|
||||||
|
BASE_SDDEVICE=`basename $SDDEVICE`
|
||||||
|
|
||||||
|
# Create a pool
|
||||||
|
${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
|
||||||
|
${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
|
||||||
|
${ZPOOL} status ${POOL_NAME} >${TMP_FILE1} || fail 3
|
||||||
|
|
||||||
|
# Add and remove a cache vdev by full path
|
||||||
|
zconfig_add_vdev ${POOL_NAME} cache ${SDDEVICE} || fail 4
|
||||||
|
${ZPOOL} remove ${POOL_NAME} ${SDDEVICE} || fail 5
|
||||||
|
${ZPOOL} status ${POOL_NAME} >${TMP_FILE2} || fail 6
|
||||||
|
cmp ${TMP_FILE1} ${TMP_FILE2} || fail 7
|
||||||
|
|
||||||
|
# Add and remove a cache vdev by shorthand path
|
||||||
|
zconfig_add_vdev ${POOL_NAME} cache ${BASE_SDDEVICE} || fail 8
|
||||||
|
${ZPOOL} remove ${POOL_NAME} ${BASE_SDDEVICE} || fail 9
|
||||||
|
${ZPOOL} status ${POOL_NAME} >${TMP_FILE2} || fail 10
|
||||||
|
cmp ${TMP_FILE1} ${TMP_FILE2} || fail 11
|
||||||
|
|
||||||
|
# Add and remove a log vdev
|
||||||
|
zconfig_add_vdev ${POOL_NAME} log ${BASE_SDDEVICE} || fail 12
|
||||||
|
${ZPOOL} remove ${POOL_NAME} ${BASE_SDDEVICE} || fail 13
|
||||||
|
${ZPOOL} status ${POOL_NAME} >${TMP_FILE2} || fail 14
|
||||||
|
cmp ${TMP_FILE1} ${TMP_FILE2} || fail 15
|
||||||
|
|
||||||
|
${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 16
|
||||||
|
${ZFS_SH} -u || fail 17
|
||||||
|
${RMMOD} scsi_debug || fail 18
|
||||||
|
|
||||||
|
rm -f ${TMP_FILE1} ${TMP_FILE2} ${TMP_CACHE} || fail 19
|
||||||
|
|
||||||
|
pass
|
||||||
|
}
|
||||||
|
run_test 10 "zpool add/remove vdev"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user