dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / test / zfs-tests / tests / functional / rsend / rsend_012_pos.ksh
blob37f32859e27f6063161df5ce934516e397699e78
1 #!/bin/ksh -p
3 # CDDL HEADER START
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]
20 # CDDL HEADER END
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
35 # DESCRIPTION:
36 # zfs send -R will backup all the filesystem properties correctly.
38 # STRATEGY:
39 # 1. Setting properties for all the filesystem and volumes randomly
40 # 2. Backup all the data from POOL by send -R
41 # 3. Restore all the data in POOL2
42 # 4. Verify all the perperties in two pools are same
45 verify_runnable "global"
47 function rand_set_prop
49 typeset dtst=$1
50 typeset prop=$2
51 shift 2
52 typeset value=$(random_get $@)
54 log_must eval "zfs set $prop='$value' $dtst"
57 function edited_prop
59 typeset behaviour=$1
60 typeset ds=$2
61 typeset backfile=$TESTDIR/edited_prop_$ds
63 case $behaviour in
64 "get")
65 typeset props=$(zfs inherit 2>&1 | \
66 awk '$2=="YES" {print $1}' | \
67 egrep -v "^vol|\.\.\.$")
68 for item in $props ; do
69 zfs get -H -o property,value $item $ds >> \
70 $backfile
71 if (($? != 0)); then
72 log_fail "zfs get -H -o property,value"\
73 "$item $ds > $backfile"
75 done
77 "set")
78 if [[ ! -f $backfile ]] ; then
79 log_fail "$ds need backup properties firstly."
82 typeset prop value
83 while read prop value ; do
84 eval zfs set $prop='$value' $ds
85 if (($? != 0)); then
86 log_fail "zfs set $prop=$value $ds"
88 done < $backfile
91 log_fail "Unrecognized behaviour: $behaviour"
92 esac
95 function cleanup
97 log_must cleanup_pool $POOL
98 log_must cleanup_pool $POOL2
100 log_must edited_prop "set" $POOL
101 log_must edited_prop "set" $POOL2
103 typeset prop
104 for prop in $(fs_inherit_prop) ; do
105 log_must zfs inherit $prop $POOL
106 log_must zfs inherit $prop $POOL2
107 done
109 #if is_shared $POOL; then
110 # log_must zfs set sharenfs=off $POOL
112 log_must setup_test_model $POOL
114 if [[ -d $TESTDIR ]]; then
115 log_must rm -rf $TESTDIR/*
119 log_assert "Verify zfs send -R will backup all the filesystem properties " \
120 "correctly."
121 log_onexit cleanup
123 log_must edited_prop "get" $POOL
124 log_must edited_prop "get" $POOL2
126 for fs in "$POOL" "$POOL/pclone" "$POOL/$FS" "$POOL/$FS/fs1" \
127 "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do
128 rand_set_prop $fs aclinherit "discard" "noallow" "secure" "passthrough"
129 rand_set_prop $fs checksum "on" "off" "fletcher2" "fletcher4" "sha256"
130 rand_set_prop $fs aclmode "discard" "groupmask" "passthrough"
131 rand_set_prop $fs atime "on" "off"
132 rand_set_prop $fs checksum "on" "off" "fletcher2" "fletcher4" "sha256"
133 rand_set_prop $fs compression "on" "off" "lzjb" "gzip" \
134 "gzip-1" "gzip-2" "gzip-3" "gzip-4" "gzip-5" "gzip-6" \
135 "gzip-7" "gzip-8" "gzip-9"
136 rand_set_prop $fs copies "1" "2" "3"
137 rand_set_prop $fs devices "on" "off"
138 rand_set_prop $fs exec "on" "off"
139 rand_set_prop $fs quota "512M" "1024M"
140 rand_set_prop $fs recordsize "512" "2K" "8K" "32K" "128K"
141 rand_set_prop $fs setuid "on" "off"
142 rand_set_prop $fs snapdir "hidden" "visible"
143 rand_set_prop $fs xattr "on" "off"
144 rand_set_prop $fs user:prop "aaa" "bbb" "23421" "()-+?"
145 done
147 for vol in "$POOL/vol" "$POOL/$FS/vol" ; do
148 rand_set_prop $vol checksum "on" "off" "fletcher2" "fletcher4" "sha256"
149 rand_set_prop $vol compression "on" "off" "lzjb" "gzip" \
150 "gzip-1" "gzip-2" "gzip-3" "gzip-4" "gzip-5" "gzip-6" \
151 "gzip-7" "gzip-8" "gzip-9"
152 rand_set_prop $vol readonly "on" "off"
153 rand_set_prop $vol copies "1" "2" "3"
154 rand_set_prop $vol user:prop "aaa" "bbb" "23421" "()-+?"
155 done
158 # Verify inherited property can be received
159 rand_set_prop $POOL sharenfs "on" "off" "rw"
162 # Duplicate POOL2 for testing
164 log_must eval "zfs send -R $POOL@final > $BACKDIR/pool-final-R"
165 log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/pool-final-R"
168 # Define all the POOL/POOL2 datasets pair
170 set -A pair "$POOL" "$POOL2" \
171 "$POOL/$FS" "$POOL2/$FS" \
172 "$POOL/$FS/fs1" "$POOL2/$FS/fs1" \
173 "$POOL/$FS/fs1/fs2" "$POOL2/$FS/fs1/fs2" \
174 "$POOL/pclone" "$POOL2/pclone" \
175 "$POOL/$FS/fs1/fclone" "$POOL2/$FS/fs1/fclone" \
176 "$POOL/vol" "$POOL2/vol" \
177 "$POOL/$FS/vol" "$POOL2/$FS/vol"
179 typeset -i i=0
180 while ((i < ${#pair[@]})); do
181 log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]}
183 ((i += 2))
184 done
187 zpool upgrade -v | grep "Snapshot properties" > /dev/null 2>&1
188 if (( $? == 0 )) ; then
190 while ((i < ${#pair[@]})); do
191 log_must cmp_ds_prop ${pair[$i]}@final ${pair[((i+1))]}@final
192 ((i += 2))
193 done
196 log_pass "Verify zfs send -R will backup all the filesystem properties " \
197 "correctly."