Merge "Removing inactive committers in accordance with Section 8 of the TSC charter."
[sdnvpn.git] / sdnvpn / test / functest / testcase_9.py
1 #!/usr/bin/python
2 #
3 # Copyright (c) 2017 All rights reserved
4 # This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Tests performed:
11 # - Peering OpenDaylight with Quagga:
12 #   - Set up a Quagga instance in the functest container
13 #   - Start a BGP router with OpenDaylight
14 #   - Add the functest Quagga as a neighbor
15 #   - Verify that the OpenDaylight and gateway Quagga peer
16 import argparse
17 import logging
18 import sys
19
20 from sdnvpn.lib import config as sdnvpn_config
21 from sdnvpn.lib import utils as test_utils
22 from sdnvpn.lib.results import Results
23
24 COMMON_CONFIG = sdnvpn_config.CommonConfig()
25 TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig("testcase_9")
26
27 logger = logging.getLogger('sdnvpn-testcase-9')
28
29 parser = argparse.ArgumentParser()
30
31 parser.add_argument("-r", "--report",
32                     help="Create json result file",
33                     action="store_true")
34
35 args = parser.parse_args()
36
37
38 def main():
39     results = Results(COMMON_CONFIG.line_length)
40     results.add_to_summary(0, "=")
41     results.add_to_summary(2, "STATUS", "SUBTEST")
42     results.add_to_summary(0, "=")
43
44     openstack_nodes = test_utils.get_nodes()
45
46     # node.is_odl() doesn't work in Apex
47     # https://jira.opnfv.org/browse/RELENG-192
48     controllers = [node for node in openstack_nodes
49                    if "running" in
50                    node.run_cmd("sudo systemctl status opendaylight")]
51
52     msg = ("Verify that all OpenStack nodes OVS br-int have "
53            "fail_mode set to secure")
54     results.record_action(msg)
55     results.add_to_summary(0, "-")
56     if not controllers:
57         msg = ("Controller (ODL) list is empty. Skipping rest of tests.")
58         logger.info(msg)
59         results.add_failure(msg)
60         return results.compile_summary()
61     else:
62         msg = ("Controller (ODL) list is ready")
63         logger.info(msg)
64         results.add_success(msg)
65     # Get fail_mode status on all nodes
66     fail_mode_statuses = test_utils.is_fail_mode_secure()
67     for node_name, status in fail_mode_statuses.iteritems():
68         msg = 'Node {} br-int is fail_mode secure'.format(node_name)
69         if status:
70             results.add_success(msg)
71         else:
72             results.add_failure(msg)
73
74     return results.compile_summary()
75
76 if __name__ == '__main__':
77     logging.basicConfig(level=logging.INFO)
78     sys.exit(main())