aboutsummaryrefslogtreecommitdiffstats
path: root/testcases
diff options
context:
space:
mode:
Diffstat (limited to 'testcases')
-rw-r--r--testcases/testcase.py56
1 files changed, 36 insertions, 20 deletions
diff --git a/testcases/testcase.py b/testcases/testcase.py
index 7d5162e6..9c755ea7 100644
--- a/testcases/testcase.py
+++ b/testcases/testcase.py
@@ -19,6 +19,7 @@ import os
import logging
import subprocess
import copy
+import time
from collections import OrderedDict
from core.results.results_constants import ResultsConstants
@@ -45,14 +46,23 @@ class TestCase(object):
:param results_dir: Where the csv formatted results are written.
"""
self._hugepages_mounted = False
+
+ # set test parameters; CLI options take precedence to testcase settings
self._logger = logging.getLogger(__name__)
self.name = cfg['Name']
self.desc = cfg.get('Description', 'No description given.')
+
+ bidirectional = cfg.get('biDirectional', False)
+ bidirectional = get_test_param('bidirectional', bidirectional)
+
+ traffic_type = cfg.get('Traffic Type', 'rfc2544')
+ traffic_type = get_test_param('traffic_type', traffic_type)
+
+ framerate = cfg.get('iLoad', 100)
+ framerate = get_test_param('iload', framerate)
+
self.deployment = cfg['Deployment']
self._frame_mod = cfg.get('Frame Modification', None)
- framerate = get_test_param('iload', None)
- if framerate == None:
- framerate = cfg.get('iLoad', 100)
# identify guest loopback method, so it can be added into reports
self.guest_loopback = []
@@ -75,7 +85,6 @@ class TestCase(object):
pre_installed_flows = cfg.get('Pre-installed Flows', 'No')
pre_installed_flows = get_test_param('pre-installed_flows', pre_installed_flows)
-
# check if test requires background load and which generator it uses
self._load_cfg = cfg.get('Load', None)
if self._load_cfg and 'tool' in self._load_cfg:
@@ -90,9 +99,9 @@ class TestCase(object):
# set traffic details, so they can be passed to vswitch and traffic ctls
self._traffic = copy.deepcopy(TRAFFIC_DEFAULTS)
- self._traffic.update({'traffic_type': cfg['Traffic Type'],
+ self._traffic.update({'traffic_type': traffic_type,
'flow_type': cfg.get('Flow Type', 'port'),
- 'bidir': cfg['biDirectional'],
+ 'bidir': bidirectional,
'multistream': int(multistream),
'stream_type': stream_type,
'pre_installed_flows' : pre_installed_flows,
@@ -152,29 +161,36 @@ class TestCase(object):
if not self._vswitch_none:
self._add_flows(vswitch_ctl)
- with traffic_ctl:
- traffic_ctl.send_traffic(self._traffic)
+ # run traffic generator if requested, otherwise wait for manual termination
+ if S.getValue('mode') == 'trafficgen-off':
+ time.sleep(2)
+ self._logger.debug("All is set. Please run traffic generator manually.")
+ input(os.linesep + "Press Enter to terminate vswitchperf..." + os.linesep + os.linesep)
+ else:
+ with traffic_ctl:
+ traffic_ctl.send_traffic(self._traffic)
- # dump vswitch flows before they are affected by VNF termination
- if not self._vswitch_none:
- vswitch_ctl.dump_vswitch_flows()
+ # dump vswitch flows before they are affected by VNF termination
+ if not self._vswitch_none:
+ vswitch_ctl.dump_vswitch_flows()
# umount hugepages if mounted
self._umount_hugepages()
- self._logger.debug("Traffic Results:")
- traffic_ctl.print_results()
-
self._logger.debug("Collector Results:")
collector.print_results()
- output_file = os.path.join(self._results_dir, "result_" + self.name +
- "_" + self.deployment + ".csv")
+ if S.getValue('mode') != 'trafficgen-off':
+ self._logger.debug("Traffic Results:")
+ traffic_ctl.print_results()
+
+ output_file = os.path.join(self._results_dir, "result_" + self.name +
+ "_" + self.deployment + ".csv")
- tc_results = self._append_results(traffic_ctl.get_results())
- TestCase._write_result_to_file(tc_results, output_file)
+ tc_results = self._append_results(traffic_ctl.get_results())
+ TestCase._write_result_to_file(tc_results, output_file)
- report.generate(output_file, tc_results, collector.get_results())
+ report.generate(output_file, tc_results, collector.get_results())
def _append_results(self, results):
"""
@@ -287,7 +303,7 @@ class TestCase(object):
return list(result.keys())
- def _add_flows(vswitch_ctl):
+ def _add_flows(self, vswitch_ctl):
"""Add flows to the vswitch
:param vswitch_ctl vswitch controller