koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 1 | # put all result preprocessing here |
| 2 | # selection, aggregation |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 3 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame^] | 4 | import logging |
| 5 | |
| 6 | |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 7 | from .stage import Stage, StepOrder |
| 8 | from .test_run_class import TestRun |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame^] | 9 | from .statistic import calc_norm_stat_props, calc_histo_stat_props |
| 10 | from .result_classes import TestJobConfig |
| 11 | from .suits.itest import ResultStorage |
| 12 | from .suits.io.fio_hist import get_lat_vals, expected_lat_bins |
| 13 | from .utils import StopTestError |
| 14 | |
| 15 | logger = logging.getLogger("wally") |
| 16 | |
| 17 | import matplotlib |
| 18 | |
| 19 | # have to be before pyplot import to avoid tkinter(default graph frontend) import error |
| 20 | matplotlib.use('svg') |
| 21 | |
| 22 | import matplotlib.pyplot as plt |
| 23 | |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 24 | |
| 25 | class CalcStatisticStage(Stage): |
| 26 | priority = StepOrder.TEST + 1 |
| 27 | |
| 28 | def run(self, ctx: TestRun) -> None: |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame^] | 29 | rstorage = ResultStorage(ctx.storage, TestJobConfig) |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 30 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame^] | 31 | for suite_cfg, path in rstorage.list_suites(): |
| 32 | if suite_cfg.test_type != 'fio': |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 33 | continue |
| 34 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame^] | 35 | 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 kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 47 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame^] | 48 | 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 kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 53 | else: |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame^] | 54 | stat_prop = calc_norm_stat_props(ts) |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 55 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame^] | 56 | results[(node_id, dev, sensor_name)] = stat_prop |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 57 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame^] | 58 | raise StopTestError() |