blob: 369f2cd04a2386be404f17c2e320d9da64a9bc77 [file] [log] [blame]
pingping-lin8b306ac2014-11-17 18:13:51 -08001
2#Testing the basic functionality of SDN-IP
3
4class SdnIpTest:
5 def __init__(self):
6 self.default = ''
7
8 def CASE1(self, main):
9
10 '''
11 Test the SDN-IP functionality
12 '''
13 import time
14 import json
15 from operator import eq
16
17 # all generated routes for all BGP peers
18 allRoutes = []
19
20 main.step("Start to generate routes for BGP peer on host1")
21 routes = main.Quaggacli.generate_routes(1, 3)
22 main.log.info(routes)
23
24 for route in routes:
25 allRoutes.append(route + "/" + "1.1.1.1")
26
27 # start to insert routes into the bgp peer
28 main.step("Start Quagga-cli on host1")
29 main.Quaggacli.loginQuagga("1.1.1.1")
30
31 main.step("Start to configure Quagga on host1")
32 main.Quaggacli.enter_config(64513)
33
34 main.step("Start to generate and add routes for BGP peer on host1")
35 routes = main.Quaggacli.generate_routes(8, 3)
36 main.Quaggacli.add_routes(routes, 1)
37
38 # add generates routes to allRoutes
39 for route in routes:
40 allRoutes.append(route + "/" + "1.1.1.1")
41
42 cell_name = main.params['ENV']['cellName']
43 ONOS1_ip = main.params['CTRL']['ip1']
44
45 main.step("Starting ONOS service")
46 # TODO: start ONOS from Mininet Script
47 # start_result = main.ONOSbench.onos_start("127.0.0.1")
48
49 main.step("Set cell for ONOS-cli environment")
50 main.ONOScli.set_cell(cell_name)
51
52 main.step("Start ONOS-cli")
53 # TODO: change the hardcode in start_onos_cli method in ONOS CLI driver
54 time.sleep(5)
55 main.ONOScli.start_onos_cli(ONOS1_ip)
56
57 main.step("Get devices in the network")
58 list_result = main.ONOScli.devices(json_format=False)
59 main.log.info(list_result)
60
61 #get all routes inside SDN-IP
62 get_routes_result = main.ONOScli.routes(json_format=True)
63
64 # parse routes from ONOS CLI
65 routes_list = []
66 routes_json_obj = json.loads(get_routes_result)
67 for route in routes_json_obj:
68 if route['prefix'] == '172.16.10.0/24':
69 continue
70 routes_list.append(route['prefix'] + "/" + route['nextHop'])
71
72 main.log.info("Start to checking routes")
73 main.log.info("Routes inserted into the system:")
74 main.log.info(sorted(allRoutes))
75 main.log.info("Routes get from ONOS CLI:")
76 main.log.info(sorted(routes_list))
77
78 if eq(sorted(allRoutes), sorted(routes_list)):
79 main.log.report("***Routes in SDN-IP are correct!***")
80 else:
81 main.log.report("***Routes in SDN-IP are wrong!***")
82
83 time.sleep(2)
84 main.step("Get intents installed on ONOS")
85 get_intents_result = main.ONOScli.intents(json_format=True)
86 main.log.info(get_intents_result)
87
88
89 #main.step("Test whether Mininet is started")
90 #main.Mininet2.handle.sendline("xterm host1")
91 #main.Mininet2.handle.expect("mininet>")
92