aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Zuchowski <[email protected]>2018-03-07 20:03:33 -0500
committerTony Hutter <[email protected]>2018-03-14 16:10:38 -0700
commit0a0af41bd926ca20a26d7476d792ce82bca9c077 (patch)
tree4d7f057fcd6d943df05695735b6b71c512c0d7e0
parent3808006edfc46b18f0a40a2e9df54c6567bf52cc (diff)
zdb and inuse tests don't pass with real disks
Due to zpool create auto-partioning in Linux (i.e. sdb1), certain utilities need to use the parition (sdb1) while others use the whole disk name (sdb). Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Paul Zuchowski <[email protected]> Closes #6939 Closes #7261
-rw-r--r--tests/zfs-tests/include/libtest.shlib31
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh11
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_005_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/inuse/inuse_005_pos.ksh8
-rwxr-xr-xtests/zfs-tests/tests/functional/inuse/inuse_008_pos.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/inuse/inuse_009_pos.ksh10
7 files changed, 59 insertions, 15 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
index 48fb5e7c5..d51d73e61 100644
--- a/tests/zfs-tests/include/libtest.shlib
+++ b/tests/zfs-tests/include/libtest.shlib
@@ -767,7 +767,11 @@ function zero_partitions #<whole_disk_name>
typeset i
if is_linux; then
- log_must parted $DEV_DSKDIR/$diskname -s -- mklabel gpt
+ DSK=$DEV_DSKDIR/$diskname
+ DSK=$(echo $DSK | sed -e "s|//|/|g")
+ log_must parted $DSK -s -- mklabel gpt
+ blockdev --rereadpt $DSK 2>/dev/null
+ block_device_wait
else
for i in 0 1 3 4 5 6 7
do
@@ -795,10 +799,11 @@ function set_partition #<slice_num> <slice_start> <size_plus_units> <whole_disk
typeset start=$2
typeset size=$3
typeset disk=$4
- [[ -z $slicenum || -z $size || -z $disk ]] && \
- log_fail "The slice, size or disk name is unspecified."
if is_linux; then
+ if [[ -z $size || -z $disk ]]; then
+ log_fail "The size or disk name is unspecified."
+ fi
typeset size_mb=${size%%[mMgG]}
size_mb=${size_mb%%[mMgG][bB]}
@@ -841,6 +846,10 @@ function set_partition #<slice_num> <slice_start> <size_plus_units> <whole_disk
blockdev --rereadpt $DEV_DSKDIR/$disk 2>/dev/null
block_device_wait
else
+ if [[ -z $slicenum || -z $size || -z $disk ]]; then
+ log_fail "The slice, size or disk name is unspecified."
+ fi
+
typeset format_file=/var/tmp/format_in.$$
echo "partition" >$format_file
@@ -3634,3 +3643,19 @@ function get_tunable_impl
return 1
}
+
+#
+# Get actual devices used by the pool (i.e. linux sdb1 not sdb).
+#
+function get_pool_devices #testpool #devdir
+{
+ typeset testpool=$1
+ typeset devdir=$2
+ typeset out=""
+
+ if is_linux; then
+ out=$(zpool status -P $testpool |grep ${devdir} | awk '{print $1}')
+ out=$(echo $out | sed -e "s|${devdir}/||g" | tr '\n' ' ')
+ fi
+ echo $out
+}
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh
index 4c57cb587..3c444ae98 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh
@@ -43,6 +43,11 @@ config_count=(1 2)
set -A DISK $DISKS
default_mirror_setup_noexit $DISKS
+
+DEVS=$(get_pool_devices ${TESTPOOL} ${DEV_RDSKDIR})
+log_note "$DEVS"
+[[ -n $DEVS ]] && set -A DISK $DEVS
+
log_must dd if=/dev/${DISK[0]} of=/dev/${DISK[1]} bs=1K count=256 conv=notrunc
for x in 0 1 ; do
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh
index 2b4057aa7..91a5c9799 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh
@@ -45,17 +45,22 @@ function cleanup
verify_runnable "global"
verify_disk_count "$DISKS" 2
set -A DISK $DISKS
+WHOLE_DISK=${DISK[0]}
default_mirror_setup_noexit $DISKS
-log_must zpool offline $TESTPOOL ${DISK[0]}
+DEVS=$(get_pool_devices ${TESTPOOL} ${DEV_RDSKDIR})
+[[ -n $DEVS ]] && set -A DISK $DEVS
+
+log_must zpool offline $TESTPOOL ${WHOLE_DISK}
log_must dd if=/dev/urandom of=$TESTDIR/testfile bs=1K count=2
log_must zpool export $TESTPOOL
+
log_must dd if=$DEV_RDSKDIR/${DISK[0]} of=$DEV_RDSKDIR/${DISK[1]} bs=1K count=256 conv=notrunc
-ubs=$(zdb -lu $DEV_RDSKDIR/${DISK[1]} | grep -e LABEL -e Uberblock -e 'labels = ')
+ubs=$(zdb -lu ${DISK[1]} | grep -e LABEL -e Uberblock -e 'labels = ')
log_note "vdev 1: ubs $ubs"
-ub_dump_counts=$(zdb -lu $DEV_RDSKDIR/${DISK[1]} | \
+ub_dump_counts=$(zdb -lu ${DISK[1]} | \
awk ' /LABEL/ {label=$NF; blocks[label]=0};
/Uberblock/ {blocks[label]++};
END {print blocks[0],blocks[1],blocks[2],blocks[3]}')
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_005_pos.ksh
index 60bbb5615..f6730f611 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_005_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_005_pos.ksh
@@ -44,6 +44,10 @@ verify_disk_count "$DISKS" 2
set -A DISK $DISKS
default_mirror_setup_noexit $DISKS
+DEVS=$(get_pool_devices ${TESTPOOL} ${DEV_RDSKDIR})
+log_note "$DEVS"
+[[ -n $DEVS ]] && set -A DISK $DEVS
+
log_must dd if=/dev/zero of=$DEV_RDSKDIR/${DISK[1]} bs=1K count=256 conv=notrunc
log_must truncate -s 0 $TEMPFILE
diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_005_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_005_pos.ksh
index 9dd1e25bf..6b0abf429 100755
--- a/tests/zfs-tests/tests/functional/inuse/inuse_005_pos.ksh
+++ b/tests/zfs-tests/tests/functional/inuse/inuse_005_pos.ksh
@@ -82,19 +82,18 @@ typeset -i i=0
unset NOINUSE_CHECK
while (( i < ${#vdevs[*]} )); do
-
for num in 0 1 2 3 ; do
eval typeset disk=\${FS_DISK$num}
zero_partitions $disk
done
-
typeset cyl=""
for num in 0 1 2 3 ; do
eval typeset slice=\${FS_SIDE$num}
disk=${slice%${SLICE_PREFIX}*}
- slice=${slice##*${SLICE_PREFIX}}
+ [[ -z $SLICE_PREFIX ]] && eval typeset disk=\${FS_DISK$num}
+ slice=$(echo $slice | awk '{ print substr($1,length($1),1) }')
log_must set_partition $slice "$cyl" $FS_SIZE $disk
- cyl=$(get_endslice $disk $slice)
+ [[ $num < 3 ]] && cyl=$(get_endslice $disk $slice)
done
if [[ -n $SINGLE_DISK && -n ${vdevs[i]} ]]; then
@@ -115,7 +114,6 @@ while (( i < ${#vdevs[*]} )); do
(( i = i + 1 ))
continue
fi
-
create_pool $TESTPOOL1 ${vdevs[i]} $vdisks spare $sdisks
verify_assertion "$rawtargets"
destroy_pool $TESTPOOL1
diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_008_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_008_pos.ksh
index 95d39d958..ddc8fa7a4 100755
--- a/tests/zfs-tests/tests/functional/inuse/inuse_008_pos.ksh
+++ b/tests/zfs-tests/tests/functional/inuse/inuse_008_pos.ksh
@@ -92,9 +92,10 @@ done
for num in 0 1 2 3 ; do
eval typeset slice=\${FS_SIDE$num}
disk=${slice%${SLICE_PREFIX}*}
- slice=${slice##*${SLICE_PREFIX}}
+ [[ -z $SLICE_PREFIX ]] && eval typeset disk=\${FS_DISK$num}
+ slice=$(echo $slice | awk '{ print substr($1,length($1),1) }')
log_must set_partition $slice "$cyl" $FS_SIZE $disk
- cyl=$(get_endslice $disk $slice)
+ [[ $num < 3 ]] && cyl=$(get_endslice $disk $slice)
done
while (( i < ${#vdevs[*]} )); do
diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_009_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_009_pos.ksh
index 6a9b9623c..a5e9fda59 100755
--- a/tests/zfs-tests/tests/functional/inuse/inuse_009_pos.ksh
+++ b/tests/zfs-tests/tests/functional/inuse/inuse_009_pos.ksh
@@ -82,13 +82,19 @@ typeset -i i=0
while (( i < ${#vdevs[*]} )); do
+ for num in 0 1 2 3 ; do
+ eval typeset disk=\${FS_DISK$num}
+ zero_partitions $disk
+ done
+
typeset cyl=""
for num in 0 1 2 3 ; do
eval typeset slice=\${FS_SIDE$num}
disk=${slice%${SLICE_PREFIX}*}
- slice=${slice##*${SLICE_PREFIX}}
+ [[ -z $SLICE_PREFIX ]] && eval typeset disk=\${FS_DISK$num}
+ slice=$(echo $slice | awk '{ print substr($1,length($1),1) }')
log_must set_partition $slice "$cyl" $FS_SIZE $disk
- cyl=$(get_endslice $disk $slice)
+ [[ $num < 3 ]] && cyl=$(get_endslice $disk $slice)
done
if [[ -n $SINGLE_DISK && -n ${vdevs[i]} ]]; then