blob: d1b6e9f7a07ac25fbb85ef095f50be8bfcbcbdd4 [file] [log] [blame]
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +03001import logging
kdanylov aka koder938f75f2018-06-27 01:52:44 +03002from typing import cast, List, Union
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +03003
kdanylov aka koder150b2192017-04-01 16:53:01 +03004import numpy
5
6from cephlib.common import float2str
kdanylov aka koder84de1e42017-05-22 14:00:07 +03007from cephlib.texttable import Texttable
kdanylov aka koderb0833332017-05-13 20:39:17 +03008from cephlib.statistic import calc_norm_stat_props, calc_histo_stat_props
kdanylov aka koder150b2192017-04-01 16:53:01 +03009
kdanylov aka koder150b2192017-04-01 16:53:01 +030010from .stage import Stage, StepOrder
11from .test_run_class import TestRun
kdanylov aka koder84de1e42017-05-22 14:00:07 +030012from .result_classes import SuiteConfig
kdanylov aka koder150b2192017-04-01 16:53:01 +030013from .suits.io.fio import FioTest
kdanylov aka koder84de1e42017-05-22 14:00:07 +030014from .suits.io.fio_job import FioJobParams
kdanylov aka koder150b2192017-04-01 16:53:01 +030015from .suits.io.fio_hist import get_lat_vals
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030016from .data_selectors import get_aggregated
kdanylov aka koder84de1e42017-05-22 14:00:07 +030017from .result_storage import IWallyStorage
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030018
19
20logger = logging.getLogger("wally")
21
kdanylov aka koder150b2192017-04-01 16:53:01 +030022
kdanylov aka koder84de1e42017-05-22 14:00:07 +030023console_report_headers = ["Description", "IOPS ~ Dev", "BW, MiBps", 'Skew/Kurt', 'lat med, ms', 'lat 95, ms']
24console_report_align = ['l', 'r', 'r', 'r', 'r', 'r']
25
26def get_console_report_table(suite: SuiteConfig, rstorage: IWallyStorage) -> List[Union[List[str], Texttable.HLINE]]:
kdanylov aka koder938f75f2018-06-27 01:52:44 +030027 table: List[Union[List[str], Texttable.HLINE]] = []
kdanylov aka koder84de1e42017-05-22 14:00:07 +030028 prev_params = None
29 for job in sorted(rstorage.iter_job(suite), key=lambda job: job.params):
30 fparams = cast(FioJobParams, job.params)
31 fparams['qd'] = None
32
33 if prev_params is not None and fparams.char_tpl != prev_params:
34 table.append(Texttable.HLINE)
35
36 prev_params = fparams.char_tpl
37
38 bw_ts = get_aggregated(rstorage, suite.storage_id, job.storage_id, metric='bw',
39 trange=job.reliable_info_range_s)
40 props = calc_norm_stat_props(bw_ts)
41 avg_iops = props.average // job.params.params['bsize']
42 iops_dev = props.deviation // job.params.params['bsize']
43
44 lat_ts = get_aggregated(rstorage, suite.storage_id, job.storage_id, metric='lat',
45 trange=job.reliable_info_range_s)
46 bins_edges = numpy.array(get_lat_vals(lat_ts.data.shape[1]), dtype='float32') / 1000 # convert us to ms
47 lat_props = calc_histo_stat_props(lat_ts, bins_edges)
48 table.append([job.params.summary,
kdanylov aka koder938f75f2018-06-27 01:52:44 +030049 f"{float2str(avg_iops):>6s} ~ {float2str(iops_dev):>6s}",
kdanylov aka koder84de1e42017-05-22 14:00:07 +030050 float2str(props.average / 1024), # Ki -> Mi
kdanylov aka koder938f75f2018-06-27 01:52:44 +030051 f"{props.skew:>5.1f}/{props.kurt:>5.1f}",
kdanylov aka koder84de1e42017-05-22 14:00:07 +030052 float2str(lat_props.perc_50), float2str(lat_props.perc_95)])
53 return table
54
55
kdanylov aka koder150b2192017-04-01 16:53:01 +030056class ConsoleReportStage(Stage):
57
58 priority = StepOrder.REPORT
59
60 def run(self, ctx: TestRun) -> None:
kdanylov aka koderb0833332017-05-13 20:39:17 +030061 for suite in ctx.rstorage.iter_suite(FioTest.name):
kdanylov aka koder84de1e42017-05-22 14:00:07 +030062 table = Texttable(max_width=200)
63 table.set_deco(Texttable.VLINES | Texttable.BORDER | Texttable.HEADER)
kdanylov aka koderb0833332017-05-13 20:39:17 +030064 tbl = ctx.rstorage.get_txt_report(suite)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030065 if tbl is None:
kdanylov aka koder84de1e42017-05-22 14:00:07 +030066 table.header(console_report_headers)
67 table.set_cols_align(console_report_align)
68 for line in get_console_report_table(suite, ctx.rstorage):
69 table.add_row(line)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030070 tbl = table.draw()
kdanylov aka koderb0833332017-05-13 20:39:17 +030071 ctx.rstorage.put_txt_report(suite, tbl)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030072 print(tbl)