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# $FreeBSD$
24
25#
26# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29# ident	"@(#)zpool_expand_002_pos.ksh	1.1	09/06/22 SMI"
30#
31
32. $STF_SUITE/include/libtest.kshlib
33
34###############################################################################
35#
36# __stc_assertion_start
37#
38# ID: zpool_expand_002_pos
39#
40# DESCRIPTION:
41# After zpool online -e poolname zvol vdevs, zpool can autoexpand by
42# Dynamic LUN Expansion
43#
44#
45# STRATEGY:
46# 1) Create a pool
47# 2) Create volume on top of the pool
48# 3) Create pool by using the zvols
49# 4) Expand the vol size by zfs set volsize
50# 5  Use zpool online -e to online the zvol vdevs
51# 6) Check that the pool size was expaned
52#
53# TESTABILITY: explicit
54#
55# TEST_AUTOMATION_LEVEL: automated
56#
57# CODING_STATUS: COMPLETED (2009-06-12)
58#
59# __stc_assertion_end
60#
61################################################################################
62
63verify_runnable "global"
64
65function cleanup
66{
67	destroy_pool $TESTPOOL1
68
69	for i in 1 2 3; do
70		if datasetexists $VFS/vol$i; then
71			log_must $ZFS destroy $VFS/vol$i
72		fi
73	done
74}
75
76log_onexit cleanup
77
78log_assert "zpool can expand after zpool online -e zvol vdevs on LUN expansion"
79
80for i in 1 2 3; do
81	log_must $ZFS create -V $org_size $VFS/vol$i
82done
83
84for type in " " mirror raidz raidz2; do
85	log_must $ZPOOL create $TESTPOOL1 $type \
86		/dev/zvol/$VFS/vol1 \
87		/dev/zvol/$VFS/vol2 \
88		/dev/zvol/$VFS/vol3
89
90	typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1)
91	if [[ $autoexp != "off" ]]; then
92		log_fail "zpool $TESTPOOL1 autoexpand should off but is $autoexp"
93	fi
94
95	typeset prev_size=$(get_pool_prop size $TESTPOOL1)
96
97	for i in 1 2 3; do
98		log_must $ZFS set volsize=$exp_size $VFS/vol$i
99	done
100
101	for i in 1 2 3; do
102		log_must $ZPOOL online -e $TESTPOOL1 /dev/zvol/$VFS/vol$i
103	done
104
105	$SYNC
106	$SLEEP 10
107	$SYNC
108
109	# check for zpool history for the pool size expansion
110	if [[ $type == " " || $type == "mirror" ]]; then
111		$ZPOOL history -il $TESTPOOL1 |  \
112			$GREP "pool '$TESTPOOL1' size:" | \
113			$GREP "internal vdev online" | \
114			$GREP "(+${EX_1GB})" >/dev/null 2>&1
115
116		if [[ $? -ne 0 ]]; then
117			log_fail "pool $TESTPOOL1" \
118				" is not autoexpand after LUN expansion"
119		fi
120	else
121		$ZPOOL history -il $TESTPOOL1 |  \
122			$GREP "pool '$TESTPOOL1' size:" | \
123			$GREP "internal vdev online" | \
124			$GREP "(+${EX_3GB})" >/dev/null 2>&1
125
126		if [[ $? -ne 0 ]] ; then
127			log_fail "pool $TESTPOOL1" \
128				" is not autoexpand after LUN expansion"
129		fi
130	fi
131
132	typeset expand_size=$(get_pool_prop size $TESTPOOL1)
133
134	log_must $ZPOOL destroy $TESTPOOL1
135
136	for i in 1 2 3; do
137		log_must $ZFS set volsize=$org_size $VFS/vol$i
138	done
139
140done
141
142log_pass "zpool can expand after zpool online -e zvol vdevs on LUN expansion"
143