blob: b334fa58b6f844c9cd8391820e0d889e7a00e31a [file] [log] [blame]
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +03001import os
koder aka kdanilov4a510ee2015-04-21 18:50:42 +03002import bisect
koder aka kdanilova047e1b2015-04-21 23:16:59 +03003import logging
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +03004
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +03005try:
6 import matplotlib.pyplot as plt
7except ImportError:
8 plt = None
9
koder aka kdanilov4a510ee2015-04-21 18:50:42 +030010import wally
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +030011from wally import charts
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030012from wally.utils import ssize2b
13from wally.statistic import round_3_digit, data_property
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +030014
koder aka kdanilov4a510ee2015-04-21 18:50:42 +030015
koder aka kdanilova047e1b2015-04-21 23:16:59 +030016logger = logging.getLogger("wally.report")
17
18
koder aka kdanilov209e85d2015-04-27 23:11:05 +030019class DiskInfo(object):
20 def __init__(self):
21 self.direct_iops_r_max = 0
22 self.direct_iops_w_max = 0
23 self.rws4k_10ms = 0
24 self.rws4k_30ms = 0
25 self.rws4k_100ms = 0
26 self.bw_write_max = 0
27 self.bw_read_max = 0
28
29
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +030030report_funcs = []
31
32
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030033class PerfInfo(object):
34 def __init__(self, name, raw, meta):
35 self.name = name
36 self.bw = None
37 self.iops = None
38 self.lat = None
39 self.raw = raw
40 self.meta = meta
41
42
43def split_and_add(data, block_size):
44 assert len(data) % block_size == 0
45 res = [0] * block_size
46
47 for idx, val in enumerate(data):
48 res[idx % block_size] += val
49
50 return res
51
52
53def process_disk_info(test_data):
54 data = {}
55 vm_count = test_data['__test_meta__']['testnodes_count']
56 for name, results in test_data['res'].items():
57 assert len(results['bw']) % vm_count == 0
58 block_count = len(results['bw']) // vm_count
59
60 pinfo = PerfInfo(name, results, test_data['__test_meta__'])
61 pinfo.bw = data_property(split_and_add(results['bw'], block_count))
62 pinfo.iops = data_property(split_and_add(results['iops'],
63 block_count))
64
65 pinfo.lat = data_property(results['lat'])
66 data[name] = pinfo
67 return data
68
69
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +030070def report(name, required_fields):
71 def closure(func):
72 report_funcs.append((required_fields.split(","), name, func))
73 return func
74 return closure
75
76
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +030077def linearity_report(processed_results, path, lab_info):
78 names = {}
79 for tp1 in ('rand', 'seq'):
80 for oper in ('read', 'write'):
81 for sync in ('sync', 'direct', 'async'):
82 sq = (tp1, oper, sync)
83 name = "{0} {1} {2}".format(*sq)
84 names["".join(word[0] for word in sq)] = name
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +030085
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +030086 colors = ['red', 'green', 'blue', 'cyan',
87 'magenta', 'black', 'yellow', 'burlywood']
88 markers = ['*', '^', 'x', 'o', '+', '.']
89 color = 0
90 marker = 0
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +030091
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +030092 plot_data = {}
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +030093
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +030094 name_pref = 'linearity_test_rrd'
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +030095
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +030096 for res in processed_results.values():
97 if res.name.startswith(name_pref):
98 iotime = 1000000. / res.iops
99 iotime_max = iotime * (1 + res.dev * 3)
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300100 bsize = ssize2b(res.raw['blocksize'])
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +0300101 plot_data[bsize] = (iotime, iotime_max)
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300102
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +0300103 min_sz = min(plot_data)
104 min_iotime, _ = plot_data.pop(min_sz)
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300105
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +0300106 x = []
107 y = []
108 e = []
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300109
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +0300110 for k, (v, vmax) in sorted(plot_data.items()):
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +0300111 y.append(v - min_iotime)
112 x.append(k)
113 e.append(y[-1] - (vmax - min_iotime))
114
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +0300115 tp = 'rrd'
116 plt.errorbar(x, y, e, linestyle='None', label=names[tp],
117 color=colors[color], ecolor="black",
118 marker=markers[marker])
119 plt.yscale('log')
120 plt.xscale('log')
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300121 # plt.show()
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +0300122
123 # ynew = approximate_line(ax, ay, ax, True)
124 # plt.plot(ax, ynew, color=colors[color])
125 # color += 1
126 # marker += 1
127 # plt.legend(loc=2)
128 # plt.title("Linearity test by %i dots" % (len(vals)))
129
130
131if plt:
132 linearity_report = report('linearity', 'linearity_test')(linearity_report)
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300133
134
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300135def render_all_html(dest, info, lab_description, img_ext, templ_name):
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300136 very_root_dir = os.path.dirname(os.path.dirname(wally.__file__))
137 templ_dir = os.path.join(very_root_dir, 'report_templates')
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300138 templ_file = os.path.join(templ_dir, templ_name)
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300139 templ = open(templ_file, 'r').read()
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300140
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300141 data = info.__dict__.copy()
142 for name, val in data.items():
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300143 if not name.startswith('__'):
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300144 if val is None:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300145 data[name] = '-'
146 elif isinstance(val, (int, float, long)):
147 data[name] = round_3_digit(val)
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300148
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300149 data['bw_read_max'] = (data['bw_read_max'][0] // 1024,
150 data['bw_read_max'][1])
151 data['bw_write_max'] = (data['bw_write_max'][0] // 1024,
152 data['bw_write_max'][1])
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300153
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300154 report = templ.format(lab_info=lab_description, img_ext=img_ext,
155 **data)
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300156 open(dest, 'w').write(report)
157
158
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300159def render_hdd_html(dest, info, lab_description, img_ext):
160 render_all_html(dest, info, lab_description, img_ext,
161 "report_hdd.html")
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300162
163
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300164def render_ceph_html(dest, info, lab_description, img_ext):
165 render_all_html(dest, info, lab_description, img_ext,
166 "report_ceph.html")
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300167
168
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300169def io_chart(title, concurence,
170 latv, latv_min, latv_max,
171 iops_or_bw, iops_or_bw_dev,
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300172 legend, fname):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300173 bar_data = iops_or_bw
174 bar_dev = iops_or_bw_dev
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300175 legend = [legend]
176
177 iops_or_bw_per_vm = []
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300178 for iops, conc in zip(iops_or_bw, concurence):
179 iops_or_bw_per_vm.append(iops / conc)
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300180
181 bar_dev_bottom = []
182 bar_dev_top = []
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300183 for val, err in zip(bar_data, bar_dev):
184 bar_dev_top.append(val + err)
185 bar_dev_bottom.append(val - err)
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300186
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300187 charts.render_vertical_bar(title, legend, [bar_data], [bar_dev_top],
188 [bar_dev_bottom], file_name=fname,
189 scale_x=concurence, label_x="clients",
190 label_y=legend[0],
191 lines=[
192 (latv, "msec", "rr", "lat"),
193 # (latv_min, None, None, "lat_min"),
194 # (latv_max, None, None, "lat_max"),
195 (iops_or_bw_per_vm, None, None,
196 legend[0] + " per client")
197 ])
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300198
199
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300200def io_chart_mpl(title, concurence,
201 latv, latv_min, latv_max,
202 iops_or_bw, iops_or_bw_err,
203 legend, fname):
204 points = " MiBps" if legend == 'BW' else ""
205 lc = len(concurence)
206 width = 0.35
207 xt = range(1, lc + 1)
208
209 op_per_vm = [v / c for v, c in zip(iops_or_bw, concurence)]
210 fig, p1 = plt.subplots()
211 xpos = [i - width / 2 for i in xt]
212
213 p1.bar(xpos, iops_or_bw, width=width, yerr=iops_or_bw_err,
214 color='y',
215 label=legend)
216
217 p1.set_yscale('log')
218 p1.grid(True)
219 p1.plot(xt, op_per_vm, label=legend + " per vm")
220 p1.legend()
221
222 p2 = p1.twinx()
223 p2.set_yscale('log')
224 p2.plot(xt, latv_max, label="latency max")
225 p2.plot(xt, latv, label="latency avg")
226 p2.plot(xt, latv_min, label="latency min")
227
228 plt.xlim(0.5, lc + 0.5)
229 plt.xticks(xt, map(str, concurence))
230 p1.set_xlabel("Threads")
231 p1.set_ylabel(legend + points)
232 p2.set_ylabel("Latency ms")
233 plt.title(title)
234 # plt.legend(, loc=2, borderaxespad=0.)
235 # plt.legend(bbox_to_anchor=(1.05, 1), loc=2)
236 plt.legend(loc=2)
237 plt.savefig(fname, format=fname.split('.')[-1])
238
239
240def make_hdd_plots(processed_results, charts_dir):
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300241 plots = [
242 ('hdd_test_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
koder aka kdanilovea7eac72015-04-21 21:37:27 +0300243 ('hdd_test_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS')
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300244 ]
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300245 return make_plots(processed_results, charts_dir, plots)
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300246
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300247
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300248def make_ceph_plots(processed_results, charts_dir):
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300249 plots = [
250 ('ceph_test_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
251 ('ceph_test_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS'),
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300252 ('ceph_test_rrd16m', 'rand_read_16m',
253 'Random read 16m direct MiBps'),
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300254 ('ceph_test_rwd16m', 'rand_write_16m',
255 'Random write 16m direct MiBps'),
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300256 ]
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300257 return make_plots(processed_results, charts_dir, plots)
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300258
259
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300260def make_plots(processed_results, charts_dir, plots):
261 file_ext = None
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300262 for name_pref, fname, desc in plots:
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300263 chart_data = []
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300264
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300265 for res in processed_results.values():
266 if res.name.startswith(name_pref):
267 chart_data.append(res)
268
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300269 if len(chart_data) == 0:
270 raise ValueError("Can't found any date for " + name_pref)
271
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300272 use_bw = ssize2b(chart_data[0].raw['blocksize']) > 16 * 1024
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300273
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300274 chart_data.sort(key=lambda x: x.raw['concurence'])
275
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300276 # if x.lat.average < max_lat]
277 lat = [x.lat.average / 1000 for x in chart_data]
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300278 lat_min = [x.lat.min / 1000 for x in chart_data]
279 lat_max = [x.lat.max / 1000 for x in chart_data]
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300280
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300281 vm_count = x.meta['testnodes_count']
282 concurence = [x.raw['concurence'] * vm_count for x in chart_data]
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300283
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300284 if use_bw:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300285 data = [x.bw.average / 1000 for x in chart_data]
286 data_dev = [x.bw.confidence / 1000 for x in chart_data]
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300287 name = "BW"
288 else:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300289 data = [x.iops.average for x in chart_data]
290 data_dev = [x.iops.confidence for x in chart_data]
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300291 name = "IOPS"
292
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300293 fname = os.path.join(charts_dir, fname)
294 if plt is not None:
295 io_chart_mpl(desc, concurence, lat, lat_min, lat_max,
296 data, data_dev, name, fname + '.svg')
297 file_ext = 'svg'
298 else:
299 io_chart(desc, concurence, lat, lat_min, lat_max,
300 data, data_dev, name, fname + '.png')
301 file_ext = 'png'
302 return file_ext
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300303
304
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300305def find_max_where(processed_results, sync_mode, blocksize, rw, iops=True):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300306 result = None
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300307 attr = 'iops' if iops else 'bw'
308 for measurement in processed_results.values():
309 ok = measurement.raw['sync_mode'] == sync_mode
310 ok = ok and (measurement.raw['blocksize'] == blocksize)
311 ok = ok and (measurement.raw['rw'] == rw)
312
313 if ok:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300314 field = getattr(measurement, attr)
315
316 if result is None:
317 result = field
318 elif field.average > result.average:
319 result = field
320
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300321 return result
322
323
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300324def get_disk_info(processed_results):
325 di = DiskInfo()
326 rws4k_iops_lat_th = []
327
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300328 di.direct_iops_w_max = find_max_where(processed_results,
329 'd', '4k', 'randwrite')
330 di.direct_iops_r_max = find_max_where(processed_results,
331 'd', '4k', 'randread')
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300332
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300333 di.bw_write_max = find_max_where(processed_results,
334 'd', '16m', 'randwrite', False)
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300335 if di.bw_write_max is None:
336 di.bw_write_max = find_max_where(processed_results,
337 'd', '1m', 'write', False)
338
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300339 di.bw_read_max = find_max_where(processed_results,
340 'd', '16m', 'randread', False)
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300341 if di.bw_read_max is None:
342 di.bw_read_max = find_max_where(processed_results,
343 'd', '1m', 'read', False)
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300344
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300345 for res in processed_results.values():
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300346 if res.raw['sync_mode'] == 's' and res.raw['blocksize'] == '4k':
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300347 if res.raw['rw'] != 'randwrite':
348 continue
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300349 rws4k_iops_lat_th.append((res.iops.average,
350 res.lat.average,
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300351 res.raw['concurence']))
352
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300353 rws4k_iops_lat_th.sort(key=lambda (_1, _2, conc): conc)
354
355 latv = [lat for _, lat, _ in rws4k_iops_lat_th]
356
357 for tlatv_ms in [10, 30, 100]:
358 tlat = tlatv_ms * 1000
359 pos = bisect.bisect_left(latv, tlat)
360 if 0 == pos:
361 iops3 = 0
362 elif pos == len(latv):
363 iops3 = latv[-1]
364 else:
365 lat1 = latv[pos - 1]
366 lat2 = latv[pos]
367
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300368 iops1, _, th1 = rws4k_iops_lat_th[pos - 1]
369 iops2, _, th2 = rws4k_iops_lat_th[pos]
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300370
371 th_lat_coef = (th2 - th1) / (lat2 - lat1)
372 th3 = th_lat_coef * (tlat - lat1) + th1
373
374 th_iops_coef = (iops2 - iops1) / (th2 - th1)
375 iops3 = th_iops_coef * (th3 - th1) + iops1
376 setattr(di, 'rws4k_{}ms'.format(tlatv_ms), int(iops3))
377
378 hdi = DiskInfo()
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300379
380 def pp(x):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300381 med, conf = x.rounded_average_conf()
382 conf_perc = int(float(conf) / med * 100)
383 return (med, conf_perc)
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300384
385 hdi.direct_iops_r_max = pp(di.direct_iops_r_max)
386 hdi.direct_iops_w_max = pp(di.direct_iops_w_max)
387 hdi.bw_write_max = pp(di.bw_write_max)
388 hdi.bw_read_max = pp(di.bw_read_max)
389
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300390 hdi.rws4k_10ms = di.rws4k_10ms if 0 != di.rws4k_10ms else None
391 hdi.rws4k_30ms = di.rws4k_30ms if 0 != di.rws4k_30ms else None
392 hdi.rws4k_100ms = di.rws4k_100ms if 0 != di.rws4k_100ms else None
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300393 return hdi
394
395
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300396@report('HDD', 'hdd_test_rrd4k,hdd_test_rws4k')
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300397def make_hdd_report(processed_results, path, charts_path, lab_info):
398 img_ext = make_hdd_plots(processed_results, charts_path)
koder aka kdanilova4a570f2015-04-23 22:11:40 +0300399 di = get_disk_info(processed_results)
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300400 render_hdd_html(path, di, lab_info, img_ext)
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300401
402
403@report('Ceph', 'ceph_test')
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300404def make_ceph_report(processed_results, path, charts_path, lab_info):
405 img_ext = make_ceph_plots(processed_results, charts_path)
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300406 di = get_disk_info(processed_results)
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300407 render_ceph_html(path, di, lab_info, img_ext)
koder aka kdanilova4a570f2015-04-23 22:11:40 +0300408
409
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300410def make_io_report(dinfo, results, path, charts_path, lab_info=None):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300411 lab_info = {
412 "total_disk": "None",
413 "total_memory": "None",
414 "nodes_count": "None",
415 "processor_count": "None"
416 }
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300417
koder aka kdanilova047e1b2015-04-21 23:16:59 +0300418 try:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300419 res_fields = sorted(dinfo.keys())
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300420 for fields, name, func in report_funcs:
koder aka kdanilovafd98742015-04-24 01:27:22 +0300421 for field in fields:
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300422 pos = bisect.bisect_left(res_fields, field)
423
424 if pos == len(res_fields):
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300425 break
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300426
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300427 if not res_fields[pos].startswith(field):
koder aka kdanilovafd98742015-04-24 01:27:22 +0300428 break
429 else:
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300430 hpath = path.format(name)
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300431 logger.debug("Generatins report " + name + " into " + hpath)
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300432 func(dinfo, hpath, charts_path, lab_info)
koder aka kdanilovafd98742015-04-24 01:27:22 +0300433 break
koder aka kdanilova4a570f2015-04-23 22:11:40 +0300434 else:
435 logger.warning("No report generator found for this load")
koder aka kdanilovafd98742015-04-24 01:27:22 +0300436
koder aka kdanilova047e1b2015-04-21 23:16:59 +0300437 except Exception as exc:
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300438 import traceback
439 traceback.print_exc()
koder aka kdanilovec1b9732015-04-23 20:43:29 +0300440 logger.error("Failed to generate html report:" + str(exc))