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 [[ "$MDS1_VERSION" -lt $(version_code 2.9.55) ]] ||
21 [[ "$OST1_VERSION" -lt $(version_code 2.9.55) ]] &&
22 skip "Need server version at least 2.9.55"
23 [[ "$mds1_FSTYPE" = "ldiskfs" ]] || [[ "$ost1_FSTYPE" = "ldiskfs" ]] &&
26 require_dsh_mds || exit 0
27 require_dsh_ost || exit 0
29 check_and_setup_lustre
31 do_facet mgs $LCTL set_param debug=+snapshot
32 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param debug=+snapshot
39 echo "Create lss_0_0 with default"
40 lsnapshot_create -n lss_0_0 ||
41 lss_err "(1) Fail to create lss_0_0 with default"
44 lsnapshot_list -n lss_0_0 ||
45 lss_err "(2) Fail to list lss_0_0"
47 echo "Create lss_0_1 with barrier off"
48 lsnapshot_create -n lss_0_1 --barrier=off ||
49 lss_err "(3) Fail to create lss_0_1 with barrier off"
52 lsnapshot_list -n lss_0_1 ||
53 lss_err "(4) Fail to list lss_0_1"
55 echo "Create lss_0_2 with comment"
56 lsnapshot_create -n lss_0_2 -c "'This is test_0'" ||
57 lss_err "(5) Fail to create lss_0_2 with comment"
60 lsnapshot_list -n lss_0_2 | grep "This is test_0" ||
61 lss_err "(6) Fail to list lss_0_2"
63 echo "Create lss_0_2 with barrier on and comment"
64 lsnapshot_create -n lss_0_3 --barrier=on -c "'Another one'" ||
65 lss_err "(7) Fail to create lss_0_3 with barrier and comment"
68 lsnapshot_list -n lss_0_3 | grep "Another one" ||
69 lss_err "(8) Fail to list lss_0_3"
71 echo "Try to create lss_0_0 that exist already"
72 lsnapshot_create -n lss_0_0 &&
73 lss_err "(9) Create snapshot with exist name should fail" ||
76 run_test 0 "create lustre snapshot"
79 mkdir -p $DIR/$tdir || lss_err "(1) Fail to mkdir $DIR/$tdir"
80 rm -f $DIR/$tdir/test-framework.sh
81 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
82 lss_err "(2) Fail to copy"
87 echo "Create lss_1a_0"
88 lsnapshot_create -n lss_1a_0 ||
89 lss_err "(3) Fail to create lss_1a_0"
91 echo "Check whether mounted (1)"
92 lsnapshot_list -n lss_1a_0 -d | grep "mounted" && {
93 lsnapshot_list -n lss_1a_0 -d
94 lss_err "(4) Expect 'not mount', got 'mounted' for lss_1a_0"
98 lsnapshot_mount -n lss_1a_0 ||
99 lss_err "(5) Fail to mount lss_1a_0"
101 echo "Check whether mounted (2)"
102 local mcount=$(lsnapshot_list -n lss_1a_0 -d | grep "not mount" | wc -l)
103 [[ $mcount -ne 0 ]] && {
104 if combined_mgs_mds ; then
105 lsnapshot_list -n lss_1a_0 -d
106 lss_err "(6.1) Got unexpected 'not mount' for lss_1a_0"
109 [[ $mcount -gt 1 ]] && {
110 lsnapshot_list -n lss_1a_0 -d
111 lss_err "(6.2) Got unexpected 'not mount' for lss_1a_0"
114 # The first 10 lines contains and only contains MGS mount status
115 lsnapshot_list -n lss_1a_0 -d | head -n 10 |
116 grep "not mount" || {
117 lsnapshot_list -n lss_1a_0 -d
118 lss_err "(6.3) Got unexpected 'not mount' for lss_1a_0"
122 local ss_fsname=$(lsnapshot_list -n lss_1a_0 |
123 awk '/^snapshot_fsname/ { print $2 }')
124 local mntpt="/mnt/$ss_fsname"
125 local saved_fsname=$FSNAME
128 lss_err "(7) Fail to create mount point $mntpt"
131 mount_client $mntpt ro || {
133 lss_err "(8) Fail to mount client for lss_1a_0"
137 echo "Check whether the file in snapshot is the same as original one"
138 diff $DIR/$tdir/test-framework.sh $mntpt/$tdir/test-framework.sh ||
139 lss_err "(9) files should be the same"
141 echo "Modify the original file, and check again"
142 echo dummy >> $DIR/$tdir/test-framework.sh
143 diff $DIR/$tdir/test-framework.sh $mntpt/$tdir/test-framework.sh &&
144 lss_err "(10) files should be different"
147 lss_err "(11) Fail to umount client for lss_1a_0"
149 echo "Umount lss_1a_0"
150 lsnapshot_umount -n lss_1a_0 ||
151 lss_err "(12) Fail to umount lss_1a_0"
153 echo "Check whether mounted (3)"
154 lsnapshot_list -n lss_1a_0 -d | grep "mounted" && {
155 lsnapshot_list -n lss_1a_0 -d
156 lss_err "(13) Expect 'not mount', got 'mounted' for lss_1a_0"
159 run_test 1a "mount/umount lustre snapshot"
162 echo "Create lss_1b_0"
163 lsnapshot_create -n lss_1b_0 ||
164 lss_err "(1) Fail to create lss_1b_0"
166 echo "Check whether mounted (1)"
167 lsnapshot_list -n lss_1b_0 -d | grep "mounted" && {
168 lsnapshot_list -n lss_1b_0 -d
169 lss_err "(2) Expect 'not mount', got 'mounted' for lss_1b_0"
172 stopall || lss_err "(3) Fail to stopall"
174 echo "Mount lss_1b_0"
175 lsnapshot_mount -n lss_1b_0 ||
176 lss_err "(4) Fail to mount lss_1b_0"
178 echo "Check whether mounted (2)"
179 lsnapshot_list -n lss_1b_0 -d | grep "not mount" && {
180 lsnapshot_list -n lss_1b_0 -d
181 lss_err "(5) Expect 'mounted', got 'not mount' for lss_1b_0"
184 echo "umount lss_1b_0"
185 lsnapshot_umount -n lss_1b_0 ||
186 lss_err "(6) Fail to umount lss_1b_0"
188 echo "Check whether mounted (3)"
189 lsnapshot_list -n lss_1b_0 -d | grep "mounted" && {
190 lsnapshot_list -n lss_1b_0 -d
191 lss_err "(7) Expect 'not mount', got 'mounted' for lss_1b_0"
194 setupall || lss_err "(8) Fail to setupall"
196 run_test 1b "mount snapshot without original filesystem mounted"
199 echo "Create lss_2_0"
200 lsnapshot_create -n lss_2_0 --barrier=off ||
201 lss_err "(1) Fail to create lss_2_0"
204 lsnapshot_list -n lss_2_0 ||
205 lss_err "(2) Fail to list lss_2_0"
207 echo "Destroy lss_2_0"
208 lsnapshot_destroy -n lss_2_0 ||
209 lss_err "(3) Fail to destroy lss_2_0"
211 echo "Try to list lss_2_0 after destroy"
212 lsnapshot_list -n lss_2_0 &&
213 lss_err "(4) List lss_2_0 should fail after destroy"
215 echo "Create lss_2_1"
216 lsnapshot_create -n lss_2_1 --barrier=off ||
217 lss_err "(5) Fail to create lss_2_1"
220 lsnapshot_list -n lss_2_1 ||
221 lss_err "(6) Fail to list lss_2_1"
224 lsnapshot_mount -n lss_2_1 ||
225 lss_err "(7) Fail to mount lss_2_1"
227 echo "Try to destroy lss_2_1 with mounted"
228 lsnapshot_destroy -n lss_2_1 &&
229 lss_err "(8) Destroy mounted snapshot without -f should fail"
231 echo "Destroy lss_2_1 by force with mounted"
232 lsnapshot_destroy -n lss_2_1 -f ||
233 lss_err "(9) Destroy mounted snapshot with -f should succeed"
235 echo "Try to list lss_2_1 after destroy"
236 lsnapshot_list -n lss_2_1 &&
237 lss_err "(10) List lss_2_1 should fail after destroy" || true
239 run_test 2 "destroy lustre snapshot"
242 echo "Create lss_3a_0"
243 lsnapshot_create -n lss_3a_0 --barrier=off -c "'It is test_3a'" ||
244 lss_err "(1) Fail to create lss_3a_0"
247 lsnapshot_list -n lss_3a_0 ||
248 lss_err "(2) Fail to list lss_3a_0"
250 local old_mtime=$(lsnapshot_list -n lss_3a_0 |
251 awk '/^modify_time/ { $1=""; print $0 }')
253 echo "Rename lss_3a_0 to lss_3a_1"
254 lsnapshot_modify -n lss_3a_0 -N "lss_3a_1" ||
255 lss_err "(3) Fail to rename lss_3a_0 to lss_3a_1"
257 echo "Try to list lss_3a_0 after rename"
258 lsnapshot_list -n lss_3a_0 &&
259 lss_err "(4) List lss_3a_0 should fail after rename"
262 lsnapshot_list -n lss_3a_1 ||
263 lss_err "(5) Fail to list lss_3a_1"
265 local new_mtime=$(lsnapshot_list -n lss_3a_1 |
266 awk '/^modify_time/ { $1=""; print $0 }')
267 echo "Check whether mtime has been changed"
268 [ "$old_mtime" != "$new_mtime" ] ||
269 lss_err "(6) mtime should be changed because of rename"
271 echo "Modify lss_3a_1's comment"
272 lsnapshot_modify -n lss_3a_1 -c "'Renamed from lss_3a_0'" ||
273 lss_err "(7) Fail to change lss_3a_1's comment"
275 echo "Check whether comment has been changed"
276 lsnapshot_list -n lss_3a_1 -d | grep "It is test_3a" && {
277 lsnapshot_list -n lss_3a_1 -d
278 lss_err "(8) The comment should have been changed"
281 echo "Modify lss_3a_1's name and comment together"
282 lsnapshot_modify -n lss_3a_1 -N "lss_3a_2" -c "'Change again'" ||
283 lss_err "(9) Fail to modify lss_3a_1"
285 echo "Mount lss_3a_2"
286 lsnapshot_mount -n lss_3a_2 ||
287 lss_err "(10) Fail to mount lss_3a_2"
289 echo "Try to rename lss_3a_2 to lss_3a_3 with mounted"
290 lsnapshot_modify -n lss_3a_2 -N "lss_3a_3" &&
291 lss_err "(11) Rename mounted snapshot lss_3a_2 should fail"
293 echo "Modify lss_3a_2's comment with mounted"
294 lsnapshot_modify -n lss_3a_2 -c "'Change comment with mounted'" ||
295 lss_err "(12) Change comment with mount should succeed"
297 echo "Umount lss_3a_2"
298 lsnapshot_umount -n lss_3a_2 ||
299 lss_err "(13) Fail to umount lss_3a_2"
301 run_test 3a "modify lustre snapshot"
304 echo "Create lss_3b_0"
305 lsnapshot_create -n lss_3b_0 --barrier=off -c "'It is test_3b'" ||
306 lss_err "(1) Fail to create lss_3b_0"
309 lsnapshot_list -n lss_3b_0 ||
310 lss_err "(2) Fail to list lss_3b_0"
312 stopall || lss_err "(3) Fail to stopall"
314 echo "Modify lss_3b_0's name and comment together"
315 lsnapshot_modify -n lss_3b_0 -N "lss_3b_1" -c "'Change again'" ||
316 lss_err "(4) Fail to modify lss_3b_0"
318 echo "Try to list lss_3b_0 after rename"
319 lsnapshot_list -n lss_3b_0 &&
320 lss_err "(5) List lss_3b_0 should fail after rename"
322 echo "Check whether comment has been changed"
323 lsnapshot_list -n lss_3b_1 -d | grep "It is test_3b" && {
324 lsnapshot_list -n lss_3b_1 -d
325 lss_err "(6) The comment should have been changed"
328 setupall || lss_err "(7) Fail to setupall"
330 run_test 3b "modify snapshot without original filesystem mounted"
332 test_4() { # LU-10843
333 combined_mgs_mds && skip "Combined MGS/MDS" && return
335 local rcmd="$LCTL get_param ldlm.namespaces.MGS.resource_count"
337 local exports=$(do_facet mgs "$LCTL get_param -n mgs.MGS.num_exports")
338 local rcount=$(do_facet mgs $rcmd)
341 stop mgs || error "stop mgs failed"
342 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
344 echo "Wait for all reconnects"
345 local CMD="$LCTL get_param -n mgs.MGS.num_exports"
346 wait_update_facet mgs "$CMD" $exports ||
347 lss_err "(1) failed to export from mgs"
349 wait_update_facet mgs "$rcmd" $rcount ||
350 lss_err "(2) failed to reconnect mds"
352 echo "Create lss_4_0"
353 lsnapshot_create -n lss_4_0 -c "'It is test_4'" ||
354 lss_err "(3) Fail to create lss_4_0"
357 lsnapshot_list -n lss_4_0 ||
358 lss_err "(4) Fail to list lss_4_0"
360 echo "Destroy lss_4_0"
361 lsnapshot_destroy -n lss_4_0 ||
362 lss_err "(5) Fail to destroy lss_4_0"
365 run_test 4 "create/delete snapshot after MGS remount"
368 do_facet mgs $LCTL set_param debug=-snapshot
369 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param debug=-snapshot
371 check_and_cleanup_lustre