1#! /usr/local/bin/ksh93 -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26
27. $STF_SUITE/include/libtest.kshlib
28
29###############################################################################
30#
31# __stc_assertion_start
32#
33# ID: zpool_expand_001_pos
34#
35# DESCRIPTION:
36# Once zpool set autoexpand=on poolname, zpool can autoexpand by
37# Dynamic LUN Expansion
38#
39#
40# STRATEGY:
41# 1) Create a pool
42# 2) Create volume on top of the pool
43# 3) Create pool by using the zvols and set autoexpand=on
44# 4) Expand the vol size by 'zfs set volsize'
45# 5) Check that the pool size was expanded
46#
47# TESTABILITY: explicit
48#
49# TEST_AUTOMATION_LEVEL: automated
50#
51# CODING_STATUS: COMPLETED (2009-06-12)
52#
53# __stc_assertion_end
54#
55################################################################################
56
57verify_runnable "global"
58
59function cleanup
60{
61	destroy_pool $TESTPOOL1
62
63	for i in 1 2 3; do
64		if datasetexists $VFS/vol$i; then
65			log_must $ZFS destroy $VFS/vol$i
66		fi
67	done
68}
69
70log_onexit cleanup
71
72log_assert "zpool can be autoexpanded after set autoexpand=on on LUN expansion"
73
74for i in 1 2 3; do
75	log_must $ZFS create -V $org_size $VFS/vol$i
76done
77
78for type in " " mirror raidz raidz2; do
79
80	log_must $ZPOOL create -o autoexpand=on $TESTPOOL1 $type \
81		/dev/zvol/$VFS/vol1 \
82		/dev/zvol/$VFS/vol2 \
83		/dev/zvol/$VFS/vol3
84
85	typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1)
86	if [[ $autoexp != "on" ]]; then
87		log_fail "zpool $TESTPOOL1 autoexpand should on but is $autoexp"
88	fi
89
90	typeset prev_size=$(get_pool_prop size $TESTPOOL1)
91
92	for i in 1 2 3; do
93		log_must $ZFS set volsize=$exp_size $VFS/vol$i
94	done
95
96	$SYNC
97	$SLEEP 10
98	$SYNC
99
100	typeset expand_size=$(get_pool_prop size $TESTPOOL1)
101
102	# check for zpool history for the pool size expansion
103	if [[ $type == "mirror" ]]; then
104		$ZPOOL history -il $TESTPOOL1 |  \
105			$GREP "pool '$TESTPOOL1' size:" | \
106			$GREP "internal vdev online" | \
107			$GREP "(+${EX_1GB})" >/dev/null 2>&1
108
109		if [[ $? -ne 0 ]] ; then
110			log_fail "pool $TESTPOOL1" \
111				" is not autoexpand after LUN expansion"
112		fi
113	else
114		$ZPOOL history -il $TESTPOOL1 |  \
115			$GREP "pool '$TESTPOOL1' size:" | \
116			$GREP "internal vdev online" | \
117			$GREP "(+${EX_3GB})" >/dev/null 2>&1
118
119		if [[ $? -ne 0 ]] ; then
120			log_fail "pool $TESTPOOL1" \
121				" is not autoexpand after LUN expansion"
122		fi
123	fi
124
125	log_must $ZPOOL destroy $TESTPOOL1
126
127	for i in 1 2 3; do
128		log_must $ZFS set volsize=$org_size $VFS/vol$i
129	done
130
131done
132
133log_pass "zpool can be autoexpanded after set autoexpand=on on LUN expansion"
134