From 1ec06237327293d18c494a915faed756188447b0 Mon Sep 17 00:00:00 2001 From: Panagiotis Karalis Date: Fri, 25 May 2018 11:53:57 +0300 Subject: Fix the logging to be compatible with functest In order to collect logs from SFC test scenarios running through functest framework (mainly for troubleshooting purposes), the logging mechanism has been updated accordingly. JIRA: SFC-125 Change-Id: Ide7c32519afa6ece299d0ac1dcb168609a2e3945 Signed-off-by: Panagiotis Karalis --- sfc/lib/cleanup.py | 4 ++-- sfc/lib/config.py | 10 ++++++---- sfc/lib/odl_utils.py | 12 ++++++------ sfc/lib/openstack_utils.py | 5 +++-- sfc/lib/results.py | 5 ++--- sfc/lib/test_utils.py | 5 ++--- sfc/lib/topology_shuffler.py | 5 ++--- sfc/tests/functest/run_sfc_tests.py | 12 ++++++------ sfc/tests/functest/sfc_chain_deletion.py | 4 ++-- sfc/tests/functest/sfc_one_chain_two_service_functions.py | 4 ++-- sfc/tests/functest/sfc_parent_function.py | 2 +- sfc/tests/functest/sfc_symmetric_chain.py | 4 ++-- sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py | 4 ++-- 13 files changed, 38 insertions(+), 38 deletions(-) diff --git a/sfc/lib/cleanup.py b/sfc/lib/cleanup.py index ca802da3..e614867d 100644 --- a/sfc/lib/cleanup.py +++ b/sfc/lib/cleanup.py @@ -1,11 +1,11 @@ +import logging import sys import time import sfc.lib.openstack_utils as os_sfc_utils import sfc.lib.odl_utils as odl_utils -from opnfv.utils import opnfv_logger as logger -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) def delete_odl_resources(odl_ip, odl_port, resource): diff --git a/sfc/lib/config.py b/sfc/lib/config.py index b8b0c148..69e1769d 100644 --- a/sfc/lib/config.py +++ b/sfc/lib/config.py @@ -8,18 +8,20 @@ # http://www.apache.org/licenses/LICENSE-2.0 # + +import logging import os +import sfc import yaml +import functest import functest.utils.functest_utils as ft_utils -import sfc import sfc.lib.test_utils as test_utils -import functest + from functest.utils import config from functest.utils import env -from opnfv.utils import opnfv_logger as logger -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) class CommonConfig(object): diff --git a/sfc/lib/odl_utils.py b/sfc/lib/odl_utils.py index ac967847..7879eab9 100644 --- a/sfc/lib/odl_utils.py +++ b/sfc/lib/odl_utils.py @@ -1,15 +1,15 @@ import ConfigParser +import functools +import json +import logging import os +import re import requests import time -import json -import re -import functools -import sfc.lib.openstack_utils as os_sfc_utils -from opnfv.utils import opnfv_logger as logger +import sfc.lib.openstack_utils as os_sfc_utils -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) ODL_MODULE_EXCEPTIONS = { diff --git a/sfc/lib/openstack_utils.py b/sfc/lib/openstack_utils.py index d518ec6f..7e629c26 100644 --- a/sfc/lib/openstack_utils.py +++ b/sfc/lib/openstack_utils.py @@ -1,9 +1,10 @@ import os import time import json +import logging import yaml -from opnfv.utils import opnfv_logger as logger + from tackerclient.tacker import client as tackerclient from functest.utils import constants from functest.utils import env @@ -24,7 +25,7 @@ from snaps.config.vm_inst import VmInstanceConfig, FloatingIpConfig from snaps.openstack.utils import ( nova_utils, neutron_utils, heat_utils, keystone_utils) -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) DEFAULT_TACKER_API_VERSION = '1.0' diff --git a/sfc/lib/results.py b/sfc/lib/results.py index 2673099b..2f2edfc0 100644 --- a/sfc/lib/results.py +++ b/sfc/lib/results.py @@ -7,10 +7,9 @@ # # http://www.apache.org/licenses/LICENSE-2.0 # +import logging -from opnfv.utils import opnfv_logger as logger - -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) class Results(object): diff --git a/sfc/lib/test_utils.py b/sfc/lib/test_utils.py index 16e5762c..36b52755 100644 --- a/sfc/lib/test_utils.py +++ b/sfc/lib/test_utils.py @@ -12,10 +12,9 @@ import subprocess import time import shutil import urllib +import logging -from opnfv.utils import opnfv_logger as logger - -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) SSH_OPTIONS = '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' FUNCTEST_RESULTS_DIR = os.path.join("home", "opnfv", "functest", "results", "odl-sfc") diff --git a/sfc/lib/topology_shuffler.py b/sfc/lib/topology_shuffler.py index 7721972d..f678137a 100644 --- a/sfc/lib/topology_shuffler.py +++ b/sfc/lib/topology_shuffler.py @@ -1,9 +1,8 @@ import datetime import random +import logging -from opnfv.utils import opnfv_logger as logger - -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) # The possible topologies we are testing TOPOLOGIES = [ diff --git a/sfc/tests/functest/run_sfc_tests.py b/sfc/tests/functest/run_sfc_tests.py index 015255a6..7c0b9d15 100644 --- a/sfc/tests/functest/run_sfc_tests.py +++ b/sfc/tests/functest/run_sfc_tests.py @@ -11,20 +11,19 @@ import importlib import os import time -import yaml +import logging import sys +import yaml -from xtesting.core import testcase +from collections import OrderedDict from opnfv.utils import ovs_logger as ovs_log -from opnfv.utils import opnfv_logger as logger from opnfv.deployment.factory import Factory as DeploymentFactory from sfc.lib import cleanup as sfc_cleanup from sfc.lib import config as sfc_config from sfc.lib import odl_utils as odl_utils +from xtesting.core import testcase -from collections import OrderedDict - -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) COMMON_CONFIG = sfc_config.CommonConfig() @@ -196,5 +195,6 @@ class SfcFunctest(testcase.TestCase): def main(): + logging.basicConfig(level=logging.INFO) SFC = SfcFunctest() sys.exit(SFC.run()) diff --git a/sfc/tests/functest/sfc_chain_deletion.py b/sfc/tests/functest/sfc_chain_deletion.py index 381a5167..849c2971 100644 --- a/sfc/tests/functest/sfc_chain_deletion.py +++ b/sfc/tests/functest/sfc_chain_deletion.py @@ -9,13 +9,13 @@ # import threading +import logging import sfc.lib.odl_utils as odl_utils import sfc.lib.config as sfc_config import sfc.lib.test_utils as test_utils from sfc.tests.functest import sfc_parent_function -from opnfv.utils import opnfv_logger as logger -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) class SfcChainDeletion(sfc_parent_function.SfcCommonTestCase): diff --git a/sfc/tests/functest/sfc_one_chain_two_service_functions.py b/sfc/tests/functest/sfc_one_chain_two_service_functions.py index 7b24d575..eeb2ec8c 100644 --- a/sfc/tests/functest/sfc_one_chain_two_service_functions.py +++ b/sfc/tests/functest/sfc_one_chain_two_service_functions.py @@ -8,13 +8,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 # import threading +import logging import sfc.lib.odl_utils as odl_utils import sfc.lib.config as sfc_config -from opnfv.utils import opnfv_logger as logger from sfc.tests.functest import sfc_parent_function """ logging configuration """ -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) class SfcOneChainTwoServiceTC(sfc_parent_function.SfcCommonTestCase): diff --git a/sfc/tests/functest/sfc_parent_function.py b/sfc/tests/functest/sfc_parent_function.py index 6161ae67..336d8d42 100644 --- a/sfc/tests/functest/sfc_parent_function.py +++ b/sfc/tests/functest/sfc_parent_function.py @@ -223,7 +223,7 @@ class SfcCommonTestCase(object): :return: Floating IPs for client and server """ - logger.info("Assigning floating IPs to client amd server instances") + logger.info("Assigning floating IPs to client and server instances") self.client_floating_ip = openstack_sfc.assign_floating_ip( self.router, self.client_instance, self.client_creator) diff --git a/sfc/tests/functest/sfc_symmetric_chain.py b/sfc/tests/functest/sfc_symmetric_chain.py index 7c453b59..067854db 100644 --- a/sfc/tests/functest/sfc_symmetric_chain.py +++ b/sfc/tests/functest/sfc_symmetric_chain.py @@ -11,14 +11,14 @@ import os import sys import threading +import logging import sfc.lib.openstack_utils as os_sfc_utils import sfc.lib.odl_utils as odl_utils import sfc.lib.config as sfc_config from sfc.tests.functest import sfc_parent_function -from opnfv.utils import opnfv_logger as logger """ logging configuration """ -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) COMMON_CONFIG = sfc_config.CommonConfig() CLIENT = "client" SERVER = "server" diff --git a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py index a8b9d84a..56a434f1 100644 --- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py +++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py @@ -9,13 +9,13 @@ # import threading +import logging import sfc.lib.odl_utils as odl_utils import sfc.lib.config as sfc_config from sfc.tests.functest import sfc_parent_function -from opnfv.utils import opnfv_logger as logger """ logging configuration """ -logger = logger.Logger(__name__).getLogger() +logger = logging.getLogger(__name__) class SfcTwoChainsSSHandHTTP(sfc_parent_function.SfcCommonTestCase): -- cgit 1.2.3-korg