On Wed, Oct 07, 2015 at 07:08:47PM +0200, Jan Tluka wrote:
Mon, Oct 05, 2015 at 04:03:58PM CEST, olichtne(a)redhat.com wrote:
>From: Ondrej Lichtner <olichtne(a)redhat.com>
>
>This adds two new functions that work as templates when working with
>Netperf and PerfRepo.
>
>netperf_baseline_template takes a TestModule (Netperf) and a
>PerfRepoBaseline object to set the threshold options of the Netperf
>module based on data available from the Baseline.
>
>netperf_result_template takes a PerfRepoResult object and result data
>returned by a netperf client to add values to the PerfRepoResult object.
>
>These templates are based on how we work with PerfRepo and Netperf so
>they might not be useful for everyone.
>
>Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
>---
> lnst/Controller/PerfRepoUtils.py | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
>diff --git a/lnst/Controller/PerfRepoUtils.py b/lnst/Controller/PerfRepoUtils.py
>index 4d30110..c5df2e0 100644
>--- a/lnst/Controller/PerfRepoUtils.py
>+++ b/lnst/Controller/PerfRepoUtils.py
>@@ -11,3 +11,38 @@ __author__ = """
> olichtne(a)redhat.com (Ondrej Lichtner)
> """
>
>+import logging
>+from lnst.Common.Utils import Noop
>+
>+def netperf_baseline_template(module, baseline):
>+ if baseline.get_texec() is None:
>+ return module
>+
>+ logging.debug("Setting Netperf threshold.")
>+ throughput = baseline.get_value('throughput')
>+ deviation = baseline.get_value('throughput_deviation')
>+ if throughput is not None and deviation is not None:
>+ module.update_options({'threshold': '%s bits/sec' %
throughput,
>+ 'threshold_deviation': '%s bits/sec'
% deviation})
>+ return module
>+
>+def netperf_result_template(perfrepo_result, netperf_result):
>+ if isinstance(perfrepo_result, Noop):
>+ return perfrepo_result
>+
>+ try:
>+ result = netperf_result.get_result()
>+ res_data = result['res_data']
>+ rate = res_data['rate']
>+ deviation = res_data['rate_deviation']
>+ except:
>+ rate = 0.0
>+ deviation = 0.0
I'd rather raise an exception here. Doing this somehow masks the error
and would report 0.0 throughput. Do we want to save such result in
database?
What do you think?
I'm not exactly sure this even can happen right now, I put it there
because I remember that previously Netperf could sometimes just not
return result data, but looking at it now I think that can only happen
when the command gets killed or something else goes catastrophically
wrong.
The main problem I tried to solve is that this will catch an KeyError
exception which wouldn't give the user/tester enough information about
what happened. But I agree that it's probably a better idea to just give
some kind of an error and don't save this result to the database. So
I'll send a v2 patch for this when I get back to the office.
-Ondrej
>+
>+ logging.debug("Adding Netperf results to PerfRepo object.")
>+ perfrepo_result.add_value('throughput', rate)
>+ perfrepo_result.add_value('throughput_min', rate - deviation)
>+ perfrepo_result.add_value('throughput_max', rate + deviation)
>+ perfrepo_result.add_value('throughput_deviation', deviation)
>+
>+ return perfrepo_result
>--
>2.6.0
>
>_______________________________________________
>LNST-developers mailing list
>LNST-developers(a)lists.fedorahosted.org
>https://lists.fedorahosted.org/mailman/listinfo/lnst-developers