Print this page
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh
1 1 #!/bin/ksh -p
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
|
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28 #
29 -# Copyright (c) 2013 by Delphix. All rights reserved.
29 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
30 30 #
31 31
32 32 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
33 33
34 34 #
35 35 # DESCRIPTION:
36 36 # zfs send -R will backup all the filesystem properties correctly.
37 37 #
38 38 # STRATEGY:
39 39 # 1. Setting properties for all the filesystem and volumes randomly
40 40 # 2. Backup all the data from POOL by send -R
41 41 # 3. Restore all the data in POOL2
42 42 # 4. Verify all the perperties in two pools are same
43 43 #
|
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
44 44
45 45 verify_runnable "global"
46 46
47 47 function rand_set_prop
48 48 {
49 49 typeset dtst=$1
50 50 typeset prop=$2
51 51 shift 2
52 52 typeset value=$(random_get $@)
53 53
54 - log_must eval "$ZFS set $prop='$value' $dtst"
54 + log_must eval "zfs set $prop='$value' $dtst"
55 55 }
56 56
57 57 function edited_prop
58 58 {
59 59 typeset behaviour=$1
60 60 typeset ds=$2
61 61 typeset backfile=$TESTDIR/edited_prop_$ds
62 62
63 63 case $behaviour in
64 64 "get")
65 - typeset props=$($ZFS inherit 2>&1 | \
66 - $AWK '$2=="YES" {print $1}' | \
67 - $EGREP -v "^vol|\.\.\.$")
65 + typeset props=$(zfs inherit 2>&1 | \
66 + awk '$2=="YES" {print $1}' | \
67 + egrep -v "^vol|\.\.\.$")
68 68 for item in $props ; do
69 69 if [[ $item == "mlslabel" ]] && \
70 70 ! is_te_enabled ; then
71 71 continue
72 72 fi
73 - $ZFS get -H -o property,value $item $ds >> \
73 + zfs get -H -o property,value $item $ds >> \
74 74 $backfile
75 75 if (($? != 0)); then
76 76 log_fail "zfs get -H -o property,value"\
77 77 "$item $ds > $backfile"
78 78 fi
79 79 done
80 80 ;;
81 81 "set")
82 82 if [[ ! -f $backfile ]] ; then
83 83 log_fail "$ds need backup properties firstly."
84 84 fi
85 85
86 86 typeset prop value
87 87 while read prop value ; do
88 - eval $ZFS set $prop='$value' $ds
88 + eval zfs set $prop='$value' $ds
89 89 if (($? != 0)); then
90 - log_fail "$ZFS set $prop=$value $ds"
90 + log_fail "zfs set $prop=$value $ds"
91 91 fi
92 92 done < $backfile
93 93 ;;
94 94 *)
95 95 log_fail "Unrecognized behaviour: $behaviour"
96 96 esac
97 97 }
98 98
99 99 function cleanup
100 100 {
101 101 log_must cleanup_pool $POOL
102 102 log_must cleanup_pool $POOL2
103 103
104 104 log_must edited_prop "set" $POOL
105 105 log_must edited_prop "set" $POOL2
106 106
107 107 typeset prop
108 108 for prop in $(fs_inherit_prop) ; do
109 - log_must $ZFS inherit $prop $POOL
110 - log_must $ZFS inherit $prop $POOL2
109 + log_must zfs inherit $prop $POOL
110 + log_must zfs inherit $prop $POOL2
111 111 done
112 112
113 113 #if is_shared $POOL; then
114 - # log_must $ZFS set sharenfs=off $POOL
114 + # log_must zfs set sharenfs=off $POOL
115 115 #fi
116 116 log_must setup_test_model $POOL
117 117
118 118 if [[ -d $TESTDIR ]]; then
119 - log_must $RM -rf $TESTDIR/*
119 + log_must rm -rf $TESTDIR/*
120 120 fi
121 121 }
122 122
123 123 log_assert "Verify zfs send -R will backup all the filesystem properties " \
124 124 "correctly."
125 125 log_onexit cleanup
126 126
127 127 log_must edited_prop "get" $POOL
128 128 log_must edited_prop "get" $POOL2
129 129
130 130 for fs in "$POOL" "$POOL/pclone" "$POOL/$FS" "$POOL/$FS/fs1" \
131 131 "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do
132 132 rand_set_prop $fs aclinherit "discard" "noallow" "secure" "passthrough"
133 133 rand_set_prop $fs checksum "on" "off" "fletcher2" "fletcher4" "sha256"
134 134 rand_set_prop $fs aclmode "discard" "groupmask" "passthrough"
135 135 rand_set_prop $fs atime "on" "off"
136 136 rand_set_prop $fs checksum "on" "off" "fletcher2" "fletcher4" "sha256"
137 137 rand_set_prop $fs compression "on" "off" "lzjb" "gzip" \
138 138 "gzip-1" "gzip-2" "gzip-3" "gzip-4" "gzip-5" "gzip-6" \
139 139 "gzip-7" "gzip-8" "gzip-9"
140 140 rand_set_prop $fs copies "1" "2" "3"
141 141 rand_set_prop $fs devices "on" "off"
142 142 rand_set_prop $fs exec "on" "off"
143 143 rand_set_prop $fs quota "512M" "1024M"
144 144 rand_set_prop $fs recordsize "512" "2K" "8K" "32K" "128K"
145 145 rand_set_prop $fs setuid "on" "off"
146 146 rand_set_prop $fs snapdir "hidden" "visible"
147 147 rand_set_prop $fs xattr "on" "off"
148 148 rand_set_prop $fs user:prop "aaa" "bbb" "23421" "()-+?"
149 149 done
150 150
151 151 for vol in "$POOL/vol" "$POOL/$FS/vol" ; do
152 152 rand_set_prop $vol checksum "on" "off" "fletcher2" "fletcher4" "sha256"
153 153 rand_set_prop $vol compression "on" "off" "lzjb" "gzip" \
154 154 "gzip-1" "gzip-2" "gzip-3" "gzip-4" "gzip-5" "gzip-6" \
155 155 "gzip-7" "gzip-8" "gzip-9"
156 156 rand_set_prop $vol readonly "on" "off"
157 157 rand_set_prop $vol copies "1" "2" "3"
|
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
158 158 rand_set_prop $vol user:prop "aaa" "bbb" "23421" "()-+?"
159 159 done
160 160
161 161
162 162 # Verify inherited property can be received
163 163 rand_set_prop $POOL sharenfs "on" "off" "rw"
164 164
165 165 #
166 166 # Duplicate POOL2 for testing
167 167 #
168 -log_must eval "$ZFS send -R $POOL@final > $BACKDIR/pool-final-R"
169 -log_must eval "$ZFS receive -d -F $POOL2 < $BACKDIR/pool-final-R"
168 +log_must eval "zfs send -R $POOL@final > $BACKDIR/pool-final-R"
169 +log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/pool-final-R"
170 170
171 171 #
172 172 # Define all the POOL/POOL2 datasets pair
173 173 #
174 174 set -A pair "$POOL" "$POOL2" \
175 175 "$POOL/$FS" "$POOL2/$FS" \
176 176 "$POOL/$FS/fs1" "$POOL2/$FS/fs1" \
177 177 "$POOL/$FS/fs1/fs2" "$POOL2/$FS/fs1/fs2" \
178 178 "$POOL/pclone" "$POOL2/pclone" \
179 179 "$POOL/$FS/fs1/fclone" "$POOL2/$FS/fs1/fclone" \
180 180 "$POOL/vol" "$POOL2/vol" \
|
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
181 181 "$POOL/$FS/vol" "$POOL2/$FS/vol"
182 182
183 183 typeset -i i=0
184 184 while ((i < ${#pair[@]})); do
185 185 log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]}
186 186
187 187 ((i += 2))
188 188 done
189 189
190 190
191 -$ZPOOL upgrade -v | $GREP "Snapshot properties" > /dev/null 2>&1
191 +zpool upgrade -v | grep "Snapshot properties" > /dev/null 2>&1
192 192 if (( $? == 0 )) ; then
193 193 i=0
194 194 while ((i < ${#pair[@]})); do
195 195 log_must cmp_ds_prop ${pair[$i]}@final ${pair[((i+1))]}@final
196 196 ((i += 2))
197 197 done
198 198 fi
199 199
200 200 log_pass "Verify zfs send -R will backup all the filesystem properties " \
201 201 "correctly."
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX