3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
10 ALWAYS_EXCEPT="$SANITY_LSNAPSHOT_EXCEPT"
11 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
15 . $LUSTRE/tests/test-framework.sh
17 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
20 require_dsh_mds || exit 0
21 require_dsh_ost || exit 0
23 check_and_setup_lustre
25 do_facet mgs $LCTL set_param debug=+snapshot
26 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param debug=+snapshot
33 echo "Create lss_0_0 with default"
34 lsnapshot_create -n lss_0_0 ||
35 lss_err "(1) Fail to create lss_0_0 with default"
38 lsnapshot_list -n lss_0_0 ||
39 lss_err "(2) Fail to list lss_0_0"
41 echo "Create lss_0_1 with barrier off"
42 lsnapshot_create -n lss_0_1 --barrier=off ||
43 lss_err "(3) Fail to create lss_0_1 with barrier off"
46 lsnapshot_list -n lss_0_1 ||
47 lss_err "(4) Fail to list lss_0_1"
49 echo "Create lss_0_2 with comment"
50 lsnapshot_create -n lss_0_2 -c "'This is test_0'" ||
51 lss_err "(5) Fail to create lss_0_2 with comment"
54 lsnapshot_list -n lss_0_2 | grep "This is test_0" ||
55 lss_err "(6) Fail to list lss_0_2"
57 echo "Create lss_0_2 with barrier on and comment"
58 lsnapshot_create -n lss_0_3 --barrier=on -c "'Another one'" ||
59 lss_err "(7) Fail to create lss_0_3 with barrier and comment"
62 lsnapshot_list -n lss_0_3 | grep "Another one" ||
63 lss_err "(8) Fail to list lss_0_3"
65 echo "Try to create lss_0_0 that exist already"
66 lsnapshot_create -n lss_0_0 &&
67 lss_err "(9) Create snapshot with exist name should fail" ||
70 run_test 0 "create lustre snapshot"
73 mkdir -p $DIR/$tdir || lss_err "(1) Fail to mkdir $DIR/$tdir"
74 rm -f $DIR/$tdir/test-framework.sh
75 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
76 lss_err "(2) Fail to copy"
81 echo "Create lss_1a_0"
82 lsnapshot_create -n lss_1a_0 ||
83 lss_err "(3) Fail to create lss_1a_0"
85 echo "Check whether mounted (1)"
86 lsnapshot_list -n lss_1a_0 -d | grep "mounted" && {
87 lsnapshot_list -n lss_1a_0 -d
88 lss_err "(4) Expect 'not mount', got 'mounted' for lss_1a_0"
92 lsnapshot_mount -n lss_1a_0 ||
93 lss_err "(5) Fail to mount lss_1a_0"
95 echo "Check whether mounted (2)"
96 local mcount=$(lsnapshot_list -n lss_1a_0 -d | grep "not mount" | wc -l)
97 [[ $mcount -ne 0 ]] && {
98 if combined_mgs_mds ; then
99 lsnapshot_list -n lss_1a_0 -d
100 lss_err "(6.1) Got unexpected 'not mount' for lss_1a_0"
103 [[ $mcount -gt 1 ]] && {
104 lsnapshot_list -n lss_1a_0 -d
105 lss_err "(6.2) Got unexpected 'not mount' for lss_1a_0"
108 # The first 10 lines contains and only contains MGS mount status
109 lsnapshot_list -n lss_1a_0 -d | head -n 10 |
110 grep "not mount" || {
111 lsnapshot_list -n lss_1a_0 -d
112 lss_err "(6.3) Got unexpected 'not mount' for lss_1a_0"
116 local ss_fsname=$(lsnapshot_list -n lss_1a_0 |
117 awk '/^snapshot_fsname/ { print $2 }')
118 local mntpt="/mnt/$ss_fsname"
119 local saved_fsname=$FSNAME
122 lss_err "(7) Fail to create mount point $mntpt"
125 mount_client $mntpt ro || {
127 lss_err "(8) Fail to mount client for lss_1a_0"
131 echo "Check whether the file in snapshot is the same as original one"
132 diff $DIR/$tdir/test-framework.sh $mntpt/$tdir/test-framework.sh ||
133 lss_err "(9) files should be the same"
135 echo "Modify the original file, and check again"
136 echo dummy >> $DIR/$tdir/test-framework.sh
137 diff $DIR/$tdir/test-framework.sh $mntpt/$tdir/test-framework.sh &&
138 lss_err "(10) files should be different"
141 lss_err "(11) Fail to umount client for lss_1a_0"
143 echo "Umount lss_1a_0"
144 lsnapshot_umount -n lss_1a_0 ||
145 lss_err "(12) Fail to umount lss_1a_0"
147 echo "Check whether mounted (3)"
148 lsnapshot_list -n lss_1a_0 -d | grep "mounted" && {
149 lsnapshot_list -n lss_1a_0 -d
150 lss_err "(13) Expect 'not mount', got 'mounted' for lss_1a_0"
153 run_test 1a "mount/umount lustre snapshot"
156 echo "Create lss_1b_0"
157 lsnapshot_create -n lss_1b_0 ||
158 lss_err "(1) Fail to create lss_1b_0"
160 echo "Check whether mounted (1)"
161 lsnapshot_list -n lss_1b_0 -d | grep "mounted" && {
162 lsnapshot_list -n lss_1b_0 -d
163 lss_err "(2) Expect 'not mount', got 'mounted' for lss_1b_0"
166 stopall || lss_err "(3) Fail to stopall"
168 echo "Mount lss_1b_0"
169 lsnapshot_mount -n lss_1b_0 ||
170 lss_err "(4) Fail to mount lss_1b_0"
172 echo "Check whether mounted (2)"
173 lsnapshot_list -n lss_1b_0 -d | grep "not mount" && {
174 lsnapshot_list -n lss_1b_0 -d
175 lss_err "(5) Expect 'mounted', got 'not mount' for lss_1b_0"
178 echo "umount lss_1b_0"
179 lsnapshot_umount -n lss_1b_0 ||
180 lss_err "(6) Fail to umount lss_1b_0"
182 echo "Check whether mounted (3)"
183 lsnapshot_list -n lss_1b_0 -d | grep "mounted" && {
184 lsnapshot_list -n lss_1b_0 -d
185 lss_err "(7) Expect 'not mount', got 'mounted' for lss_1b_0"
188 setupall || lss_err "(8) Fail to setupall"
190 run_test 1b "mount snapshot without original filesystem mounted"
193 echo "Create lss_2_0"
194 lsnapshot_create -n lss_2_0 --barrier=off ||
195 lss_err "(1) Fail to create lss_2_0"
198 lsnapshot_list -n lss_2_0 ||
199 lss_err "(2) Fail to list lss_2_0"
201 echo "Destroy lss_2_0"
202 lsnapshot_destroy -n lss_2_0 ||
203 lss_err "(3) Fail to destroy lss_2_0"
205 echo "Try to list lss_2_0 after destroy"
206 lsnapshot_list -n lss_2_0 &&
207 lss_err "(4) List lss_2_0 should fail after destroy"
209 echo "Create lss_2_1"
210 lsnapshot_create -n lss_2_1 --barrier=off ||
211 lss_err "(5) Fail to create lss_2_1"
214 lsnapshot_list -n lss_2_1 ||
215 lss_err "(6) Fail to list lss_2_1"
218 lsnapshot_mount -n lss_2_1 ||
219 lss_err "(7) Fail to mount lss_2_1"
221 echo "Try to destroy lss_2_1 with mounted"
222 lsnapshot_destroy -n lss_2_1 &&
223 lss_err "(8) Destroy mounted snapshot without -f should fail"
225 echo "Destroy lss_2_1 by force with mounted"
226 lsnapshot_destroy -n lss_2_1 -f ||
227 lss_err "(9) Destroy mounted snapshot with -f should succeed"
229 echo "Try to list lss_2_1 after destroy"
230 lsnapshot_list -n lss_2_1 &&
231 lss_err "(10) List lss_2_1 should fail after destroy" || true
233 run_test 2 "destroy lustre snapshot"
236 echo "Create lss_3a_0"
237 lsnapshot_create -n lss_3a_0 --barrier=off -c "'It is test_3a'" ||
238 lss_err "(1) Fail to create lss_3a_0"
241 lsnapshot_list -n lss_3a_0 ||
242 lss_err "(2) Fail to list lss_3a_0"
244 local old_mtime=$(lsnapshot_list -n lss_3a_0 |
245 awk '/^modify_time/ { $1=""; print $0 }')
247 echo "Rename lss_3a_0 to lss_3a_1"
248 lsnapshot_modify -n lss_3a_0 -N "lss_3a_1" ||
249 lss_err "(3) Fail to rename lss_3a_0 to lss_3a_1"
251 echo "Try to list lss_3a_0 after rename"
252 lsnapshot_list -n lss_3a_0 &&
253 lss_err "(4) List lss_3a_0 should fail after rename"
256 lsnapshot_list -n lss_3a_1 ||
257 lss_err "(5) Fail to list lss_3a_1"
259 local new_mtime=$(lsnapshot_list -n lss_3a_1 |
260 awk '/^modify_time/ { $1=""; print $0 }')
261 echo "Check whether mtime has been changed"
262 [ "$old_mtime" != "$new_mtime" ] ||
263 lss_err "(6) mtime should be changed because of rename"
265 echo "Modify lss_3a_1's comment"
266 lsnapshot_modify -n lss_3a_1 -c "'Renamed from lss_3a_0'" ||
267 lss_err "(7) Fail to change lss_3a_1's comment"
269 echo "Check whether comment has been changed"
270 lsnapshot_list -n lss_3a_1 -d | grep "It is test_3a" && {
271 lsnapshot_list -n lss_3a_1 -d
272 lss_err "(8) The comment should have been changed"
275 echo "Modify lss_3a_1's name and comment together"
276 lsnapshot_modify -n lss_3a_1 -N "lss_3a_2" -c "'Change again'" ||
277 lss_err "(9) Fail to modify lss_3a_1"
279 echo "Mount lss_3a_2"
280 lsnapshot_mount -n lss_3a_2 ||
281 lss_err "(10) Fail to mount lss_3a_2"
283 echo "Try to rename lss_3a_2 to lss_3a_3 with mounted"
284 lsnapshot_modify -n lss_3a_2 -N "lss_3a_3" &&
285 lss_err "(11) Rename mounted snapshot lss_3a_2 should fail"
287 echo "Modify lss_3a_2's comment with mounted"
288 lsnapshot_modify -n lss_3a_2 -c "'Change comment with mounted'" ||
289 lss_err "(12) Change comment with mount should succeed"
291 echo "Umount lss_3a_2"
292 lsnapshot_umount -n lss_3a_2 ||
293 lss_err "(13) Fail to umount lss_3a_2"
295 run_test 3a "modify lustre snapshot"
298 echo "Create lss_3b_0"
299 lsnapshot_create -n lss_3b_0 --barrier=off -c "'It is test_3b'" ||
300 lss_err "(1) Fail to create lss_3b_0"
303 lsnapshot_list -n lss_3b_0 ||
304 lss_err "(2) Fail to list lss_3b_0"
306 stopall || lss_err "(3) Fail to stopall"
308 echo "Modify lss_3b_0's name and comment together"
309 lsnapshot_modify -n lss_3b_0 -N "lss_3b_1" -c "'Change again'" ||
310 lss_err "(4) Fail to modify lss_3b_0"
312 echo "Try to list lss_3b_0 after rename"
313 lsnapshot_list -n lss_3b_0 &&
314 lss_err "(5) List lss_3b_0 should fail after rename"
316 echo "Check whether comment has been changed"
317 lsnapshot_list -n lss_3b_1 -d | grep "It is test_3b" && {
318 lsnapshot_list -n lss_3b_1 -d
319 lss_err "(6) The comment should have been changed"
322 setupall || lss_err "(7) Fail to setupall"
324 run_test 3b "modify snapshot without original filesystem mounted"
327 do_facet mgs $LCTL set_param debug=-snapshot
328 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param debug=-snapshot
330 check_and_cleanup_lustre