diff options
-rw-r--r-- | sdnvpn/lib/gather_logs.py | 2 | ||||
-rw-r--r-- | sdnvpn/lib/utils.py | 34 | ||||
-rwxr-xr-x | sdnvpn/sh_utils/fetch-log-script.sh | 17 | ||||
-rw-r--r-- | sdnvpn/test/functest/config.yaml | 5 | ||||
-rw-r--r-- | sdnvpn/test/functest/run_sdnvpn_tests.py (renamed from sdnvpn/test/functest/run_tests.py) | 2 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_1.py | 10 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_2.py | 11 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_3.py | 16 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_4.py | 10 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_7.py | 8 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_8.py | 10 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_9.py | 78 | ||||
-rw-r--r-- | setup.cfg | 2 |
13 files changed, 167 insertions, 38 deletions
diff --git a/sdnvpn/lib/gather_logs.py b/sdnvpn/lib/gather_logs.py index cf84f43..9afa077 100644 --- a/sdnvpn/lib/gather_logs.py +++ b/sdnvpn/lib/gather_logs.py @@ -45,7 +45,7 @@ def gather_logs(name): % node.get_dict()['name']) ft_utils.execute_command_raise('cd %s;tar czvf sdnvpn-logs-%s.tar.gz' - '-C /tmp/ sdnvpn-logs/' + ' sdnvpn-logs/' % (CONST.__getattribute__('dir_results'), name)) diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py index e22e455..a7aa991 100644 --- a/sdnvpn/lib/utils.py +++ b/sdnvpn/lib/utils.py @@ -649,3 +649,37 @@ def create_router_association(neutron_client, bgpvpn_id, router_id): def create_network_association(neutron_client, bgpvpn_id, neutron_network_id): json_body = {"network_association": {"network_id": neutron_network_id}} return neutron_client.create_network_association(bgpvpn_id, json_body) + + +def is_fail_mode_secure(): + """ + Checks the value of the attribute fail_mode, + if it is set to secure. This check is performed + on all OVS br-int interfaces, for all OpenStack nodes. + """ + is_secure = {} + openstack_nodes = get_nodes() + get_ovs_int_cmd = ("sudo ovs-vsctl show | " + "grep -i bridge | " + "awk '{print $2}'") + # Define OVS get fail_mode command + get_ovs_fail_mode_cmd = ("sudo ovs-vsctl get-fail-mode br-int") + for openstack_node in openstack_nodes: + if not openstack_node.is_active(): + continue + + ovs_int_list = (openstack_node.run_cmd(get_ovs_int_cmd). + strip().split('\n')) + if 'br-int' in ovs_int_list: + # Execute get fail_mode command + br_int_fail_mode = (openstack_node. + run_cmd(get_ovs_fail_mode_cmd).strip()) + if br_int_fail_mode == 'secure': + # success + 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)) + is_secure[openstack_node.name] = False + return is_secure diff --git a/sdnvpn/sh_utils/fetch-log-script.sh b/sdnvpn/sh_utils/fetch-log-script.sh index 8e825d0..c3c037d 100755 --- a/sdnvpn/sh_utils/fetch-log-script.sh +++ b/sdnvpn/sh_utils/fetch-log-script.sh @@ -1,7 +1,7 @@ #!/bin/bash ### Configuration Required -set -e +# set -e tmp_folder=/tmp/opnfv-logs-$HOSTNAME/ rm -rf $tmp_folder @@ -80,6 +80,9 @@ log_command_exec(){ echo "$cmd" >> $file echo "==========================================================" >> $file $cmd 2>&1 >> $file + if [ "$?" -ne "0" ]; then + echo "Something went wrong with log gathering" + fi } flows() @@ -94,10 +97,13 @@ flows() node(){ node=$tmp_folder/$HOSTNAME.txt log_command_exec "$node" ifconfig -a - files_folders=( /opt/opendaylight/data/log/ /var/log/openvswitch/ /var/log/neutron/) + files_folders=( /opt/opendaylight/data/log/ /var/log/openvswitch/ /var/log/neutron/ /var/log/nova/) for ((i = 0; i < ${#files_folders[@]};i++));do if [ -e ${files_folders[$i]} ];then cp -r ${files_folders[$i]} $tmp_folder/ + if [ "$?" -ne "0" ]; then + echo "Something went wrong with log tranferring from nodes" + fi fi done # not all messages only tail the last 10k lines @@ -110,6 +116,9 @@ _curl_data_store(){ touch $file echo "============================= $url ======================" >> $file curl --silent -u admin:admin -X GET http://$odl_ip_port/$url | python -mjson.tool 2>&1 >> $file + if [ "$?" -ne "0" ]; then + echo "Something went wrong while reading from datastore" + fi } _get_output_karaf(){ @@ -118,7 +127,9 @@ _get_output_karaf(){ shift echo "============================ KARAF $@ ===================" >> $file sshpass -p karaf ssh -p 8101 -o "StrictHostKeyChecking no" karaf@localhost "$@" 2>&1 >> $file - + if [ "$?" -ne "0" ]; then + echo "Something went wrong with log gathering from karaf" + fi } datastore() { diff --git a/sdnvpn/test/functest/config.yaml b/sdnvpn/test/functest/config.yaml index 6480c4c..3ffd215 100644 --- a/sdnvpn/test/functest/config.yaml +++ b/sdnvpn/test/functest/config.yaml @@ -153,3 +153,8 @@ testcases: secgroup_descr: Security group for SDNVPN test cases targets: '88:88' route_distinguishers: '18:18' + + testcase_9: + enabled: true + description: Verify that all OpenStack nodes OVS br-int have fail_mode set to secure. + testname_db: functest_testcase_9 diff --git a/sdnvpn/test/functest/run_tests.py b/sdnvpn/test/functest/run_sdnvpn_tests.py index 1bffe67..e671264 100644 --- a/sdnvpn/test/functest/run_tests.py +++ b/sdnvpn/test/functest/run_sdnvpn_tests.py @@ -97,7 +97,7 @@ def main(report=False): gather_logs('overall') except Exception as ex: logger.error(('Something went wrong in the Log gathering.' - 'Ex: Trace: %s') + 'Ex: %s, Trace: %s') % ex, traceback.format_exc()) if overall_status == "FAIL": sys.exit(-1) diff --git a/sdnvpn/test/functest/testcase_1.py b/sdnvpn/test/functest/testcase_1.py index 8291151..540fe9a 100644 --- a/sdnvpn/test/functest/testcase_1.py +++ b/sdnvpn/test/functest/testcase_1.py @@ -10,12 +10,12 @@ import argparse import logging -from random import randint - -import functest.utils.openstack_utils as os_utils +import sys -from sdnvpn.lib import utils as test_utils +from functest.utils import openstack_utils as os_utils +from random import randint from sdnvpn.lib import config as sdnvpn_config +from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results parser = argparse.ArgumentParser() @@ -222,4 +222,4 @@ def main(): if __name__ == '__main__': logging.basicConfig(level=logging.INFO) - main() + sys.exit(main()) diff --git a/sdnvpn/test/functest/testcase_2.py b/sdnvpn/test/functest/testcase_2.py index 0265aee..cea93ce 100644 --- a/sdnvpn/test/functest/testcase_2.py +++ b/sdnvpn/test/functest/testcase_2.py @@ -10,14 +10,13 @@ import argparse import logging -from random import randint import sys -import functest.utils.openstack_utils as os_utils - -import sdnvpn.lib.utils as test_utils +from functest.utils import openstack_utils as os_utils +from random import randint +from sdnvpn.lib import config as sdnvpn_config +from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -import sdnvpn.lib.config as sdnvpn_config parser = argparse.ArgumentParser() @@ -262,4 +261,4 @@ def main(): if __name__ == '__main__': logging.basicConfig(level=logging.INFO) - main() + sys.exit(main()) diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py index 24d413c..058a270 100644 --- a/sdnvpn/test/functest/testcase_3.py +++ b/sdnvpn/test/functest/testcase_3.py @@ -11,17 +11,17 @@ # - Start a BGP router with OpenDaylight # - Add the functest Quagga as a neighbor # - Verify that the OpenDaylight and gateway Quagga peer + +import argparse import logging import os -import argparse +import sys +from functest.utils import functest_utils as ft_utils +from functest.utils import openstack_utils as os_utils from sdnvpn.lib import quagga -import sdnvpn.lib.utils as test_utils -import sdnvpn.lib.config as sdnvpn_config - -import functest.utils.openstack_utils as os_utils -import functest.utils.functest_utils as ft_utils - +from sdnvpn.lib import utils as test_utils +from sdnvpn.lib import config as sdnvpn_config from sdnvpn.lib.results import Results COMMON_CONFIG = sdnvpn_config.CommonConfig() @@ -287,4 +287,4 @@ def main(): if __name__ == '__main__': logging.basicConfig(level=logging.INFO) - main() + sys.exit(main()) diff --git a/sdnvpn/test/functest/testcase_4.py b/sdnvpn/test/functest/testcase_4.py index cff60f1..0ca1563 100644 --- a/sdnvpn/test/functest/testcase_4.py +++ b/sdnvpn/test/functest/testcase_4.py @@ -10,12 +10,12 @@ import argparse import logging -from random import randint - -import functest.utils.openstack_utils as os_utils +import sys -from sdnvpn.lib import utils as test_utils +from functest.utils import openstack_utils as os_utils +from random import randint from sdnvpn.lib import config as sdnvpn_config +from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results parser = argparse.ArgumentParser() @@ -228,4 +228,4 @@ def main(): if __name__ == '__main__': logging.basicConfig(level=logging.INFO) - main() + sys.exit(main()) diff --git a/sdnvpn/test/functest/testcase_7.py b/sdnvpn/test/functest/testcase_7.py index 21bc12b..607a299 100644 --- a/sdnvpn/test/functest/testcase_7.py +++ b/sdnvpn/test/functest/testcase_7.py @@ -20,11 +20,11 @@ network associated: """ import argparse import logging +import sys -import functest.utils.openstack_utils as os_utils - -from sdnvpn.lib import utils as test_utils +from functest.utils import openstack_utils as os_utils from sdnvpn.lib import config as sdnvpn_config +from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results parser = argparse.ArgumentParser() @@ -174,4 +174,4 @@ def main(): if __name__ == '__main__': logging.basicConfig(level=logging.INFO) - main() + sys.exit(main()) diff --git a/sdnvpn/test/functest/testcase_8.py b/sdnvpn/test/functest/testcase_8.py index 7738c75..11f13bb 100644 --- a/sdnvpn/test/functest/testcase_8.py +++ b/sdnvpn/test/functest/testcase_8.py @@ -20,12 +20,12 @@ Test whether router assoc can coexist with floating IP """ import argparse import logging +import sys -import functest.utils.openstack_utils as os_utils - -import sdnvpn.lib.utils as test_utils +from functest.utils import openstack_utils as os_utils +from sdnvpn.lib import config as sdnvpn_config +from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -import sdnvpn.lib.config as sdnvpn_config parser = argparse.ArgumentParser() @@ -176,4 +176,4 @@ def main(): if __name__ == '__main__': logging.basicConfig(level=logging.INFO) - main() + sys.exit(main()) diff --git a/sdnvpn/test/functest/testcase_9.py b/sdnvpn/test/functest/testcase_9.py new file mode 100644 index 0000000..053c02e --- /dev/null +++ b/sdnvpn/test/functest/testcase_9.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# +# Copyright (c) 2017 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 +# +# Tests performed: +# - Peering OpenDaylight with Quagga: +# - Set up a Quagga instance in the functest container +# - Start a BGP router with OpenDaylight +# - Add the functest Quagga as a neighbor +# - Verify that the OpenDaylight and gateway Quagga peer +import argparse +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 + +COMMON_CONFIG = sdnvpn_config.CommonConfig() +TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig("testcase_9") + +logger = logging.getLogger('sdnvpn-testcase-9') + +parser = argparse.ArgumentParser() + +parser.add_argument("-r", "--report", + help="Create json result file", + action="store_true") + +args = parser.parse_args() + + +def main(): + results = Results(COMMON_CONFIG.line_length) + results.add_to_summary(0, "=") + results.add_to_summary(2, "STATUS", "SUBTEST") + results.add_to_summary(0, "=") + + openstack_nodes = test_utils.get_nodes() + + # node.is_odl() doesn't work in Apex + # https://jira.opnfv.org/browse/RELENG-192 + controllers = [node for node in openstack_nodes + if "running" in + node.run_cmd("sudo systemctl status opendaylight")] + + msg = ("Verify that all OpenStack nodes OVS br-int have " + "fail_mode set to secure") + results.record_action(msg) + results.add_to_summary(0, "-") + if not controllers: + msg = ("Controller (ODL) list is empty. Skipping rest of tests.") + logger.info(msg) + results.add_failure(msg) + return results.compile_summary() + else: + msg = ("Controller (ODL) list is ready") + logger.info(msg) + results.add_success(msg) + # Get fail_mode status on all nodes + fail_mode_statuses = test_utils.is_fail_mode_secure() + for node_name, status in fail_mode_statuses.iteritems(): + msg = 'Node {} br-int is fail_mode secure'.format(node_name) + if status: + results.add_success(msg) + else: + results.add_failure(msg) + + return results.compile_summary() + +if __name__ == '__main__': + logging.basicConfig(level=logging.INFO) + sys.exit(main()) @@ -5,3 +5,5 @@ home-page = https://wiki.opnfv.org/display/sdnvpn/SDNVPN+project+main+page [files] packages = sdnvpn +scripts = + sdnvpn/test/functest/run_sdnvpn_tests.py |