diff options
Diffstat (limited to 'testcases/testcase.py')
-rw-r--r-- | testcases/testcase.py | 30 |
1 files changed, 23 insertions, 7 deletions
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. |