2 # vim: ts=8 sw=2 smarttab
4 # $0.sh - run mon workload generator
7 [[ "$VERBOSE" != "" && $VERBOSE -eq 1 ]] && echo "## DEBUG ## $*"
10 d
"check for required binaries"
12 required_bins
="ceph crushtool ceph_test_mon_workloadgen"
13 for b
in $required_bins; do
15 if [[ $?
-ne 0 ]]; then
16 echo "Unable to find '$b' in PATH"
23 crush_map_fn
=test.crush.map
30 # Assume the test is in PATH
31 bin_test
=ceph_test_mon_workloadgen
34 if [[ "$LOADGEN_NUM_OSDS" != "" ]]; then
35 num_osds
=$LOADGEN_NUM_OSDS
39 [ ! -z $DURATION ] && duration
=$DURATION
43 crush_testing_root
="`ceph osd tree | grep 'root[ \t]\+testing'`"
45 d
"$crush_testing_root"
47 if [[ "$crush_testing_root" == "" ]]; then
52 d
"generate run_id (create_crush = $create_crush)"
56 d
"run_id = $run_id ; create_crush = $create_crush"
58 if [[ $create_crush -eq 1 ]]; then
59 tmp_crush_fn
="/tmp/ceph.$run_id.crush"
60 ceph osd getcrushmap
-o $tmp_crush_fn
61 crushtool
-d $tmp_crush_fn -o $tmp_crush_fn.plain
64 root_ids_raw
="`cat $tmp_crush_fn.plain | grep id`"
67 for l
in $root_ids_raw; do
68 root_id
=`echo $l | sed 's/.*-\([[:digit:]]\+\).*/\1/'`
69 d
"root id = $root_id ; highest = $highest_root_id"
70 if [[ $root_id -gt $highest_root_id ]]; then
71 highest_root_id
=$root_id
74 our_root_id
=$
(($highest_root_id+1))
77 cat << EOF >> $tmp_crush_fn.plain
89 step choose firstn 0 type osd
92 rule testingmetadata {
98 step choose firstn 0 type osd
107 step choose firstn 0 type osd
112 if [[ $VERBOSE -eq 1 ]]; then
113 cat $tmp_crush_fn.plain
116 crushtool
-c $tmp_crush_fn.plain
-o $tmp_crush_fn
117 if [[ $?
-eq 1 ]]; then
118 echo "Error compiling test crush map; probably need newer crushtool"
125 ceph osd setcrushmap
-i $tmp_crush_fn
128 keyring
="/tmp/ceph.$run_id.keyring"
130 ceph auth get-or-create-key osd.admin mon
'allow rwx' osd
'allow *'
131 ceph auth
export |
grep -v "export" > $keyring
135 for osd
in `seq 1 $num_osds`; do
137 osd_ids
="$osd_ids $id"
139 ceph osd crush
set $id osd.
$id 1.0 host=testhost rack
=testrack root
=testing
147 for i
in $osd_ids; do
149 if [[ $stub_id_args == "" ]]; then
150 stub_id_args
="--stub-id $i"
153 if [[ $l != "" ]]; then
154 if [[ $i -gt $
(($l+1)) ]]; then
155 stub_id_args
="$stub_id_args..$l --stub-id $i"
161 if [[ $l -gt $f ]]; then
162 stub_id_args
="$stub_id_args..$l"
165 args
="$EXTRA_ARGS --duration $duration $stub_id_args"
169 $bin_test --keyring $keyring $args