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 | 41 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/lnst/Controller/PerfRepoUtils.py b/lnst/Controller/PerfRepoUtils.py
index 4d30110..4a46a84 100644
--- a/lnst/Controller/PerfRepoUtils.py
+++ b/lnst/Controller/PerfRepoUtils.py
@@ -11,3 +11,44 @@ __author__ = """
olichtne(a)redhat.com (Ondrej Lichtner)
"""
+import logging
+from lnst.Common.Utils import Noop
+
+class PerfRepoTemplateError(Exception):
+ pass
+
+def netperf_baseline_template(module, baseline):
+ if baseline.get_texec() is None:
+ return module
+
+ try:
+ throughput = baseline.get_value('throughput')
+ deviation = baseline.get_value('throughput_deviation')
+ except:
+ raise PerfRepoTemplateError("Invalid baseline TestExecution passed.")
+
+ logging.debug("Setting Netperf threshold.")
+ 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:
+ raise PerfRepoTemplateError("Netperf didn't return usable result
data.")
+
+ 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.1