From: Ondrej Lichtner olichtne@redhat.com
This function transforms the PerfRepo TestExecution object representing a baseline into a dictionary acceptable by the Netperf module.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Controller/PerfRepoUtils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/lnst/Controller/PerfRepoUtils.py b/lnst/Controller/PerfRepoUtils.py index 533652b..4c545e4 100644 --- a/lnst/Controller/PerfRepoUtils.py +++ b/lnst/Controller/PerfRepoUtils.py @@ -34,6 +34,22 @@ def netperf_baseline_template(module, baseline): 'threshold_deviation': '%s bits/sec' % deviation}) return module
+def perfrepo_baseline_to_dict(baseline): + if baseline.get_texec() is None: + return {} + + try: + throughput = baseline.get_value('throughput') + deviation = baseline.get_value('throughput_deviation') + except: + logging.error("Invalid baseline TestExecution passed.") + return {} + + if throughput is not None and deviation is not None: + return {'threshold': '%s bits/sec' % throughput, + 'threshold_deviation': '%s bits/sec' % deviation} + return {} + def netperf_result_template(perfrepo_result, netperf_result): if isinstance(perfrepo_result, Noop): return perfrepo_result