# http://www.apache.org/licenses/LICENSE-2.0
import yaml
-import logging
import pkg_resources
from functest.utils import config
import functest.utils.functest_utils as ft_utils
+from sdnvpn.lib import logutil
-logger = logging.getLogger('sdnvpn_test_config')
+logger = logutil.getLogger('sdnvpn_test_config')
class CommonConfig(object):
--- /dev/null
+#!/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 os.path.exists(log_file):
+ feature.Feature.configure_logger(logger, log_file)
+ else:
+ logger.setLevel(logging.DEBUG)
+ return logger
# http://www.apache.org/licenses/LICENSE-2.0
#
-import logging
import os.path
import shutil
import sys
from keystoneclient import client as keystoneclient
from neutronclient.neutron import client as neutronclient
-from functest.utils import config
from functest.utils import env
+from sdnvpn.lib import logutil
-logger = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
DEFAULT_API_VERSION = '2'
DEFAULT_HEAT_API_VERSION = '1'
#
"""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 = logging.getLogger('sdnvpn-quagga')
+logger = logutil.getLogger('sdnvpn-quagga')
COMMON_CONFIG = config.CommonConfig()
#
# 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 = logging.getLogger('sdnvpn-results')
+logger = logutil.getLogger('sdnvpn-results')
class Results(object):
#
# http://www.apache.org/licenses/LICENSE-2.0
#
-import logging
import os
import time
import requests
from sdnvpn.lib import config as sdnvpn_config
import sdnvpn.lib.openstack_utils as os_utils
+from sdnvpn.lib import logutil
-logger = logging.getLogger('sdnvpn_test_utils')
+logger = logutil.getLogger('sdnvpn_test_utils')
common_config = sdnvpn_config.CommonConfig()
"""
Class to represent extra route for a router
"""
+
def __init__(self, destination, nexthop):
self.destination = destination
self.nexthop = nexthop
"""
Class to represent allowed address pair for a neutron port
"""
+
def __init__(self, ipaddress, macaddress):
self.ipaddress = ipaddress
self.macaddress = macaddress
if len(floatingip_ids) != 0:
for floatingip_id in floatingip_ids:
if not os_utils.delete_floating_ip(neutron_client, floatingip_id):
- logging.error('Fail to delete all floating ips. '
- 'Floating ip with id {} was not deleted.'.
- format(floatingip_id))
+ logger.error('Fail to delete all floating ips. '
+ 'Floating ip with id {} was not deleted.'.
+ format(floatingip_id))
return False
if len(bgpvpn_ids) != 0:
for router_id, subnet_id in interfaces:
if not os_utils.remove_interface_router(neutron_client,
router_id, subnet_id):
- logging.error('Fail to delete all interface routers. '
- 'Interface router with id {} was not deleted.'.
- format(router_id))
+ logger.error('Fail to delete all interface routers. '
+ 'Interface router with id {} was not deleted.'.
+ format(router_id))
if len(router_ids) != 0:
for router_id in router_ids:
if not os_utils.remove_gateway_router(neutron_client, router_id):
- logging.error('Fail to delete all gateway routers. '
- 'Gateway router with id {} was not deleted.'.
- format(router_id))
+ logger.error('Fail to delete all gateway routers. '
+ 'Gateway router with id {} was not deleted.'.
+ format(router_id))
if len(subnet_ids) != 0:
for subnet_id in subnet_ids:
if not os_utils.delete_neutron_subnet(neutron_client, subnet_id):
- logging.error('Fail to delete all subnets. '
- 'Subnet with id {} was not deleted.'.
- format(subnet_id))
+ logger.error('Fail to delete all subnets. '
+ 'Subnet with id {} was not deleted.'.
+ format(subnet_id))
return False
if len(router_ids) != 0:
for router_id in router_ids:
if not os_utils.delete_neutron_router(neutron_client, router_id):
- logging.error('Fail to delete all routers. '
- 'Router with id {} was not deleted.'.
- format(router_id))
+ logger.error('Fail to delete all routers. '
+ 'Router with id {} was not deleted.'.
+ format(router_id))
return False
if len(network_ids) != 0:
for network_id in network_ids:
if not os_utils.delete_neutron_net(neutron_client, network_id):
- logging.error('Fail to delete all networks. '
- 'Network with id {} was not deleted.'.
- format(network_id))
+ logger.error('Fail to delete all networks. '
+ 'Network with id {} was not deleted.'.
+ format(network_id))
return False
return True
if len(instance_ids) != 0:
for instance_id in instance_ids:
if not os_utils.delete_instance(nova_client, instance_id):
- logging.error('Fail to delete all instances. '
- 'Instance with id {} was not deleted.'.
- format(instance_id))
+ logger.error('Fail to delete all instances. '
+ 'Instance with id {} was not deleted.'.
+ format(instance_id))
return False
return True
if len(image_ids) != 0:
for image_id in image_ids:
if not os_utils.delete_glance_image(glance_client, image_id):
- logging.error('Fail to delete all images. '
- 'Image with id {} was not deleted.'.
- format(image_id))
+ logger.error('Fail to delete all images. '
+ 'Image with id {} was not deleted.'.
+ format(image_id))
return False
return True
is_secure[openstack_node.name] = True
else:
# failure
- logging.error('The fail_mode for br-int was not secure '
- 'in {} node'.format(openstack_node.name))
+ logger.error('The fail_mode for br-int was not secure '
+ 'in {} node'.format(openstack_node.name))
is_secure[openstack_node.name] = False
return is_secure
from sdnvpn.lib.gather_logs import gather_logs
from sdnvpn.lib import utils as test_utils
+
COMMON_CONFIG = sdnvpn_config.CommonConfig()
class SdnvpnFunctest(feature.Feature):
- __logger = logging.getLogger(__name__)
-
def execute(self):
nova_client = os_utils.get_nova_client()
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")
+ self.logger.info("Setting net/subnet/port/router "
+ "quota to unlimited")
test_utils.update_nw_subnet_port_quota(
neutron_client,
tenant_id,
# Workaround for
# https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115
- self.__logger.info("Setting instances quota class to unlimited")
+ self.logger.info("Setting instances quota class to unlimited")
test_utils.update_instance_quota_class(
nova_client,
COMMON_CONFIG.nova_instances_quota_class)
test_descr = testcases[tc]['description']
title = ("Running '%s - %s'" %
(test_name, test_descr))
- self.__logger.info(title)
- self.__logger.info("%s\n" % ("=" * len(title)))
+ self.logger.info(title)
+ self.logger.info("%s\n" % ("=" * len(title)))
try:
- self.__logger.info("Importing the testcase %s" % test_name)
+ self.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)
+ self.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)
+ self.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()))
+ self.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)
+ self.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))
+ self.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")
+ self.logger.info("Resetting subnet/net/port quota")
test_utils.update_nw_subnet_port_quota(neutron_client,
tenant_id,
neutron_nw_quota,
neutron_port_quota,
neutron_router_quota)
- self.__logger.info("Resetting instances quota class")
+ self.logger.info("Resetting instances quota class")
test_utils.update_instance_quota_class(nova_client, instances_quota)
try:
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)
+ self.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()))
+ self.logger.error(('Something went wrong in the Log gathering.'
+ 'Ex: %s, Trace: %s')
+ % (ex, traceback.format_exc()))
if overall_status == "PASS":
self.result = 100
#
#
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 = logging.getLogger('sdnvpn-tempest')
+logger = logutil.getLogger('sdnvpn-tempest')
def main():
src_tempest_dir = tempest_utils.get_verifier_deployment_dir(
verifier_id, deployment_id)
-
if not src_tempest_dir:
logger.error("Rally deployment not found.")
exit(-1)
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
main()
# http://www.apache.org/licenses/LICENSE-2.0
#
-import logging
import sys
-import time
from random import randint
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 = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
# http://www.apache.org/licenses/LICENSE-2.0
#
-import logging
import re
import sys
import time
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 = logging.getLogger('__name__')
+logger = logutil.getLogger('__name__')
std_out_lock = Lock()
format(vm.name))
# Atomic write to std out
with std_out_lock:
- logging.error("Failure during ping from "
- "instance {}: {}".
- format(vm.name, console_line))
+ logger.error("Failure during ping from "
+ "instance {}: {}".
+ format(vm.name, console_line))
elif re.match(r'ping.*OK', console_line):
# Atomic write to std out
with std_out_lock:
- logging.info("Ping from instance {}: {}".
- format(vm.name, console_line))
+ logger.info("Ping from instance {}: {}".
+ format(vm.name, console_line))
lines_offset = len(vm_console_out_lines)
except:
# Atomic write to std out
with std_out_lock:
- logging.error("Failure in monitor_thread of instance {}".
- format(vm.name))
+ logger.error("Failure in monitor_thread of instance {}".
+ format(vm.name))
# Return to main process
return
thread_inputs = [monitor_input1, monitor_input2, monitor_input3]
thread_outputs = [monitor_output1, monitor_output2, monitor_output3]
try:
- logging.info("Starting all monitor threads")
+ logger.info("Starting all monitor threads")
# Start all monitor threads
for thread in threads:
thread.start()
- logging.info("Wait before subtest")
+ logger.info("Wait before subtest")
test_utils.wait_before_subtest()
monitor_err_msg = ""
for thread_output in thread_outputs:
# Stop monitor thread 2 and delete instance vm_2
thread_inputs[1]["stop_thread"] = True
if not os_utils.delete_instance(nova_client, vm_2.id):
- logging.error("Fail to delete vm_2 instance during "
- "testing process")
+ logger.error("Fail to delete vm_2 instance during "
+ "testing process")
raise Exception("Fail to delete instance vm_2.")
for thread_input in thread_inputs:
thread_input["stop_thread"] = True
threads.append(monitor_thread4)
thread_inputs.append(monitor_input4)
thread_outputs.append(monitor_output4)
- logging.info("Starting monitor thread of vm_4")
+ logger.info("Starting monitor thread of vm_4")
threads[0].start()
test_utils.wait_before_subtest()
monitor_err_msg = ""
raise
finally:
# Give a stop signal to all threads
- logging.info("Sending stop signal to monitor thread")
+ logger.info("Sending stop signal to monitor thread")
for thread_input in thread_inputs:
thread_input["stop_thread"] = True
# Wait for all threads to stop and return to the main process
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
# 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 = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
logger.error("One or more instances is down")
# TODO: Handle this appropriately
- logging.info("Wait before subtest")
+ logger.info("Wait before subtest")
test_utils.wait_before_subtest()
# Get added OVS groups
added_ovs_groups = (len(initial_ovs_groups) -
for compute_node in compute_nodes:
compute_node.run_cmd("sudo ovs-vsctl set-controller {} {}".
format(ovs_br, ovs_controller_conn))
- logging.info("Wait before subtest")
+ logger.info("Wait before subtest")
test_utils.wait_before_subtest()
# Get OVS groups added after the reconnection
added_ovs_groups = (len(initial_ovs_groups) -
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
# 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 = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
if not instances_up:
logger.error("One or more instances is down")
- logging.info("Wait before subtest")
+ logger.info("Wait before subtest")
test_utils.wait_before_subtest()
# Get added OVS flows and groups
added_ovs_flows = len(test_utils.get_ovs_flows(compute_nodes,
compute_node.run_cmd("sudo ovs-vsctl set-controller {} {}".
format(ovs_br, ovs_controller_conn))
- logging.info("Wait before subtest resync type 1")
+ logger.info("Wait before subtest resync type 1")
test_utils.wait_before_subtest()
# Get OVS flows added after the reconnection
resynced_ovs_flows = len(test_utils.get_ovs_flows(
compute_node.run_cmd("sudo iptables -D OUTPUT -p tcp --dport 6653"
" -j DROP")
- logging.info("Wait before subtest resync type 2")
+ logger.info("Wait before subtest resync type 2")
test_utils.wait_before_subtest()
# Get OVS flows added after the reconnection
resynced_ovs_flows = len(test_utils.get_ovs_flows(
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
# http://www.apache.org/licenses/LICENSE-2.0
#
-import logging
import sys
from random import randint
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 = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
# http://www.apache.org/licenses/LICENSE-2.0
#
-import logging
import sys
from random import randint
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 = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
# - Add the functest Quagga as a neighbor
# - Verify that the OpenDaylight and gateway Quagga peer
-import logging
import os
import sys
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 = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
# http://www.apache.org/licenses/LICENSE-2.0
#
-import logging
import sys
from random import randint
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 = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
- 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 = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
# - 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 = logging.getLogger(__name__)
+logger = logutil.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())
# - 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 = logging.getLogger('__name__')
+logger = logutil.getLogger('__name__')
def main():
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())