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
8 # http://www.apache.org/licenses/LICENSE-2.0
12 import functest.utils.functest_logger as ft_logger
13 from sdnvpn.lib import config as sdnvpn_config
14 from sdnvpn.lib.results import Results
15 from opnfv.deployment.factory import Factory as DeploymentFactory
17 parser = argparse.ArgumentParser()
19 parser.add_argument("-r", "--report",
20 help="Create json result file",
23 args = parser.parse_args()
25 logger = ft_logger.Logger("sdnvpn-testcase-3").getLogger()
27 COMMON_CONFIG = sdnvpn_config.CommonConfig()
28 TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig("testcase_3")
32 results = Results(COMMON_CONFIG.line_length)
33 results.add_to_summary(0, "=")
34 results.add_to_summary(2, "STATUS", "SUBTEST")
35 results.add_to_summary(0, "=")
37 # TODO unhardcode this to work with apex
38 deploymentHandler = DeploymentFactory.get_handler(
44 openstack_nodes = deploymentHandler.get_nodes()
46 controllers = [node for node in openstack_nodes
49 msg = ("Verify that OpenDaylight can start/communicate with zrpcd/Quagga")
50 results.record_action(msg)
51 results.add_to_summary(0, "-")
54 msg = ("Controller (ODL) list is empty")
56 results.add_failure(msg)
58 msg = ("Controller (ODL) list is ready")
60 results.add_success(msg)
62 for controller in controllers:
63 logger.info("Starting bgp speaker of controller at IP %s "
65 logger.info("Checking if zrpcd is "
66 "running on the controller node")
68 cmd = "systemctl status zrpcd"
69 output = controller.run_cmd(cmd)
70 msg = ("zrpcd is running")
73 logger.info("zrpcd is not running on the controller node")
74 results.add_failure(msg)
76 logger.info("zrpcd is running on the controller node")
77 results.add_success(msg)
79 results.add_to_summary(0, "-")
81 # TODO here we need the external ip of the controller
82 cmd_start_quagga = '/opt/opendaylight/bin/client "odl:configure-bgp ' \
83 '-op start-bgp-server --as-num 100 ' \
84 '--router-id {0}"'.format(controller.ip)
86 controller.run_cmd(cmd_start_quagga)
88 logger.info("Checking if bgpd is running"
89 " on the controller node")
91 # Check if there is a non-zombie bgpd process
92 output_bgpd = controller.run_cmd("ps --no-headers -C bgpd -o state")
93 states = output_bgpd.split()
94 running = any([s != 'Z' for s in states])
96 msg = ("bgpd is running")
98 logger.info("bgpd is not running on the controller node")
99 results.add_failure(msg)
101 logger.info("bgpd is running on the controller node")
102 results.add_success(msg)
104 results.add_to_summary(0, "-")
106 cmd_stop_quagga = '/opt/opendaylight/bin/client -v "odl:configure' \
107 '-bgp -op stop-bgp-server"'
109 controller.run_cmd(cmd_stop_quagga)
111 # disabled because of buggy upstream
112 # https://github.com/6WIND/zrpcd/issues/15
113 # logger.info("Checking if bgpd is still running"
114 # " on the controller node")
116 # output_bgpd = controller.run_cmd("ps --no-headers -C bgpd -o state")
117 # states = output_bgpd.split()
118 # running = any([s != 'Z' for s in states])
120 # msg = ("bgpd is stopped")
122 # logger.info("bgpd is not running on the controller node")
123 # results.add_success(msg)
125 # logger.info("bgpd is still running on the controller node")
126 # results.add_failure(msg)
128 return results.compile_summary()
131 if __name__ == '__main__':