#!/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.
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
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',
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')
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.
# 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
# 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']:
# 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']:
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')
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()
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
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'):