bugfix: mount hugepages for PVP and PVVP scenarios
[vswitchperf.git] / vsperf
diff --git a/vsperf b/vsperf
index f6ddc63..50f0996 100755 (executable)
--- a/vsperf
+++ b/vsperf
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-# Copyright 2015 Intel Corporation.
+# Copyright 2015-2016 Intel Corporation.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -26,10 +26,12 @@ import datetime
 import shutil
 import unittest
 import xmlrunner
+import locale
 
 sys.dont_write_bytecode = True
 
 from conf import settings
+from conf import get_test_param
 from core.loader import Loader
 from testcases import TestCase
 from tools import tasks
@@ -119,6 +121,8 @@ def parse_arguments():
                         help='list all system metrics loggers and exit')
     parser.add_argument('--list-vswitches', action='store_true',
                         help='list all system vswitches and exit')
+    parser.add_argument('--list-fwdapps', action='store_true',
+                        help='list all system forwarding applications and exit')
     parser.add_argument('--list-vnfs', action='store_true',
                         help='list all system vnfs and exit')
     parser.add_argument('--list-settings', action='store_true',
@@ -138,6 +142,7 @@ def parse_arguments():
                        help='debug level')
     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')
@@ -237,6 +242,17 @@ def apply_filter(tests, tc_filter):
     return result
 
 
+def check_and_set_locale():
+    """ Function will check locale settings. In case, that it isn't configured
+    properly, then default values specified by DEFAULT_LOCALE will be used.
+    """
+
+    system_locale = locale.getdefaultlocale()
+    if None in system_locale:
+        os.environ['LC_ALL'] = settings.getValue('DEFAULT_LOCALE')
+        logging.warning("Locale was not properly configured. Default values were set. Old locale: %s, New locale: %s",
+                        system_locale, locale.getdefaultlocale())
+
 class MockTestCase(unittest.TestCase):
     """Allow use of xmlrunner to generate Jenkins compatible output without
     using xmlrunner to actually run tests.
@@ -288,6 +304,7 @@ def main():
     # than both a settings file and environment variables
     settings.load_from_dict(args)
 
+    vswitch_none =  False
     # set dpdk and ovs paths accorfing to VNF and VSWITCH
     if settings.getValue('VSWITCH').endswith('Vanilla'):
         # settings paths for Vanilla
@@ -305,10 +322,15 @@ def main():
         # default - set to VHOST USER but can be changed during enhancement
         settings.setValue('RTE_SDK', (settings.getValue('RTE_SDK_USER')))
         settings.setValue('OVS_DIR', (settings.getValue('OVS_DIR_USER')))
+        if 'none' == settings.getValue('VSWITCH').strip().lower():
+            vswitch_none = True
 
     configure_logging(settings.getValue('VERBOSITY'))
     logger = logging.getLogger()
 
+    # check and fix locale
+    check_and_set_locale()
+
     # configure trafficgens
 
     if args['trafficgen']:
@@ -321,11 +343,25 @@ def main():
 
     # configure vswitch
     if args['vswitch']:
-        vswitches = Loader().get_vswitches()
-        if args['vswitch'] not in vswitches:
-            logging.error('There are no vswitches matching \'%s\' found in'
-                          ' \'%s\'. Exiting...', args['vswitch'],
-                          settings.getValue('VSWITCH_DIR'))
+        vswitch_none =  'none' == args['vswitch'].strip().lower()
+        if vswitch_none:
+            settings.setValue('VSWITCH', 'none')
+        else:
+            vswitches = Loader().get_vswitches()
+            if args['vswitch'] not in vswitches:
+                logging.error('There are no vswitches matching \'%s\' found in'
+                              ' \'%s\'. Exiting...', args['vswitch'],
+                              settings.getValue('VSWITCH_DIR'))
+                sys.exit(1)
+
+    if args['fwdapp']:
+        settings.setValue('PKTFWD', args['fwdapp'])
+        fwdapps = Loader().get_pktfwds()
+        if args['fwdapp'] not in fwdapps:
+            logging.error('There are no forwarding application'
+                          ' matching \'%s\' found in'
+                          ' \'%s\'. Exiting...', args['fwdapp'],
+                          settings.getValue('PKTFWD_DIR'))
             sys.exit(1)
 
     if args['vnf']:
@@ -343,6 +379,14 @@ def main():
             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:
+        tmp_gl = []
+        for i in range(len(settings.getValue('GUEST_LOOPBACK'))):
+            tmp_gl.append(guest_loopback)
+        settings.setValue('GUEST_LOOPBACK', tmp_gl)
+
     # generate results directory name
     date = datetime.datetime.fromtimestamp(time.time())
     results_dir = "results_" + date.strftime('%Y-%m-%d_%H-%M-%S')
@@ -380,6 +424,10 @@ def main():
         print(Loader().get_vswitches_printable())
         exit()
 
+    if args['list_fwdapps']:
+        print(Loader().get_pktfwds_printable())
+        exit()
+
     if args['list_vnfs']:
         print(Loader().get_vnfs_printable())
         exit()
@@ -417,6 +465,11 @@ def main():
     suite = unittest.TestSuite()
     for test in selected_tests:
         try:
+            if vswitch_none:
+                if test.deployment.lower() != 'p2p':
+                    logging.error('\'none\' vswitch option supported only'
+                                  ' for p2p deployment.')
+                    sys.exit(1)
             test.run()
             suite.addTest(MockTestCase('', True, test.name))
         #pylint: disable=broad-except
@@ -433,11 +486,15 @@ def main():
     if args['opnfvpod']:
         pod_name = args['opnfvpod']
         installer_name = settings.getValue('OPNFV_INSTALLER')
+        opnfv_url = settings.getValue('OPNFV_URL')
+        pkg_list = settings.getValue('PACKAGE_LIST')
 
         int_data = {'cuse': False,
                     'vanilla': False,
                     'pod': pod_name,
-                    'installer': installer_name}
+                    'installer': installer_name,
+                    'pkg_list': pkg_list,
+                    'db_url': opnfv_url}
         if settings.getValue('VSWITCH').endswith('Vanilla'):
             int_data['vanilla'] = True
         if settings.getValue('VNF').endswith('Cuse'):