bugfix: Parameter duration does not work
[vswitchperf.git] / vsperf
diff --git a/vsperf b/vsperf
index 4b1d86d..53f5507 100755 (executable)
--- a/vsperf
+++ b/vsperf
@@ -53,7 +53,8 @@ VERBOSITY_LEVELS = {
 
 _TEMPLATE_RST = {'head'  : 'tools/report/report_head.rst',
                  'foot'  : 'tools/report/report_foot.rst',
-                 'final' : 'test_report.rst'
+                 'final' : 'test_report.rst',
+                 'tmp'   : 'tools/report/report_tmp_caption.rst'
                 }
 
 def parse_arguments():
@@ -145,7 +146,8 @@ def parse_arguments():
     group.add_argument('-m', '--mode', help='vsperf mode of operation;\
             Values: "normal" - execute vSwitch, VNF and traffic generator;\
             "trafficgen" - execute only traffic generator; "trafficgen-off" \
-            - execute vSwitch and VNF', default='normal')
+            - execute vSwitch and VNF; trafficgen-pause - execute vSwitch \
+            and VNF but pause before traffic transmission ', default='normal')
 
     group.add_argument('-f', '--test-spec', help='test specification file')
     group.add_argument('-d', '--test-dir', help='directory containing tests')
@@ -154,11 +156,11 @@ def parse_arguments():
             name contains RFC2544 less those containing "p2p"')
     group.add_argument('--verbosity', choices=list_logging_levels(),
                        help='debug level')
+    group.add_argument('--run-integration', action='store_true', help='run integration tests')
     group.add_argument('--trafficgen', help='traffic generator to use')
     group.add_argument('--vswitch', help='vswitch implementation to use')
     group.add_argument('--fwdapp', help='packet forwarding application to use')
     group.add_argument('--vnf', help='vnf to use')
-    group.add_argument('--duration', help='traffic transmit duration')
     group.add_argument('--sysmetrics', help='system metrics logger to use')
     group = parser.add_argument_group('test behavior options')
     group.add_argument('--xunit', action='store_true',
@@ -277,13 +279,29 @@ def generate_final_report(path):
     rst_results = glob.glob(os.path.join(path, 'result*rst'))
     if len(rst_results):
         try:
-            test_report = os.path.join(path, _TEMPLATE_RST['final'])
-            retval = subprocess.call('cat {} {} {} > {}'.format(_TEMPLATE_RST['head'], ' '.join(rst_results),
-                                                                _TEMPLATE_RST['foot'], test_report), shell=True)
+            test_report = os.path.join(path, '{}_{}'.format(settings.getValue('VSWITCH'), _TEMPLATE_RST['final']))
+            # create report caption directly - it is not worth to execute jinja machinery
+            report_caption = '{}\n{} {}\n{}\n\n'.format(
+                '============================================================',
+                'Performance report for',
+                Loader().get_vswitches()[settings.getValue('VSWITCH')].__doc__.strip().split('\n')[0],
+
+                '============================================================')
+
+            with open(_TEMPLATE_RST['tmp'], 'w') as file_:
+                file_.write(report_caption)
+
+            retval = subprocess.call('cat {} {} {} {} > {}'.format(_TEMPLATE_RST['tmp'], _TEMPLATE_RST['head'],
+                                                                   ' '.join(rst_results), _TEMPLATE_RST['foot'],
+                                                                   test_report), shell=True)
             if retval == 0 and os.path.isfile(test_report):
                 logging.info('Overall test report written to "%s"', test_report)
             else:
                 logging.error('Generatrion of overall test report has failed.')
+
+            # remove temporary file
+            os.remove(_TEMPLATE_RST['tmp'])
+
         except subprocess.CalledProcessError:
             logging.error('Generatrion of overall test report has failed.')
 
@@ -325,6 +343,13 @@ def main():
 
     settings.load_from_dir('conf')
 
+    performance_test = True
+
+    # Load non performance/integration tests
+    if args['run_integration']:
+        performance_test = False
+        settings.load_from_dir('conf/integration')
+
     # load command line parameters first in case there are settings files
     # to be used
     settings.load_from_dict(args)
@@ -406,13 +431,6 @@ def main():
                           settings.getValue('vnf_dir'))
             sys.exit(1)
 
-    if args['duration']:
-        if args['duration'].isdigit() and int(args['duration']) > 0:
-            settings.setValue('duration', args['duration'])
-        else:
-            logging.error('The selected Duration is not a number')
-            sys.exit(1)
-
     # update global settings
     guest_loopback = get_test_param('guest_loopback', None)
     if guest_loopback:
@@ -455,10 +473,13 @@ def main():
     else:
         # configure tests
         testcases = settings.getValue('PERFORMANCE_TESTS')
+        if args['run_integration']:
+            testcases = settings.getValue('INTEGRATION_TESTS')
+
         all_tests = []
         for cfg in testcases:
             try:
-                all_tests.append(TestCase(cfg, results_path))
+                all_tests.append(TestCase(cfg, results_path, performance_test))
             except (Exception) as _:
                 logger.exception("Failed to create test: %s",
                                  cfg.get('Name', '<Name not set>'))