]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh
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.
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.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
36 # Verify 'zfs get all' can get all properties for all datasets in the system
39 # 1. Create datasets for testing
40 # 2. Issue 'zfs get all' command
41 # 3. Verify the command gets all available properties of all datasets
44 verify_runnable
"both"
48 [[ -e $propfile ]] && $RM -f $propfile
50 datasetexists
$clone && \
51 log_must
$ZFS destroy
$clone
52 for snap
in $fssnap $volsnap ; do
54 log_must
$ZFS destroy
$snap
57 if [[ -n $globalzone ]] ; then
58 for pool
in $TESTPOOL1 $TESTPOOL2 $TESTPOOL3; do
60 log_must
$ZPOOL destroy
-f $pool
62 for file in `$LS $TESTDIR1/poolfile*`; do
66 for fs
in $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS2 $TESTPOOL/$TESTFS3; do
67 datasetexists
$fs && \
68 log_must
$ZFS destroy
-rf $fs
73 log_assert
"Verify the functions of 'zfs get all' work."
78 if is_global_zone
; then
82 set -A opts
"" "-r" "-H" "-p" "-rHp" "-o name" \
83 "-s local,default,temporary,inherited,none" \
84 "-o name -s local,default,temporary,inherited,none" \
85 "-rHp -o name -s local,default,temporary,inherited,none"
86 set -A usrprops
"a:b=c" "d_1:1_e=0f" "123:456=789"
90 clone
=$TESTPOOL/$TESTCLONE
91 volsnap
=$TESTPOOL/$TESTVOL@
$TESTSNAP
93 #set user defined properties for $TESTPOOL
94 for usrprop
in ${usrprops[@]}; do
95 log_must
$ZFS set $usrprop $TESTPOOL
97 # create snapshot and clone in $TESTPOOL
98 log_must
$ZFS snapshot
$fssnap
99 log_must
$ZFS clone
$fssnap $clone
100 log_must
$ZFS snapshot
$volsnap
102 # collect datasets which can be set user defined properties
103 usrpropds
="$clone $fs"
105 # collect all datasets which we are creating
106 allds
="$fs $clone $fssnap $volsnap"
108 #create pool and datasets to guarantee testing under multiple pools and datasets.
109 file=$TESTDIR1/poolfile
110 typeset
-i FILESIZE
=104857600 #100M
111 (( DFILESIZE
= FILESIZE
* 2 )) # double of FILESIZE
112 typeset
-i VOLSIZE
=10485760 #10M
113 availspace
=$
(get_prop available
$TESTPOOL)
116 # make sure 'availspace' is larger then twice of FILESIZE to create a new pool.
117 # If any, we only totally create 3 pools for multple datasets testing to limit
119 while (( availspace
> DFILESIZE
)) && (( i
< 3 )) ; do
122 if [[ -n $globalzone ]] ; then
123 log_must
$MKFILE $FILESIZE ${file}$i
124 eval pool
=\
$TESTPOOL$i
125 log_must
$ZPOOL create
$pool ${file}$i
127 eval pool
=$TESTPOOL/\
$TESTFS$i
128 log_must
$ZFS create
$pool
131 #set user defined properties for testing
132 for usrprop
in ${usrprops[@]}; do
133 log_must
$ZFS set $usrprop $pool
136 #create datasets in pool
137 log_must
$ZFS create
$pool/$TESTFS
138 log_must
$ZFS snapshot
$pool/$TESTFS@
$TESTSNAP
139 log_must
$ZFS clone
$pool/$TESTFS@
$TESTSNAP $pool/$TESTCLONE
141 if [[ -n $globalzone ]] ; then
142 log_must
$ZFS create
-V $VOLSIZE $pool/$TESTVOL
144 log_must
$ZFS create
$pool/$TESTVOL
147 ds
=`$ZFS list -H -r -o name -t filesystem,volume $pool`
148 usrpropds
="$usrpropds $pool/$TESTFS $pool/$TESTCLONE $pool/$TESTVOL"
149 allds
="$allds $pool/$TESTFS $pool/$TESTCLONE $pool/$TESTVOL \
150 $pool/$TESTFS@$TESTSNAP"
152 availspace
=$
(get_prop available
$TESTPOOL)
155 #the expected number of property for each type of dataset in this testing
156 typeset
-i fspropnum
=27
157 typeset
-i snappropnum
=8
158 typeset
-i volpropnum
=15
159 propfile
=/var
/tmp
/allpropfile.$$
163 typeset
-i failflag
=0
164 while (( i
< ${#opts[*]} )); do
165 [[ -e $propfile ]] && $RM -f $propfile
166 log_must
eval "$ZFS get ${opts[i]} all >$propfile"
169 $GREP $ds $propfile >/dev
/null
2>&1
171 log_fail
"There is no property for" \
172 "dataset $ds in 'get all' output."
174 propnum
=`$CAT $propfile | $AWK '{print $1}' | \
175 $GREP "${ds}$" | $WC -l`
176 ds_type
=`$ZFS get -H -o value type $ds`
179 (( propnum
< fspropnum
)) && \
183 (( propnum
< snappropnum
)) && \
187 (( propnum
< volpropnum
)) && \
192 (( failflag
!= 0 )) && \
193 log_fail
" 'zfs get all' fails to get out " \
194 "all properties for dataset $ds."
203 log_note
"'zfs get' can get particular property for all datasets with that property."
205 function do_particular_prop_test
#<property> <suitable datasets>
210 for prop
in ${commprops[*]}; do
211 ds
=`$ZFS get -H -o name $prop`
213 [[ "$ds" != "$allds" ]] && \
214 log_fail
"The result datasets are $ds, but all suitable" \
215 "datasets are $allds for the property $prop"
219 # Here, we do a testing for user defined properties and the most common properties
221 commprop
="type creation used referenced compressratio"
222 usrprop
="a:b d_1:1_e 123:456"
224 do_particular_prop_test
"$commprop" "$allds"
225 do_particular_prop_test
"$usrprop" "$usrpropds"
227 log_pass
"'zfs get all' works as expected."