4 . $
(dirname $0)/..
/..
/standalone
/ceph-helpers.sh
6 export RBD_FORCE_ALLOW_V1
=1
8 # make sure rbd pool is EMPTY.. this is a test script!!
9 rbd
ls |
wc -l |
grep -v '^0$' && echo "nonempty rbd pool, aborting! run this script on an empty test cluster only." && exit 1
11 IMGS
="testimg1 testimg2 testimg3 testimg4 testimg5 testimg6 testimg-diff1 testimg-diff2 testimg-diff3 foo foo2 bar bar2 test1 test2 test3 test4 clone2"
14 "$@" && return 1 ||
return 0
18 if ceph osd dump |
grep ^pool |
grep "'rbd'" |
grep tier
; then
25 (rbd snap purge
$img || true
) >/dev
/null
2>&1
26 (rbd
rm $img || true
) >/dev
/null
2>&1
31 echo "testing import, export, resize, and snapshots..."
32 TMP_FILES
="/tmp/img1 /tmp/img1.new /tmp/img2 /tmp/img2.new /tmp/img3 /tmp/img3.new /tmp/img-diff1.new /tmp/img-diff2.new /tmp/img-diff3.new /tmp/img1.snap1 /tmp/img1.snap1 /tmp/img-diff1.snap1"
38 dd if=/bin
/sh of
=/tmp
/img1 bs
=1k count
=1 seek
=10
39 dd if=/bin
/dd of
=/tmp
/img1 bs
=1k count
=10 seek
=100
40 dd if=/bin
/rm of
=/tmp
/img1 bs
=1k count
=100 seek
=1000
41 dd if=/bin
/ls of
=/tmp
/img1 bs
=1k seek
=10000
42 dd if=/bin
/ln of
=/tmp
/img1 bs
=1k seek
=100000
45 rbd import
$RBD_CREATE_ARGS /tmp
/img1 testimg1
46 rbd resize testimg1
--size=256 --allow-shrink
47 rbd
export testimg1
/tmp
/img2
48 rbd snap create testimg1
--snap=snap1
49 rbd resize testimg1
--size=128 && exit 1 || true
# shrink should fail
50 rbd resize testimg1
--size=128 --allow-shrink
51 rbd
export testimg1
/tmp
/img3
54 rbd info testimg1 |
grep 'size 128 MiB'
55 rbd info
--snap=snap1 testimg1 |
grep 'size 256 MiB'
58 rm -rf /tmp
/diff-testimg1-1
/tmp
/diff-testimg1-2
59 rbd export-diff testimg1
--snap=snap1
/tmp
/diff-testimg1-1
60 rbd export-diff testimg1
--from-snap=snap1
/tmp
/diff-testimg1-2
63 rbd create
$RBD_CREATE_ARGS --size=1 testimg-diff1
64 rbd import-diff
--sparse-size 8K
/tmp
/diff-testimg1-1 testimg-diff1
65 rbd import-diff
--sparse-size 8K
/tmp
/diff-testimg1-2 testimg-diff1
68 rbd info testimg1 |
grep 'size 128 MiB'
69 rbd info
--snap=snap1 testimg1 |
grep 'size 256 MiB'
70 rbd info testimg-diff1 |
grep 'size 128 MiB'
71 rbd info
--snap=snap1 testimg-diff1 |
grep 'size 256 MiB'
74 rbd copy testimg1
--snap=snap1 testimg2
75 rbd copy testimg1 testimg3
76 rbd copy testimg-diff1
--sparse-size 768K
--snap=snap1 testimg-diff2
77 rbd copy testimg-diff1
--sparse-size 768K testimg-diff3
80 rbd info testimg2 |
grep 'size 256 MiB'
81 rbd info testimg3 |
grep 'size 128 MiB'
82 rbd info testimg-diff2 |
grep 'size 256 MiB'
83 rbd info testimg-diff3 |
grep 'size 128 MiB'
86 rbd deep copy testimg1 testimg4
87 rbd deep copy testimg1
--snap=snap1 testimg5
88 rbd info testimg4 |
grep 'size 128 MiB'
89 rbd info testimg5 |
grep 'size 256 MiB'
90 rbd snap
ls testimg4 |
grep -v 'SNAPID' |
wc -l |
grep 1
91 rbd snap
ls testimg4 |
grep '.*snap1.*'
93 rbd
export testimg1
/tmp
/img1.new
94 rbd
export testimg2
/tmp
/img2.new
95 rbd
export testimg3
/tmp
/img3.new
96 rbd
export testimg-diff1
/tmp
/img-diff1.new
97 rbd
export testimg-diff2
/tmp
/img-diff2.new
98 rbd
export testimg-diff3
/tmp
/img-diff3.new
100 cmp /tmp
/img2
/tmp
/img2.new
101 cmp /tmp
/img3
/tmp
/img3.new
102 cmp /tmp
/img2
/tmp
/img-diff2.new
103 cmp /tmp
/img3
/tmp
/img-diff3.new
106 rbd snap rollback
--snap=snap1 testimg1
107 rbd snap rollback
--snap=snap1 testimg-diff1
108 rbd info testimg1 |
grep 'size 256 MiB'
109 rbd info testimg-diff1 |
grep 'size 256 MiB'
110 rbd
export testimg1
/tmp
/img1.snap1
111 rbd
export testimg-diff1
/tmp
/img-diff1.snap1
112 cmp /tmp
/img2
/tmp
/img1.snap1
113 cmp /tmp
/img2
/tmp
/img-diff1.snap1
115 # test create, copy of zero-length images
118 rbd create testimg2
-s 0
119 rbd
cp testimg2 testimg3
120 rbd deep
cp testimg2 testimg6
123 rbd snap
rm --snap=snap1 testimg1
124 rbd snap
rm --snap=snap1 testimg-diff1
125 rbd info
--snap=snap1 testimg1
2>&1 |
grep 'error setting snapshot context: (2) No such file or directory'
126 rbd info
--snap=snap1 testimg-diff1
2>&1 |
grep 'error setting snapshot context: (2) No such file or directory'
129 rbd sparsify testimg1
136 echo "testing rename..."
139 rbd create
--image-format 1 -s 1 foo
140 rbd create
--image-format 2 -s 1 bar
142 rbd rename foo2 bar
2>&1 |
grep exists
144 rbd rename bar2 foo2
2>&1 |
grep exists
146 ceph osd pool create rbd2
8
148 rbd create
-p rbd2
-s 1 foo
149 rbd rename rbd
2/foo rbd
2/bar
150 rbd
-p rbd2
ls |
grep bar
151 rbd rename rbd
2/bar foo
152 rbd rename
--pool rbd2 foo bar
153 ! rbd rename rbd
2/bar
--dest-pool rbd foo
154 rbd rename
--pool rbd2 bar
--dest-pool rbd2 foo
155 rbd
-p rbd2
ls |
grep foo
156 ceph osd pool
rm rbd2 rbd2
--yes-i-really-really-mean-it
165 rbd create
--image-format 1 -s 1 test1
166 rbd create
--image-format 1 -s 1 test2
169 rbd
ls |
wc -l |
grep 2
170 # look for fields in output of ls -l without worrying about space
171 rbd
ls -l |
grep 'test1.*1 MiB.*1'
172 rbd
ls -l |
grep 'test2.*1 MiB.*1'
177 rbd create
--image-format 2 -s 1 test1
178 rbd create
--image-format 2 -s 1 test2
181 rbd
ls |
wc -l |
grep 2
182 rbd
ls -l |
grep 'test1.*1 MiB.*2'
183 rbd
ls -l |
grep 'test2.*1 MiB.*2'
188 rbd create
--image-format 2 -s 1 test1
189 rbd create
--image-format 1 -s 1 test2
192 rbd
ls |
wc -l |
grep 2
193 rbd
ls -l |
grep 'test1.*1 MiB.*2'
194 rbd
ls -l |
grep 'test2.*1 MiB.*1'
197 # test that many images can be shown by ls
198 for i
in $
(seq -w 00 99); do
199 rbd create image.
$i -s 1
201 rbd
ls |
wc -l |
grep 100
202 rbd
ls -l |
grep image |
wc -l |
grep 100
203 for i
in $
(seq -w 00 99); do
207 for i
in $
(seq -w 00 99); do
208 rbd create image.
$i --image-format 2 -s 1
210 rbd
ls |
wc -l |
grep 100
211 rbd
ls -l |
grep image |
wc -l |
grep 100
212 for i
in $
(seq -w 00 99); do
218 echo "testing remove..."
221 rbd remove
"NOT_EXIST" && exit 1 || true
# remove should fail
222 rbd create
--image-format 1 -s 1 test1
224 rbd
ls |
wc -l |
grep "^0$"
226 rbd create
--image-format 2 -s 1 test2
228 rbd
ls |
wc -l |
grep "^0$"
230 # check that remove succeeds even if it's
231 # interrupted partway through. simulate this
232 # by removing some objects manually.
234 # remove with header missing (old format)
235 rbd create
--image-format 1 -s 1 test1
236 rados
rm -p rbd test1.rbd
238 rbd
ls |
wc -l |
grep "^0$"
240 if [ $tiered -eq 0 ]; then
241 # remove with header missing
242 rbd create
--image-format 2 -s 1 test2
243 HEADER
=$
(rados
-p rbd
ls |
grep '^rbd_header')
244 rados
-p rbd
rm $HEADER
246 rbd
ls |
wc -l |
grep "^0$"
248 # remove with id missing
249 rbd create
--image-format 2 -s 1 test2
250 rados
-p rbd
rm rbd_id.test2
252 rbd
ls |
wc -l |
grep "^0$"
254 # remove with header and id missing
255 rbd create
--image-format 2 -s 1 test2
256 HEADER
=$
(rados
-p rbd
ls |
grep '^rbd_header')
257 rados
-p rbd
rm $HEADER
258 rados
-p rbd
rm rbd_id.test2
260 rbd
ls |
wc -l |
grep "^0$"
263 # remove with rbd_children object missing (and, by extension,
264 # with child not mentioned in rbd_children)
265 rbd create
--image-format 2 -s 1 test2
266 rbd snap create test2@snap
267 rbd snap protect test2@snap
268 rbd clone test2@snap clone
--rbd-default-clone-format 1
270 rados
-p rbd
rm rbd_children
272 rbd
ls |
grep clone |
wc -l |
grep '^0$'
274 rbd snap unprotect test2@snap
275 rbd snap
rm test2@snap
280 echo "testing locking..."
283 rbd create
$RBD_CREATE_ARGS -s 1 test1
284 rbd lock list test1 |
wc -l |
grep '^0$'
285 rbd lock add test1 id
286 rbd lock list test1 |
grep ' 1 '
287 LOCKER
=$
(rbd lock list test1 |
tail -n 1 |
awk '{print $1;}')
288 rbd lock remove test1 id
$LOCKER
289 rbd lock list test1 |
wc -l |
grep '^0$'
291 rbd lock add test1 id
--shared tag
292 rbd lock list test1 |
grep ' 1 '
293 rbd lock add test1 id
--shared tag
294 rbd lock list test1 |
grep ' 2 '
295 rbd lock add test1 id2
--shared tag
296 rbd lock list test1 |
grep ' 3 '
297 rbd lock list test1 |
tail -n 1 |
awk '{print $2, $1;}' |
xargs rbd lock remove test1
298 if rbd info test1 |
grep -qE "features:.*exclusive"
300 # new locking functionality requires all locks to be released
301 while [ -n "$(rbd lock list test1)" ]
303 rbd lock list test1 |
tail -n 1 |
awk '{print $2, $1;}' |
xargs rbd lock remove test1
309 test_pool_image_args
() {
310 echo "testing pool and image args..."
313 ceph osd pool delete
test test --yes-i-really-really-mean-it || true
314 ceph osd pool create
test 32
316 truncate
-s 1 /tmp
/empty
/tmp
/empty@snap
318 rbd
ls |
wc -l |
grep 0
319 rbd create
-s 1 test1
320 rbd
ls |
grep -q test1
321 rbd import
--image test2
/tmp
/empty
322 rbd
ls |
grep -q test2
323 rbd
--dest test3 import
/tmp
/empty
324 rbd
ls |
grep -q test3
325 rbd import
/tmp
/empty foo
328 # should fail due to "destination snapname specified"
329 rbd import
--dest test
/empty@snap
/tmp
/empty
&& exit 1 || true
330 rbd import
/tmp
/empty test
/empty@snap
&& exit 1 || true
331 rbd import
--image test
/empty@snap
/tmp
/empty
&& exit 1 || true
332 rbd import
/tmp
/empty@snap
&& exit 1 || true
334 rbd
ls test |
wc -l |
grep 0
335 rbd import
/tmp
/empty test
/test1
336 rbd
ls test |
grep -q test1
337 rbd
-p test import
/tmp
/empty test2
338 rbd
ls test |
grep -q test2
339 rbd
--image test3
-p test import
/tmp
/empty
340 rbd
ls test |
grep -q test3
341 rbd
--image test4
-p test import
/tmp
/empty
342 rbd
ls test |
grep -q test4
343 rbd
--dest test5
-p test import
/tmp
/empty
344 rbd
ls test |
grep -q test5
345 rbd
--dest test6
--dest-pool test import
/tmp
/empty
346 rbd
ls test |
grep -q test6
347 rbd
--image test7
--dest-pool test import
/tmp
/empty
348 rbd
ls test |
grep -q test7
349 rbd
--image test
/test8 import
/tmp
/empty
350 rbd
ls test |
grep -q test8
351 rbd
--dest test
/test9 import
/tmp
/empty
352 rbd
ls test |
grep -q test9
353 rbd import
--pool test /tmp
/empty
354 rbd
ls test |
grep -q empty
356 # copy with no explicit pool goes to pool rbd
357 rbd copy test
/test9 test10
358 rbd
ls test |
grep -qv test10
359 rbd
ls |
grep -q test10
360 rbd copy test
/test9 test
/test10
361 rbd
ls test |
grep -q test10
362 rbd copy
--pool test test10
--dest-pool test test11
363 rbd
ls test |
grep -q test11
364 rbd copy
--dest-pool rbd
--pool test test11 test12
366 rbd
ls test |
grep -qv test12
368 rm -f /tmp
/empty
/tmp
/empty@snap
369 ceph osd pool delete
test test --yes-i-really-really-mean-it
371 for f
in foo test1 test10 test12 test2 test3
; do
377 echo "testing clone..."
379 rbd create test1
$RBD_CREATE_ARGS -s 1
380 rbd snap create test1@s1
381 rbd snap protect test1@s1
383 ceph osd pool create rbd2
8
385 rbd clone test1@s1 rbd
2/clone
386 rbd
-p rbd2
ls |
grep clone
387 rbd
-p rbd2
ls -l |
grep clone |
grep test1@s1
388 rbd
ls |
grep -v clone
389 rbd flatten rbd
2/clone
390 rbd snap create rbd
2/clone@s1
391 rbd snap protect rbd
2/clone@s1
392 rbd clone rbd
2/clone@s1 clone2
394 rbd
ls -l |
grep clone2 |
grep rbd
2/clone@s1
395 rbd
-p rbd2
ls |
grep -v clone2
398 rbd snap unprotect rbd
2/clone@s1
399 rbd snap
rm rbd
2/clone@s1
401 rbd snap unprotect test1@s1
404 ceph osd pool
rm rbd2 rbd2
--yes-i-really-really-mean-it
408 echo "testing trash..."
411 rbd create
$RBD_CREATE_ARGS -s 1 test1
412 rbd create
$RBD_CREATE_ARGS -s 1 test2
415 rbd
ls |
wc -l |
grep 2
416 rbd
ls -l |
grep 'test1.*2.*'
417 rbd
ls -l |
grep 'test2.*2.*'
421 rbd
ls |
wc -l |
grep 1
422 rbd
ls -l |
grep 'test2.*2.*'
424 rbd trash
ls |
grep test1
425 rbd trash
ls |
wc -l |
grep 1
426 rbd trash
ls -l |
grep 'test1.*USER.*'
427 rbd trash
ls -l |
grep -v 'protected until'
429 ID
=`rbd trash ls | cut -d ' ' -f 1`
433 ID
=`rbd trash ls | cut -d ' ' -f 1`
434 rbd info
--image-id $ID |
grep "rbd image 'test2'"
436 rbd trash restore
$ID
438 rbd
ls |
wc -l |
grep 1
439 rbd
ls -l |
grep 'test2.*2.*'
441 rbd trash
mv test2
--expires-at "3600 sec"
442 rbd trash
ls |
grep test2
443 rbd trash
ls |
wc -l |
grep 1
444 rbd trash
ls -l |
grep 'test2.*USER.*protected until'
446 rbd trash
rm $ID 2>&1 |
grep 'Deferment time has not expired'
447 rbd trash
rm --image-id $ID --force
449 rbd create
$RBD_CREATE_ARGS -s 1 test1
450 rbd snap create test1@snap1
451 rbd snap protect test1@snap1
454 rbd trash
ls |
grep test1
455 rbd trash
ls |
wc -l |
grep 1
456 rbd trash
ls -l |
grep 'test1.*USER.*'
457 rbd trash
ls -l |
grep -v 'protected until'
459 ID
=`rbd trash ls | cut -d ' ' -f 1`
460 rbd snap
ls --image-id $ID |
grep -v 'SNAPID' |
wc -l |
grep 1
461 rbd snap
ls --image-id $ID |
grep '.*snap1.*'
463 rbd snap unprotect
--image-id $ID --snap snap1
464 rbd snap
rm --image-id $ID --snap snap1
465 rbd snap
ls --image-id $ID |
grep -v 'SNAPID' |
wc -l |
grep 0
467 rbd trash restore
$ID
468 rbd snap create test1@snap1
469 rbd snap create test1@snap2
470 rbd snap
ls --image-id $ID |
grep -v 'SNAPID' |
wc -l |
grep 2
471 rbd snap purge
--image-id $ID
472 rbd snap
ls --image-id $ID |
grep -v 'SNAPID' |
wc -l |
grep 0
474 rbd
rm --rbd_move_to_trash_on_remove=true
--rbd_move_to_trash_on_remove_expire_seconds=3600 test1
475 rbd trash
ls |
grep test1
476 rbd trash
ls |
wc -l |
grep 1
477 rbd trash
ls -l |
grep 'test1.*USER.*protected until'
478 rbd trash
rm $ID 2>&1 |
grep 'Deferment time has not expired'
479 rbd trash
rm --image-id $ID --force
485 echo "testing trash purge..."
488 rbd trash
ls |
wc -l |
grep 0
491 rbd create
$RBD_CREATE_ARGS --size 256 testimg1
492 rbd create
$RBD_CREATE_ARGS --size 256 testimg2
493 rbd trash
mv testimg1
494 rbd trash
mv testimg2
495 rbd trash
ls |
wc -l |
grep 2
497 rbd trash
ls |
wc -l |
grep 0
499 rbd create
$RBD_CREATE_ARGS --size 256 testimg1
500 rbd create
$RBD_CREATE_ARGS --size 256 testimg2
501 rbd trash
mv testimg1
--expires-at "1 hour"
502 rbd trash
mv testimg2
--expires-at "3 hours"
503 rbd trash
ls |
wc -l |
grep 2
505 rbd trash
ls |
wc -l |
grep 2
506 rbd trash purge
--expired-before "now + 2 hours"
507 rbd trash
ls |
wc -l |
grep 1
508 rbd trash
ls |
grep testimg2
509 rbd trash purge
--expired-before "now + 4 hours"
510 rbd trash
ls |
wc -l |
grep 0
512 rbd create
$RBD_CREATE_ARGS --size 256 testimg1
513 rbd snap create testimg1@snap
# pin testimg1
514 rbd create
$RBD_CREATE_ARGS --size 256 testimg2
515 rbd create
$RBD_CREATE_ARGS --size 256 testimg3
516 rbd trash
mv testimg1
517 rbd trash
mv testimg2
518 rbd trash
mv testimg3
519 rbd trash
ls |
wc -l |
grep 3
520 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
521 rbd trash
ls |
wc -l |
grep 1
522 rbd trash
ls |
grep testimg1
523 ID
=$
(rbd trash
ls |
awk '{ print $1 }')
524 rbd snap purge
--image-id $ID
526 rbd trash
ls |
wc -l |
grep 0
528 rbd create
$RBD_CREATE_ARGS --size 256 testimg1
529 rbd create
$RBD_CREATE_ARGS --size 256 testimg2
530 rbd snap create testimg2@snap
# pin testimg2
531 rbd create
$RBD_CREATE_ARGS --size 256 testimg3
532 rbd trash
mv testimg1
533 rbd trash
mv testimg2
534 rbd trash
mv testimg3
535 rbd trash
ls |
wc -l |
grep 3
536 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
537 rbd trash
ls |
wc -l |
grep 1
538 rbd trash
ls |
grep testimg2
539 ID
=$
(rbd trash
ls |
awk '{ print $1 }')
540 rbd snap purge
--image-id $ID
542 rbd trash
ls |
wc -l |
grep 0
544 rbd create
$RBD_CREATE_ARGS --size 256 testimg1
545 rbd create
$RBD_CREATE_ARGS --size 256 testimg2
546 rbd create
$RBD_CREATE_ARGS --size 256 testimg3
547 rbd snap create testimg3@snap
# pin testimg3
548 rbd trash
mv testimg1
549 rbd trash
mv testimg2
550 rbd trash
mv testimg3
551 rbd trash
ls |
wc -l |
grep 3
552 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
553 rbd trash
ls |
wc -l |
grep 1
554 rbd trash
ls |
grep testimg3
555 ID
=$
(rbd trash
ls |
awk '{ print $1 }')
556 rbd snap purge
--image-id $ID
558 rbd trash
ls |
wc -l |
grep 0
560 # test purging a clone with a chain of parents
561 rbd create
$RBD_CREATE_ARGS --size 256 testimg1
562 rbd snap create testimg1@snap
563 rbd clone
--rbd-default-clone-format=2 testimg1@snap testimg2
564 rbd snap
rm testimg1@snap
565 rbd create
$RBD_CREATE_ARGS --size 256 testimg3
566 rbd snap create testimg2@snap
567 rbd clone
--rbd-default-clone-format=2 testimg2@snap testimg4
568 rbd clone
--rbd-default-clone-format=2 testimg2@snap testimg5
569 rbd snap
rm testimg2@snap
570 rbd snap create testimg4@snap
571 rbd clone
--rbd-default-clone-format=2 testimg4@snap testimg6
572 rbd snap
rm testimg4@snap
573 rbd trash
mv testimg1
574 rbd trash
mv testimg2
575 rbd trash
mv testimg3
576 rbd trash
mv testimg4
577 rbd trash
ls |
wc -l |
grep 4
578 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
579 rbd trash
ls |
wc -l |
grep 3
580 rbd trash
ls |
grep testimg1
581 rbd trash
ls |
grep testimg2
582 rbd trash
ls |
grep testimg4
583 rbd trash
mv testimg6
584 rbd trash
ls |
wc -l |
grep 4
585 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
586 rbd trash
ls |
wc -l |
grep 2
587 rbd trash
ls |
grep testimg1
588 rbd trash
ls |
grep testimg2
589 rbd trash
mv testimg5
590 rbd trash
ls |
wc -l |
grep 3
592 rbd trash
ls |
wc -l |
grep 0
594 rbd create
$RBD_CREATE_ARGS --size 256 testimg1
595 rbd snap create testimg1@snap
596 rbd clone
--rbd-default-clone-format=2 testimg1@snap testimg2
597 rbd snap
rm testimg1@snap
598 rbd create
$RBD_CREATE_ARGS --size 256 testimg3
599 rbd snap create testimg3@snap
# pin testimg3
600 rbd snap create testimg2@snap
601 rbd clone
--rbd-default-clone-format=2 testimg2@snap testimg4
602 rbd clone
--rbd-default-clone-format=2 testimg2@snap testimg5
603 rbd snap
rm testimg2@snap
604 rbd snap create testimg4@snap
605 rbd clone
--rbd-default-clone-format=2 testimg4@snap testimg6
606 rbd snap
rm testimg4@snap
607 rbd trash
mv testimg1
608 rbd trash
mv testimg2
609 rbd trash
mv testimg3
610 rbd trash
mv testimg4
611 rbd trash
ls |
wc -l |
grep 4
612 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
613 rbd trash
ls |
wc -l |
grep 4
614 rbd trash
mv testimg6
615 rbd trash
ls |
wc -l |
grep 5
616 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
617 rbd trash
ls |
wc -l |
grep 3
618 rbd trash
ls |
grep testimg1
619 rbd trash
ls |
grep testimg2
620 rbd trash
ls |
grep testimg3
621 rbd trash
mv testimg5
622 rbd trash
ls |
wc -l |
grep 4
623 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
624 rbd trash
ls |
wc -l |
grep 1
625 rbd trash
ls |
grep testimg3
626 ID
=$
(rbd trash
ls |
awk '{ print $1 }')
627 rbd snap purge
--image-id $ID
629 rbd trash
ls |
wc -l |
grep 0
631 # test purging a clone with a chain of auto-delete parents
632 rbd create
$RBD_CREATE_ARGS --size 256 testimg1
633 rbd snap create testimg1@snap
634 rbd clone
--rbd-default-clone-format=2 testimg1@snap testimg2
635 rbd snap
rm testimg1@snap
636 rbd create
$RBD_CREATE_ARGS --size 256 testimg3
637 rbd snap create testimg2@snap
638 rbd clone
--rbd-default-clone-format=2 testimg2@snap testimg4
639 rbd clone
--rbd-default-clone-format=2 testimg2@snap testimg5
640 rbd snap
rm testimg2@snap
641 rbd snap create testimg4@snap
642 rbd clone
--rbd-default-clone-format=2 testimg4@snap testimg6
643 rbd snap
rm testimg4@snap
644 rbd
rm --rbd_move_parent_to_trash_on_remove=true testimg1
645 rbd
rm --rbd_move_parent_to_trash_on_remove=true testimg2
646 rbd trash
mv testimg3
647 rbd
rm --rbd_move_parent_to_trash_on_remove=true testimg4
648 rbd trash
ls |
wc -l |
grep 4
649 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
650 rbd trash
ls |
wc -l |
grep 3
651 rbd trash
ls |
grep testimg1
652 rbd trash
ls |
grep testimg2
653 rbd trash
ls |
grep testimg4
654 rbd trash
mv testimg6
655 rbd trash
ls |
wc -l |
grep 4
656 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
657 rbd trash
ls |
wc -l |
grep 2
658 rbd trash
ls |
grep testimg1
659 rbd trash
ls |
grep testimg2
660 rbd trash
mv testimg5
661 rbd trash
ls |
wc -l |
grep 3
663 rbd trash
ls |
wc -l |
grep 0
665 rbd create
$RBD_CREATE_ARGS --size 256 testimg1
666 rbd snap create testimg1@snap
667 rbd clone
--rbd-default-clone-format=2 testimg1@snap testimg2
668 rbd snap
rm testimg1@snap
669 rbd create
$RBD_CREATE_ARGS --size 256 testimg3
670 rbd snap create testimg3@snap
# pin testimg3
671 rbd snap create testimg2@snap
672 rbd clone
--rbd-default-clone-format=2 testimg2@snap testimg4
673 rbd clone
--rbd-default-clone-format=2 testimg2@snap testimg5
674 rbd snap
rm testimg2@snap
675 rbd snap create testimg4@snap
676 rbd clone
--rbd-default-clone-format=2 testimg4@snap testimg6
677 rbd snap
rm testimg4@snap
678 rbd
rm --rbd_move_parent_to_trash_on_remove=true testimg1
679 rbd
rm --rbd_move_parent_to_trash_on_remove=true testimg2
680 rbd trash
mv testimg3
681 rbd
rm --rbd_move_parent_to_trash_on_remove=true testimg4
682 rbd trash
ls |
wc -l |
grep 4
683 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
684 rbd trash
ls |
wc -l |
grep 4
685 rbd trash
mv testimg6
686 rbd trash
ls |
wc -l |
grep 5
687 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
688 rbd trash
ls |
wc -l |
grep 3
689 rbd trash
ls |
grep testimg1
690 rbd trash
ls |
grep testimg2
691 rbd trash
ls |
grep testimg3
692 rbd trash
mv testimg5
693 rbd trash
ls |
wc -l |
grep 4
694 rbd trash purge
2>&1 |
grep 'some expired images could not be removed'
695 rbd trash
ls |
wc -l |
grep 1
696 rbd trash
ls |
grep testimg3
697 ID
=$
(rbd trash
ls |
awk '{ print $1 }')
698 rbd snap purge
--image-id $ID
700 rbd trash
ls |
wc -l |
grep 0
703 test_deep_copy_clone
() {
704 echo "testing deep copy clone..."
707 rbd create testimg1
$RBD_CREATE_ARGS --size 256
708 rbd snap create testimg1
--snap=snap1
709 rbd snap protect testimg1@snap1
710 rbd clone testimg1@snap1 testimg2
711 rbd snap create testimg2@snap2
712 rbd deep copy testimg2 testimg3
713 rbd info testimg3 |
grep 'size 256 MiB'
714 rbd info testimg3 |
grep 'parent: rbd/testimg1@snap1'
715 rbd snap
ls testimg3 |
grep -v 'SNAPID' |
wc -l |
grep 1
716 rbd snap
ls testimg3 |
grep '.*snap2.*'
717 rbd info testimg2 |
grep 'features:.*deep-flatten' || rbd snap
rm testimg2@snap2
718 rbd info testimg3 |
grep 'features:.*deep-flatten' || rbd snap
rm testimg3@snap2
721 rbd snap unprotect testimg1@snap1
722 rbd snap purge testimg2
723 rbd snap purge testimg3
727 rbd snap protect testimg1@snap1
728 rbd clone testimg1@snap1 testimg2
729 rbd snap create testimg2@snap2
730 rbd deep copy
--flatten testimg2 testimg3
731 rbd info testimg3 |
grep 'size 256 MiB'
732 rbd info testimg3 |
grep -v 'parent:'
733 rbd snap
ls testimg3 |
grep -v 'SNAPID' |
wc -l |
grep 1
734 rbd snap
ls testimg3 |
grep '.*snap2.*'
735 rbd info testimg2 |
grep 'features:.*deep-flatten' || rbd snap
rm testimg2@snap2
737 rbd snap unprotect testimg1@snap1
743 echo "testing clone v2..."
746 rbd create
$RBD_CREATE_ARGS -s 1 test1
747 rbd snap create test1@
1
748 rbd clone
--rbd-default-clone-format=1 test1@
1 test2
&& exit 1 || true
749 rbd clone
--rbd-default-clone-format=2 test1@
1 test2
750 rbd clone
--rbd-default-clone-format=2 test1@
1 test3
752 rbd snap protect test1@
1
753 rbd clone
--rbd-default-clone-format=1 test1@
1 test4
755 rbd children test1@
1 |
sort |
tr '\n' ' ' |
grep -E "test2.*test3.*test4"
756 rbd children
--descendants test1 |
sort |
tr '\n' ' ' |
grep -E "test2.*test3.*test4"
759 rbd snap unprotect test1@
1
761 rbd snap remove test1@
1
762 rbd snap list
--all test1 |
grep -E "trash \(1\) *$"
764 rbd snap create test1@
2
765 rbd
rm test1
2>&1 |
grep 'image has snapshots'
768 rbd
rm test1
2>&1 |
grep 'linked clones'
771 rbd
rm test1
2>&1 |
grep 'linked clones'
774 rbd snap list
--all test1 |
wc -l |
grep '^0$'
778 rbd create
$RBD_CREATE_ARGS -s 1 test1
779 rbd snap create test1@
1
780 rbd snap create test1@
2
781 rbd clone test1@
1 test2
--rbd-default-clone-format 2
782 rbd clone test1@
2 test3
--rbd-default-clone-format 2
785 expect_fail rbd
rm test1
786 rbd
rm test1
--rbd-move-parent-to-trash-on-remove=true
787 rbd trash
ls -a |
grep test1
789 rbd trash
ls -a |
grep test1
791 rbd trash
ls -a | expect_fail
grep test1
794 test_thick_provision
() {
795 echo "testing thick provision..."
798 # Try to create small and large thick-pro image and
799 # check actual size. (64M and 4G)
801 # Small thick-pro image test
802 rbd create
$RBD_CREATE_ARGS --thick-provision -s 64M test1
805 while [ $count -lt 10 ]
807 rbd du|
grep test1|
tr -s " "|cut
-d " " -f 4-5|
grep '^64 MiB' && ret
=$?
812 count
=`expr $count + 1`
821 rbd
ls |
grep test1 |
wc -l |
grep '^0$'
823 # Large thick-pro image test
824 rbd create
$RBD_CREATE_ARGS --thick-provision -s 4G test1
827 while [ $count -lt 10 ]
829 rbd du|
grep test1|
tr -s " "|cut
-d " " -f 4-5|
grep '^4 GiB' && ret
=$?
834 count
=`expr $count + 1`
843 rbd
ls |
grep test1 |
wc -l |
grep '^0$'
847 echo "testing namespace..."
850 rbd namespace
ls |
wc -l |
grep '^0$'
851 rbd namespace create rbd
/test1
852 rbd namespace create
--pool rbd
--namespace test2
853 rbd namespace create
--namespace test3
854 expect_fail rbd namespace create rbd
/test3
856 rbd namespace list |
grep 'test' |
wc -l |
grep '^3$'
858 expect_fail rbd namespace remove
--pool rbd missing
860 rbd create
$RBD_CREATE_ARGS --size 1G rbd
/test1/image1
862 # default test1 ns to test2 ns clone
863 rbd bench
--io-type write --io-pattern rand
--io-total 32M
--io-size 4K rbd
/test1/image1
864 rbd snap create rbd
/test1/image1@
1
865 rbd clone
--rbd-default-clone-format 2 rbd
/test1/image1@
1 rbd
/test2/image1
866 rbd snap
rm rbd
/test1/image1@
1
867 cmp <(rbd
export rbd
/test1/image1
-) <(rbd
export rbd
/test2/image1
-)
868 rbd
rm rbd
/test2/image1
870 # default ns to test1 ns clone
871 rbd create
$RBD_CREATE_ARGS --size 1G rbd
/image2
872 rbd bench
--io-type write --io-pattern rand
--io-total 32M
--io-size 4K rbd
/image2
873 rbd snap create rbd
/image2@
1
874 rbd clone
--rbd-default-clone-format 2 rbd
/image2@
1 rbd
/test2/image2
875 rbd snap
rm rbd
/image2@
1
876 cmp <(rbd
export rbd
/image2
-) <(rbd
export rbd
/test2/image2
-)
877 expect_fail rbd
rm rbd
/image2
878 rbd
rm rbd
/test2/image2
881 # v1 clones are supported within the same namespace
882 rbd create
$RBD_CREATE_ARGS --size 1G rbd
/test1/image3
883 rbd snap create rbd
/test1/image3@
1
884 rbd snap protect rbd
/test1/image3@
1
885 rbd clone
--rbd-default-clone-format 1 rbd
/test1/image3@
1 rbd
/test1/image4
886 rbd
rm rbd
/test1/image4
887 rbd snap unprotect rbd
/test1/image3@
1
888 rbd snap
rm rbd
/test1/image3@
1
889 rbd
rm rbd
/test1/image3
891 rbd create
$RBD_CREATE_ARGS --size 1G
--namespace test1 image2
892 expect_fail rbd namespace remove rbd
/test1
894 rbd group create rbd
/test1/group1
895 rbd group image add rbd
/test1/group1 rbd
/test1/image1
896 rbd group
rm rbd
/test1/group1
898 rbd trash move rbd
/test1/image1
899 ID
=`rbd trash --namespace test1 ls | cut -d ' ' -f 1`
900 rbd trash
rm rbd
/test1/${ID}
902 rbd remove rbd
/test1/image2
904 rbd namespace remove
--pool rbd
--namespace test1
905 rbd namespace remove
--namespace test3
907 rbd namespace list |
grep 'test' |
wc -l |
grep '^1$'
908 rbd namespace remove rbd
/test2
911 get_migration_state
() {
914 rbd
--format xml status
$image |
915 $XMLSTARLET sel
-t -v '//status/migration/state'
919 echo "testing migration..."
921 ceph osd pool create rbd2
8
924 # Convert to new format
925 rbd create
--image-format 1 -s 128M test1
926 rbd info test1 |
grep 'format: 1'
927 rbd migration prepare test1
--image-format 2
928 test "$(get_migration_state test1)" = prepared
929 rbd info test1 |
grep 'format: 2'
930 rbd
rm test1
&& exit 1 || true
931 rbd migration execute test1
932 test "$(get_migration_state test1)" = executed
933 rbd migration commit test1
934 get_migration_state test1
&& exit 1 || true
936 # Enable layering (and some other features)
937 rbd info test1 |
grep 'features: .*layering' && exit 1 || true
938 rbd migration prepare test1
--image-feature \
939 layering
,exclusive-lock
,object-map
,fast-diff
,deep-flatten
940 rbd info test1 |
grep 'features: .*layering'
941 rbd migration execute test1
942 rbd migration commit test1
944 # Migration to other pool
945 rbd migration prepare test1 rbd
2/test1
946 test "$(get_migration_state rbd2/test1)" = prepared
947 rbd
ls |
wc -l |
grep '^0$'
948 rbd
-p rbd2
ls |
grep test1
949 rbd migration execute test1
950 test "$(get_migration_state rbd2/test1)" = executed
951 rbd
rm rbd
2/test1
&& exit 1 || true
952 rbd migration commit test1
954 # Migration to other namespace
955 rbd namespace create rbd
2/ns1
956 rbd namespace create rbd
2/ns2
957 rbd migration prepare rbd
2/test1 rbd
2/ns
1/test1
958 test "$(get_migration_state rbd2/ns1/test1)" = prepared
959 rbd migration execute rbd
2/test1
960 test "$(get_migration_state rbd2/ns1/test1)" = executed
961 rbd migration commit rbd
2/test1
962 rbd migration prepare rbd
2/ns
1/test1 rbd
2/ns
2/test1
963 rbd migration execute rbd
2/ns
2/test1
964 rbd migration commit rbd
2/ns
2/test1
967 rbd create
-s 128M test1
968 rbd migration prepare test1
--data-pool rbd2
969 rbd info test1 |
grep 'data_pool: rbd2'
970 rbd migration execute test1
971 rbd migration commit test1
974 rbd migration prepare test1
975 expect_fail rbd trash
mv test1
976 ID
=`rbd trash ls -a | cut -d ' ' -f 1`
977 expect_fail rbd trash
rm $ID
978 expect_fail rbd trash restore
$ID
979 rbd migration abort test1
983 dd if=/dev
/urandom bs
=1M count
=1 | rbd
--image-format 2 import
- test1
984 md5sum=$
(rbd
export test1
- |
md5sum)
985 rbd snap create test1@snap1
986 rbd snap protect test1@snap1
987 rbd snap create test1@snap2
988 rbd clone test1@snap1 clone_v1
--rbd_default_clone_format=1
989 rbd clone test1@snap2 clone_v2
--rbd_default_clone_format=2
990 rbd info clone_v1 | fgrep
'parent: rbd/test1@snap1'
991 rbd info clone_v2 | fgrep
'parent: rbd/test1@snap2'
992 rbd info clone_v2 |
grep 'op_features: clone-child'
993 test "$(rbd export clone_v1 - | md5sum)" = "${md5sum}"
994 test "$(rbd export clone_v2 - | md5sum)" = "${md5sum}"
995 test "$(rbd children test1@snap1)" = "rbd/clone_v1"
996 test "$(rbd children test1@snap2)" = "rbd/clone_v2"
997 rbd migration prepare test1 rbd
2/test2
998 rbd info clone_v1 | fgrep
'parent: rbd2/test2@snap1'
999 rbd info clone_v2 | fgrep
'parent: rbd2/test2@snap2'
1000 rbd info clone_v2 | fgrep
'op_features: clone-child'
1001 test "$(rbd children rbd2/test2@snap1)" = "rbd/clone_v1"
1002 test "$(rbd children rbd2/test2@snap2)" = "rbd/clone_v2"
1003 rbd migration execute test1
1004 expect_fail rbd migration commit test1
1005 rbd migration commit test1
--force
1006 test "$(rbd export clone_v1 - | md5sum)" = "${md5sum}"
1007 test "$(rbd export clone_v2 - | md5sum)" = "${md5sum}"
1008 rbd migration prepare rbd
2/test2 test1
1009 rbd info clone_v1 | fgrep
'parent: rbd/test1@snap1'
1010 rbd info clone_v2 | fgrep
'parent: rbd/test1@snap2'
1011 rbd info clone_v2 | fgrep
'op_features: clone-child'
1012 test "$(rbd children test1@snap1)" = "rbd/clone_v1"
1013 test "$(rbd children test1@snap2)" = "rbd/clone_v2"
1014 rbd migration execute test1
1015 expect_fail rbd migration commit test1
1016 rbd migration commit test1
--force
1017 test "$(rbd export clone_v1 - | md5sum)" = "${md5sum}"
1018 test "$(rbd export clone_v2 - | md5sum)" = "${md5sum}"
1021 rbd snap unprotect test1@snap1
1022 rbd snap purge test1
1025 for format
in 1 2; do
1026 # Abort migration after successful prepare
1027 rbd create
-s 128M
--image-format ${format} test2
1028 rbd migration prepare test2
--data-pool rbd2
1029 rbd bench
--io-type write --io-size 1024 --io-total 1024 test2
1030 rbd migration abort test2
1031 rbd bench
--io-type write --io-size 1024 --io-total 1024 test2
1034 # Abort migration after successful execute
1035 rbd create
-s 128M
--image-format ${format} test2
1036 rbd migration prepare test2
--data-pool rbd2
1037 rbd bench
--io-type write --io-size 1024 --io-total 1024 test2
1038 rbd migration execute test2
1039 rbd migration abort test2
1040 rbd bench
--io-type write --io-size 1024 --io-total 1024 test2
1043 # Migration is automatically aborted if prepare failed
1044 rbd create
-s 128M
--image-format ${format} test2
1045 rbd migration prepare test2
--data-pool INVALID_DATA_POOL
&& exit 1 || true
1046 rbd bench
--io-type write --io-size 1024 --io-total 1024 test2
1049 # Abort migration to other pool
1050 rbd create
-s 128M
--image-format ${format} test2
1051 rbd migration prepare test2 rbd
2/test2
1052 rbd bench
--io-type write --io-size 1024 --io-total 1024 rbd
2/test2
1053 rbd migration abort test2
1054 rbd bench
--io-type write --io-size 1024 --io-total 1024 test2
1057 # The same but abort using destination image
1058 rbd create
-s 128M
--image-format ${format} test2
1059 rbd migration prepare test2 rbd
2/test2
1060 rbd migration abort rbd
2/test2
1061 rbd bench
--io-type write --io-size 1024 --io-total 1024 test2
1064 test $format = 1 && continue
1066 # Abort migration to other namespace
1067 rbd create
-s 128M
--image-format ${format} test2
1068 rbd migration prepare test2 rbd
2/ns
1/test3
1069 rbd bench
--io-type write --io-size 1024 --io-total 1024 rbd
2/ns
1/test3
1070 rbd migration abort test2
1071 rbd bench
--io-type write --io-size 1024 --io-total 1024 test2
1076 ceph osd pool
rm rbd2 rbd2
--yes-i-really-really-mean-it
1080 echo "testing config..."
1083 expect_fail rbd config global
set osd rbd_cache true
1084 expect_fail rbd config global
set global debug_ms
10
1085 expect_fail rbd config global
set global rbd_UNKNOWN false
1086 expect_fail rbd config global
set global rbd_cache INVALID
1087 rbd config global
set global rbd_cache false
1088 rbd config global
set client rbd_cache true
1089 rbd config global
set client
.123 rbd_cache false
1090 rbd config global get global rbd_cache |
grep '^false$'
1091 rbd config global get client rbd_cache |
grep '^true$'
1092 rbd config global get client
.123 rbd_cache |
grep '^false$'
1093 expect_fail rbd config global get client.UNKNOWN rbd_cache
1094 rbd config global list global |
grep '^rbd_cache * false * global *$'
1095 rbd config global list client |
grep '^rbd_cache * true * client *$'
1096 rbd config global list client
.123 |
grep '^rbd_cache * false * client.123 *$'
1097 rbd config global list client.UNKNOWN |
grep '^rbd_cache * true * client *$'
1098 rbd config global
rm client rbd_cache
1099 expect_fail rbd config global get client rbd_cache
1100 rbd config global list client |
grep '^rbd_cache * false * global *$'
1101 rbd config global
rm client
.123 rbd_cache
1102 rbd config global
rm global rbd_cache
1104 rbd config pool
set rbd rbd_cache true
1105 rbd config pool list rbd |
grep '^rbd_cache * true * pool *$'
1106 rbd config pool get rbd rbd_cache |
grep '^true$'
1108 rbd create
$RBD_CREATE_ARGS -s 1 test1
1110 rbd config image list rbd
/test1 |
grep '^rbd_cache * true * pool *$'
1111 rbd config image
set rbd
/test1 rbd_cache false
1112 rbd config image list rbd
/test1 |
grep '^rbd_cache * false * image *$'
1113 rbd config image get rbd
/test1 rbd_cache |
grep '^false$'
1114 rbd config image remove rbd
/test1 rbd_cache
1115 expect_fail rbd config image get rbd
/test1 rbd_cache
1116 rbd config image list rbd
/test1 |
grep '^rbd_cache * true * pool *$'
1118 rbd config pool remove rbd rbd_cache
1119 expect_fail rbd config pool get rbd rbd_cache
1120 rbd config pool list rbd |
grep '^rbd_cache * true * config *$'
1125 test_trash_purge_schedule
() {
1126 echo "testing trash purge schedule..."
1128 ceph osd pool create rbd2
8
1130 rbd namespace create rbd
2/ns1
1132 test "$(ceph rbd trash purge schedule list)" = "{}"
1133 ceph rbd trash purge schedule status | fgrep
'"scheduled": []'
1135 expect_fail rbd trash purge schedule
ls
1136 test "$(rbd trash purge schedule ls -R --format json)" = "[]"
1138 rbd trash purge schedule add
-p rbd
1d
01:30
1140 rbd trash purge schedule
ls -p rbd |
grep 'every 1d starting at 01:30'
1141 expect_fail rbd trash purge schedule
ls
1142 rbd trash purge schedule
ls -R |
grep 'every 1d starting at 01:30'
1143 rbd trash purge schedule
ls -R -p rbd |
grep 'every 1d starting at 01:30'
1144 expect_fail rbd trash purge schedule
ls -p rbd2
1145 test "$(rbd trash purge schedule ls -p rbd2 -R --format json)" = "[]"
1147 rbd trash purge schedule add
-p rbd
2/ns1
2d
1148 test "$(rbd trash purge schedule ls -p rbd2 -R --format json)" != "[]"
1149 rbd trash purge schedule
ls -p rbd2
-R |
grep 'rbd2 *ns1 *every 2d'
1150 rbd trash purge schedule
rm -p rbd
2/ns1
1151 test "$(rbd trash purge schedule ls -p rbd2 -R --format json)" = "[]"
1153 for i
in `seq 12`; do
1154 test "$(rbd trash purge schedule status --format xml |
1155 $XMLSTARLET sel -t -v '//scheduled/item/pool')" = 'rbd' && break
1158 rbd trash purge schedule status
1159 test "$(rbd trash purge schedule status --format xml |
1160 $XMLSTARLET sel -t -v '//scheduled/item/pool')" = 'rbd'
1161 test "$(rbd trash purge schedule status -p rbd --format xml |
1162 $XMLSTARLET sel -t -v '//scheduled/item/pool')" = 'rbd'
1164 rbd trash purge schedule add
2d
00:17
1165 rbd trash purge schedule
ls |
grep 'every 2d starting at 00:17'
1166 rbd trash purge schedule
ls -R |
grep 'every 2d starting at 00:17'
1167 expect_fail rbd trash purge schedule
ls -p rbd2
1168 rbd trash purge schedule
ls -p rbd2
-R |
grep 'every 2d starting at 00:17'
1169 rbd trash purge schedule
ls -p rbd
2/ns1
-R |
grep 'every 2d starting at 00:17'
1170 test "$(rbd trash purge schedule ls -R -p rbd2/ns1 --format xml |
1171 $XMLSTARLET sel -t -v '//schedules/schedule/pool')" = "-"
1172 test "$(rbd trash purge schedule ls -R -p rbd2/ns1 --format xml |
1173 $XMLSTARLET sel -t -v '//schedules/schedule/namespace')" = "-"
1174 test "$(rbd trash purge schedule ls -R -p rbd2/ns1 --format xml |
1175 $XMLSTARLET sel -t -v '//schedules/schedule/items/item/start_time')" = "00:17:00"
1177 for i
in `seq 12`; do
1178 rbd trash purge schedule status
--format xml |
1179 $XMLSTARLET sel
-t -v '//scheduled/item/pool' |
grep 'rbd2' && break
1182 rbd trash purge schedule status
1183 rbd trash purge schedule status
--format xml |
1184 $XMLSTARLET sel
-t -v '//scheduled/item/pool' |
grep 'rbd2'
1185 echo $
(rbd trash purge schedule status
--format xml |
1186 $XMLSTARLET sel
-t -v '//scheduled/item/pool') |
grep 'rbd rbd2 rbd2'
1187 test "$(rbd trash purge schedule status -p rbd --format xml |
1188 $XMLSTARLET sel -t -v '//scheduled/item/pool')" = 'rbd'
1189 test "$(echo $(rbd trash purge schedule status -p rbd2 --format xml |
1190 $XMLSTARLET sel -t -v '//scheduled/item/pool'))" = 'rbd2 rbd2'
1192 test "$(echo $(rbd trash purge schedule ls -R --format xml |
1193 $XMLSTARLET sel -t -v '//schedules/schedule/items'))" = "2d00:17:00 1d01:30:00"
1195 rbd trash purge schedule add
1d
1196 rbd trash purge schedule
ls |
grep 'every 2d starting at 00:17'
1197 rbd trash purge schedule
ls |
grep 'every 1d'
1199 rbd trash purge schedule
ls -R --format xml |
1200 $XMLSTARLET sel
-t -v '//schedules/schedule/items' |
grep '2d00:17'
1202 rbd trash purge schedule
rm 1d
1203 rbd trash purge schedule
ls |
grep 'every 2d starting at 00:17'
1204 rbd trash purge schedule
rm 2d
00:17
1205 expect_fail rbd trash purge schedule
ls
1207 for p
in rbd2 rbd
2/ns1
; do
1208 rbd create
$RBD_CREATE_ARGS -s 1 rbd
2/ns
1/test1
1209 rbd trash
mv rbd
2/ns
1/test1
1210 rbd trash
ls rbd
2/ns1 |
wc -l |
grep '^1$'
1212 rbd trash purge schedule add
-p $p 1m
1213 rbd trash purge schedule list
-p rbd2
-R |
grep 'every 1m'
1214 rbd trash purge schedule list
-p rbd
2/ns1
-R |
grep 'every 1m'
1216 for i
in `seq 12`; do
1217 rbd trash
ls rbd
2/ns1 |
wc -l |
grep '^1$' ||
break
1220 rbd trash
ls rbd
2/ns1 |
wc -l |
grep '^0$'
1222 # repeat with kicked in schedule, see https://tracker.ceph.com/issues/53915
1223 rbd trash purge schedule list
-p rbd2
-R |
grep 'every 1m'
1224 rbd trash purge schedule list
-p rbd
2/ns1
-R |
grep 'every 1m'
1226 rbd trash purge schedule status |
grep 'rbd2 *ns1'
1227 rbd trash purge schedule status
-p rbd2 |
grep 'rbd2 *ns1'
1228 rbd trash purge schedule status
-p rbd
2/ns1 |
grep 'rbd2 *ns1'
1230 rbd trash purge schedule
rm -p $p 1m
1234 rbd trash purge schedule add
2m
1235 expect_fail rbd trash purge schedule add
-p rbd dummy
1236 expect_fail rbd trash purge schedule add dummy
1237 expect_fail rbd trash purge schedule remove
-p rbd dummy
1238 expect_fail rbd trash purge schedule remove dummy
1239 rbd trash purge schedule
ls -p rbd |
grep 'every 1d starting at 01:30'
1240 rbd trash purge schedule
ls |
grep 'every 2m'
1241 rbd trash purge schedule remove
-p rbd
1d
01:30
1242 rbd trash purge schedule remove
2m
1243 test "$(rbd trash purge schedule ls -R --format json)" = "[]"
1246 ceph osd pool
rm rbd2 rbd2
--yes-i-really-really-mean-it
1249 test_mirror_snapshot_schedule
() {
1250 echo "testing mirror snapshot schedule..."
1252 ceph osd pool create rbd2
8
1254 rbd namespace create rbd
2/ns1
1256 rbd mirror pool
enable rbd2 image
1257 rbd mirror pool
enable rbd
2/ns1 image
1258 rbd mirror pool peer add rbd2 cluster1
1260 test "$(ceph rbd mirror snapshot schedule list)" = "{}"
1261 ceph rbd mirror snapshot schedule status | fgrep
'"scheduled_images": []'
1263 expect_fail rbd mirror snapshot schedule
ls
1264 test "$(rbd mirror snapshot schedule ls -R --format json)" = "[]"
1266 rbd create
$RBD_CREATE_ARGS -s 1 rbd
2/ns
1/test1
1268 test "$(rbd mirror image status rbd2/ns1/test1 |
1269 grep -c mirror.primary)" = '0'
1271 rbd mirror image
enable rbd
2/ns
1/test1 snapshot
1273 test "$(rbd mirror image status rbd2/ns1/test1 |
1274 grep -c mirror.primary)" = '1'
1276 rbd mirror snapshot schedule add
-p rbd
2/ns1
--image test1
1m
1277 expect_fail rbd mirror snapshot schedule
ls
1278 rbd mirror snapshot schedule
ls -R |
grep 'rbd2 *ns1 *test1 *every 1m'
1279 expect_fail rbd mirror snapshot schedule
ls -p rbd2
1280 rbd mirror snapshot schedule
ls -p rbd2
-R |
grep 'rbd2 *ns1 *test1 *every 1m'
1281 expect_fail rbd mirror snapshot schedule
ls -p rbd
2/ns1
1282 rbd mirror snapshot schedule
ls -p rbd
2/ns1
-R |
grep 'rbd2 *ns1 *test1 *every 1m'
1283 test "$(rbd mirror snapshot schedule ls -p rbd2/ns1 --image test1)" = 'every 1m'
1285 for i
in `seq 12`; do
1286 test "$(rbd mirror image status rbd2/ns1/test1 |
1287 grep -c mirror.primary)" -gt '1' && break
1291 test "$(rbd mirror image status rbd2/ns1/test1 |
1292 grep -c mirror.primary)" -gt '1'
1294 # repeat with kicked in schedule, see https://tracker.ceph.com/issues/53915
1295 expect_fail rbd mirror snapshot schedule
ls
1296 rbd mirror snapshot schedule
ls -R |
grep 'rbd2 *ns1 *test1 *every 1m'
1297 expect_fail rbd mirror snapshot schedule
ls -p rbd2
1298 rbd mirror snapshot schedule
ls -p rbd2
-R |
grep 'rbd2 *ns1 *test1 *every 1m'
1299 expect_fail rbd mirror snapshot schedule
ls -p rbd
2/ns1
1300 rbd mirror snapshot schedule
ls -p rbd
2/ns1
-R |
grep 'rbd2 *ns1 *test1 *every 1m'
1301 test "$(rbd mirror snapshot schedule ls -p rbd2/ns1 --image test1)" = 'every 1m'
1303 rbd mirror snapshot schedule status
1304 test "$(rbd mirror snapshot schedule status --format xml |
1305 $XMLSTARLET sel -t -v '//scheduled_images/image/image')" = 'rbd2/ns1/test1'
1306 test "$(rbd mirror snapshot schedule status -p rbd2 --format xml |
1307 $XMLSTARLET sel -t -v '//scheduled_images/image/image')" = 'rbd2/ns1/test1'
1308 test "$(rbd mirror snapshot schedule status -p rbd2/ns1 --format xml |
1309 $XMLSTARLET sel -t -v '//scheduled_images/image/image')" = 'rbd2/ns1/test1'
1310 test "$(rbd mirror snapshot schedule status -p rbd2/ns1 --image test1 --format xml |
1311 $XMLSTARLET sel -t -v '//scheduled_images/image/image')" = 'rbd2/ns1/test1'
1313 rbd mirror image demote rbd
2/ns
1/test1
1314 for i
in `seq 12`; do
1315 rbd mirror snapshot schedule status |
grep 'rbd2/ns1/test1' ||
break
1318 rbd mirror snapshot schedule status | expect_fail
grep 'rbd2/ns1/test1'
1320 rbd mirror image promote rbd
2/ns
1/test1
1321 for i
in `seq 12`; do
1322 rbd mirror snapshot schedule status |
grep 'rbd2/ns1/test1' && break
1325 rbd mirror snapshot schedule status |
grep 'rbd2/ns1/test1'
1327 rbd mirror snapshot schedule add
1h
00:15
1328 test "$(rbd mirror snapshot schedule ls)" = 'every 1h starting at 00:15:00'
1329 rbd mirror snapshot schedule
ls -R |
grep 'every 1h starting at 00:15:00'
1330 rbd mirror snapshot schedule
ls -R |
grep 'rbd2 *ns1 *test1 *every 1m'
1331 expect_fail rbd mirror snapshot schedule
ls -p rbd2
1332 rbd mirror snapshot schedule
ls -p rbd2
-R |
grep 'every 1h starting at 00:15:00'
1333 rbd mirror snapshot schedule
ls -p rbd2
-R |
grep 'rbd2 *ns1 *test1 *every 1m'
1334 expect_fail rbd mirror snapshot schedule
ls -p rbd
2/ns1
1335 rbd mirror snapshot schedule
ls -p rbd
2/ns1
-R |
grep 'every 1h starting at 00:15:00'
1336 rbd mirror snapshot schedule
ls -p rbd
2/ns1
-R |
grep 'rbd2 *ns1 *test1 *every 1m'
1337 test "$(rbd mirror snapshot schedule ls -p rbd2/ns1 --image test1)" = 'every 1m'
1340 expect_fail rbd mirror snapshot schedule add dummy
1341 expect_fail rbd mirror snapshot schedule add
-p rbd
2/ns1
--image test1 dummy
1342 expect_fail rbd mirror snapshot schedule remove dummy
1343 expect_fail rbd mirror snapshot schedule remove
-p rbd
2/ns1
--image test1 dummy
1344 test "$(rbd mirror snapshot schedule ls)" = 'every 1h starting at 00:15:00'
1345 test "$(rbd mirror snapshot schedule ls -p rbd2/ns1 --image test1)" = 'every 1m'
1347 rbd
rm rbd
2/ns
1/test1
1348 for i
in `seq 12`; do
1349 rbd mirror snapshot schedule status |
grep 'rbd2/ns1/test1' ||
break
1352 rbd mirror snapshot schedule status | expect_fail
grep 'rbd2/ns1/test1'
1354 rbd mirror snapshot schedule remove
1355 test "$(rbd mirror snapshot schedule ls -R --format json)" = "[]"
1358 ceph osd pool
rm rbd2 rbd2
--yes-i-really-really-mean-it
1361 test_perf_image_iostat
() {
1362 echo "testing perf image iostat..."
1365 ceph osd pool create rbd1
8
1367 rbd namespace create rbd
1/ns
1368 ceph osd pool create rbd2
8
1370 rbd namespace create rbd
2/ns
1372 IMAGE_SPECS
=("test1" "rbd1/test2" "rbd1/ns/test3" "rbd2/test4" "rbd2/ns/test5")
1373 for spec
in "${IMAGE_SPECS[@]}"; do
1374 # ensure all images are created without a separate data pool
1375 # as we filter iostat by specific pool specs below
1376 rbd create
$RBD_CREATE_ARGS --size 10G
--rbd-default-data-pool '' $spec
1380 for spec
in "${IMAGE_SPECS[@]}"; do
1381 rbd bench
--io-type write --io-pattern rand
--io-total 10G
--io-threads 1 \
1382 --rbd-cache false
$spec >/dev
/null
2>&1 &
1386 # test specifying pool spec via spec syntax
1387 test "$(rbd perf image iostat --format json rbd1 |
1388 jq -r 'map(.image) | sort | join(" ")')" = 'test2'
1389 test "$(rbd perf image iostat --format json rbd1/ns |
1390 jq -r 'map(.image) | sort | join(" ")')" = 'test3'
1391 test "$(rbd perf image iostat --format json --rbd-default-pool rbd1 /ns |
1392 jq -r 'map(.image) | sort | join(" ")')" = 'test3'
1394 # test specifying pool spec via options
1395 test "$(rbd perf image iostat --format json --pool rbd2 |
1396 jq -r 'map(.image) | sort | join(" ")')" = 'test4'
1397 test "$(rbd perf image iostat --format json --pool rbd2 --namespace ns |
1398 jq -r 'map(.image) | sort | join(" ")')" = 'test5'
1399 test "$(rbd perf image iostat --format json --rbd-default-pool rbd2 --namespace ns |
1400 jq -r 'map(.image) | sort | join(" ")')" = 'test5'
1402 # test omitting pool spec (-> GLOBAL_POOL_KEY)
1403 test "$(rbd perf image iostat --format json |
1404 jq -r 'map(.image) | sort | join(" ")')" = 'test1 test2 test3 test4 test5'
1406 for pid
in "${BENCH_PIDS[@]}"; do
1412 ceph osd pool
rm rbd2 rbd2
--yes-i-really-really-mean-it
1413 ceph osd pool
rm rbd1 rbd1
--yes-i-really-really-mean-it
1416 test_mirror_pool_peer_bootstrap_create
() {
1417 echo "testing mirror pool peer bootstrap create..."
1420 ceph osd pool create rbd1
8
1422 rbd mirror pool
enable rbd1 image
1423 ceph osd pool create rbd2
8
1425 rbd mirror pool
enable rbd2 pool
1427 readarray
-t MON_ADDRS
< <(ceph mon dump |
1428 sed -n 's/^[0-9]: \(.*\) mon\.[a-z]$/\1/p')
1430 # check that all monitors make it to the token even if only one
1431 # valid monitor is specified
1432 BAD_MON_ADDR
="1.2.3.4:6789"
1433 MON_HOST
="${MON_ADDRS[0]},$BAD_MON_ADDR"
1434 TOKEN
="$(rbd mirror pool peer bootstrap create \
1435 --mon-host "$MON_HOST" rbd1 | base64 -d)"
1436 TOKEN_FSID
="$(jq -r '.fsid' <<< "$TOKEN")"
1437 TOKEN_CLIENT_ID
="$(jq -r '.client_id' <<< "$TOKEN")"
1438 TOKEN_KEY
="$(jq -r '.key' <<< "$TOKEN")"
1439 TOKEN_MON_HOST
="$(jq -r '.mon_host' <<< "$TOKEN")"
1441 test "$TOKEN_FSID" = "$(ceph fsid)"
1442 test "$TOKEN_KEY" = "$(ceph auth get-key client.$TOKEN_CLIENT_ID)"
1443 for addr
in "${MON_ADDRS[@]}"; do
1444 fgrep
"$addr" <<< "$TOKEN_MON_HOST"
1446 expect_fail fgrep
"$BAD_MON_ADDR" <<< "$TOKEN_MON_HOST"
1448 # check that the token does not change, including across pools
1449 test "$(rbd mirror pool peer bootstrap create \
1450 --mon-host "$MON_HOST" rbd1 | base64 -d)" = "$TOKEN"
1451 test "$(rbd mirror pool peer bootstrap create \
1452 rbd1 | base64 -d)" = "$TOKEN"
1453 test "$(rbd mirror pool peer bootstrap create \
1454 --mon-host "$MON_HOST" rbd2 | base64 -d)" = "$TOKEN"
1455 test "$(rbd mirror pool peer bootstrap create \
1456 rbd2 | base64 -d)" = "$TOKEN"
1458 ceph osd pool
rm rbd2 rbd2
--yes-i-really-really-mean-it
1459 ceph osd pool
rm rbd1 rbd1
--yes-i-really-really-mean-it
1462 test_pool_image_args
1471 test_thick_provision
1472 RBD_CREATE_ARGS
="--image-format 2"
1478 test_deep_copy_clone
1480 test_thick_provision
1482 test_trash_purge_schedule
1483 test_mirror_snapshot_schedule
1484 test_perf_image_iostat
1485 test_mirror_pool_peer_bootstrap_create