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_003_neg.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_003_neg
39#
40# Description:
41# Once set zpool autoexpand=off, zpool can *NOT* autoexpand by
42# Dynamic LUN Expansion
43#
44#
45# STRATEGY:
46# 1) Create a pool
47# 2) Create volumes on top of the pool
48# 3) Create pool by using the zvols and set autoexpand=off
49# 4) Expand the vol size by zfs set volsize
50# 5) Check that the pool size is not changed
51#
52# TESTABILITY: explicit
53#
54# TEST_AUTOMATION_LEVEL: automated
55#
56# CODING_STATUS: COMPLETED (2009-06-12)
57#
58# __stc_assertion_end
59#
60################################################################################
61
62verify_runnable "global"
63
64function cleanup
65{
66	destroy_pool $TESTPOOL1
67
68	for i in 1 2 3; do
69		if datasetexists $VFS/vol$i; then
70			log_must $ZFS destroy $VFS/vol$i
71		fi
72	done
73}
74
75log_onexit cleanup
76
77log_assert "zpool can not expand if set autoexpand=off after LUN expansion"
78
79for i  in 1 2 3; do
80	log_must $ZFS create -V $org_size $VFS/vol$i
81done
82
83for type in "" mirror raidz raidz2; do
84	log_must $ZPOOL create $TESTPOOL1 $type \
85		/dev/zvol/$VFS/vol1 \
86		/dev/zvol/$VFS/vol2 \
87		/dev/zvol/$VFS/vol3
88
89	typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1)
90	if [[ $autoexp != "off" ]]; then
91		log_fail "zpool $TESTPOOL1 autoexpand should off but is $autoexp"
92	fi
93
94	typeset prev_size=$(get_pool_prop size $TESTPOOL1)
95
96	for i in 1 2 3; do
97		log_must $ZFS set volsize=$exp_size $VFS/vol$i
98	done
99
100	$SYNC
101	$SLEEP 10
102	$SYNC
103
104	# check for zpool history for the pool size expansion
105	$ZPOOL history -il $TESTPOOL1 |  \
106		$GREP "pool '$TESTPOOL1' size:" | \
107		$GREP "internal vdev online" >/dev/null 2>&1
108
109	if [[ $? -eq 0 ]]; then
110		log_fail "pool $TESTPOOL1" \
111			" is not autoexpand after LUN expansion"
112	fi
113
114	typeset expand_size=$(get_pool_prop size $TESTPOOL1)
115
116	if [[ "$prev_size" != "$expand_size" ]]; then
117		log_fail "pool $TESTPOOL1 size changed after LUN expansion"
118	fi
119
120	log_must $ZPOOL destroy $TESTPOOL1
121
122	for i in 1 2 3; do
123		log_must $ZFS set volsize=$org_size $VFS/vol$i
124	done
125
126done
127
128log_pass "zpool can not expand if set autoexpand=off after LUN expansion"
129