From c99fda7cb1019c036c5caa828e2febe935d4aaf0 Mon Sep 17 00:00:00 2001 From: Martin Klozik Date: Wed, 19 Aug 2015 07:52:39 +0100 Subject: Initial reporting implemenation Reporting from TOIT was merged and improved. Default template was modified to support any testcase and to show more details about system environment. Affected files: * docs/NEWS.md * testcases/testcase.py * tools/report/__init__.py * tools/report/report.jinja * tools/report/report.py * tools/systeminfo.py * vsperf JIRA: VSPERF-71 Change-Id: I4dc84ca69e5c292eae1f8dede1411c06ae3ef8af Signed-off-by: Martin Klozik (martinx.klozik@intel.com) Reviewed-by: Maryam Tahhan Reviewed-by: Billy O Mahony --- testcases/testcase.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'testcases/testcase.py') diff --git a/testcases/testcase.py b/testcases/testcase.py index 77d5992d..6191a117 100644 --- a/testcases/testcase.py +++ b/testcases/testcase.py @@ -19,6 +19,7 @@ import os import logging from collections import OrderedDict +from core.results.results_constants import ResultsConstants import core.component_factory as component_factory from core.loader import Loader @@ -39,7 +40,7 @@ class TestCase(object): self.name = cfg['Name'] self.desc = cfg.get('Description', 'No description given.') self._traffic_type = cfg['Traffic Type'] - self._deployment = cfg['Deployment'] + self.deployment = cfg['Deployment'] self._collector = cfg['Collector'] self._bidir = cfg['biDirectional'] self._frame_mod = cfg.get('Frame Modification', None) @@ -61,10 +62,10 @@ class TestCase(object): self._traffic_type, loader.get_trafficgen_class()) vnf_ctl = component_factory.create_vnf( - self._deployment, + self.deployment, loader.get_vnf_class()) vswitch_ctl = component_factory.create_vswitch( - self._deployment, + self.deployment, loader.get_vswitch_class(), self._bidir) collector_ctl = component_factory.create_collector( @@ -98,13 +99,28 @@ class TestCase(object): self._logger.debug("Collector Results:") self._logger.debug(collector_ctl.get_results()) + output_file = "result_" + self.name + "_" + self.deployment +".csv" - output_file = "result_" + self.name + "_" + self._deployment +".csv" - - self._write_result_to_file( - traffic_ctl.get_results(), + TestCase._write_result_to_file( + self._append_results(traffic_ctl.get_results()), os.path.join(self._results_dir, output_file)) + def _append_results(self, results): + """ + Method appends mandatory Test Case results to list of dictionaries. + + :param results: list of dictionaries which contains results from + traffic generator. + + :returns: modified list of dictionaries. + """ + for item in results: + item[ResultsConstants.ID] = self.name + item[ResultsConstants.DEPLOYMENT] = self.deployment + + return results + + @staticmethod def _write_result_to_file(results, output): """Write list of dictionaries to a CSV file. -- cgit 1.2.3-korg