blob: 112826e34eff53550826eaeb44cb3a732dc4907e [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 kdanilov108ac362017-01-19 20:17:16 +02004from io import BytesIO
koder aka kdanilovf2865172016-12-30 03:35:11 +02005import logging
koder aka kdanilov108ac362017-01-19 20:17:16 +02006from typing import Any
koder aka kdanilovf2865172016-12-30 03:35:11 +02007
koder aka kdanilovffaf48d2016-12-27 02:25:29 +02008from .stage import Stage, StepOrder
9from .test_run_class import TestRun
koder aka kdanilovf2865172016-12-30 03:35:11 +020010from .statistic import calc_norm_stat_props, calc_histo_stat_props
koder aka kdanilov108ac362017-01-19 20:17:16 +020011from .result_classes import StatProps, DataSource, TimeSeries
12from .hlstorage import ResultStorage
koder aka kdanilovf2865172016-12-30 03:35:11 +020013from .suits.io.fio_hist import get_lat_vals, expected_lat_bins
koder aka kdanilov108ac362017-01-19 20:17:16 +020014from .suits.io.fio import FioTest
koder aka kdanilovf2865172016-12-30 03:35:11 +020015from .utils import StopTestError
16
koder aka kdanilovf2865172016-12-30 03:35:11 +020017import matplotlib
koder aka kdanilovf2865172016-12-30 03:35:11 +020018matplotlib.use('svg')
koder aka kdanilovf2865172016-12-30 03:35:11 +020019import matplotlib.pyplot as plt
20
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020021
koder aka kdanilov108ac362017-01-19 20:17:16 +020022logger = logging.getLogger("wally")
23
24
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020025class CalcStatisticStage(Stage):
26 priority = StepOrder.TEST + 1
27
28 def run(self, ctx: TestRun) -> None:
koder aka kdanilov108ac362017-01-19 20:17:16 +020029 rstorage = ResultStorage(ctx.storage)
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020030
koder aka kdanilov108ac362017-01-19 20:17:16 +020031 for suite in rstorage.iter_suite(FioTest.name):
32 for job in rstorage.iter_job(suite):
koder aka kdanilovf2865172016-12-30 03:35:11 +020033 results = {}
koder aka kdanilov108ac362017-01-19 20:17:16 +020034 for ts in rstorage.iter_ts(suite, job):
35 if ts.source.sensor == 'lat':
koder aka kdanilovf2865172016-12-30 03:35:11 +020036 if ts.second_axis_size != expected_lat_bins:
37 logger.error("Sensor %s.%s on node %s has" +
38 "second_axis_size=%s. Can only process sensors with second_axis_size=%s.",
koder aka kdanilov108ac362017-01-19 20:17:16 +020039 ts.source.dev, ts.source.sensor, ts.source.node_id,
40 ts.second_axis_size, expected_lat_bins)
koder aka kdanilovf2865172016-12-30 03:35:11 +020041 continue
42 ts.bins_edges = get_lat_vals(ts.second_axis_size)
koder aka kdanilov108ac362017-01-19 20:17:16 +020043 stat_prop = calc_histo_stat_props(ts) # type: StatProps
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020044
koder aka kdanilovf2865172016-12-30 03:35:11 +020045 elif ts.second_axis_size != 1:
46 logger.warning("Sensor %s.%s on node %s provide 2D data with " +
47 "ts.second_axis_size=%s. Can't process it.",
koder aka kdanilov108ac362017-01-19 20:17:16 +020048 ts.source.dev, ts.source.sensor, ts.source.node_id, ts.second_axis_size)
koder aka kdanilovf2865172016-12-30 03:35:11 +020049 continue
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020050 else:
koder aka kdanilovf2865172016-12-30 03:35:11 +020051 stat_prop = calc_norm_stat_props(ts)
koder aka kdanilovffaf48d2016-12-27 02:25:29 +020052
koder aka kdanilovf2865172016-12-30 03:35:11 +020053 raise StopTestError()