blob: 18b23afdbb01e64304f36d14720529a2f34519a4 [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))
pingping-lindabe7972014-11-17 19:29:44 -080077 utilities.assert_equals(expect=sorted(allRoutes), actual=sorted(routes_list),
78 onpass="***Routes in SDN-IP are correct!***",
79 onfail="***Routes in SDN-IP are wrong!***")
pingping-lin8b306ac2014-11-17 18:13:51 -080080
81 time.sleep(2)
82 main.step("Get intents installed on ONOS")
83 get_intents_result = main.ONOScli.intents(json_format=True)
84 main.log.info(get_intents_result)
85
86
87 #main.step("Test whether Mininet is started")
88 #main.Mininet2.handle.sendline("xterm host1")
89 #main.Mininet2.handle.expect("mininet>")
90