]> git.proxmox.com Git - ceph.git/blame - ceph/qa/workunits/mon/workloadgen.sh
bump version to 12.1.1-pve1 while rebasing patches
[ceph.git] / ceph / qa / workunits / mon / workloadgen.sh
CommitLineData
7c673cae
FG
1#!/bin/bash -x
2# vim: ts=8 sw=2 smarttab
3#
4# $0.sh - run mon workload generator
5
6d() {
7 [[ "$VERBOSE" != "" && $VERBOSE -eq 1 ]] && echo "## DEBUG ## $*"
8}
9
10d "check for required binaries"
11
12required_bins="ceph crushtool ceph_test_mon_workloadgen"
13for 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
19done
20
21d "Start workunit"
22
23crush_map_fn=test.crush.map
24create_crush=0
25clobber_crush=0
26new_cluster=0
27do_run=0
28num_osds=0
29
30# Assume the test is in PATH
31bin_test=ceph_test_mon_workloadgen
32
33num_osds=10
34if [[ "$LOADGEN_NUM_OSDS" != "" ]]; then
35 num_osds=$LOADGEN_NUM_OSDS
36fi
37
38duration=300
39[ ! -z $DURATION ] && duration=$DURATION
40
41d "checking osd tree"
42
43crush_testing_root="`ceph osd tree | grep 'root[ \t]\+testing'`"
44
45d "$crush_testing_root"
46
47if [[ "$crush_testing_root" == "" ]]; then
48 d "set create_crush"
49 create_crush=1
50fi
51
52d "generate run_id (create_crush = $create_crush)"
53
54run_id=`uuidgen`
55
56d "run_id = $run_id ; create_crush = $create_crush"
57
58if [[ $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
78root testing {
79 id -$our_root_id
80 alg straw
81 hash 0 # rjenkins1
82}
83rule 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}
92rule 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}
101rule 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}
110EOF
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
126fi
127
128keyring="/tmp/ceph.$run_id.keyring"
129
130ceph auth get-or-create-key osd.admin mon 'allow rwx' osd 'allow *'
131ceph auth export | grep -v "export" > $keyring
132
133osd_ids=""
134
135for 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
140done
141
142d "osds: $osd_ids"
143
144stub_id_args=""
145f=
146l=
147for 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
160done
161if [[ $l -gt $f ]]; then
162 stub_id_args="$stub_id_args..$l"
163fi
164
165args="$EXTRA_ARGS --duration $duration $stub_id_args"
166
167d "running: $args"
168
169$bin_test --keyring $keyring $args