From 6f0104e3771d71c056a75ded2584e27892749ca1 Mon Sep 17 00:00:00 2001 From: sara hartse Date: Wed, 20 Jun 2018 12:32:21 -0700 Subject: [PATCH] add real scsi device expand test --- tests/runfiles/linux.run | 2 +- .../cli_root/zpool_expand/Makefile.am | 3 +- .../zpool_expand/zpool_expand_005_pos.ksh | 101 ++++++++++++++++++ 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100755 tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_005_pos.ksh diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run index bd301e3288df..c80352bdbfe5 100644 --- a/tests/runfiles/linux.run +++ b/tests/runfiles/linux.run @@ -333,7 +333,7 @@ tags = ['functional', 'cli_root', 'zpool_events'] [tests/functional/cli_root/zpool_expand] tests = ['zpool_expand_001_pos', 'zpool_expand_002_pos', - 'zpool_expand_003_neg', 'zpool_expand_004_pos'] + 'zpool_expand_003_neg', 'zpool_expand_004_pos', 'zpool_expand_005_pos'] tags = ['functional', 'cli_root', 'zpool_expand'] [tests/functional/cli_root/zpool_export] diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile.am index 2fae015b53ba..beaa411e37cb 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile.am +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile.am @@ -5,7 +5,8 @@ dist_pkgdata_SCRIPTS = \ zpool_expand_001_pos.ksh \ zpool_expand_002_pos.ksh \ zpool_expand_003_neg.ksh \ - zpool_expand_004_pos.ksh + zpool_expand_004_pos.ksh \ + zpool_expand_005_pos.ksh dist_pkgdata_DATA = \ zpool_expand.cfg diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_005_pos.ksh new file mode 100755 index 000000000000..8430c95b5cf1 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_005_pos.ksh @@ -0,0 +1,101 @@ +#! /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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2012, 2018 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/include/blkdev.shlib +. $STF_SUITE/tests/functional/cli_root/zpool_expand/zpool_expand.cfg + +# +# DESCRIPTION: +# +# STRATEGY: +# 1) Create a scsi_debug device and a pool based on it +# 2) Expand the device and rescan the scsi bus +# 3) Reopen the pool and check that it detects new available space +# 4) Online the device and check that the pool has been expanded +# + +verify_runnable "global" + +function cleanup +{ + if poolexists $TESTPOOL1; then + log_must zpool destroy $TESTPOOL1 + fi + unload_scsi_debug +} + +log_onexit cleanup + +log_assert "zpool based on scsi device can be expanded with zpool online -e" + +# run scsi_debug to create a device +MINVDEVSIZE_MB=$((MINVDEVSIZE / 1048576)) +load_scsi_debug $MINVDEVSIZE_MB 1 1 1 '512b' +block_device_wait +SDISK=$(get_debug_device) +log_must zpool create $TESTPOOL1 $SDISK + +typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1) +if [[ $autoexp != "off" ]]; then + log_fail "zpool $TESTPOOL1 autoexpand should be off but is $autoexp" +fi + +typeset prev_size=$(get_pool_prop size $TESTPOOL1) +log_note "original pool size: $prev_size" + +# resize the scsi_debug device +echo "5" > /sys/bus/pseudo/drivers/scsi_debug/virtual_gb +# rescan the device to detect the new size +echo "1" > /sys/class/block/$SDISK/device/rescan +block_device_wait + +# reopen the pool so ZFS can see the new space +log_must zpool reopen $TESTPOOL1 + +typeset expandsize=$(get_pool_prop expandsize $TESTPOOL1) +log_note "pool expandsize: $expandsize" +if [[ "$zpool_expandsize" = "-" ]]; then + log_fail "pool $TESTPOOL1 did not detect any " \ + "expandsize after reopen" +fi + +# online the device so the zpool will use the new space +log_must zpool online -e $TESTPOOL1 $SDISK + +typeset new_size=$(get_pool_prop size $TESTPOOL1) +log_note "new pool size: $new_size" +if [[ $new_size -le $prev_size ]]; then + log_fail "pool $TESTPOOL1 did not expand " \ + "after LUN expansion and zpool online -e" +fi + +log_pass "zpool based on scsi_debug can be expanded with reopen and online -e"