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 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
22 skip "Need server version at least 2.9.55" && exit 0
23 [[ $(facet_fstype mds1) = "ldiskfs" ]] ||
24 [[ $(facet_fstype ost1) = "ldiskfs" ]] &&
25 skip "can't test snapshots with ldiskfs" && exit 0
27 require_dsh_mds || exit 0
28 require_dsh_ost || exit 0
30 check_and_setup_lustre
32 do_facet mgs $LCTL set_param debug=+snapshot
33 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param debug=+snapshot
40 echo "Create lss_0_0 with default"
41 lsnapshot_create -n lss_0_0 ||
42 lss_err "(1) Fail to create lss_0_0 with default"
45 lsnapshot_list -n lss_0_0 ||
46 lss_err "(2) Fail to list lss_0_0"
48 echo "Create lss_0_1 with barrier off"
49 lsnapshot_create -n lss_0_1 --barrier=off ||
50 lss_err "(3) Fail to create lss_0_1 with barrier off"
53 lsnapshot_list -n lss_0_1 ||
54 lss_err "(4) Fail to list lss_0_1"
56 echo "Create lss_0_2 with comment"
57 lsnapshot_create -n lss_0_2 -c "'This is test_0'" ||
58 lss_err "(5) Fail to create lss_0_2 with comment"
61 lsnapshot_list -n lss_0_2 | grep "This is test_0" ||
62 lss_err "(6) Fail to list lss_0_2"
64 echo "Create lss_0_2 with barrier on and comment"
65 lsnapshot_create -n lss_0_3 --barrier=on -c "'Another one'" ||
66 lss_err "(7) Fail to create lss_0_3 with barrier and comment"
69 lsnapshot_list -n lss_0_3 | grep "Another one" ||
70 lss_err "(8) Fail to list lss_0_3"
72 echo "Try to create lss_0_0 that exist already"
73 lsnapshot_create -n lss_0_0 &&
74 lss_err "(9) Create snapshot with exist name should fail" ||
77 run_test 0 "create lustre snapshot"
80 mkdir -p $DIR/$tdir || lss_err "(1) Fail to mkdir $DIR/$tdir"
81 rm -f $DIR/$tdir/test-framework.sh
82 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
83 lss_err "(2) Fail to copy"
88 echo "Create lss_1a_0"
89 lsnapshot_create -n lss_1a_0 ||
90 lss_err "(3) Fail to create lss_1a_0"
92 echo "Check whether mounted (1)"
93 lsnapshot_list -n lss_1a_0 -d | grep "mounted" && {
94 lsnapshot_list -n lss_1a_0 -d
95 lss_err "(4) Expect 'not mount', got 'mounted' for lss_1a_0"
99 lsnapshot_mount -n lss_1a_0 ||
100 lss_err "(5) Fail to mount lss_1a_0"
102 echo "Check whether mounted (2)"
103 local mcount=$(lsnapshot_list -n lss_1a_0 -d | grep "not mount" | wc -l)
104 [[ $mcount -ne 0 ]] && {
105 if combined_mgs_mds ; then
106 lsnapshot_list -n lss_1a_0 -d
107 lss_err "(6.1) Got unexpected 'not mount' for lss_1a_0"
110 [[ $mcount -gt 1 ]] && {
111 lsnapshot_list -n lss_1a_0 -d
112 lss_err "(6.2) Got unexpected 'not mount' for lss_1a_0"
115 # The first 10 lines contains and only contains MGS mount status
116 lsnapshot_list -n lss_1a_0 -d | head -n 10 |
117 grep "not mount" || {
118 lsnapshot_list -n lss_1a_0 -d
119 lss_err "(6.3) Got unexpected 'not mount' for lss_1a_0"
123 local ss_fsname=$(lsnapshot_list -n lss_1a_0 |
124 awk '/^snapshot_fsname/ { print $2 }')
125 local mntpt="/mnt/$ss_fsname"
126 local saved_fsname=$FSNAME
129 lss_err "(7) Fail to create mount point $mntpt"
132 mount_client $mntpt ro || {
134 lss_err "(8) Fail to mount client for lss_1a_0"
138 echo "Check whether the file in snapshot is the same as original one"
139 diff $DIR/$tdir/test-framework.sh $mntpt/$tdir/test-framework.sh ||
140 lss_err "(9) files should be the same"
142 echo "Modify the original file, and check again"
143 echo dummy >> $DIR/$tdir/test-framework.sh
144 diff $DIR/$tdir/test-framework.sh $mntpt/$tdir/test-framework.sh &&
145 lss_err "(10) files should be different"
148 lss_err "(11) Fail to umount client for lss_1a_0"
150 echo "Umount lss_1a_0"
151 lsnapshot_umount -n lss_1a_0 ||
152 lss_err "(12) Fail to umount lss_1a_0"
154 echo "Check whether mounted (3)"
155 lsnapshot_list -n lss_1a_0 -d | grep "mounted" && {
156 lsnapshot_list -n lss_1a_0 -d
157 lss_err "(13) Expect 'not mount', got 'mounted' for lss_1a_0"
160 run_test 1a "mount/umount lustre snapshot"
163 echo "Create lss_1b_0"
164 lsnapshot_create -n lss_1b_0 ||
165 lss_err "(1) Fail to create lss_1b_0"
167 echo "Check whether mounted (1)"
168 lsnapshot_list -n lss_1b_0 -d | grep "mounted" && {
169 lsnapshot_list -n lss_1b_0 -d
170 lss_err "(2) Expect 'not mount', got 'mounted' for lss_1b_0"
173 stopall || lss_err "(3) Fail to stopall"
175 echo "Mount lss_1b_0"
176 lsnapshot_mount -n lss_1b_0 ||
177 lss_err "(4) Fail to mount lss_1b_0"
179 echo "Check whether mounted (2)"
180 lsnapshot_list -n lss_1b_0 -d | grep "not mount" && {
181 lsnapshot_list -n lss_1b_0 -d
182 lss_err "(5) Expect 'mounted', got 'not mount' for lss_1b_0"
185 echo "umount lss_1b_0"
186 lsnapshot_umount -n lss_1b_0 ||
187 lss_err "(6) Fail to umount lss_1b_0"
189 echo "Check whether mounted (3)"
190 lsnapshot_list -n lss_1b_0 -d | grep "mounted" && {
191 lsnapshot_list -n lss_1b_0 -d
192 lss_err "(7) Expect 'not mount', got 'mounted' for lss_1b_0"
195 setupall || lss_err "(8) Fail to setupall"
197 run_test 1b "mount snapshot without original filesystem mounted"
200 echo "Create lss_2_0"
201 lsnapshot_create -n lss_2_0 --barrier=off ||
202 lss_err "(1) Fail to create lss_2_0"
205 lsnapshot_list -n lss_2_0 ||
206 lss_err "(2) Fail to list lss_2_0"
208 echo "Destroy lss_2_0"
209 lsnapshot_destroy -n lss_2_0 ||
210 lss_err "(3) Fail to destroy lss_2_0"
212 echo "Try to list lss_2_0 after destroy"
213 lsnapshot_list -n lss_2_0 &&
214 lss_err "(4) List lss_2_0 should fail after destroy"
216 echo "Create lss_2_1"
217 lsnapshot_create -n lss_2_1 --barrier=off ||
218 lss_err "(5) Fail to create lss_2_1"
221 lsnapshot_list -n lss_2_1 ||
222 lss_err "(6) Fail to list lss_2_1"
225 lsnapshot_mount -n lss_2_1 ||
226 lss_err "(7) Fail to mount lss_2_1"
228 echo "Try to destroy lss_2_1 with mounted"
229 lsnapshot_destroy -n lss_2_1 &&
230 lss_err "(8) Destroy mounted snapshot without -f should fail"
232 echo "Destroy lss_2_1 by force with mounted"
233 lsnapshot_destroy -n lss_2_1 -f ||
234 lss_err "(9) Destroy mounted snapshot with -f should succeed"
236 echo "Try to list lss_2_1 after destroy"
237 lsnapshot_list -n lss_2_1 &&
238 lss_err "(10) List lss_2_1 should fail after destroy" || true
240 run_test 2 "destroy lustre snapshot"
243 echo "Create lss_3a_0"
244 lsnapshot_create -n lss_3a_0 --barrier=off -c "'It is test_3a'" ||
245 lss_err "(1) Fail to create lss_3a_0"
248 lsnapshot_list -n lss_3a_0 ||
249 lss_err "(2) Fail to list lss_3a_0"
251 local old_mtime=$(lsnapshot_list -n lss_3a_0 |
252 awk '/^modify_time/ { $1=""; print $0 }')
254 echo "Rename lss_3a_0 to lss_3a_1"
255 lsnapshot_modify -n lss_3a_0 -N "lss_3a_1" ||
256 lss_err "(3) Fail to rename lss_3a_0 to lss_3a_1"
258 echo "Try to list lss_3a_0 after rename"
259 lsnapshot_list -n lss_3a_0 &&
260 lss_err "(4) List lss_3a_0 should fail after rename"
263 lsnapshot_list -n lss_3a_1 ||
264 lss_err "(5) Fail to list lss_3a_1"
266 local new_mtime=$(lsnapshot_list -n lss_3a_1 |
267 awk '/^modify_time/ { $1=""; print $0 }')
268 echo "Check whether mtime has been changed"
269 [ "$old_mtime" != "$new_mtime" ] ||
270 lss_err "(6) mtime should be changed because of rename"
272 echo "Modify lss_3a_1's comment"
273 lsnapshot_modify -n lss_3a_1 -c "'Renamed from lss_3a_0'" ||
274 lss_err "(7) Fail to change lss_3a_1's comment"
276 echo "Check whether comment has been changed"
277 lsnapshot_list -n lss_3a_1 -d | grep "It is test_3a" && {
278 lsnapshot_list -n lss_3a_1 -d
279 lss_err "(8) The comment should have been changed"
282 echo "Modify lss_3a_1's name and comment together"
283 lsnapshot_modify -n lss_3a_1 -N "lss_3a_2" -c "'Change again'" ||
284 lss_err "(9) Fail to modify lss_3a_1"
286 echo "Mount lss_3a_2"
287 lsnapshot_mount -n lss_3a_2 ||
288 lss_err "(10) Fail to mount lss_3a_2"
290 echo "Try to rename lss_3a_2 to lss_3a_3 with mounted"
291 lsnapshot_modify -n lss_3a_2 -N "lss_3a_3" &&
292 lss_err "(11) Rename mounted snapshot lss_3a_2 should fail"
294 echo "Modify lss_3a_2's comment with mounted"
295 lsnapshot_modify -n lss_3a_2 -c "'Change comment with mounted'" ||
296 lss_err "(12) Change comment with mount should succeed"
298 echo "Umount lss_3a_2"
299 lsnapshot_umount -n lss_3a_2 ||
300 lss_err "(13) Fail to umount lss_3a_2"
302 run_test 3a "modify lustre snapshot"
305 echo "Create lss_3b_0"
306 lsnapshot_create -n lss_3b_0 --barrier=off -c "'It is test_3b'" ||
307 lss_err "(1) Fail to create lss_3b_0"
310 lsnapshot_list -n lss_3b_0 ||
311 lss_err "(2) Fail to list lss_3b_0"
313 stopall || lss_err "(3) Fail to stopall"
315 echo "Modify lss_3b_0's name and comment together"
316 lsnapshot_modify -n lss_3b_0 -N "lss_3b_1" -c "'Change again'" ||
317 lss_err "(4) Fail to modify lss_3b_0"
319 echo "Try to list lss_3b_0 after rename"
320 lsnapshot_list -n lss_3b_0 &&
321 lss_err "(5) List lss_3b_0 should fail after rename"
323 echo "Check whether comment has been changed"
324 lsnapshot_list -n lss_3b_1 -d | grep "It is test_3b" && {
325 lsnapshot_list -n lss_3b_1 -d
326 lss_err "(6) The comment should have been changed"
329 setupall || lss_err "(7) Fail to setupall"
331 run_test 3b "modify snapshot without original filesystem mounted"
334 do_facet mgs $LCTL set_param debug=-snapshot
335 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param debug=-snapshot
337 check_and_cleanup_lustre