4 . $
(dirname $0)/..
/..
/standalone
/ceph-helpers.sh
16 echo "usage: $0 [-h|-l|-t <testname> [-t <testname>...] [--no-cleanup]]"
19 function expect_false
()
22 if "$@"; then return 1; else return 0; fi
25 function save_commit_position
()
29 rados
-p rbd getomapval journal.
${journal} client_ \
30 $TMPDIR/${journal}.client_.omap
33 function restore_commit_position
()
37 rados
-p rbd setomapval journal.
${journal} client_ \
38 < $TMPDIR/${journal}.client_.omap
43 local image
=testrbdjournal$$
45 rbd create
--image-feature exclusive-lock
--image-feature journaling \
47 local journal
=$
(rbd info
${image} --format=xml
2>/dev
/null |
48 $XMLSTARLET sel
-t -v "//image/journal")
50 rbd journal info
${journal}
51 rbd journal info
--journal ${journal}
52 rbd journal info
--image ${image}
54 rbd feature disable
${image} journaling
56 rbd info
${image} --format=xml
2>/dev
/null |
57 expect_false
$XMLSTARLET sel
-t -v "//image/journal"
58 expect_false rbd journal info
${journal}
59 expect_false rbd journal info
--image ${image}
61 rbd feature
enable ${image} journaling
63 local journal1
=$
(rbd info
${image} --format=xml
2>/dev
/null |
64 $XMLSTARLET sel
-t -v "//image/journal")
65 test "${journal}" = "${journal1}"
67 rbd journal info
${journal}
69 rbd journal status
${journal}
72 save_commit_position
${journal}
73 rbd bench
--io-type write ${image} --io-size 4096 --io-threads 1 \
74 --io-total $
((4096 * count
)) --io-pattern seq
75 rbd journal status
--image ${image} | fgrep
"tid=$((count - 1))"
76 restore_commit_position
${journal}
77 rbd journal status
--image ${image} | fgrep
"positions=[]"
78 local count1
=$
(rbd journal inspect
--verbose ${journal} |
79 grep -c 'event_type.*AioWrite')
80 test "${count}" -eq "${count1}"
82 rbd journal
export ${journal} $TMPDIR/journal.
export
83 local size
=$
(stat
-c "%s" $TMPDIR/journal.
export)
86 rbd
export ${image} $TMPDIR/${image}.
export
88 local image1
=${image}1
89 rbd create
--image-feature exclusive-lock
--image-feature journaling \
91 journal1
=$
(rbd info
${image1} --format=xml
2>/dev
/null |
92 $XMLSTARLET sel
-t -v "//image/journal")
94 save_commit_position
${journal1}
95 rbd journal import
--dest ${image1} $TMPDIR/journal.
export
96 rbd snap create
${image1}@
test
97 restore_commit_position
${journal1}
98 # check that commit position is properly updated: the journal should contain
99 # 14 entries (2 AioFlush + 10 AioWrite + 1 SnapCreate + 1 OpFinish) and
100 # commit position set to tid=14
101 rbd journal inspect
--image ${image1} --verbose |
awk '
102 /AioFlush/ {a++} # match: "event_type": "AioFlush",
103 /AioWrite/ {w++} # match: "event_type": "AioWrite",
104 /SnapCreate/ {s++} # match: "event_type": "SnapCreate",
105 /OpFinish/ {f++} # match: "event_type": "OpFinish",
106 /entries inspected/ {t=$1; e=$4} # match: 14 entries inspected, 0 errors
107 {print} # for diagnostic
109 if (a != 2 || w != 10 || s != 1 || f != 1 || t != 14 || e != 0) exit(1)
113 rbd
export ${image1}@
test $TMPDIR/${image1}.
export
114 cmp $TMPDIR/${image}.
export $TMPDIR/${image1}.
export
116 rbd journal
reset ${journal}
118 rbd journal inspect
--verbose ${journal} | expect_false
grep 'event_type'
120 rbd snap purge
${image1}
130 local expected_val
=$4
132 local val
=$
(rbd
--format xml
${cmd} --image ${image} |
133 $XMLSTARLET sel
-t -v "${param}")
134 test "${val}" = "${expected_val}"
139 local image
=testrbdcreate$$
141 rbd create
--image-feature exclusive-lock
--image-feature journaling \
143 --journal-object-size 20M \
144 --journal-splay-width 6 \
147 rbd_assert_eq
${image} 'journal info' '//journal/order' 25
148 rbd_assert_eq
${image} 'journal info' '//journal/splay_width' 6
149 rbd_assert_eq
${image} 'journal info' '//journal/object_pool' rbd
156 local src
=testrbdcopys$$
157 rbd create
--size 256 ${src}
159 local image
=testrbdcopy$$
160 rbd copy
--image-feature exclusive-lock
--image-feature journaling \
162 --journal-object-size 20M \
163 --journal-splay-width 6 \
168 rbd_assert_eq
${image} 'journal info' '//journal/order' 25
169 rbd_assert_eq
${image} 'journal info' '//journal/splay_width' 6
170 rbd_assert_eq
${image} 'journal info' '//journal/object_pool' rbd
177 local src
=testrbdcopys$$
178 rbd create
--size 256 ${src}
179 rbd snap create
${src}@snap1
181 local dest
=testrbdcopy$$
182 rbd deep copy
--image-feature exclusive-lock
--image-feature journaling \
184 --journal-object-size 20M \
185 --journal-splay-width 6 \
188 rbd snap purge
${src}
191 rbd_assert_eq
${dest} 'journal info' '//journal/order' 25
192 rbd_assert_eq
${dest} 'journal info' '//journal/splay_width' 6
193 rbd_assert_eq
${dest} 'journal info' '//journal/object_pool' rbd
195 rbd snap purge
${dest}
201 local parent
=testrbdclonep$$
202 rbd create
--image-feature layering
--size 256 ${parent}
203 rbd snap create
${parent}@snap
204 rbd snap protect
${parent}@snap
206 local image
=testrbdclone$$
207 rbd clone
--image-feature layering
--image-feature exclusive-lock
--image-feature journaling \
209 --journal-object-size 20M \
210 --journal-splay-width 6 \
211 ${parent}@snap
${image}
213 rbd_assert_eq
${image} 'journal info' '//journal/order' 25
214 rbd_assert_eq
${image} 'journal info' '//journal/splay_width' 6
215 rbd_assert_eq
${image} 'journal info' '//journal/object_pool' rbd
218 rbd snap unprotect
${parent}@snap
219 rbd snap purge
${parent}
225 local src
=testrbdimports$$
226 rbd create
--size 256 ${src}
228 rbd
export ${src} $TMPDIR/${src}.
export
231 local image
=testrbdimport$$
232 rbd import
--image-feature exclusive-lock
--image-feature journaling \
234 --journal-object-size 20M \
235 --journal-splay-width 6 \
236 $TMPDIR/${src}.
export ${image}
238 rbd_assert_eq
${image} 'journal info' '//journal/order' 25
239 rbd_assert_eq
${image} 'journal info' '//journal/splay_width' 6
240 rbd_assert_eq
${image} 'journal info' '//journal/object_pool' rbd
247 local image
=testrbdfeature$$
249 rbd create
--image-feature exclusive-lock
--size 256 ${image}
251 rbd feature
enable ${image} journaling \
253 --journal-object-size 20M \
254 --journal-splay-width 6
256 rbd_assert_eq
${image} 'journal info' '//journal/order' 25
257 rbd_assert_eq
${image} 'journal info' '//journal/splay_width' 6
258 rbd_assert_eq
${image} 'journal info' '//journal/object_pool' rbd
263 TESTS
+=" rbd_journal"
268 TESTS
+=" rbd_feature"
278 while [[ $# -gt 0 ]]; do
290 if [[ -z "$1" ]]; then
291 echo "missing argument to '-t'"
305 if [[ $do_list -eq 1 ]]; then
310 TMPDIR
=/tmp
/rbd_journal$$
313 trap "rm -fr $TMPDIR" 0
316 if test -z "$tests_to_run" ; then
317 tests_to_run
="$TESTS"
320 for i
in $tests_to_run; do