blob: f26cd5c358a4b44d197f4c119ecc64da6c09d94d [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08002# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
shahshreya4e13a062014-11-11 16:46:18 -08004
5import time
6import sys
7import os
8import re
9import time
10import json
11
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080012time.sleep( 1 )
13
14
shahshreya4e13a062014-11-11 16:46:18 -080015class MultiProd13:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080016
17 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080018 self.default = ''
19
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080020 def CASE1( self, main ):
21 """
shahshreya4e13a062014-11-11 16:46:18 -080022 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080023 cell <name>
24 onos-verify-cell
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080025 onos-remove-raft-logs
shahshreya4e13a062014-11-11 16:46:18 -080026 git pull
27 mvn clean install
28 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080029 onos-install -f
30 onos-wait-for-start
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080031 """
32 cell_name = main.params[ 'ENV' ][ 'cellName' ]
33 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
34 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
35 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
36 ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
37 ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
38 ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
39
40 main.case( "Setting up test environment" )
41 main.log.report(
42 "This testcase is testing setting up test environment" )
43 main.log.report( "__________________________________" )
44
45 main.step( "Applying cell variable to environment" )
46 cell_result1 = main.ONOSbench.set_cell( cell_name )
47 #cell_result2 = main.ONOScli1.set_cell( cell_name )
48 #cell_result3 = main.ONOScli2.set_cell( cell_name )
49 #cell_result4 = main.ONOScli3.set_cell( cell_name )
50 verify_result = main.ONOSbench.verify_cell()
shahshreyae6c7cf42014-11-26 16:39:01 -080051 cell_result = cell_result1
52
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080053 main.step( "Removing raft logs before a clen installation of ONOS" )
54 remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
shahshreyae6c7cf42014-11-26 16:39:01 -080055
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080056 main.step( "Git checkout and pull master and get version" )
57 main.ONOSbench.git_checkout( "master" )
shahshreya4e13a062014-11-11 16:46:18 -080058 git_pull_result = main.ONOSbench.git_pull()
59 print "git_pull_result = ", git_pull_result
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080060 version_result = main.ONOSbench.get_version( report=True )
shahshreya4e13a062014-11-11 16:46:18 -080061
62 if git_pull_result == 1:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080063 main.step( "Using mvn clean & install" )
shahshreya4e13a062014-11-11 16:46:18 -080064 clean_install_result = main.ONOSbench.clean_install()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080065 #clean_install_result = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -080066
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080067 main.step( "Creating ONOS package" )
shahshreya4e13a062014-11-11 16:46:18 -080068 package_result = main.ONOSbench.onos_package()
69
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080070 #main.step( "Creating a cell" )
71 # cell_create_result = main.ONOSbench.create_cell_file( **************
72 # )
shahshreya4e13a062014-11-11 16:46:18 -080073
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080074 main.step( "Installing ONOS package" )
75 onos1_install_result = main.ONOSbench.onos_install(
76 options="-f",
77 node=ONOS1_ip )
78 onos2_install_result = main.ONOSbench.onos_install(
79 options="-f",
80 node=ONOS2_ip )
81 onos3_install_result = main.ONOSbench.onos_install(
82 options="-f",
83 node=ONOS3_ip )
84 onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result
shahshreya4e13a062014-11-11 16:46:18 -080085 if onos_install_result == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080086 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080087 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080088 main.log.report( "Installing ONOS package failed" )
89
90 onos1_isup = main.ONOSbench.isup( ONOS1_ip )
91 onos2_isup = main.ONOSbench.isup( ONOS2_ip )
92 onos3_isup = main.ONOSbench.isup( ONOS3_ip )
shahshreya4e13a062014-11-11 16:46:18 -080093 onos_isup = onos1_isup and onos2_isup and onos3_isup
94 if onos_isup == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080095 main.log.report( "ONOS instances are up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080096 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080097 main.log.report( "ONOS instances may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080098
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080099 main.step( "Starting ONOS service" )
shahshreya4e13a062014-11-11 16:46:18 -0800100 start_result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800101 #start_result = main.ONOSbench.onos_start( ONOS1_ip )
102 startcli1 = main.ONOScli1.start_onos_cli( ONOS_ip=ONOS1_ip )
103 startcli2 = main.ONOScli2.start_onos_cli( ONOS_ip=ONOS2_ip )
104 startcli3 = main.ONOScli3.start_onos_cli( ONOS_ip=ONOS3_ip )
shahshreya4e13a062014-11-11 16:46:18 -0800105 print startcli1
106 print startcli2
107 print startcli3
shahshreya4e13a062014-11-11 16:46:18 -0800108
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800109 case1_result = ( package_result and
110 cell_result and verify_result and onos_install_result and
111 onos_isup and start_result )
112 utilities.assert_equals( expect=main.TRUE, actual=case1_result,
113 onpass="Test startup successful",
114 onfail="Test startup NOT successful" )
115
116 def CASE11( self, main ):
117 """
shahshreya4e13a062014-11-11 16:46:18 -0800118 Cleanup sequence:
119 onos-service <node_ip> stop
120 onos-uninstall
121
122 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800123
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800124 """
125 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
126 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
127 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800128
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800129 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800130
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800131 main.step( "Testing ONOS kill function" )
132 kill_result1 = main.ONOSbench.onos_kill( ONOS1_ip )
133 kill_result2 = main.ONOSbench.onos_kill( ONOS2_ip )
134 kill_result3 = main.ONOSbench.onos_kill( ONOS3_ip )
135
136 main.step( "Stopping ONOS service" )
137 stop_result1 = main.ONOSbench.onos_stop( ONOS1_ip )
138 stop_result2 = main.ONOSbench.onos_stop( ONOS2_ip )
139 stop_result3 = main.ONOSbench.onos_stop( ONOS3_ip )
140
141 main.step( "Uninstalling ONOS service" )
shahshreya4e13a062014-11-11 16:46:18 -0800142 uninstall_result = main.ONOSbench.onos_uninstall()
143
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800144 def CASE3( self, main ):
145 """
shahshreya4e13a062014-11-11 16:46:18 -0800146 Test 'onos' command and its functionality in driver
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800147 """
148 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
149 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
150 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800151
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800152 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800153
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800154 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800155 cmdstr1 = "system:name"
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800156 cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
157 main.log.info( "onos command returned: " + cmd_result1 )
158 cmd_result2 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr1 )
159 main.log.info( "onos command returned: " + cmd_result2 )
160 cmd_result3 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr1 )
161 main.log.info( "onos command returned: " + cmd_result3 )
shahshreya4e13a062014-11-11 16:46:18 -0800162
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800163 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800164 cmdstr2 = "onos:topology"
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800165 cmd_result4 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
166 main.log.info( "onos command returned: " + cmd_result4 )
167 cmd_result5 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr2 )
168 main.log.info( "onos command returned: " + cmd_result5 )
169 cmd_result6 = main.ONOSbench.onos_cli( ONOS6_ip, cmdstr2 )
170 main.log.info( "onos command returned: " + cmd_result6 )
shahshreya4e13a062014-11-11 16:46:18 -0800171
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800172 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800173 import re
174 import time
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800175 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
176 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
177 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
178 ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
179 ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
180 ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
181
182 main.log.report(
183 "This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode" )
184 main.log.report( "__________________________________" )
185 main.case( "Pingall Test(No intents are added)" )
186 main.step( "Assigning switches to controllers" )
187 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
188 main.Mininet1.assign_sw_controller(
189 sw=str( i ),
190 count=3,
191 ip1=ONOS1_ip,
192 port1=ONOS1_port,
193 ip2=ONOS2_ip,
194 port2=ONOS2_port,
195 ip3=ONOS3_ip,
196 port3=ONOS3_port )
shahshreya4e13a062014-11-11 16:46:18 -0800197
198 switch_mastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800199 for i in range( 1, 29 ):
200 response = main.Mininet1.get_sw_controller( "s" + str( i ) )
201 print( "Response is " + str( response ) )
202 if re.search( "tcp:" + ONOS1_ip, response ):
shahshreya4e13a062014-11-11 16:46:18 -0800203 switch_mastership = switch_mastership and main.TRUE
204 else:
205 switch_mastership = main.FALSE
206
207 if switch_mastership == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800208 main.log.report( "Controller assignment successfull" )
shahshreya4e13a062014-11-11 16:46:18 -0800209 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800210 main.log.report( "Controller assignment failed" )
211 # REACTIVE FWD test
212 main.step( "Pingall" )
shahshreya4e13a062014-11-11 16:46:18 -0800213 ping_result = main.FALSE
214 time1 = time.time()
215 ping_result = main.Mininet1.pingall()
216 time2 = time.time()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800217 print "Time for pingall: %2f seconds" % ( time2 - time1 )
218
shahshreya4e13a062014-11-11 16:46:18 -0800219 case4_result = switch_mastership and ping_result
220 if ping_result == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800221 main.log.report(
222 "Pingall Test in reactive mode to discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800223 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800224 main.log.report(
225 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800226
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800227 utilities.assert_equals(
228 expect=main.TRUE,
229 actual=case4_result,
230 onpass="Controller assignment and Pingall Test successful",
231 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800232
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800233 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800234 import json
235 from subprocess import Popen, PIPE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800236 # assumes that sts is already in you PYTHONPATH
237 from sts.topology.teston_topology import TestONTopology
238 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
239 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
240 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
241
242 main.log.report(
243 "This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes" )
244 main.log.report( "__________________________________" )
245 main.case(
246 "Testing Mininet topology with the topology of multi instances ONOS" )
247 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800248 devices1 = main.ONOScli1.devices()
249 devices2 = main.ONOScli2.devices()
250 devices3 = main.ONOScli3.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800251 # print "devices1 = ", devices1
252 # print "devices2 = ", devices2
253 # print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800254 hosts1 = main.ONOScli1.hosts()
255 hosts2 = main.ONOScli2.hosts()
256 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800257 # print "hosts1 = ", hosts1
258 # print "hosts2 = ", hosts2
259 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800260 ports1 = main.ONOScli1.ports()
261 ports2 = main.ONOScli2.ports()
262 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800263 # print "ports1 = ", ports1
264 # print "ports2 = ", ports2
265 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800266 links1 = main.ONOScli1.links()
267 links2 = main.ONOScli2.links()
268 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800269 # print "links1 = ", links1
270 # print "links2 = ", links2
271 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800272
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800273 print "**************"
274
275 main.step( "Start continuous pings" )
276 main.Mininet2.pingLong(
277 src=main.params[ 'PING' ][ 'source1' ],
278 target=main.params[ 'PING' ][ 'target1' ],
279 pingTime=500 )
280 main.Mininet2.pingLong(
281 src=main.params[ 'PING' ][ 'source2' ],
282 target=main.params[ 'PING' ][ 'target2' ],
283 pingTime=500 )
284 main.Mininet2.pingLong(
285 src=main.params[ 'PING' ][ 'source3' ],
286 target=main.params[ 'PING' ][ 'target3' ],
287 pingTime=500 )
288 main.Mininet2.pingLong(
289 src=main.params[ 'PING' ][ 'source4' ],
290 target=main.params[ 'PING' ][ 'target4' ],
291 pingTime=500 )
292 main.Mininet2.pingLong(
293 src=main.params[ 'PING' ][ 'source5' ],
294 target=main.params[ 'PING' ][ 'target5' ],
295 pingTime=500 )
296 main.Mininet2.pingLong(
297 src=main.params[ 'PING' ][ 'source6' ],
298 target=main.params[ 'PING' ][ 'target6' ],
299 pingTime=500 )
300 main.Mininet2.pingLong(
301 src=main.params[ 'PING' ][ 'source7' ],
302 target=main.params[ 'PING' ][ 'target7' ],
303 pingTime=500 )
304 main.Mininet2.pingLong(
305 src=main.params[ 'PING' ][ 'source8' ],
306 target=main.params[ 'PING' ][ 'target8' ],
307 pingTime=500 )
308 main.Mininet2.pingLong(
309 src=main.params[ 'PING' ][ 'source9' ],
310 target=main.params[ 'PING' ][ 'target9' ],
311 pingTime=500 )
312 main.Mininet2.pingLong(
313 src=main.params[ 'PING' ][ 'source10' ],
314 target=main.params[ 'PING' ][ 'target10' ],
315 pingTime=500 )
316
317 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800318 global ctrls
319 ctrls = []
320 count = 1
321 while True:
322 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800323 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
324 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
325 temp = temp + ( "ONOS" + str( count ), )
326 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
327 temp = temp + \
328 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
329 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800330 count = count + 1
331 else:
332 break
333 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800334 Topo = TestONTopology(
335 main.Mininet1,
336 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800337 MNTopo = Topo
338
339 Topology_Check = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800340 main.step( "Compare ONOS Topology to MN Topology" )
341
342 switches_results1 = main.Mininet1.compare_switches(
343 MNTopo,
344 json.loads( devices1 ) )
shahshreya4e13a062014-11-11 16:46:18 -0800345 print "switches_Result1 = ", switches_results1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800346 utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
347 onpass="ONOS1 Switches view is correct",
348 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800349
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800350 switches_results2 = main.Mininet1.compare_switches(
351 MNTopo,
352 json.loads( devices2 ) )
353 utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
354 onpass="ONOS2 Switches view is correct",
355 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800356
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800357 switches_results3 = main.Mininet1.compare_switches(
358 MNTopo,
359 json.loads( devices3 ) )
360 utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
361 onpass="ONOS3 Switches view is correct",
362 onfail="ONOS3 Switches view is incorrect" )
363
364 """
365 ports_results1 = main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
366 utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
shahshreya4e13a062014-11-11 16:46:18 -0800367 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800368 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800369
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800370 ports_results2 = main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
371 utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
shahshreya4e13a062014-11-11 16:46:18 -0800372 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800373 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800374
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800375 ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
376 utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
shahshreya4e13a062014-11-11 16:46:18 -0800377 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800378 onfail="ONOS3 Ports view is incorrect" )
379 """
380 links_results1 = main.Mininet1.compare_links(
381 MNTopo,
382 json.loads( links1 ) )
383 utilities.assert_equals( expect=main.TRUE, actual=links_results1,
384 onpass="ONOS1 Links view is correct",
385 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800386
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800387 links_results2 = main.Mininet1.compare_links(
388 MNTopo,
389 json.loads( links2 ) )
390 utilities.assert_equals( expect=main.TRUE, actual=links_results2,
391 onpass="ONOS2 Links view is correct",
392 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800393
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800394 links_results3 = main.Mininet1.compare_links(
395 MNTopo,
396 json.loads( links3 ) )
397 utilities.assert_equals( expect=main.TRUE, actual=links_results3,
398 onpass="ONOS2 Links view is correct",
399 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800400
401 #topo_result = switches_results1 and switches_results2 and switches_results3\
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800402 # and ports_results1 and ports_results2 and ports_results3\
403 # and links_results1 and links_results2 and links_results3
404
shahshreya4e13a062014-11-11 16:46:18 -0800405 topo_result = switches_results1 and switches_results2 and switches_results3\
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800406 and links_results1 and links_results2 and links_results3
shahshreya4e13a062014-11-11 16:46:18 -0800407
408 if topo_result == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800409 main.log.report(
410 "Topology Check Test with mininet and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800411 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800412 main.log.report(
413 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800414
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800415 utilities.assert_equals( expect=main.TRUE, actual=topo_result,
416 onpass="Topology Check Test successful",
417 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800418
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800419 def CASE10( self ):
420 main.log.report(
421 "This testcase uninstalls the reactive forwarding app" )
422 main.log.report( "__________________________________" )
423 main.case( "Uninstalling reactive forwarding app" )
424 # Unistall onos-app-fwd app to disable reactive forwarding
425 appUninstall_result1 = main.ONOScli1.feature_uninstall(
426 "onos-app-fwd" )
427 appUninstall_result2 = main.ONOScli2.feature_uninstall(
428 "onos-app-fwd" )
429 appUninstall_result3 = main.ONOScli3.feature_uninstall(
430 "onos-app-fwd" )
431 main.log.info( "onos-app-fwd uninstalled" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800432
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800433 # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
434 # So sleep for 15s
435 time.sleep( 15 )
shahshreyaa9d79f22014-11-18 15:41:29 -0800436
shahshreyae6c7cf42014-11-26 16:39:01 -0800437 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800438 main.log.info( hosts )
439
shahshreyaeac353b2014-11-18 17:19:20 -0800440 case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800441 utilities.assert_equals(
442 expect=main.TRUE,
443 actual=case10_result,
444 onpass="Reactive forwarding app uninstallation successful",
445 onfail="Reactive forwarding app uninstallation failed" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800446
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800447 def CASE6( self ):
448 main.log.report(
449 "This testcase is testing the addition of host intents and then doing pingall" )
450 main.log.report( "__________________________________" )
451 main.case( "Obtaining hostsfor adding host intents" )
452 main.step( "Get hosts" )
shahshreyaeac353b2014-11-18 17:19:20 -0800453 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800454 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800455
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800456 main.step( "Get all devices id" )
shahshreya4e13a062014-11-11 16:46:18 -0800457 devices_id_list = main.ONOScli1.get_all_devices_id()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800458 main.log.info( devices_id_list )
shahshreya4e13a062014-11-11 16:46:18 -0800459
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800460 # ONOS displays the hosts in hex format unlike mininet which does in decimal format
461 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800462
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800463 """
464 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
465 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
466 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
467 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
468 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
469 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
470 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
471 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
472 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
473 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
474 hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
475 """
476 for i in range( 8, 18 ):
477 main.log.info(
478 "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
479 host1 = "00:00:00:00:00:" + \
480 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
481 host2 = "00:00:00:00:00:" + \
482 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
483 # NOTE: get host can return None
484 # TODO: handle this
485 host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
486 host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
487 tmp_result = main.ONOScli1.add_host_intent( host1_id, host2_id )
shahshreya4e13a062014-11-11 16:46:18 -0800488
489 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800490 # print "flowHandle = ", flowHandle
491 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800492
493 count = 1
494 i = 8
495 Ping_Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800496 while i < 18:
497 main.log.info(
498 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
499 ping = main.Mininet1.pingHost(
500 src="h" + str( i ), target="h" + str( i + 10 ) )
501 if ping == main.FALSE and count < 5:
502 count += 1
shahshreya4e13a062014-11-11 16:46:18 -0800503 #i = 8
504 Ping_Result = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800505 main.log.report( "Ping between h" +
506 str( i ) +
507 " and h" +
508 str( i +
509 10 ) +
510 " failed. Making attempt number " +
511 str( count ) +
512 " in 2 seconds" )
513 time.sleep( 2 )
514 elif ping == main.FALSE:
515 main.log.report( "All ping attempts between h" +
516 str( i ) +
517 " and h" +
518 str( i +
519 10 ) +
520 "have failed" )
521 i = 19
shahshreya4e13a062014-11-11 16:46:18 -0800522 Ping_Result = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800523 elif ping == main.TRUE:
524 main.log.info( "Ping test between h" +
525 str( i ) +
526 " and h" +
527 str( i +
528 10 ) +
529 "passed!" )
530 i += 1
shahshreya4e13a062014-11-11 16:46:18 -0800531 Ping_Result = main.TRUE
532 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800533 main.log.info( "Unknown error" )
shahshreya4e13a062014-11-11 16:46:18 -0800534 Ping_Result = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800535 if Ping_Result == main.FALSE:
536 main.log.report(
537 "Host intents have not ben installed correctly. Cleaning up" )
538 # main.cleanup()
539 # main.exit()
540 if Ping_Result == main.TRUE:
541 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800542
543 case6_result = Ping_Result
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800544 utilities.assert_equals(
545 expect=main.TRUE,
546 actual=case6_result,
547 onpass="Host intent addition and Pingall Test successful",
548 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800549
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800550 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800551
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800552 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800553
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800554 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800555
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800556 main.log.report(
557 "This testscase is killing a link to ensure that link discovery is consistent" )
558 main.log.report( "__________________________________" )
559 main.case(
560 "Killing a link to Ensure that Link Discovery is Working Properly" )
561 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800562
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800563 main.Mininet2.pingLong(
564 src=main.params[ 'PING' ][ 'source1' ],
565 target=main.params[ 'PING' ][ 'target1' ],
566 pingTime=500 )
567 main.Mininet2.pingLong(
568 src=main.params[ 'PING' ][ 'source2' ],
569 target=main.params[ 'PING' ][ 'target2' ],
570 pingTime=500 )
571 main.Mininet2.pingLong(
572 src=main.params[ 'PING' ][ 'source3' ],
573 target=main.params[ 'PING' ][ 'target3' ],
574 pingTime=500 )
575 main.Mininet2.pingLong(
576 src=main.params[ 'PING' ][ 'source4' ],
577 target=main.params[ 'PING' ][ 'target4' ],
578 pingTime=500 )
579 main.Mininet2.pingLong(
580 src=main.params[ 'PING' ][ 'source5' ],
581 target=main.params[ 'PING' ][ 'target5' ],
582 pingTime=500 )
583 main.Mininet2.pingLong(
584 src=main.params[ 'PING' ][ 'source6' ],
585 target=main.params[ 'PING' ][ 'target6' ],
586 pingTime=500 )
587 main.Mininet2.pingLong(
588 src=main.params[ 'PING' ][ 'source7' ],
589 target=main.params[ 'PING' ][ 'target7' ],
590 pingTime=500 )
591 main.Mininet2.pingLong(
592 src=main.params[ 'PING' ][ 'source8' ],
593 target=main.params[ 'PING' ][ 'target8' ],
594 pingTime=500 )
595 main.Mininet2.pingLong(
596 src=main.params[ 'PING' ][ 'source9' ],
597 target=main.params[ 'PING' ][ 'target9' ],
598 pingTime=500 )
599 main.Mininet2.pingLong(
600 src=main.params[ 'PING' ][ 'source10' ],
601 target=main.params[ 'PING' ][ 'target10' ],
602 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800603
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800604 main.step( "Determine the current number of switches and links" )
shahshreya4e13a062014-11-11 16:46:18 -0800605 topology_output = main.ONOScli1.topology()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800606 topology_result = main.ONOSbench.get_topology( topology_output )
607 activeSwitches = topology_result[ 'devices' ]
608 links = topology_result[ 'links' ]
609 print "activeSwitches = ", type( activeSwitches )
610 print "links = ", type( links )
611 main.log.info(
612 "Currently there are %s switches and %s links" %
613 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800614
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800615 main.step( "Kill Link between s3 and s28" )
616 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
617 time.sleep( link_sleep )
shahshreya4e13a062014-11-11 16:46:18 -0800618 topology_output = main.ONOScli2.topology()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800619 Link_Down = main.ONOSbench.check_status(
620 topology_output, activeSwitches, str(
621 int( links ) - 2 ) )
shahshreya4e13a062014-11-11 16:46:18 -0800622 if Link_Down == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800623 main.log.report( "Link Down discovered properly" )
624 utilities.assert_equals(
625 expect=main.TRUE,
626 actual=Link_Down,
627 onpass="Link Down discovered properly",
628 onfail="Link down was not discovered in " +
629 str( link_sleep ) +
630 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800631
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800632 main.step( "Bring link between s3 and s28 back up" )
633 Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
634 time.sleep( link_sleep )
635 topology_output = main.ONOScli2.topology()
636 Link_Up = main.ONOSbench.check_status(
637 topology_output,
638 activeSwitches,
639 str( links ) )
640 if Link_Up == main.TRUE:
641 main.log.report( "Link up discovered properly" )
642 utilities.assert_equals(
643 expect=main.TRUE,
644 actual=Link_Up,
645 onpass="Link up discovered properly",
646 onfail="Link up was not discovered in " +
647 str( link_sleep ) +
648 " seconds" )
649
650 main.step( "Compare ONOS Topology to MN Topology" )
651 main.case(
652 "Testing Mininet topology with the topology of multi instances ONOS" )
653 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800654 devices1 = main.ONOScli1.devices()
655 devices2 = main.ONOScli2.devices()
656 devices3 = main.ONOScli3.devices()
657 print "devices1 = ", devices1
658 print "devices2 = ", devices2
659 print "devices3 = ", devices3
660 hosts1 = main.ONOScli1.hosts()
661 hosts2 = main.ONOScli2.hosts()
662 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800663 # print "hosts1 = ", hosts1
664 # print "hosts2 = ", hosts2
665 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800666 ports1 = main.ONOScli1.ports()
667 ports2 = main.ONOScli2.ports()
668 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800669 # print "ports1 = ", ports1
670 # print "ports2 = ", ports2
671 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800672 links1 = main.ONOScli1.links()
673 links2 = main.ONOScli2.links()
674 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800675 # print "links1 = ", links1
676 # print "links2 = ", links2
677 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800678
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800679 print "**************"
680
681 main.step( "Start continuous pings" )
682 main.Mininet2.pingLong(
683 src=main.params[ 'PING' ][ 'source1' ],
684 target=main.params[ 'PING' ][ 'target1' ],
685 pingTime=500 )
686 main.Mininet2.pingLong(
687 src=main.params[ 'PING' ][ 'source2' ],
688 target=main.params[ 'PING' ][ 'target2' ],
689 pingTime=500 )
690 main.Mininet2.pingLong(
691 src=main.params[ 'PING' ][ 'source3' ],
692 target=main.params[ 'PING' ][ 'target3' ],
693 pingTime=500 )
694 main.Mininet2.pingLong(
695 src=main.params[ 'PING' ][ 'source4' ],
696 target=main.params[ 'PING' ][ 'target4' ],
697 pingTime=500 )
698 main.Mininet2.pingLong(
699 src=main.params[ 'PING' ][ 'source5' ],
700 target=main.params[ 'PING' ][ 'target5' ],
701 pingTime=500 )
702 main.Mininet2.pingLong(
703 src=main.params[ 'PING' ][ 'source6' ],
704 target=main.params[ 'PING' ][ 'target6' ],
705 pingTime=500 )
706 main.Mininet2.pingLong(
707 src=main.params[ 'PING' ][ 'source7' ],
708 target=main.params[ 'PING' ][ 'target7' ],
709 pingTime=500 )
710 main.Mininet2.pingLong(
711 src=main.params[ 'PING' ][ 'source8' ],
712 target=main.params[ 'PING' ][ 'target8' ],
713 pingTime=500 )
714 main.Mininet2.pingLong(
715 src=main.params[ 'PING' ][ 'source9' ],
716 target=main.params[ 'PING' ][ 'target9' ],
717 pingTime=500 )
718 main.Mininet2.pingLong(
719 src=main.params[ 'PING' ][ 'source10' ],
720 target=main.params[ 'PING' ][ 'target10' ],
721 pingTime=500 )
722
723 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800724 global ctrls
725 ctrls = []
726 count = 1
727 while True:
728 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800729 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
730 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
731 temp = temp + ( "ONOS" + str( count ), )
732 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
733 temp = temp + \
734 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
735 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800736 count = count + 1
737 else:
738 break
739 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800740 Topo = TestONTopology(
741 main.Mininet1,
742 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800743 MNTopo = Topo
744
745 Topology_Check = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800746 main.step( "Compare ONOS Topology to MN Topology" )
747
748 switches_results1 = main.Mininet1.compare_switches(
749 MNTopo,
750 json.loads( devices1 ) )
shahshreya4e13a062014-11-11 16:46:18 -0800751 print "switches_Result1 = ", switches_results1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800752 utilities.assert_equals( expect=main.TRUE, actual=switches_results1,
753 onpass="ONOS1 Switches view is correct",
754 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800755
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800756 switches_results2 = main.Mininet1.compare_switches(
757 MNTopo,
758 json.loads( devices2 ) )
759 utilities.assert_equals( expect=main.TRUE, actual=switches_results2,
760 onpass="ONOS2 Switches view is correct",
761 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800762
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800763 switches_results3 = main.Mininet1.compare_switches(
764 MNTopo,
765 json.loads( devices3 ) )
766 utilities.assert_equals( expect=main.TRUE, actual=switches_results3,
767 onpass="ONOS3 Switches view is correct",
768 onfail="ONOS3 Switches view is incorrect" )
769
770 """
771 ports_results1 = main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) )
772 utilities.assert_equals( expect=main.TRUE, actual=ports_results1,
shahshreya4e13a062014-11-11 16:46:18 -0800773 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800774 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800775
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800776 ports_results2 = main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) )
777 utilities.assert_equals( expect=main.TRUE, actual=ports_results2,
shahshreya4e13a062014-11-11 16:46:18 -0800778 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800779 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800780
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800781 ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) )
782 utilities.assert_equals( expect=main.TRUE, actual=ports_results3,
shahshreya4e13a062014-11-11 16:46:18 -0800783 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800784 onfail="ONOS3 Ports view is incorrect" )
785 """
786 links_results1 = main.Mininet1.compare_links(
787 MNTopo,
788 json.loads( links1 ) )
789 utilities.assert_equals( expect=main.TRUE, actual=links_results1,
790 onpass="ONOS1 Links view is correct",
791 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800792
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800793 links_results2 = main.Mininet1.compare_links(
794 MNTopo,
795 json.loads( links2 ) )
796 utilities.assert_equals( expect=main.TRUE, actual=links_results2,
797 onpass="ONOS2 Links view is correct",
798 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800799
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800800 links_results3 = main.Mininet1.compare_links(
801 MNTopo,
802 json.loads( links3 ) )
803 utilities.assert_equals( expect=main.TRUE, actual=links_results3,
804 onpass="ONOS2 Links view is correct",
805 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800806
shahshreya4e13a062014-11-11 16:46:18 -0800807 #topo_result = switches_results1 and switches_results2 and switches_results3\
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800808 # and ports_results1 and ports_results2 and ports_results3\
809 # and links_results1 and links_results2 and links_results3
810
shahshreya4e13a062014-11-11 16:46:18 -0800811 topo_result = switches_results1 and switches_results2 and switches_results3\
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800812 and links_results1 and links_results2 and links_results3
shahshreya4e13a062014-11-11 16:46:18 -0800813
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800814 utilities.assert_equals(
815 expect=main.TRUE,
816 actual=topo_result and Link_Up and Link_Down,
817 onpass="Topology Check Test successful",
818 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800819
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800820 def CASE8( self ):
821 """
shahshreyaeac353b2014-11-18 17:19:20 -0800822 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800823 """
824 main.log.report(
825 "This testcase removes host any previously added intents" )
826 main.log.report( "__________________________________" )
827 main.log.info( "Removing any previously installed intents" )
828 main.case( "Removing intents" )
829 main.step( "Obtain the intent id's" )
830 intent_result = main.ONOScli1.intents( json_format=False )
831
832 intent_linewise = intent_result.split( "\n" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800833 intentList = []
shahshreya4e13a062014-11-11 16:46:18 -0800834 for line in intent_linewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800835 if line.startswith( "id=" ):
836 intentList.append( line )
shahshreyaa9d79f22014-11-18 15:41:29 -0800837
838 intentids = []
839 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800840 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800841 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800842 main.log.info( "id = " + id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800843
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800844 main.step(
845 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800846 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800847 main.ONOScli1.remove_intent( intent_id=id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800848
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800849 intent_result = main.ONOScli1.intents( json_format=False )
850 main.log.info( "intent_result = " + intent_result )
shahshreya4e13a062014-11-11 16:46:18 -0800851 case8_result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800852
shahshreyaeac353b2014-11-18 17:19:20 -0800853 i = 8
854 Ping_Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800855 while i < 18:
856 main.log.info(
857 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
858 ping = main.Mininet1.pingHost(
859 src="h" + str( i ), target="h" + str( i + 10 ) )
860 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800861 i = 19
shahshreyaeac353b2014-11-18 17:19:20 -0800862 Ping_Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800863 elif ping == main.FALSE:
864 i += 1
shahshreyaeac353b2014-11-18 17:19:20 -0800865 Ping_Result = main.FALSE
866 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800867 main.log.info( "Unknown error" )
shahshreyaeac353b2014-11-18 17:19:20 -0800868 Ping_Result = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800869
870 # Note: If the ping result failed, that means the intents have been
871 # withdrawn correctly.
872 if Ping_Result == main.TRUE:
873 main.log.report( "Host intents have not been withdrawn correctly" )
874 # main.cleanup()
875 # main.exit()
876 if Ping_Result == main.FALSE:
877 main.log.report( "Host intents have been withdrawn correctly" )
shahshreyaeac353b2014-11-18 17:19:20 -0800878
879 case8_result = case8_result and Ping_Result
880
881 if case8_result == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800882 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800883 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800884 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800885
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800886 utilities.assert_equals( expect=main.FALSE, actual=case8_result,
887 onpass="Intent removal test failed",
888 onfail="Intent removal test successful" )
889
890 def CASE9( self ):
891 """
shahshreya4e13a062014-11-11 16:46:18 -0800892 This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case.
893 Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800894 """
895 main.log.report(
896 "This testcase adds point intents and then does pingall" )
897 main.log.report( "__________________________________" )
898 main.log.info( "Adding point intents" )
899 main.case(
900 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
901 main.step(
902 "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
903 ptp_intent_result = main.ONOScli1.add_point_intent(
904 "of:0000000000003008/1",
905 "of:0000000000006018/1" )
shahshreya4e13a062014-11-11 16:46:18 -0800906 if ptp_intent_result == main.TRUE:
907 get_intent_result = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800908 main.log.info( "Point to point intent install successful" )
909 # main.log.info( get_intent_result )
shahshreya4e13a062014-11-11 16:46:18 -0800910
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800911 ptp_intent_result = main.ONOScli1.add_point_intent(
912 "of:0000000000006018/1",
913 "of:0000000000003008/1" )
shahshreya4e13a062014-11-11 16:46:18 -0800914 if ptp_intent_result == main.TRUE:
915 get_intent_result = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800916 main.log.info( "Point to point intent install successful" )
917 # main.log.info( get_intent_result )
shahshreya4e13a062014-11-11 16:46:18 -0800918
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800919 main.step(
920 "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
921 ptp_intent_result = main.ONOScli1.add_point_intent(
922 "of:0000000000003009/1",
923 "of:0000000000006019/1" )
shahshreya4e13a062014-11-11 16:46:18 -0800924 if ptp_intent_result == main.TRUE:
925 get_intent_result = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800926 main.log.info( "Point to point intent install successful" )
927 # main.log.info( get_intent_result )
shahshreya4e13a062014-11-11 16:46:18 -0800928
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800929 ptp_intent_result = main.ONOScli1.add_point_intent(
930 "of:0000000000006019/1",
931 "of:0000000000003009/1" )
shahshreya4e13a062014-11-11 16:46:18 -0800932 if ptp_intent_result == main.TRUE:
933 get_intent_result = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800934 main.log.info( "Point to point intent install successful" )
935 # main.log.info( get_intent_result )
936
937 main.step(
938 "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
939 ptp_intent_result = main.ONOScli1.add_point_intent(
940 "of:0000000000003010/1",
941 "of:0000000000006020/1" )
shahshreya4e13a062014-11-11 16:46:18 -0800942 if ptp_intent_result == main.TRUE:
943 get_intent_result = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800944 main.log.info( "Point to point intent install successful" )
945 # main.log.info( get_intent_result )
shahshreya4e13a062014-11-11 16:46:18 -0800946
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800947 ptp_intent_result = main.ONOScli1.add_point_intent(
948 "of:0000000000006020/1",
949 "of:0000000000003010/1" )
950 if ptp_intent_result == main.TRUE:
951 get_intent_result = main.ONOScli1.intents()
952 main.log.info( "Point to point intent install successful" )
953 # main.log.info( get_intent_result )
954
955 main.step(
956 "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
957 ptp_intent_result = main.ONOScli1.add_point_intent(
958 "of:0000000000003011/1",
959 "of:0000000000006021/1" )
960 if ptp_intent_result == main.TRUE:
961 get_intent_result = main.ONOScli1.intents()
962 main.log.info( "Point to point intent install successful" )
963 # main.log.info( get_intent_result )
964
965 ptp_intent_result = main.ONOScli1.add_point_intent(
966 "of:0000000000006021/1",
967 "of:0000000000003011/1" )
968 if ptp_intent_result == main.TRUE:
969 get_intent_result = main.ONOScli1.intents()
970 main.log.info( "Point to point intent install successful" )
971 # main.log.info( get_intent_result )
972
973 main.step(
974 "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
975 ptp_intent_result = main.ONOScli1.add_point_intent(
976 "of:0000000000003012/1",
977 "of:0000000000006022/1" )
978 if ptp_intent_result == main.TRUE:
979 get_intent_result = main.ONOScli1.intents()
980 main.log.info( "Point to point intent install successful" )
981 # main.log.info( get_intent_result )
982
983 ptp_intent_result = main.ONOScli1.add_point_intent(
984 "of:0000000000006022/1",
985 "of:0000000000003012/1" )
986 if ptp_intent_result == main.TRUE:
987 get_intent_result = main.ONOScli1.intents()
988 main.log.info( "Point to point intent install successful" )
989 # main.log.info( get_intent_result )
990
991 main.step(
992 "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
993 ptp_intent_result = main.ONOScli1.add_point_intent(
994 "of:0000000000003013/1",
995 "of:0000000000006023/1" )
996 if ptp_intent_result == main.TRUE:
997 get_intent_result = main.ONOScli1.intents()
998 main.log.info( "Point to point intent install successful" )
999 # main.log.info( get_intent_result )
1000
1001 ptp_intent_result = main.ONOScli1.add_point_intent(
1002 "of:0000000000006023/1",
1003 "of:0000000000003013/1" )
1004 if ptp_intent_result == main.TRUE:
1005 get_intent_result = main.ONOScli1.intents()
1006 main.log.info( "Point to point intent install successful" )
1007 # main.log.info( get_intent_result )
1008
1009 main.step(
1010 "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
1011 ptp_intent_result = main.ONOScli1.add_point_intent(
1012 "of:0000000000003014/1",
1013 "of:0000000000006024/1" )
1014 if ptp_intent_result == main.TRUE:
1015 get_intent_result = main.ONOScli1.intents()
1016 main.log.info( "Point to point intent install successful" )
1017 # main.log.info( get_intent_result )
1018
1019 ptp_intent_result = main.ONOScli1.add_point_intent(
1020 "of:0000000000006024/1",
1021 "of:0000000000003014/1" )
1022 if ptp_intent_result == main.TRUE:
1023 get_intent_result = main.ONOScli1.intents()
1024 main.log.info( "Point to point intent install successful" )
1025 # main.log.info( get_intent_result )
1026
1027 main.step(
1028 "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
1029 ptp_intent_result = main.ONOScli1.add_point_intent(
1030 "of:0000000000003015/1",
1031 "of:0000000000006025/1" )
1032 if ptp_intent_result == main.TRUE:
1033 get_intent_result = main.ONOScli1.intents()
1034 main.log.info( "Point to point intent install successful" )
1035 # main.log.info( get_intent_result )
1036
1037 ptp_intent_result = main.ONOScli1.add_point_intent(
1038 "of:0000000000006025/1",
1039 "of:0000000000003015/1" )
1040 if ptp_intent_result == main.TRUE:
1041 get_intent_result = main.ONOScli1.intents()
1042 main.log.info( "Point to point intent install successful" )
1043 # main.log.info( get_intent_result )
1044
1045 main.step(
1046 "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
1047 ptp_intent_result = main.ONOScli1.add_point_intent(
1048 "of:0000000000003016/1",
1049 "of:0000000000006026/1" )
1050 if ptp_intent_result == main.TRUE:
1051 get_intent_result = main.ONOScli1.intents()
1052 main.log.info( "Point to point intent install successful" )
1053 # main.log.info( get_intent_result )
1054
1055 ptp_intent_result = main.ONOScli1.add_point_intent(
1056 "of:0000000000006026/1",
1057 "of:0000000000003016/1" )
1058 if ptp_intent_result == main.TRUE:
1059 get_intent_result = main.ONOScli1.intents()
1060 main.log.info( "Point to point intent install successful" )
1061 # main.log.info( get_intent_result )
1062
1063 main.step(
1064 "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
1065 ptp_intent_result = main.ONOScli1.add_point_intent(
1066 "of:0000000000003017/1",
1067 "of:0000000000006027/1" )
1068 if ptp_intent_result == main.TRUE:
1069 get_intent_result = main.ONOScli1.intents()
1070 main.log.info( "Point to point intent install successful" )
1071 # main.log.info( get_intent_result )
1072
1073 ptp_intent_result = main.ONOScli1.add_point_intent(
1074 "of:0000000000006027/1",
1075 "of:0000000000003017/1" )
1076 if ptp_intent_result == main.TRUE:
1077 get_intent_result = main.ONOScli1.intents()
1078 main.log.info( "Point to point intent install successful" )
1079 # main.log.info( get_intent_result )
1080
1081 print(
1082 "_______________________________________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001083
1084 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001085 # print "flowHandle = ", flowHandle
1086 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001087
1088 count = 1
1089 i = 8
1090 Ping_Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001091 while i < 18:
1092 main.log.info(
1093 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1094 ping = main.Mininet1.pingHost(
1095 src="h" + str( i ), target="h" + str( i + 10 ) )
1096 if ping == main.FALSE and count < 5:
1097 count += 1
shahshreya4e13a062014-11-11 16:46:18 -08001098 #i = 8
1099 Ping_Result = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001100 main.log.report( "Ping between h" +
1101 str( i ) +
1102 " and h" +
1103 str( i +
1104 10 ) +
1105 " failed. Making attempt number " +
1106 str( count ) +
1107 " in 2 seconds" )
1108 time.sleep( 2 )
1109 elif ping == main.FALSE:
1110 main.log.report( "All ping attempts between h" +
1111 str( i ) +
1112 " and h" +
1113 str( i +
1114 10 ) +
1115 "have failed" )
1116 i = 19
shahshreya4e13a062014-11-11 16:46:18 -08001117 Ping_Result = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001118 elif ping == main.TRUE:
1119 main.log.info( "Ping test between h" +
1120 str( i ) +
1121 " and h" +
1122 str( i +
1123 10 ) +
1124 "passed!" )
1125 i += 1
shahshreya4e13a062014-11-11 16:46:18 -08001126 Ping_Result = main.TRUE
1127 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001128 main.log.info( "Unknown error" )
shahshreya4e13a062014-11-11 16:46:18 -08001129 Ping_Result = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001130 if Ping_Result == main.FALSE:
1131 main.log.report(
1132 "Ping all test after Point intents addition failed. Cleaning up" )
1133 # main.cleanup()
1134 # main.exit()
1135 if Ping_Result == main.TRUE:
1136 main.log.report(
1137 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001138
1139 case8_result = Ping_Result
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001140 utilities.assert_equals(
1141 expect=main.TRUE,
1142 actual=case8_result,
1143 onpass="Ping all test after Point intents addition successful",
1144 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001145
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001146 def CASE31( self ):
1147 """
1148 This test case adds point intent related to SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
1149 """
shahshreyaa9d79f22014-11-18 15:41:29 -08001150 import json
1151
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001152 main.log.report(
1153 "This test case adds point intent related to SDN-IP matching on ICMP" )
1154 main.case(
1155 "Adding bidirectional point intent related to SDN-IP matching on ICMP" )
1156 main.step( "Adding bidirectional point intent" )
1157 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1158 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1159 # of:0000000000006018/1
1160
1161 hosts_json = json.loads( main.ONOScli1.hosts() )
1162 for i in range( 8, 11 ):
1163 main.log.info(
1164 "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
1165 host1 = "00:00:00:00:00:" + \
1166 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1167 host2 = "00:00:00:00:00:" + \
1168 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
1169 host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
1170 host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
shahshreyaa9d79f22014-11-18 15:41:29 -08001171 for host in hosts_json:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001172 if host[ 'id' ] == host1_id:
1173 ip1 = host[ 'ips' ][ 0 ]
1174 ip1 = str( ip1 + "/32" )
1175 device1 = host[ 'location' ][ 'device' ]
1176 device1 = str( device1 + "/1" )
1177 elif host[ 'id' ] == host2_id:
1178 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1179 device2 = host[ 'location' ][ "device" ]
1180 device2 = str( device2 + "/1" )
1181
1182 p_intent_result1 = main.ONOScli1.add_point_intent(
1183 ingress_device=device1,
1184 egress_device=device2,
1185 ipSrc=ip1,
1186 ipDst=ip2,
1187 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1188 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1189
1190 get_intent_result = main.ONOScli1.intents( json_format=False )
1191 main.log.info( get_intent_result )
1192
1193 p_intent_result2 = main.ONOScli1.add_point_intent(
1194 ingress_device=device2,
1195 egress_device=device1,
1196 ipSrc=ip2,
1197 ipDst=ip1,
1198 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1199 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1200
1201 get_intent_result = main.ONOScli1.intents( json_format=False )
1202 main.log.info( get_intent_result )
1203 if ( p_intent_result1 and p_intent_result2 ) == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001204 #get_intent_result = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001205 # main.log.info( get_intent_result )
1206 main.log.info(
1207 "Point intent related to SDN-IP matching on ICMP install successful" )
1208
1209 time.sleep( 15 )
1210 get_intent_result = main.ONOScli1.intents( json_format=False )
1211 main.log.info( "intents = " + get_intent_result )
shahshreyae6c7cf42014-11-26 16:39:01 -08001212 get_flows_result = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001213 main.log.info( "flows = " + get_flows_result )
1214
shahshreyae6c7cf42014-11-26 16:39:01 -08001215 count = 1
1216 i = 8
1217 Ping_Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001218 while i < 11:
1219 main.log.info(
1220 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1221 ping = main.Mininet1.pingHost(
1222 src="h" + str( i ), target="h" + str( i + 10 ) )
1223 if ping == main.FALSE and count < 3:
1224 count += 1
shahshreyae6c7cf42014-11-26 16:39:01 -08001225 #i = 8
1226 Ping_Result = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001227 main.log.report( "Ping between h" +
1228 str( i ) +
1229 " and h" +
1230 str( i +
1231 10 ) +
1232 " failed. Making attempt number " +
1233 str( count ) +
1234 " in 2 seconds" )
1235 time.sleep( 2 )
1236 elif ping == main.FALSE:
1237 main.log.report( "All ping attempts between h" +
1238 str( i ) +
1239 " and h" +
1240 str( i +
1241 10 ) +
1242 "have failed" )
1243 i = 19
shahshreyae6c7cf42014-11-26 16:39:01 -08001244 Ping_Result = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001245 elif ping == main.TRUE:
1246 main.log.info( "Ping test between h" +
1247 str( i ) +
1248 " and h" +
1249 str( i +
1250 10 ) +
1251 "passed!" )
1252 i += 1
shahshreyae6c7cf42014-11-26 16:39:01 -08001253 Ping_Result = main.TRUE
1254 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001255 main.log.info( "Unknown error" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001256 Ping_Result = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001257 if Ping_Result == main.FALSE:
1258 main.log.report(
1259 "Ping test after Point intents related to SDN-IP matching on ICMP failed." )
1260 # main.cleanup()
1261 # main.exit()
1262 if Ping_Result == main.TRUE:
1263 main.log.report(
1264 "Ping all test after Point intents related to SDN-IP matching on ICMP successful" )
1265
shahshreyae6c7cf42014-11-26 16:39:01 -08001266 case31_result = Ping_Result and p_intent_result1 and p_intent_result2
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001267 utilities.assert_equals(
1268 expect=main.TRUE,
1269 actual=case31_result,
1270 onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
1271 onfail="Point intent related to SDN-IP matching on ICMP and ping test failed" )
1272
1273 def CASE32( self ):
1274 """
1275 This test case adds point intent related to SDN-IP matching on TCP ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
shahshreyae6c7cf42014-11-26 16:39:01 -08001276 Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001277 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001278 import json
1279
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001280 main.log.report(
1281 "This test case adds point intent related to SDN-IP matching on TCP" )
1282 main.case(
1283 "Adding bidirectional point intent related to SDN-IP matching on TCP" )
1284 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001285 """
1286 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1
1287
1288 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001289
shahshreyae6c7cf42014-11-26 16:39:01 -08001290 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1
1291
1292 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1
1293
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001294 """
1295 hosts_json = json.loads( main.ONOScli1.hosts() )
1296 for i in range( 8, 9 ):
1297 main.log.info(
1298 "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
1299 host1 = "00:00:00:00:00:" + \
1300 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1301 host2 = "00:00:00:00:00:" + \
1302 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
1303 host1_id = main.ONOScli1.get_host( host1 )[ 'id' ]
1304 host2_id = main.ONOScli1.get_host( host2 )[ 'id' ]
shahshreyae6c7cf42014-11-26 16:39:01 -08001305 for host in hosts_json:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001306 if host[ 'id' ] == host1_id:
1307 ip1 = host[ 'ips' ][ 0 ]
1308 ip1 = str( ip1 + "/32" )
1309 device1 = host[ 'location' ][ 'device' ]
1310 device1 = str( device1 + "/1" )
1311 elif host[ 'id' ] == host2_id:
1312 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1313 device2 = host[ 'location' ][ "device" ]
1314 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001315
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001316 p_intent_result1 = main.ONOScli1.add_point_intent(
1317 ingress_device=device1,
1318 egress_device=device2,
1319 ipSrc=ip1,
1320 ipDst=ip2,
1321 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1322 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1323 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1324 p_intent_result2 = main.ONOScli1.add_point_intent(
1325 ingress_device=device2,
1326 egress_device=device1,
1327 ipSrc=ip2,
1328 ipDst=ip1,
1329 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1330 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1331 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1332
1333 p_intent_result3 = main.ONOScli1.add_point_intent(
1334 ingress_device=device1,
1335 egress_device=device2,
1336 ipSrc=ip1,
1337 ipDst=ip2,
1338 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1339 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1340 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
1341 p_intent_result4 = main.ONOScli1.add_point_intent(
1342 ingress_device=device2,
1343 egress_device=device1,
1344 ipSrc=ip2,
1345 ipDst=ip1,
1346 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1347 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1348 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001349
1350 p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001351 if p_intent_result == main.TRUE:
1352 get_intent_result = main.ONOScli1.intents( json_format=False )
1353 main.log.info( get_intent_result )
1354 main.log.info(
1355 "Point intent related to SDN-IP matching on TCP install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001356
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001357 iperf_result = main.Mininet1.iperf( 'h8', 'h18' )
1358 if iperf_result == main.TRUE:
1359 main.log.report( "iperf test successful" )
1360 else:
1361 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001362
1363 case32_result = p_intent_result and iperf_result
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001364 utilities.assert_equals(
1365 expect=main.TRUE,
1366 actual=case32_result,
1367 onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
1368 onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001369
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001370 def CASE33( self ):
1371 """
1372 This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001373 Here the mac address to be rewritten is the mac address of the egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001374 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001375 import json
1376 import time
1377
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001378 main.log.report(
1379 "This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action" )
1380 main.case(
1381 "Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip" )
1382 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001383 """
1384 add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001385
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001386 add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
1387 """
1388 main.case(
1389 "Installing multipoint to single point intent with rewrite mac address" )
1390 main.step( "Uninstalling proxy arp app" )
1391 # Unistall onos-app-proxyarp app to disable reactive forwarding
1392 appUninstall_result1 = main.ONOScli1.feature_uninstall(
1393 "onos-app-proxyarp" )
1394 appUninstall_result2 = main.ONOScli2.feature_uninstall(
1395 "onos-app-proxyarp" )
1396 appUninstall_result3 = main.ONOScli3.feature_uninstall(
1397 "onos-app-proxyarp" )
1398 main.log.info( "onos-app-proxyarp uninstalled" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001399
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001400 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1401 main.Mininet1.changeIP(
1402 host='h8',
1403 intf='h8-eth0',
1404 newIP='10.0.1.1',
1405 newNetmask='255.255.255.0' )
1406 main.Mininet1.changeIP(
1407 host='h9',
1408 intf='h9-eth0',
1409 newIP='10.0.2.1',
1410 newNetmask='255.255.255.0' )
1411 main.Mininet1.changeIP(
1412 host='h10',
1413 intf='h10-eth0',
1414 newIP='10.0.3.1',
1415 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001416
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001417 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1418 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1419 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1420 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001421
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001422 main.step(
1423 "Assigning random mac address to the default gateways since proxyarp app is uninstalled" )
1424 main.Mininet1.addStaticMACAddress(
1425 host='h8',
1426 GW='10.0.1.254',
1427 macaddr='00:00:00:00:11:11' )
1428 main.Mininet1.addStaticMACAddress(
1429 host='h9',
1430 GW='10.0.2.254',
1431 macaddr='00:00:00:00:22:22' )
1432 main.Mininet1.addStaticMACAddress(
1433 host='h10',
1434 GW='10.0.3.254',
1435 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001436
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001437 main.step( "Verify static gateway and MAC address assignment" )
1438 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1439 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1440 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1441
1442 main.step( "Adding multipoint to singlepoint intent" )
1443 p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
1444 ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
1445 ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1446 egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
1447 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1448 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1449
1450 p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(
1451 ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
1452 ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1453 egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
1454 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1455 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1456
1457 get_intent_result = main.ONOScli1.intents( json_format=False )
1458 main.log.info( "intents = " + get_intent_result )
1459
1460 time.sleep( 10 )
1461 get_flows_result = main.ONOScli1.flows( json_format=False )
1462 main.log.info( "flows = " + get_flows_result )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001463
1464 count = 1
1465 i = 8
1466 Ping_Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001467
1468 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1469 ping = main.Mininet1.pingHost(
1470 src="h" + str( i ), target="h" + str( i + 2 ) )
1471 if ping == main.FALSE and count < 3:
1472 count += 1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001473 Ping_Result = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001474 main.log.report( "Ping between h" +
1475 str( i ) +
1476 " and h" +
1477 str( i +
1478 2 ) +
1479 " failed. Making attempt number " +
1480 str( count ) +
1481 " in 2 seconds" )
1482 time.sleep( 2 )
1483 elif ping == main.FALSE:
1484 main.log.report( "All ping attempts between h" +
1485 str( i ) +
1486 " and h" +
1487 str( i +
1488 10 ) +
1489 "have failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001490 Ping_Result = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001491 elif ping == main.TRUE:
1492 main.log.info( "Ping test between h" +
1493 str( i ) +
1494 " and h" +
1495 str( i +
1496 2 ) +
1497 "passed!" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001498 Ping_Result = main.TRUE
1499 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001500 main.log.info( "Unknown error" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001501 Ping_Result = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001502
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001503 if Ping_Result == main.FALSE:
1504 main.log.report( "Ping test failed." )
1505 # main.cleanup()
1506 # main.exit()
1507 if Ping_Result == main.TRUE:
1508 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001509
1510 p_intent_result = p_intent_result1 and p_intent_result2
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001511 if p_intent_result == main.TRUE:
1512 main.log.info(
1513 "Multi point intent with rewrite mac address installation successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001514 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001515 main.log.info(
1516 "Multi point intent with rewrite mac address installation failed" )
1517
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001518 case33_result = p_intent_result and Ping_Result
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001519 utilities.assert_equals(
1520 expect=main.TRUE,
1521 actual=case33_result,
1522 onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
1523 onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed" )