blob: 4f55c022ad2ca1b33e1906d5e8e1bc198aef07af [file] [log] [blame]
pingping-lin3d87a132014-12-04 14:22:49 -08001# from cupshelpers.config import prefix
pingping-lin8b306ac2014-11-17 18:13:51 -08002
pingping-linc6b86fa2014-12-01 16:18:10 -08003# Testing the basic functionality of SDN-IP
pingping-lin8b306ac2014-11-17 18:13:51 -08004
5class SdnIpTest:
6 def __init__(self):
7 self.default = ''
8
9 def CASE1(self, main):
10
11 '''
12 Test the SDN-IP functionality
pingping-lin6f6332e2014-11-19 19:13:58 -080013 allRoutes_expected: all expected routes for all BGP peers
pingping-lin3d87a132014-12-04 14:22:49 -080014 routeIntents_expected: all expected MultiPointToSinglePointIntent intents
15 bgpIntents_expected: expected PointToPointIntent intents
16 allRoutes_actual: all routes from ONOS LCI
17 routeIntents_actual: actual MultiPointToSinglePointIntent intents from ONOS CLI
18 bgpIntents_actual: actual PointToPointIntent intents from ONOS CLI
pingping-lin8b306ac2014-11-17 18:13:51 -080019 '''
20 import time
21 import json
22 from operator import eq
pingping-linc6b86fa2014-12-01 16:18:10 -080023 # from datetime import datetime
pingping-lin01355a62014-12-02 20:58:14 -080024 from time import localtime, strftime
pingping-linc6b86fa2014-12-01 16:18:10 -080025
pingping-lin3228e132014-11-20 17:49:02 -080026 main.case("The test case is to help to setup the TestON environment and test new drivers")
pingping-lin6f6332e2014-11-19 19:13:58 -080027 SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json"
28 # all expected routes for all BGP peers
29 allRoutes_expected = []
pingping-lin36fbe802014-11-25 16:01:14 -080030 main.step("Start to generate routes for all BGP peers")
pingping-linc6b86fa2014-12-01 16:18:10 -080031 # bgpPeerHosts = []
32 # for i in range(3, 5):
pingping-lin36fbe802014-11-25 16:01:14 -080033 # bgpPeerHosts.append("host" + str(i))
pingping-linc6b86fa2014-12-01 16:18:10 -080034 # main.log.info("BGP Peer Hosts are:" + bgpPeerHosts)
pingping-lin6f6332e2014-11-19 19:13:58 -080035
pingping-linc6b86fa2014-12-01 16:18:10 -080036 # for i in range(3, 5):
pingping-lin36fbe802014-11-25 16:01:14 -080037 # QuaggaCliHost = "QuaggaCliHost" + str(i)
38 # prefixes = main.QuaggaCliHost.generate_prefixes(3, 10)
pingping-lin6f6332e2014-11-19 19:13:58 -080039
pingping-lin36fbe802014-11-25 16:01:14 -080040 # main.log.info(prefixes)
pingping-linc6b86fa2014-12-01 16:18:10 -080041 # allRoutes_expected.append(prefixes)
pingping-lin36fbe802014-11-25 16:01:14 -080042 main.log.info("Generate prefixes for host3")
43 prefixes_host3 = main.QuaggaCliHost3.generate_prefixes(3, 10)
44 main.log.info(prefixes_host3)
45 # generate route with next hop
46 for prefix in prefixes_host3:
47 allRoutes_expected.append(prefix + "/" + "192.168.20.1")
48 routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(prefixes_host3, "192.168.20.1", "00:00:00:00:02:02", SDNIP_JSON_FILE_PATH)
pingping-lin6f6332e2014-11-19 19:13:58 -080049
pingping-lin36fbe802014-11-25 16:01:14 -080050 main.log.info("Generate prefixes for host4")
51 prefixes_host4 = main.QuaggaCliHost4.generate_prefixes(4, 10)
52 main.log.info(prefixes_host4)
53 # generate route with next hop
54 for prefix in prefixes_host4:
55 allRoutes_expected.append(prefix + "/" + "192.168.30.1")
56 routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(prefixes_host4, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
pingping-lin6f6332e2014-11-19 19:13:58 -080057
pingping-lin36fbe802014-11-25 16:01:14 -080058 routeIntents_expected = routeIntents_expected_host3 + routeIntents_expected_host4
pingping-lin8b306ac2014-11-17 18:13:51 -080059
pingping-lin8b306ac2014-11-17 18:13:51 -080060
61 cell_name = main.params['ENV']['cellName']
62 ONOS1_ip = main.params['CTRL']['ip1']
pingping-lin81ef0652014-12-02 21:39:23 -080063 main.step("Set cell for ONOS-cli environment")
64 main.ONOScli.set_cell(cell_name)
65 verify_result = main.ONOSbench.verify_cell()
66 main.log.report("Removing raft logs")
67 main.ONOSbench.onos_remove_raft_logs()
68 main.log.report("Uninstalling ONOS")
69 main.ONOSbench.onos_uninstall(ONOS1_ip)
70 main.step("Creating ONOS package")
71 package_result = main.ONOSbench.onos_package()
pingping-lin8b306ac2014-11-17 18:13:51 -080072
73 main.step("Starting ONOS service")
74 # TODO: start ONOS from Mininet Script
pingping-lin3d87a132014-12-04 14:22:49 -080075 # start_result = main.ONOSbench.onos_start("127.0.0.1")
pingping-lin81ef0652014-12-02 21:39:23 -080076 main.step("Installing ONOS package")
77 onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
pingping-lin3d87a132014-12-04 14:22:49 -080078
pingping-lin81ef0652014-12-02 21:39:23 -080079 main.step("Checking if ONOS is up yet")
80 time.sleep(60)
81 onos1_isup = main.ONOSbench.isup(ONOS1_ip)
82 if not onos1_isup:
83 main.log.report("ONOS1 didn't start!")
pingping-linc6b86fa2014-12-01 16:18:10 -080084
pingping-lin8b306ac2014-11-17 18:13:51 -080085 main.step("Start ONOS-cli")
86 # TODO: change the hardcode in start_onos_cli method in ONOS CLI driver
pingping-linc6b86fa2014-12-01 16:18:10 -080087
88 main.ONOScli.start_onos_cli(ONOS1_ip)
pingping-lin8b306ac2014-11-17 18:13:51 -080089
90 main.step("Get devices in the network")
91 list_result = main.ONOScli.devices(json_format=False)
92 main.log.info(list_result)
pingping-lin81ef0652014-12-02 21:39:23 -080093 time.sleep(10)
94 main.log.info("Installing sdn-ip feature")
95 main.ONOScli.feature_install("onos-app-sdnip")
pingping-linbc230942014-12-03 18:36:27 -080096 time.sleep(10)
97 main.step("Login all BGP peers and add routes into peers")
98 main.log.info("Login Quagga CLI on host3")
99 main.QuaggaCliHost3.loginQuagga("1.168.30.2")
100 main.log.info("Enter configuration model of Quagga CLI on host3")
101 main.QuaggaCliHost3.enter_config(64514)
102 main.log.info("Add routes to Quagga on host3")
103 main.QuaggaCliHost3.add_routes(prefixes_host3, 1)
104
105 main.log.info("Login Quagga CLI on host4")
106 main.QuaggaCliHost4.loginQuagga("1.168.30.3")
107 main.log.info("Enter configuration model of Quagga CLI on host4")
108 main.QuaggaCliHost4.enter_config(64516)
109 main.log.info("Add routes to Quagga on host4")
110 main.QuaggaCliHost4.add_routes(prefixes_host4, 1)
111 time.sleep(60)
pingping-lin8b306ac2014-11-17 18:13:51 -0800112
pingping-linc6b86fa2014-12-01 16:18:10 -0800113 # get all routes inside SDN-IP
pingping-lin36fbe802014-11-25 16:01:14 -0800114 get_routes_result = main.ONOScli.routes(json_format=True)
pingping-linc6b86fa2014-12-01 16:18:10 -0800115
pingping-lin8b306ac2014-11-17 18:13:51 -0800116 # parse routes from ONOS CLI
pingping-lin36fbe802014-11-25 16:01:14 -0800117 allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
pingping-linc6b86fa2014-12-01 16:18:10 -0800118
pingping-lin36fbe802014-11-25 16:01:14 -0800119 allRoutes_str_expected = str(sorted(allRoutes_expected))
pingping-linc6b86fa2014-12-01 16:18:10 -0800120 allRoutes_str_actual = str(allRoutes_actual).replace('u', "")
pingping-lin6f6332e2014-11-19 19:13:58 -0800121 main.step("Check routes installed")
122 main.log.info("Routes expected:")
pingping-lin36fbe802014-11-25 16:01:14 -0800123 main.log.info(allRoutes_str_expected)
pingping-lin8b306ac2014-11-17 18:13:51 -0800124 main.log.info("Routes get from ONOS CLI:")
pingping-lin36fbe802014-11-25 16:01:14 -0800125 main.log.info(allRoutes_str_actual)
126 utilities.assert_equals(expect=allRoutes_str_expected, actual=allRoutes_str_actual,
pingping-lin6f6332e2014-11-19 19:13:58 -0800127 onpass="***Routes in SDN-IP are correct!***",
128 onfail="***Routes in SDN-IP are wrong!***")
pingping-lin3d87a132014-12-04 14:22:49 -0800129 if(eq(allRoutes_str_expected, allRoutes_str_actual)):
130 main.log.report("***Routes in SDN-IP after adding routes are correct!***")
131 else:
132 main.log.report("***Routes in SDN-IP after adding routes are wrong!***")
pingping-lin8b306ac2014-11-17 18:13:51 -0800133
pingping-lin36fbe802014-11-25 16:01:14 -0800134 time.sleep(20)
pingping-lin6f6332e2014-11-19 19:13:58 -0800135 get_intents_result = main.ONOScli.intents(json_format=True)
136
137
138 main.step("Check MultiPointToSinglePointIntent intents installed")
139 # route_intents_expected are generated when generating routes
140 # get rpoute intents from ONOS CLI
pingping-linc6b86fa2014-12-01 16:18:10 -0800141 routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
pingping-lin36fbe802014-11-25 16:01:14 -0800142 routeIntents_str_expected = str(sorted(routeIntents_expected))
pingping-linc6b86fa2014-12-01 16:18:10 -0800143 routeIntents_str_actual = str(routeIntents_actual).replace('u', "")
pingping-lin6f6332e2014-11-19 19:13:58 -0800144 main.log.info("MultiPointToSinglePoint intents expected:")
pingping-lin36fbe802014-11-25 16:01:14 -0800145 main.log.info(routeIntents_str_expected)
pingping-lin6f6332e2014-11-19 19:13:58 -0800146 main.log.info("MultiPointToSinglePoint intents get from ONOS CLI:")
pingping-lin36fbe802014-11-25 16:01:14 -0800147 main.log.info(routeIntents_str_actual)
148 utilities.assert_equals(expect=True, actual=eq(routeIntents_str_expected, routeIntents_str_actual),
pingping-lin6f6332e2014-11-19 19:13:58 -0800149 onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
150 onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***")
151
pingping-lin3d87a132014-12-04 14:22:49 -0800152 if(eq(routeIntents_str_expected, routeIntents_str_actual)):
153 main.log.report("***MultiPointToSinglePoint Intents before deleting routes correct!***")
154 else:
155 main.log.report("***MultiPointToSinglePoint Intents before deleting routes wrong!***")
pingping-lin6f6332e2014-11-19 19:13:58 -0800156
157 main.step("Check BGP PointToPointIntent intents installed")
158 # bgp intents expected
pingping-lin36fbe802014-11-25 16:01:14 -0800159 bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
pingping-lin6f6332e2014-11-19 19:13:58 -0800160 # get BGP intents from ONOS CLI
pingping-lin36fbe802014-11-25 16:01:14 -0800161 bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(get_intents_result)
pingping-lin3228e132014-11-20 17:49:02 -0800162
pingping-linc6b86fa2014-12-01 16:18:10 -0800163 bgpIntents_str_expected = str(bgpIntents_expected).replace('u', "")
pingping-lin3228e132014-11-20 17:49:02 -0800164 bgpIntents_str_actual = str(bgpIntents_actual)
pingping-lin6f6332e2014-11-19 19:13:58 -0800165 main.log.info("PointToPointIntent intents expected:")
pingping-lin3228e132014-11-20 17:49:02 -0800166 main.log.info(bgpIntents_str_expected)
pingping-lin6f6332e2014-11-19 19:13:58 -0800167 main.log.info("PointToPointIntent intents get from ONOS CLI:")
pingping-lin3228e132014-11-20 17:49:02 -0800168 main.log.info(bgpIntents_str_actual)
169
170 utilities.assert_equals(expect=True, actual=eq(bgpIntents_str_expected, bgpIntents_str_actual),
pingping-lin6f6332e2014-11-19 19:13:58 -0800171 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
172 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***")
pingping-lin8b306ac2014-11-17 18:13:51 -0800173
pingping-lin3d87a132014-12-04 14:22:49 -0800174
175 if (eq(bgpIntents_str_expected, bgpIntents_str_actual)):
176 main.log.report("***PointToPointIntent Intents in SDN-IP are correct!***")
177 else:
178 main.log.report("***PointToPointIntent Intents in SDN-IP are wrong!***")
179
180
181
pingping-linc6b86fa2014-12-01 16:18:10 -0800182 #============================= Ping Test ========================
183 # wait until all MultiPointToSinglePoint
184 time.sleep(20)
pingping-lindd3b0e42014-12-02 11:46:54 -0800185 ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
pingping-linbc230942014-12-03 18:36:27 -0800186 ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
pingping-lindd3b0e42014-12-02 11:46:54 -0800187 ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
pingping-linc6b86fa2014-12-01 16:18:10 -0800188 main.log.info(ping_test_results)
189
190 # ping test
191
192 #============================= Deleting Routes ==================
193 main.step("Check deleting routes installed")
194 main.QuaggaCliHost3.delete_routes(prefixes_host3, 1)
195 main.QuaggaCliHost4.delete_routes(prefixes_host4, 1)
196
197 # main.log.info("main.ONOScli.get_routes_num() = " )
198 # main.log.info(main.ONOScli.get_routes_num())
199 # utilities.assert_equals(expect = "Total SDN-IP routes = 1", actual= main.ONOScli.get_routes_num(),
200 get_routes_result = main.ONOScli.routes(json_format=True)
201 allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
202 main.log.info("allRoutes_actual = ")
203 main.log.info(allRoutes_actual)
204
205 utilities.assert_equals(expect="[]", actual=str(allRoutes_actual),
206 onpass="***Route number in SDN-IP is 0, correct!***",
207 onfail="***Routes number in SDN-IP is not 0, wrong!***")
208
pingping-lin3d87a132014-12-04 14:22:49 -0800209 if(eq(allRoutes_str_expected, allRoutes_str_actual)):
210 main.log.report("***Routes in SDN-IP after deleting correct!***")
211 else:
212 main.log.report("***Routes in SDN-IP after deleting wrong!***")
213
pingping-linc6b86fa2014-12-01 16:18:10 -0800214 main.step("Check intents after deleting routes")
215 get_intents_result = main.ONOScli.intents(json_format=True)
216 routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
217 main.log.info("main.ONOScli.intents()= ")
218 main.log.info(routeIntents_actual)
219 utilities.assert_equals(expect="[]", actual=str(routeIntents_actual),
220 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
221 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***")
222
pingping-lin3d87a132014-12-04 14:22:49 -0800223 if(eq(routeIntents_str_expected, routeIntents_str_actual)):
224 main.log.report("***MultiPointToSinglePoint Intents after deleting routes correct!***")
225 else:
226 main.log.report("***MultiPointToSinglePoint Intents after deleting routes wrong!***")
pingping-linc6b86fa2014-12-01 16:18:10 -0800227
228 time.sleep(20)
pingping-lindd3b0e42014-12-02 11:46:54 -0800229 ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
pingping-linbc230942014-12-03 18:36:27 -0800230 ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
pingping-lindd3b0e42014-12-02 11:46:54 -0800231 ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
pingping-linc6b86fa2014-12-01 16:18:10 -0800232 main.log.info(ping_test_results)
pingping-lin81ef0652014-12-02 21:39:23 -0800233 time.sleep(30)
pingping-linc6b86fa2014-12-01 16:18:10 -0800234
235 # main.step("Test whether Mininet is started")
236 # main.Mininet2.handle.sendline("xterm host1")
237 # main.Mininet2.handle.expect("mininet>")
pingping-lin8b306ac2014-11-17 18:13:51 -0800238
pingping-lin3d87a132014-12-04 14:22:49 -0800239
240 def CASE2(self, main):
241
242 '''
243 Test the SDN-IP functionality
244 allRoutes_expected: all expected routes for all BGP peers
245 routeIntents_expected: all expected MultiPointToSinglePointIntent intents
246 bgpIntents_expected: expected PointToPointIntent intents
247 allRoutes_actual: all routes from ONOS LCI
248 routeIntents_actual: actual MultiPointToSinglePointIntent intents from ONOS CLI
249 bgpIntents_actual: actual PointToPointIntent intents from ONOS CLI
250 '''
251 import time
252 import json
253 from operator import eq
254 from time import localtime, strftime
255
256 main.case("The test case is to help to setup the TestON environment and test new drivers")
257 SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json"
258 # all expected routes for all BGP peers
259 allRoutes_expected = []
260 main.step("Start to generate routes for all BGP peers")
261
262 main.log.info("Generate prefixes for host3")
263 prefixes_host3 = main.QuaggaCliHost3.generate_prefixes(3, 10)
264 main.log.info(prefixes_host3)
265 # generate route with next hop
266 for prefix in prefixes_host3:
267 allRoutes_expected.append(prefix + "/" + "192.168.20.1")
268 routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(prefixes_host3, "192.168.20.1", "00:00:00:00:02:02", SDNIP_JSON_FILE_PATH)
269
270 main.log.info("Generate prefixes for host4")
271 prefixes_host4 = main.QuaggaCliHost4.generate_prefixes(4, 10)
272 main.log.info(prefixes_host4)
273 # generate route with next hop
274 for prefix in prefixes_host4:
275 allRoutes_expected.append(prefix + "/" + "192.168.30.1")
276 routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(prefixes_host4, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
277
278 routeIntents_expected = routeIntents_expected_host3 + routeIntents_expected_host4
279
280 main.log.report("Removing raft logs")
281 main.ONOSbench.onos_remove_raft_logs()
282 main.log.report("Uninstalling ONOS")
283 main.ONOSbench.onos_uninstall(ONOS1_ip)
284
285 cell_name = main.params['ENV']['cellName']
286 ONOS1_ip = main.params['CTRL']['ip1']
287 main.step("Set cell for ONOS-cli environment")
288 main.ONOScli.set_cell(cell_name)
289 verify_result = main.ONOSbench.verify_cell()
290 #main.log.report("Removing raft logs")
291 #main.ONOSbench.onos_remove_raft_logs()
292 #main.log.report("Uninstalling ONOS")
293 #main.ONOSbench.onos_uninstall(ONOS1_ip)
294 main.step("Creating ONOS package")
295 package_result = main.ONOSbench.onos_package()
296
297 main.step("Installing ONOS package")
298 onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip)
299
300 main.step("Checking if ONOS is up yet")
301 time.sleep(60)
302 onos1_isup = main.ONOSbench.isup(ONOS1_ip)
303 if not onos1_isup:
304 main.log.report("ONOS1 didn't start!")
305
306 main.step("Start ONOS-cli")
307 main.ONOScli.start_onos_cli(ONOS1_ip)
308
309 main.step("Get devices in the network")
310 list_result = main.ONOScli.devices(json_format=False)
311 main.log.info(list_result)
312 time.sleep(10)
313 main.log.info("Installing sdn-ip feature")
314 main.ONOScli.feature_install("onos-app-sdnip")
315 time.sleep(10)
316
317
318 main.step("Check BGP PointToPointIntent intents installed")
319 # bgp intents expected
320 bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
321 # get BGP intents from ONOS CLI
322 get_intents_result = main.ONOScli.intents(json_format=True)
323 bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(get_intents_result)
324
325 bgpIntents_str_expected = str(bgpIntents_expected).replace('u', "")
326 bgpIntents_str_actual = str(bgpIntents_actual)
327 main.log.info("PointToPointIntent intents expected:")
328 main.log.info(bgpIntents_str_expected)
329 main.log.info("PointToPointIntent intents get from ONOS CLI:")
330 main.log.info(bgpIntents_str_actual)
331
332 utilities.assert_equals(expect=True, actual=eq(bgpIntents_str_expected, bgpIntents_str_actual),
333 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
334 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***")
335
336 if (eq(bgpIntents_str_expected, bgpIntents_str_actual)):
337 main.log.report("***PointToPointIntent Intents in SDN-IP are correct!***")
338 else:
339 main.log.report("***PointToPointIntent Intents in SDN-IP are wrong!***")
340
341
342 allRoutes_str_expected = str(sorted(allRoutes_expected))
343 routeIntents_str_expected = str(sorted(routeIntents_expected))
344 ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
345 # round_num = 0;
346 # while(True):
347 for round_num in range(1, 6):
348 # round = round + 1;
349 main.log.report("The Round " + str(round_num) + " test starts........................................")
350
351 main.step("Login all BGP peers and add routes into peers")
352 main.log.info("Login Quagga CLI on host3")
353 main.QuaggaCliHost3.loginQuagga("1.168.30.2")
354 main.log.info("Enter configuration model of Quagga CLI on host3")
355 main.QuaggaCliHost3.enter_config(64514)
356 main.log.info("Add routes to Quagga on host3")
357 main.QuaggaCliHost3.add_routes(prefixes_host3, 1)
358
359 main.log.info("Login Quagga CLI on host4")
360 main.QuaggaCliHost4.loginQuagga("1.168.30.3")
361 main.log.info("Enter configuration model of Quagga CLI on host4")
362 main.QuaggaCliHost4.enter_config(64516)
363 main.log.info("Add routes to Quagga on host4")
364 main.QuaggaCliHost4.add_routes(prefixes_host4, 1)
365 time.sleep(60)
366
367 # get all routes inside SDN-IP
368 get_routes_result = main.ONOScli.routes(json_format=True)
369
370 # parse routes from ONOS CLI
371 allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
372
373 # allRoutes_str_expected = str(sorted(allRoutes_expected))
374 allRoutes_str_actual = str(allRoutes_actual).replace('u', "")
375 main.step("Check routes installed")
376 main.log.info("Routes expected:")
377 main.log.info(allRoutes_str_expected)
378 main.log.info("Routes get from ONOS CLI:")
379 main.log.info(allRoutes_str_actual)
380 utilities.assert_equals(expect=allRoutes_str_expected, actual=allRoutes_str_actual,
381 onpass="***Routes in SDN-IP are correct!***",
382 onfail="***Routes in SDN-IP are wrong!***")
383 if(eq(allRoutes_str_expected, allRoutes_str_actual)):
384 main.log.report("***Routes in SDN-IP after adding correct!***")
385 else:
386 main.log.report("***Routes in SDN-IP after adding wrong!***")
387
388 time.sleep(20)
389 get_intents_result = main.ONOScli.intents(json_format=True)
390
391
392 main.step("Check MultiPointToSinglePointIntent intents installed")
393 # route_intents_expected are generated when generating routes
394 # get route intents from ONOS CLI
395 routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
396 # routeIntents_str_expected = str(sorted(routeIntents_expected))
397 routeIntents_str_actual = str(routeIntents_actual).replace('u', "")
398 main.log.info("MultiPointToSinglePoint intents expected:")
399 main.log.info(routeIntents_str_expected)
400 main.log.info("MultiPointToSinglePoint intents get from ONOS CLI:")
401 main.log.info(routeIntents_str_actual)
402 utilities.assert_equals(expect=True, actual=eq(routeIntents_str_expected, routeIntents_str_actual),
403 onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
404 onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***")
405
406 if(eq(routeIntents_str_expected, routeIntents_str_actual)):
407 main.log.report("***MultiPointToSinglePoint Intents after adding routes correct!***")
408 else:
409 main.log.report("***MultiPointToSinglePoint Intents after adding routes wrong!***")
410
411 #============================= Ping Test ========================
412 # wait until all MultiPointToSinglePoint
413 time.sleep(20)
414 # ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
415 ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + str(round_num) + "-ping-results-before-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
416 ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
417 main.log.info(ping_test_results)
418 # ping test
419
420 #============================= Deleting Routes ==================
421 main.step("Check deleting routes installed")
422 main.log.info("Delete routes to Quagga on host3")
423 main.QuaggaCliHost3.delete_routes(prefixes_host3, 1)
424 main.log.info("Delete routes to Quagga on host4")
425 main.QuaggaCliHost4.delete_routes(prefixes_host4, 1)
426
427 get_routes_result = main.ONOScli.routes(json_format=True)
428 allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
429 main.log.info("allRoutes_actual = ")
430 main.log.info(allRoutes_actual)
431
432 utilities.assert_equals(expect="[]", actual=str(allRoutes_actual),
433 onpass="***Route number in SDN-IP is 0, correct!***",
434 onfail="***Routes number in SDN-IP is not 0, wrong!***")
435
436 if(eq(allRoutes_str_expected, allRoutes_str_actual)):
437 main.log.report("***Routes in SDN-IP after deleting correct!***")
438 else:
439 main.log.report("***Routes in SDN-IP after deleting wrong!***")
440
441 main.step("Check intents after deleting routes")
442 get_intents_result = main.ONOScli.intents(json_format=True)
443 routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
444 main.log.info("main.ONOScli.intents()= ")
445 main.log.info(routeIntents_actual)
446 utilities.assert_equals(expect="[]", actual=str(routeIntents_actual),
447 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***",
448 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***")
449
450 if(eq(routeIntents_str_expected, routeIntents_str_actual)):
451 main.log.report("***MultiPointToSinglePoint Intents after deleting routes correct!***")
452 else:
453 main.log.report("***MultiPointToSinglePoint Intents after deleting routes wrong!***")
454
455 time.sleep(20)
456 # ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
457 ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + str(round_num) + "-ping-results-after-delete-routes-" + strftime("%Y-%m-%d_%H:%M:%S", localtime()) + ".txt"
458 ping_test_results = main.QuaggaCliHost.ping_test("1.168.30.100", ping_test_script, ping_test_results_file)
459 main.log.info(ping_test_results)
460 time.sleep(30)
461
462
463