blob: 5ca53afb940d27edcc29e378627e54486c635fe7 [file] [log] [blame]
koder aka kdanilov7f59d562016-12-26 01:34:23 +02001# put all result preprocessing here
2# selection, aggregation
koder aka kdanilovffaf48d2016-12-27 02:25:29 +02003
koder aka kdanilovf2865172016-12-30 03:35:11 +02004import logging
5
6
koder aka kdanilovffaf48d2016-12-27 02:25:29 +02007from .stage import Stage, StepOrder
8from .test_run_class import TestRun
koder aka kdanilovf2865172016-12-30 03:35:11 +02009from .statistic import calc_norm_stat_props, calc_histo_stat_props
10from .result_classes import TestJobConfig
11from .suits.itest import ResultStorage
12from .suits.io.fio_hist import get_lat_vals, expected_lat_bins
13from .utils import StopTestError
14
15logger = logging.getLogger("wally")
16
17import matplotlib
18
19# have to be before pyplot import to avoid tkinter(default graph frontend) import error
20matplotlib.use('svg')
21
22import matplotlib.pyplot as plt
23
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020024
25class CalcStatisticStage(Stage):
26 priority = StepOrder.TEST + 1
27
28 def run(self, ctx: TestRun) -> None:
koder aka kdanilovf2865172016-12-30 03:35:11 +020029 rstorage = ResultStorage(ctx.storage, TestJobConfig)
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020030
koder aka kdanilovf2865172016-12-30 03:35:11 +020031 for suite_cfg, path in rstorage.list_suites():
32 if suite_cfg.test_type != 'fio':
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020033 continue
34
koder aka kdanilovf2865172016-12-30 03:35:11 +020035 for job_cfg, path, _ in rstorage.list_jobs_in_suite(path):
36 results = {}
37 for node_id, dev, sensor_name in rstorage.list_ts_in_job(path):
38 ts = rstorage.load_ts(path, node_id, dev, sensor_name)
39 if dev == 'fio' and sensor_name == 'lat':
40 if ts.second_axis_size != expected_lat_bins:
41 logger.error("Sensor %s.%s on node %s has" +
42 "second_axis_size=%s. Can only process sensors with second_axis_size=%s.",
43 dev, sensor_name, node_id, ts.second_axis_size, expected_lat_bins)
44 continue
45 ts.bins_edges = get_lat_vals(ts.second_axis_size)
46 stat_prop = calc_histo_stat_props(ts)
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020047
koder aka kdanilovf2865172016-12-30 03:35:11 +020048 elif ts.second_axis_size != 1:
49 logger.warning("Sensor %s.%s on node %s provide 2D data with " +
50 "ts.second_axis_size=%s. Can't process it.",
51 dev, sensor_name, node_id, ts.second_axis_size)
52 continue
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020053 else:
koder aka kdanilovf2865172016-12-30 03:35:11 +020054 stat_prop = calc_norm_stat_props(ts)
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020055
koder aka kdanilovf2865172016-12-30 03:35:11 +020056 results[(node_id, dev, sensor_name)] = stat_prop
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020057
koder aka kdanilovf2865172016-12-30 03:35:11 +020058 raise StopTestError()