diff options
-rw-r--r-- | sdnvpn/lib/config.py | 6 | ||||
-rw-r--r-- | sdnvpn/lib/logutil.py | 22 | ||||
-rw-r--r-- | sdnvpn/lib/openstack_utils.py | 4 | ||||
-rw-r--r-- | sdnvpn/lib/quagga.py | 4 | ||||
-rw-r--r-- | sdnvpn/lib/results.py | 4 | ||||
-rw-r--r-- | sdnvpn/lib/utils.py | 4 | ||||
-rw-r--r-- | sdnvpn/test/functest/run_sdnvpn_tests.py | 50 | ||||
-rw-r--r-- | sdnvpn/test/functest/run_tempest.py | 4 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_1.py | 4 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_10.py | 5 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_11.py | 4 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_12.py | 4 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_13.py | 16 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_2.py | 4 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_3.py | 8 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_4.py | 4 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_7.py | 4 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_8.py | 4 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_9.py | 4 |
19 files changed, 76 insertions, 83 deletions
diff --git a/sdnvpn/lib/config.py b/sdnvpn/lib/config.py index e63574b..847b41c 100644 --- a/sdnvpn/lib/config.py +++ b/sdnvpn/lib/config.py @@ -7,14 +7,14 @@ # # http://www.apache.org/licenses/LICENSE-2.0 +import logging import yaml import pkg_resources from functest.utils import config import functest.utils.functest_utils as ft_utils -from sdnvpn.lib import logutil -logger = logutil.getLogger('sdnvpn_test_config') +logger = logging.getLogger('sdnvpn_test_config') class CommonConfig(object): @@ -53,7 +53,7 @@ class CommonConfig(object): # TODO does functest have an ubuntu image somewhere? self.ubuntu_image_name = "sdnvpn-ubuntu" self.ubuntu_image_path = '{0}/{1}'.format( - getattr(config.CONF, 'dir_functest_images'), + getattr(config.CONF, 'dir_functest_data'), "ubuntu-16.04-server-cloudimg-amd64-disk1.img") self.custom_flavor_name = 'm1.custom' self.custom_flavor_ram = 1024 diff --git a/sdnvpn/lib/logutil.py b/sdnvpn/lib/logutil.py deleted file mode 100644 index 3765734..0000000 --- a/sdnvpn/lib/logutil.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2018 All rights reserved -# This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -import logging -import os.path - -from xtesting.core import feature - - -def getLogger(module_name): - logger = logging.getLogger(module_name) - log_file = "{}/{}.log".format("/var/lib/xtesting/results", "bgpvpn") - if not os.path.exists(log_file): - open(log_file, 'w+') - feature.Feature.configure_logger(logger, log_file) - return logger diff --git a/sdnvpn/lib/openstack_utils.py b/sdnvpn/lib/openstack_utils.py index 447e87b..a7ac80b 100644 --- a/sdnvpn/lib/openstack_utils.py +++ b/sdnvpn/lib/openstack_utils.py @@ -8,6 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import os.path import shutil import sys @@ -24,9 +25,8 @@ from keystoneclient import client as keystoneclient from neutronclient.neutron import client as neutronclient from functest.utils import env -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) DEFAULT_API_VERSION = '2' DEFAULT_HEAT_API_VERSION = '1' diff --git a/sdnvpn/lib/quagga.py b/sdnvpn/lib/quagga.py index 27bf122..e072f1c 100644 --- a/sdnvpn/lib/quagga.py +++ b/sdnvpn/lib/quagga.py @@ -9,15 +9,15 @@ # """Utilities for setting up quagga peering""" +import logging import re import time import functest.utils.functest_utils as ft_utils import sdnvpn.lib.config as config from sdnvpn.lib.utils import run_odl_cmd, exec_cmd -from sdnvpn.lib import logutil -logger = logutil.getLogger('sdnvpn-quagga') +logger = logging.getLogger('sdnvpn-quagga') COMMON_CONFIG = config.CommonConfig() diff --git a/sdnvpn/lib/results.py b/sdnvpn/lib/results.py index 42d1865..e1a5e5a 100644 --- a/sdnvpn/lib/results.py +++ b/sdnvpn/lib/results.py @@ -7,12 +7,12 @@ # # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import time import functest.utils.functest_utils as ft_utils -from sdnvpn.lib import logutil -logger = logutil.getLogger('sdnvpn-results') +logger = logging.getLogger('sdnvpn-results') class Results(object): diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py index aafd69b..0748803 100644 --- a/sdnvpn/lib/utils.py +++ b/sdnvpn/lib/utils.py @@ -7,6 +7,7 @@ # # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import os import time import requests @@ -18,9 +19,8 @@ from opnfv.deployment.factory import Factory as DeploymentFactory from sdnvpn.lib import config as sdnvpn_config import sdnvpn.lib.openstack_utils as os_utils -from sdnvpn.lib import logutil -logger = logutil.getLogger('sdnvpn_test_utils') +logger = logging.getLogger('sdnvpn_test_utils') common_config = sdnvpn_config.CommonConfig() diff --git a/sdnvpn/test/functest/run_sdnvpn_tests.py b/sdnvpn/test/functest/run_sdnvpn_tests.py index 8e55b2d..e4d55f1 100644 --- a/sdnvpn/test/functest/run_sdnvpn_tests.py +++ b/sdnvpn/test/functest/run_sdnvpn_tests.py @@ -21,6 +21,7 @@ from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib.gather_logs import gather_logs from sdnvpn.lib import utils as test_utils +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() @@ -42,8 +43,8 @@ class SdnvpnFunctest(feature.Feature): neutron_quota['port'], neutron_quota['router']) instances_quota = test_utils.get_nova_instances_quota(nova_client) - self.logger.info("Setting net/subnet/port/router " - "quota to unlimited") + logger.info("Setting net/subnet/port/router " + "quota to unlimited") test_utils.update_nw_subnet_port_quota( neutron_client, tenant_id, @@ -55,13 +56,14 @@ class SdnvpnFunctest(feature.Feature): # Workaround for # https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115 - self.logger.info("Setting instances quota class to unlimited") + logger.info("Setting instances quota class to unlimited") test_utils.update_instance_quota_class( nova_client, COMMON_CONFIG.nova_instances_quota_class) # Clean up the stale floating ip's so that required # ip addresses are available for sdnvpn testcases + logger.info("Cleaning up the Floating IP Addresses") floating_ips = os_utils.get_floating_ips(neutron_client) if floating_ips is not None: for floating_ip in floating_ips: @@ -79,37 +81,37 @@ class SdnvpnFunctest(feature.Feature): test_descr = testcases[tc]['description'] title = ("Running '%s - %s'" % (test_name, test_descr)) - self.logger.info(title) - self.logger.info("%s\n" % ("=" * len(title))) + logger.info(title) + logger.info("%s\n" % ("=" * len(title))) try: - self.logger.info("Importing the testcase %s" % test_name) + logger.info("Importing the testcase %s" % test_name) t = importlib.import_module(test_name, package=None) - self.logger.info("Calling the testcase %s main method" - % test_name) + logger.info("Calling the testcase %s main method" + % test_name) result = t.main() - self.logger.info("Execution is complete for the" - " testcase %s" % test_name) + logger.info("Execution is complete for the" + " testcase %s" % test_name) except Exception as ex: result = -1 - self.logger.info("Caught Exception in %s: %s Trace: %s" - % (test_name, ex, - traceback.format_exc())) + logger.info("Caught Exception in %s: %s Trace: %s" + % (test_name, ex, + traceback.format_exc())) if result < 0: status = "FAIL" overall_status = "FAIL" - self.logger.info("Testcase %s failed" % test_name) + logger.info("Testcase %s failed" % test_name) else: status = result.get("status") self.details.update( {test_name: {'status': status, 'details': result.get("details")}}) - self.logger.info("Results of test case '%s - %s':\n%s\n" - % (test_name, test_descr, result)) + logger.info("Results of test case '%s - %s':\n%s\n" + % (test_name, test_descr, result)) if status == "FAIL": overall_status = "FAIL" - self.logger.info("Resetting subnet/net/port quota") + logger.info("Resetting subnet/net/port quota") test_utils.update_nw_subnet_port_quota(neutron_client, tenant_id, neutron_nw_quota, @@ -117,7 +119,7 @@ class SdnvpnFunctest(feature.Feature): neutron_port_quota, neutron_router_quota) - self.logger.info("Resetting instances quota class") + logger.info("Resetting instances quota class") test_utils.update_instance_quota_class(nova_client, instances_quota) try: @@ -125,13 +127,13 @@ class SdnvpnFunctest(feature.Feature): if installer_type in ["fuel", "apex"]: gather_logs('overall') else: - self.logger.info("Skipping log gathering because installer" - "type %s is neither fuel nor apex" % - installer_type) + logger.info("Skipping log gathering because installer" + "type %s is neither fuel nor apex" % + installer_type) except Exception as ex: - self.logger.error(('Something went wrong in the Log gathering.' - 'Ex: %s, Trace: %s') - % (ex, traceback.format_exc())) + logger.error(('Something went wrong in the Log gathering.' + 'Ex: %s, Trace: %s') + % (ex, traceback.format_exc())) if overall_status == "PASS": self.result = 100 diff --git a/sdnvpn/test/functest/run_tempest.py b/sdnvpn/test/functest/run_tempest.py index 68045fa..a1ef004 100644 --- a/sdnvpn/test/functest/run_tempest.py +++ b/sdnvpn/test/functest/run_tempest.py @@ -9,14 +9,14 @@ # # import ConfigParser +import logging import os import re import shutil import functest.opnfv_tests.openstack.tempest.conf_utils as tempest_utils -from sdnvpn.lib import logutil -logger = logutil.getLogger('sdnvpn-tempest') +logger = logging.getLogger('sdnvpn-tempest') def main(): diff --git a/sdnvpn/test/functest/testcase_1.py b/sdnvpn/test/functest/testcase_1.py index b1f3dae..35e32b2 100644 --- a/sdnvpn/test/functest/testcase_1.py +++ b/sdnvpn/test/functest/testcase_1.py @@ -8,6 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import sys from random import randint @@ -15,9 +16,8 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( diff --git a/sdnvpn/test/functest/testcase_10.py b/sdnvpn/test/functest/testcase_10.py index f776ecf..aebc146 100644 --- a/sdnvpn/test/functest/testcase_10.py +++ b/sdnvpn/test/functest/testcase_10.py @@ -8,6 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import re import sys import time @@ -17,10 +18,8 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil - -logger = logutil.getLogger('__name__') +logger = logging.getLogger('__name__') std_out_lock = Lock() diff --git a/sdnvpn/test/functest/testcase_11.py b/sdnvpn/test/functest/testcase_11.py index 9c3dcaa..c597c4d 100644 --- a/sdnvpn/test/functest/testcase_11.py +++ b/sdnvpn/test/functest/testcase_11.py @@ -8,15 +8,15 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import sys from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( diff --git a/sdnvpn/test/functest/testcase_12.py b/sdnvpn/test/functest/testcase_12.py index 5c91775..3e13d69 100644 --- a/sdnvpn/test/functest/testcase_12.py +++ b/sdnvpn/test/functest/testcase_12.py @@ -8,15 +8,15 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import sys from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( diff --git a/sdnvpn/test/functest/testcase_13.py b/sdnvpn/test/functest/testcase_13.py index 1c1f985..8beb1db 100644 --- a/sdnvpn/test/functest/testcase_13.py +++ b/sdnvpn/test/functest/testcase_13.py @@ -8,6 +8,8 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import logging +import os import sys from random import randint @@ -15,9 +17,8 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( @@ -31,6 +32,17 @@ def main(): results.add_to_summary(2, "STATUS", "SUBTEST") results.add_to_summary(0, "=") + if not os.path.isfile(COMMON_CONFIG.ubuntu_image_path): + logger.info("Downloading image") + image_dest_path = '/'.join( + COMMON_CONFIG.ubuntu_image_path.split('/')[:-1]) + os_utils.download_url( + "http://artifacts.opnfv.org/sdnvpn/" + "ubuntu-16.04-server-cloudimg-amd64-disk1.img", + image_dest_path) + else: + logger.info("Using old image") + nova_client = os_utils.get_nova_client() neutron_client = os_utils.get_neutron_client() glance_client = os_utils.get_glance_client() diff --git a/sdnvpn/test/functest/testcase_2.py b/sdnvpn/test/functest/testcase_2.py index 250ac4f..ee74d8d 100644 --- a/sdnvpn/test/functest/testcase_2.py +++ b/sdnvpn/test/functest/testcase_2.py @@ -8,6 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import sys from random import randint @@ -15,9 +16,8 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py index 4475fb8..95023c6 100644 --- a/sdnvpn/test/functest/testcase_3.py +++ b/sdnvpn/test/functest/testcase_3.py @@ -14,6 +14,7 @@ # - Add the functest Quagga as a neighbor # - Verify that the OpenDaylight and gateway Quagga peer +import logging import os import sys @@ -22,10 +23,9 @@ from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( @@ -140,10 +140,12 @@ def main(): # Taken from the sfc tests if not os.path.isfile(COMMON_CONFIG.ubuntu_image_path): logger.info("Downloading image") + image_dest_path = '/'.join( + COMMON_CONFIG.ubuntu_image_path.split('/')[:-1]) os_utils.download_url( "http://artifacts.opnfv.org/sdnvpn/" "ubuntu-16.04-server-cloudimg-amd64-disk1.img", - "/home/opnfv/functest/data/") + image_dest_path) else: logger.info("Using old image") diff --git a/sdnvpn/test/functest/testcase_4.py b/sdnvpn/test/functest/testcase_4.py index c0100ce..9b11cc3 100644 --- a/sdnvpn/test/functest/testcase_4.py +++ b/sdnvpn/test/functest/testcase_4.py @@ -8,6 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import sys from random import randint @@ -15,10 +16,9 @@ from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( diff --git a/sdnvpn/test/functest/testcase_7.py b/sdnvpn/test/functest/testcase_7.py index 6594045..ada45a5 100644 --- a/sdnvpn/test/functest/testcase_7.py +++ b/sdnvpn/test/functest/testcase_7.py @@ -18,16 +18,16 @@ network associated: - Assign a floating IP to a VM - Ping it """ +import logging import sys from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( diff --git a/sdnvpn/test/functest/testcase_8.py b/sdnvpn/test/functest/testcase_8.py index afdfef5..e667dba 100644 --- a/sdnvpn/test/functest/testcase_8.py +++ b/sdnvpn/test/functest/testcase_8.py @@ -16,16 +16,16 @@ # - Try to ping from one VM to the other # - Assign a floating IP to the VM in the router assoc network # - Ping it the floating ip +import logging import sys from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import openstack_utils as os_utils from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil -logger = logutil.getLogger(__name__) +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( diff --git a/sdnvpn/test/functest/testcase_9.py b/sdnvpn/test/functest/testcase_9.py index a4cfa5a..b77360d 100644 --- a/sdnvpn/test/functest/testcase_9.py +++ b/sdnvpn/test/functest/testcase_9.py @@ -13,18 +13,18 @@ # - Start a BGP router with OpenDaylight # - Add the functest Quagga as a neighbor # - Verify that the OpenDaylight and gateway Quagga peer +import logging import sys from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -from sdnvpn.lib import logutil COMMON_CONFIG = sdnvpn_config.CommonConfig() TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( "sdnvpn.test.functest.testcase_9") -logger = logutil.getLogger('__name__') +logger = logging.getLogger('__name__') def main(): |