summaryrefslogtreecommitdiffstats
path: root/vsperf
diff options
context:
space:
mode:
Diffstat (limited to 'vsperf')
-rwxr-xr-xvsperf35
1 files changed, 32 insertions, 3 deletions
diff --git a/vsperf b/vsperf
index 93772326..4b1d86d0 100755
--- a/vsperf
+++ b/vsperf
@@ -28,6 +28,8 @@ import unittest
import xmlrunner
import locale
import copy
+import glob
+import subprocess
sys.dont_write_bytecode = True
@@ -39,7 +41,6 @@ from tools import tasks
from tools.pkt_gen import trafficgen
from tools.opnfvdashboard import opnfvdashboard
from tools.pkt_gen.trafficgen.trafficgenhelper import TRAFFIC_DEFAULTS
-from conf import get_test_param
import core.component_factory as component_factory
VERBOSITY_LEVELS = {
@@ -50,6 +51,10 @@ VERBOSITY_LEVELS = {
'critical': logging.CRITICAL
}
+_TEMPLATE_RST = {'head' : 'tools/report/report_head.rst',
+ 'foot' : 'tools/report/report_foot.rst',
+ 'final' : 'test_report.rst'
+ }
def parse_arguments():
"""
@@ -262,6 +267,27 @@ def check_and_set_locale():
logging.warning("Locale was not properly configured. Default values were set. Old locale: %s, New locale: %s",
system_locale, locale.getdefaultlocale())
+
+def generate_final_report(path):
+ """ Function will check if partial test results are available
+ and generates final report in rst format.
+ """
+
+ # check if there are any results in rst format
+ 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)
+ 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.')
+ except subprocess.CalledProcessError:
+ logging.error('Generatrion of overall test report has failed.')
+
+
class MockTestCase(unittest.TestCase):
"""Allow use of xmlrunner to generate Jenkins compatible output without
using xmlrunner to actually run tests.
@@ -313,7 +339,7 @@ def main():
# than both a settings file and environment variables
settings.load_from_dict(args)
- vswitch_none = False
+ vswitch_none = False
# set dpdk and ovs paths accorfing to VNF and VSWITCH
if settings.getValue('VSWITCH').endswith('Vanilla'):
# settings paths for Vanilla
@@ -351,7 +377,7 @@ def main():
# configure vswitch
if args['vswitch']:
- vswitch_none = 'none' == args['vswitch'].strip().lower()
+ vswitch_none = 'none' == args['vswitch'].strip().lower()
if vswitch_none:
settings.setValue('VSWITCH', 'none')
else:
@@ -499,6 +525,9 @@ def main():
suite.addTest(MockTestCase(str(ex), False, test.name))
logger.info("Continuing with next test...")
+ # generate final rst report with results of all executed TCs
+ generate_final_report(results_path)
+
if settings.getValue('XUNIT'):
xmlrunner.XMLTestRunner(
output=settings.getValue('XUNIT_DIR'), outsuffix="",