]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/cli/osdmaptool/test-map-pgs.t
0c474d76b53d323f44eb19283f28ad50f56ff816
[ceph.git] / ceph / src / test / cli / osdmaptool / test-map-pgs.t
1 $ NUM_OSDS=500
2 $ POOL_COUNT=1 # data + metadata + rbd
3 $ SIZE=3
4 $ PG_BITS=4
5 #
6 # create an osdmap with a few hundred devices and a realistic crushmap
7 #
8 $ OSD_MAP="osdmap"
9 $ osdmaptool --osd_pool_default_size $SIZE --pg_bits $PG_BITS --createsimple $NUM_OSDS "$OSD_MAP" > /dev/null
10 osdmaptool: osdmap file 'osdmap'
11 $ CRUSH_MAP="crushmap"
12 $ CEPH_ARGS="--debug-crush 0" crushtool --outfn "$CRUSH_MAP" --build --num_osds $NUM_OSDS node straw 10 rack straw 10 root straw 0
13 $ osdmaptool --import-crush "$CRUSH_MAP" "$OSD_MAP" > /dev/null
14 osdmaptool: osdmap file 'osdmap'
15 $ OUT="$TESTDIR/out"
16 #
17 # --test-map-pgs
18 #
19 $ osdmaptool --mark-up-in --test-map-pgs "$OSD_MAP" > "$OUT"
20 osdmaptool: osdmap file 'osdmap'
21 $ PG_NUM=$(($NUM_OSDS << $PG_BITS))
22 $ grep "pg_num $PG_NUM" "$OUT" || cat $OUT
23 pool 0 pg_num 8000
24 $ TOTAL=$((POOL_COUNT * $PG_NUM))
25 $ grep -E "size $SIZE[[:space:]]$TOTAL" $OUT || cat $OUT
26 size 3\t8000 (esc)
27 $ STATS_CRUSH=$(grep '^ avg ' "$OUT")
28 #
29 # --test-map-pgs --test-random is expected to change nothing regarding the totals
30 #
31 $ osdmaptool --mark-up-in --test-random --test-map-pgs "$OSD_MAP" > "$OUT"
32 osdmaptool: osdmap file 'osdmap'
33 $ PG_NUM=$(($NUM_OSDS << $PG_BITS))
34 $ grep "pg_num $PG_NUM" "$OUT" || cat $OUT
35 pool 0 pg_num 8000
36 $ TOTAL=$((POOL_COUNT * $PG_NUM))
37 $ grep -E "size $SIZE[[:space:]]$TOTAL" $OUT || cat $OUT
38 size 3\t8000 (esc)
39 $ STATS_RANDOM=$(grep '^ avg ' "$OUT")
40 # it is almost impossible to get the same stats with random and crush
41 # if they are, it most probably means something went wrong somewhere
42 $ test "$STATS_CRUSH" != "$STATS_RANDOM"
43 #
44 # cleanup
45 #
46 $ rm -f "$CRUSH_MAP" "$OSD_MAP" "$OUT"