]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/mon/workloadgen.sh
bump version to 12.1.1-pve1 while rebasing patches
[ceph.git] / ceph / qa / workunits / mon / workloadgen.sh
1 #!/bin/bash -x
2 # vim: ts=8 sw=2 smarttab
3 #
4 # $0.sh - run mon workload generator
5
6 d() {
7 [[ "$VERBOSE" != "" && $VERBOSE -eq 1 ]] && echo "## DEBUG ## $*"
8 }
9
10 d "check for required binaries"
11
12 required_bins="ceph crushtool ceph_test_mon_workloadgen"
13 for b in $required_bins; do
14 which $b >& /dev/null
15 if [[ $? -ne 0 ]]; then
16 echo "Unable to find '$b' in PATH"
17 exit 1
18 fi
19 done
20
21 d "Start workunit"
22
23 crush_map_fn=test.crush.map
24 create_crush=0
25 clobber_crush=0
26 new_cluster=0
27 do_run=0
28 num_osds=0
29
30 # Assume the test is in PATH
31 bin_test=ceph_test_mon_workloadgen
32
33 num_osds=10
34 if [[ "$LOADGEN_NUM_OSDS" != "" ]]; then
35 num_osds=$LOADGEN_NUM_OSDS
36 fi
37
38 duration=300
39 [ ! -z $DURATION ] && duration=$DURATION
40
41 d "checking osd tree"
42
43 crush_testing_root="`ceph osd tree | grep 'root[ \t]\+testing'`"
44
45 d "$crush_testing_root"
46
47 if [[ "$crush_testing_root" == "" ]]; then
48 d "set create_crush"
49 create_crush=1
50 fi
51
52 d "generate run_id (create_crush = $create_crush)"
53
54 run_id=`uuidgen`
55
56 d "run_id = $run_id ; create_crush = $create_crush"
57
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
62
63 highest_root_id=0
64 root_ids_raw="`cat $tmp_crush_fn.plain | grep id`"
65 ifs=$IFS
66 IFS=$'\n'
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
72 fi
73 done
74 our_root_id=$(($highest_root_id+1))
75 IFS=$ifs
76
77 cat << EOF >> $tmp_crush_fn.plain
78 root testing {
79 id -$our_root_id
80 alg straw
81 hash 0 # rjenkins1
82 }
83 rule testingdata {
84 ruleset 0
85 type replicated
86 min_size 1
87 max_size 10
88 step take testing
89 step choose firstn 0 type osd
90 step emit
91 }
92 rule testingmetadata {
93 ruleset 1
94 type replicated
95 min_size 1
96 max_size 10
97 step take testing
98 step choose firstn 0 type osd
99 step emit
100 }
101 rule testingrbd {
102 ruleset 2
103 type replicated
104 min_size 1
105 max_size 10
106 step take testing
107 step choose firstn 0 type osd
108 step emit
109 }
110 EOF
111
112 if [[ $VERBOSE -eq 1 ]]; then
113 cat $tmp_crush_fn.plain
114 fi
115
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"
119 echo "NOK"
120 exit 1
121 fi
122
123 d "created crush"
124
125 ceph osd setcrushmap -i $tmp_crush_fn
126 fi
127
128 keyring="/tmp/ceph.$run_id.keyring"
129
130 ceph auth get-or-create-key osd.admin mon 'allow rwx' osd 'allow *'
131 ceph auth export | grep -v "export" > $keyring
132
133 osd_ids=""
134
135 for osd in `seq 1 $num_osds`; do
136 id=`ceph osd create`
137 osd_ids="$osd_ids $id"
138 d "osd.$id"
139 ceph osd crush set $id osd.$id 1.0 host=testhost rack=testrack root=testing
140 done
141
142 d "osds: $osd_ids"
143
144 stub_id_args=""
145 f=
146 l=
147 for i in $osd_ids; do
148 d "i: $i"
149 if [[ $stub_id_args == "" ]]; then
150 stub_id_args="--stub-id $i"
151 f=$i
152 fi
153 if [[ $l != "" ]]; then
154 if [[ $i -gt $(($l+1)) ]]; then
155 stub_id_args="$stub_id_args..$l --stub-id $i"
156 f=$i
157 fi
158 fi
159 l=$i
160 done
161 if [[ $l -gt $f ]]; then
162 stub_id_args="$stub_id_args..$l"
163 fi
164
165 args="$EXTRA_ARGS --duration $duration $stub_id_args"
166
167 d "running: $args"
168
169 $bin_test --keyring $keyring $args