]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/rados/test_crushdiff.sh
9 OSD_NUM
=$
(ceph osd
ls |
wc -l)
17 pool
=test-crushdiff-rep-$$
18 ceph osd pool create
${pool} 32
20 rados
-p ${REP_POOL} bench
5 write --no-cleanup
22 if [ ${OSD_NUM} -gt 3 ]; then
23 pool
=test-crushdiff-ec-$$
24 ceph osd pool create
${pool} 32 32 erasure
26 rados
-p ${EC_POOL} bench
5 write --no-cleanup
33 test -n "${EC_POOL}" &&
34 ceph osd pool delete
"${EC_POOL}" "${EC_POOL}" \
35 --yes-i-really-really-mean-it
38 test -n "${REP_POOL}" &&
39 ceph osd pool delete
"${REP_POOL}" "${REP_POOL}" \
40 --yes-i-really-really-mean-it
43 test -n "${TEMPDIR}" && rm -Rf ${TEMPDIR}
47 trap "cleanup" INT TERM EXIT
51 # test without crushmap modification
53 crushdiff
export ${TEMPDIR}/cm.txt
--verbose
54 crushdiff compare
${TEMPDIR}/cm.txt
--verbose
55 crushdiff import
${TEMPDIR}/cm.txt
--verbose
57 # test using a compiled crushmap
59 crushdiff
export ${TEMPDIR}/cm
--compiled --verbose
60 crushdiff compare
${TEMPDIR}/cm
--compiled --verbose
61 crushdiff import
${TEMPDIR}/cm
--compiled --verbose
63 # test using "offline" osdmap and pg-dump
65 ceph osd getmap
-o ${TEMPDIR}/osdmap
66 ceph pg dump
--format json
> ${TEMPDIR}/pg-dump
68 crushdiff
export ${TEMPDIR}/cm.txt
--osdmap ${TEMPDIR}/osdmap
--verbose
69 crushdiff compare
${TEMPDIR}/cm.txt
--osdmap ${TEMPDIR}/osdmap \
70 --pg-dump ${TEMPDIR}/pg-dump
--verbose |
tee ${TEMPDIR}/compare.txt
72 # test the diff is zero when the crushmap is not modified
74 grep '^0/[0-9]* (0\.00%) pgs affected' ${TEMPDIR}/compare.txt
75 grep '^0/[0-9]* (0\.00%) objects affected' ${TEMPDIR}/compare.txt
76 grep '^0/[0-9]* (0\.00%) pg shards to move' ${TEMPDIR}/compare.txt
77 grep '^0/[0-9]* (0\.00%) pg object shards to move' ${TEMPDIR}/compare.txt
78 grep '^0\.00/.* (0\.00%) bytes to move' ${TEMPDIR}/compare.txt
79 crushdiff import
${TEMPDIR}/cm.txt
--osdmap ${TEMPDIR}/osdmap
--verbose
81 if [ ${OSD_NUM} -gt 3 ]; then
83 # test the diff is non-zero when the crushmap is modified
85 cat ${TEMPDIR}/cm.txt
>&2
87 weight
=$
(awk '/item osd\.0 weight ([0-9.]+)/ {print $4 * 3}' \
90 sed -i -Ee 's/^(.*item osd\.0 weight )[0-9.]+/\1'${weight}'/' \
92 crushdiff compare
${TEMPDIR}/cm.txt
--osdmap ${TEMPDIR}/osdmap \
93 --pg-dump ${TEMPDIR}/pg-dump
--verbose |
tee ${TEMPDIR}/compare.txt
94 grep '^[1-9][0-9]*/[0-9]* (.*%) pgs affected' ${TEMPDIR}/compare.txt
95 grep '^[1-9][0-9]*/[0-9]* (.*%) objects affected' ${TEMPDIR}/compare.txt
96 grep '^[1-9][0-9]*/[0-9]* (.*%) pg shards to move' ${TEMPDIR}/compare.txt
97 grep '^[1-9][0-9]*/[0-9]* (.*%) pg object shards to move' \
98 ${TEMPDIR}/compare.txt
99 grep '^.*/.* (.*%) bytes to move' ${TEMPDIR}/compare.txt
100 crushdiff import
${TEMPDIR}/cm.txt
--osdmap ${TEMPDIR}/osdmap
--verbose