blob: 1775ebb56f2a2c4612332fc03ad21d538a906ce1 [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
kelvin-onlab8a832582015-01-16 17:06:11 -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
shahshreya4e13a062014-11-11 16:46:18 -08009import json
10
kelvin-onlab8a832582015-01-16 17:06:11 -080011time.sleep( 1 )
12
13
shahshreya4e13a062014-11-11 16:46:18 -080014class ProdFunc13:
kelvin-onlab8a832582015-01-16 17:06:11 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
kelvin-onlab8a832582015-01-16 17:06:11 -080019 def CASE1( self, main ):
20 """
shahshreya4e13a062014-11-11 16:46:18 -080021 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080022 cell <name>
23 onos-verify-cell
24 onos-remove-raft-log
shahshreya4e13a062014-11-11 16:46:18 -080025 git pull
26 mvn clean install
27 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080028 onos-install -f
29 onos-wait-for-start
kelvin-onlab8a832582015-01-16 17:06:11 -080030 """
31 cell_name = main.params[ 'ENV' ][ 'cellName' ]
32 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
33 ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080034
kelvin-onlab8a832582015-01-16 17:06:11 -080035 main.case( "Setting up test environment" )
36 main.log.report(
37 "This testcase is testing setting up test environment" )
38 main.log.report( "__________________________________" )
39
40 main.step( "Applying cell variable to environment" )
41 cell_result = main.ONOSbench.set_cell( cell_name )
shahshreyae6c7cf42014-11-26 16:39:01 -080042 verify_result = main.ONOSbench.verify_cell()
kelvin-onlab8a832582015-01-16 17:06:11 -080043
44 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreyae6c7cf42014-11-26 16:39:01 -080045 main.ONOSbench.onos_remove_raft_logs()
46
kelvin-onlab8a832582015-01-16 17:06:11 -080047 main.step( "Git checkout and pull master and get version" )
48 main.ONOSbench.git_checkout( "master" )
shahshreya4e13a062014-11-11 16:46:18 -080049 git_pull_result = main.ONOSbench.git_pull()
kelvin-onlab8a832582015-01-16 17:06:11 -080050 main.log.info( "git_pull_result = " + git_pull_result )
51 version_result = main.ONOSbench.get_version( report=True )
52
shahshreya4e13a062014-11-11 16:46:18 -080053 if git_pull_result == 1:
kelvin-onlab8a832582015-01-16 17:06:11 -080054 main.step( "Using mvn clean & install" )
shahshreya4e13a062014-11-11 16:46:18 -080055 clean_install_result = main.ONOSbench.clean_install()
56 #clean_install_result = main.TRUE
shahshreyaa22f8f82014-12-08 16:59:21 -080057 elif git_pull_result == 0:
kelvin-onlab8a832582015-01-16 17:06:11 -080058 main.log.report(
59 "Git Pull Failed, look into logs for detailed reason" )
shahshreyaa22f8f82014-12-08 16:59:21 -080060 main.cleanup()
kelvin-onlab8a832582015-01-16 17:06:11 -080061 main.exit()
62
63 main.step( "Creating ONOS package" )
shahshreya4e13a062014-11-11 16:46:18 -080064 package_result = main.ONOSbench.onos_package()
65
kelvin-onlab8a832582015-01-16 17:06:11 -080066 main.step( "Installing ONOS package" )
shahshreya4e13a062014-11-11 16:46:18 -080067 onos_install_result = main.ONOSbench.onos_install()
68 if onos_install_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080069 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080070 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080071 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080072
73 onos1_isup = main.ONOSbench.isup()
74 if onos1_isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080075 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080076 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080077 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080078
kelvin-onlab8a832582015-01-16 17:06:11 -080079 main.step( "Starting ONOS service" )
80 start_result = main.ONOSbench.onos_start( ONOS1_ip )
shahshreya4e13a062014-11-11 16:46:18 -080081
kelvin-onlab8a832582015-01-16 17:06:11 -080082 main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
83
84 case1_result = ( package_result and
85 cell_result and verify_result and onos_install_result and
86 onos1_isup and start_result )
87 utilities.assert_equals( expect=main.TRUE, actual=case1_result,
88 onpass="Test startup successful",
89 onfail="Test startup NOT successful" )
90
91 def CASE2( self, main ):
92 """
shahshreyaa22f8f82014-12-08 16:59:21 -080093 Switch Down
kelvin-onlab8a832582015-01-16 17:06:11 -080094 """
95 # NOTE: You should probably run a topology check after this
96 import time
shahshreyaa22f8f82014-12-08 16:59:21 -080097 import json
shahshreyaa22f8f82014-12-08 16:59:21 -080098
kelvin-onlab8a832582015-01-16 17:06:11 -080099 main.case( "Switch down discovery" )
100 main.log.report( "This testcase is testing a switch down discovery" )
101 main.log.report( "__________________________________" )
102
103 switch_sleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreyaa22f8f82014-12-08 16:59:21 -0800104
105 description = "Killing a switch to ensure it is discovered correctly"
kelvin-onlab8a832582015-01-16 17:06:11 -0800106 main.log.report( description )
107 main.case( description )
shahshreyaa22f8f82014-12-08 16:59:21 -0800108
kelvin-onlab8a832582015-01-16 17:06:11 -0800109 # TODO: Make this switch parameterizable
110 main.step( "Kill s28 " )
111 main.log.report( "Deleting s28" )
112 # FIXME: use new dynamic topo functions
113 main.Mininet1.del_switch( "s28" )
114 main.log.info(
115 "Waiting " +
116 str( switch_sleep ) +
117 " seconds for switch down to be discovered" )
118 time.sleep( switch_sleep )
119 # Peek at the deleted switch
120 device = main.ONOS2.get_device( dpid="0028" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800121 print "device = ", device
kelvin-onlab8a832582015-01-16 17:06:11 -0800122 if device[ u'available' ] == 'False':
shahshreyaa22f8f82014-12-08 16:59:21 -0800123 case2_result = main.FALSE
124 else:
125 case2_result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800126 utilities.assert_equals( expect=main.TRUE, actual=case2_result,
127 onpass="Switch down discovery successful",
128 onfail="Switch down discovery failed" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800129
kelvin-onlab8a832582015-01-16 17:06:11 -0800130 def CASE11( self, main ):
131 """
shahshreya4e13a062014-11-11 16:46:18 -0800132 Cleanup sequence:
133 onos-service <node_ip> stop
134 onos-uninstall
135
136 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800137
kelvin-onlab8a832582015-01-16 17:06:11 -0800138 """
139 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800140
kelvin-onlab8a832582015-01-16 17:06:11 -0800141 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800142
kelvin-onlab8a832582015-01-16 17:06:11 -0800143 main.step( "Testing ONOS kill function" )
144 kill_result = main.ONOSbench.onos_kill( ONOS1_ip )
shahshreya4e13a062014-11-11 16:46:18 -0800145
kelvin-onlab8a832582015-01-16 17:06:11 -0800146 main.step( "Stopping ONOS service" )
147 stop_result = main.ONOSbench.onos_stop( ONOS1_ip )
shahshreya4e13a062014-11-11 16:46:18 -0800148
kelvin-onlab8a832582015-01-16 17:06:11 -0800149 main.step( "Uninstalling ONOS service" )
shahshreya4e13a062014-11-11 16:46:18 -0800150 uninstall_result = main.ONOSbench.onos_uninstall()
151
kelvin-onlab8a832582015-01-16 17:06:11 -0800152 def CASE3( self, main ):
153 """
shahshreya4e13a062014-11-11 16:46:18 -0800154 Test 'onos' command and its functionality in driver
kelvin-onlab8a832582015-01-16 17:06:11 -0800155 """
156 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800157
kelvin-onlab8a832582015-01-16 17:06:11 -0800158 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800159
kelvin-onlab8a832582015-01-16 17:06:11 -0800160 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800161 cmdstr1 = "system:name"
kelvin-onlab8a832582015-01-16 17:06:11 -0800162 cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 )
163 main.log.info( "onos command returned: " + cmd_result1 )
shahshreya4e13a062014-11-11 16:46:18 -0800164
kelvin-onlab8a832582015-01-16 17:06:11 -0800165 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800166 cmdstr2 = "onos:topology"
kelvin-onlab8a832582015-01-16 17:06:11 -0800167 cmd_result2 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 )
168 main.log.info( "onos command returned: " + cmd_result2 )
shahshreya4e13a062014-11-11 16:46:18 -0800169
kelvin-onlab8a832582015-01-16 17:06:11 -0800170 def CASE20( self ):
171 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800172 Exit from mininet cli
173 reinstall ONOS
kelvin-onlab8a832582015-01-16 17:06:11 -0800174 """
175 cell_name = main.params[ 'ENV' ][ 'cellName' ]
176 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
177 ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
178
179 main.log.report(
180 "This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology" )
181 main.log.report( "_____________________________________________" )
182 main.case( "Disconnecting mininet and restarting ONOS" )
183 main.step( "Disconnecting mininet and restarting ONOS" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800184 mininet_disconnect = main.Mininet1.disconnect()
185
kelvin-onlab8a832582015-01-16 17:06:11 -0800186 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800187 main.ONOSbench.onos_remove_raft_logs()
188
kelvin-onlab8a832582015-01-16 17:06:11 -0800189 main.step( "Applying cell variable to environment" )
190 cell_result = main.ONOSbench.set_cell( cell_name )
shahshreyae6c7cf42014-11-26 16:39:01 -0800191 verify_result = main.ONOSbench.verify_cell()
shahshreyae6c7cf42014-11-26 16:39:01 -0800192
193 onos_install_result = main.ONOSbench.onos_install()
194 if onos_install_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800195 main.log.report( "Installing ONOS package successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800196 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800197 main.log.report( "Installing ONOS package failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800198
199 onos1_isup = main.ONOSbench.isup()
200 if onos1_isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800201 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800202 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800203 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800204
kelvin-onlab8a832582015-01-16 17:06:11 -0800205 main.step( "Starting ONOS service" )
206 start_result = main.ONOSbench.onos_start( ONOS1_ip )
207
208 main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -0800209 print "mininet_disconnect =", mininet_disconnect
210 print "onos_install_result =", onos_install_result
211 print "onos1_isup =", onos1_isup
212 print "start_result =", start_result
shahshreyae6c7cf42014-11-26 16:39:01 -0800213
kelvin-onlab8a832582015-01-16 17:06:11 -0800214 case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
215 utilities.assert_equals(
216 expect=main.TRUE,
217 actual=case20_result,
218 onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
219 onfail="Exiting functionality mininet topology and reinstalling ONOS failed" )
220
221 def CASE21( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800222 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800223 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800224 On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
225 which starts the rest and copies the links json file to the onos instance
kelvin-onlab8a832582015-01-16 17:06:11 -0800226 Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800227 from the json config file
kelvin-onlab8a832582015-01-16 17:06:11 -0800228 """
229 main.log.report(
230 "This testcase starts the packet layer topology and REST" )
231 main.log.report( "_____________________________________________" )
232 main.case( "Starting LINC-OE and other components" )
233 main.step( "Starting LINC-OE and other components" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800234 start_console_result = main.LincOE1.start_console()
235 optical_mn_script = main.LincOE2.run_optical_mn_script()
kelvin-onlab8a832582015-01-16 17:06:11 -0800236 onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(
237 instance_name=main.params[ 'CTRL' ][ 'ip1' ],
238 json_file=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
239
240 print "start_console_result =", start_console_result
241 print "optical_mn_script = ", optical_mn_script
242 print "onos_topo_cfg_result =", onos_topo_cfg_result
shahshreyae6c7cf42014-11-26 16:39:01 -0800243
244 case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
kelvin-onlab8a832582015-01-16 17:06:11 -0800245 utilities.assert_equals(
246 expect=main.TRUE,
247 actual=case21_result,
248 onpass="Packet optical topology spawned successsfully",
249 onfail="Packet optical topology spawning failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800250
kelvin-onlab8a832582015-01-16 17:06:11 -0800251 def CASE22( self, main ):
252 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800253 Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
254 Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
255 and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
kelvin-onlab8a832582015-01-16 17:06:11 -0800256 """
257 main.log.report(
258 "This testcase compares the optical+packet topology against what is expected" )
259 main.case( "Topology comparision" )
260 main.step( "Topology comparision" )
261 main.ONOS3.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
262 devices_result = main.ONOS3.devices( json_format=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800263
264 print "devices_result = ", devices_result
kelvin-onlab8a832582015-01-16 17:06:11 -0800265 devices_linewise = devices_result.split( "\n" )
266 devices_linewise = devices_linewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800267 roadmCount = 0
268 packetLayerSWCount = 0
269 for line in devices_linewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800270 components = line.split( "," )
271 availability = components[ 1 ].split( "=" )[ 1 ]
272 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800273 if availability == 'true' and type == 'ROADM':
274 roadmCount += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800275 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800276 packetLayerSWCount += 1
277 if roadmCount == 4:
kelvin-onlab8a832582015-01-16 17:06:11 -0800278 print "Number of Optical Switches = %d and is correctly detected" % roadmCount
279 main.log.info(
280 "Number of Optical Switches = " +
281 str( roadmCount ) +
282 " and is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800283 opticalSW_result = main.TRUE
284 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800285 print "Number of Optical Switches = %d and is wrong" % roadCount
286 main.log.info(
287 "Number of Optical Switches = " +
288 str( roadmCount ) +
289 " and is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800290 opticalSW_result = main.FALSE
291
292 if packetLayerSWCount == 2:
kelvin-onlab8a832582015-01-16 17:06:11 -0800293 print "Number of Packet layer or mininet Switches = %d and is correctly detected" % packetLayerSWCount
294 main.log.info(
295 "Number of Packet layer or mininet Switches = " +
296 str( packetLayerSWCount ) +
297 " and is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800298 packetSW_result = main.TRUE
299 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800300 print "Number of Packet layer or mininet Switches = %d and is wrong" % packetLayerSWCount
301 main.log.info(
302 "Number of Packet layer or mininet Switches = " +
303 str( packetLayerSWCount ) +
304 " and is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800305 packetSW_result = main.FALSE
306 print "_________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800307
308 links_result = main.ONOS3.links( json_format=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800309 print "links_result = ", links_result
310 print "_________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800311
312 # NOTE:Since only point intents are added, there is no requirement to discover the hosts
313 # Therfore, the below portion of the code is commented.
314 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800315 #Discover hosts using pingall
kelvin-onlab8a832582015-01-16 17:06:11 -0800316 pingall_result = main.LincOE2.pingall()
317
318 hosts_result = main.ONOS3.hosts( json_format=False )
319 main.log.info( "hosts_result = "+hosts_result )
320 main.log.info( "_________________________________" )
321 hosts_linewise = hosts_result.split( "\n" )
322 hosts_linewise = hosts_linewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800323 hostCount = 0
324 for line in hosts_linewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800325 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800326 hostCount +=1
327 if hostCount ==2:
328 print "Number of hosts = %d and is correctly detected" %hostCount
kelvin-onlab8a832582015-01-16 17:06:11 -0800329 main.log.info( "Number of hosts = " + str( hostCount ) +" and is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800330 hostDiscovery = main.TRUE
331 else:
332 print "Number of hosts = %d and is wrong" %hostCount
kelvin-onlab8a832582015-01-16 17:06:11 -0800333 main.log.info( "Number of hosts = " + str( hostCount ) +" and is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800334 hostDiscovery = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800335 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800336 case22_result = opticalSW_result and packetSW_result
kelvin-onlab8a832582015-01-16 17:06:11 -0800337 utilities.assert_equals(
338 expect=main.TRUE,
339 actual=case22_result,
340 onpass="Packet optical topology discovery successful",
341 onfail="Packet optical topology discovery failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800342
kelvin-onlab8a832582015-01-16 17:06:11 -0800343 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800344 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800345 """
346 Add bidirectional point intents between 2 packet layer( mininet ) devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800347 ping mininet hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800348 """
349 main.log.report(
350 "This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts" )
351 main.case( "Topology comparision" )
352 main.step( "Adding point intents" )
353 ptp_intent_result = main.ONOS3.add_point_intent(
354 "of:0000ffffffff0001/1",
355 "of:0000ffffffff0002/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800356 if ptp_intent_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800357 get_intent_result = main.ONOS3.intents( json_format=False )
358 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800359
kelvin-onlab8a832582015-01-16 17:06:11 -0800360 ptp_intent_result = main.ONOS3.add_point_intent(
361 "of:0000ffffffff0002/1",
362 "of:0000ffffffff0001/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800363 if ptp_intent_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800364 get_intent_result = main.ONOS3.intents( json_format=False )
365 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800366
kelvin-onlab8a832582015-01-16 17:06:11 -0800367 time.sleep( 10 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800368 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800369 main.log.info( "flows :" + flowHandle )
shahshreyae6c7cf42014-11-26 16:39:01 -0800370
371 # Sleep for 30 seconds to provide time for the intent state to change
kelvin-onlab8a832582015-01-16 17:06:11 -0800372 time.sleep( 30 )
373 intentHandle = main.ONOS3.intents( json_format=False )
374 main.log.info( "intents :" + intentHandle )
375
shahshreyae6c7cf42014-11-26 16:39:01 -0800376 Ping_Result = main.TRUE
377 count = 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800378 main.log.info( "\n\nh1 is Pinging h2" )
379 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800380 #ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800381 if ping == main.FALSE and count < 5:
382 count += 1
shahshreyae6c7cf42014-11-26 16:39:01 -0800383 Ping_Result = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800384 main.log.info(
385 "Ping between h1 and h2 failed. Making attempt number " +
386 str( count ) +
387 " in 2 seconds" )
388 time.sleep( 2 )
389 elif ping == main.FALSE:
390 main.log.info( "All ping attempts between h1 and h2 have failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800391 Ping_Result = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800392 elif ping == main.TRUE:
393 main.log.info( "Ping test between h1 and h2 passed!" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800394 Ping_Result = main.TRUE
395 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800396 main.log.info( "Unknown error" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800397 Ping_Result = main.ERROR
kelvin-onlab8a832582015-01-16 17:06:11 -0800398
399 if Ping_Result == main.FALSE:
400 main.log.report(
401 "Point intents for packet optical have not ben installed correctly. Cleaning up" )
402 if Ping_Result == main.TRUE:
403 main.log.report(
404 "Point Intents for packet optical have been installed correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800405
406 case23_result = Ping_Result
kelvin-onlab8a832582015-01-16 17:06:11 -0800407 utilities.assert_equals(
408 expect=main.TRUE,
409 actual=case23_result,
410 onpass="Point intents addition for packet optical and Pingall Test successful",
411 onfail="Point intents addition for packet optical and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800412
kelvin-onlab8a832582015-01-16 17:06:11 -0800413 def CASE24( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800414 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800415 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800416 """
417 Test Rerouting of Packet Optical by bringing a port down ( port 22 ) of a switch( switchID=1 ), so that link ( between switch1 port22 - switch4-port30 ) is inactive
shahshreyae6c7cf42014-11-26 16:39:01 -0800418 and do a ping test. If rerouting is successful, ping should pass. also check the flows
kelvin-onlab8a832582015-01-16 17:06:11 -0800419 """
420 main.log.report(
421 "This testcase tests rerouting and pings mininet hosts" )
422 main.case( "Test rerouting and pings mininet hosts" )
423 main.step( "Bring a port down and verify the link state" )
424 main.LincOE1.port_down( sw_id="1", pt_id="22" )
425 links_nonjson = main.ONOS3.links( json_format=False )
426 main.log.info( "links = " + links_nonjson )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800427
428 links = main.ONOS3.links()
kelvin-onlab8a832582015-01-16 17:06:11 -0800429 main.log.info( "links = " + links )
430
431 links_result = json.loads( links )
shahshreyae6c7cf42014-11-26 16:39:01 -0800432 links_state_result = main.FALSE
433 for item in links_result:
kelvin-onlab8a832582015-01-16 17:06:11 -0800434 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
435 'src' ][ 'port' ] == "22":
436 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
437 'dst' ][ 'port' ] == "30":
438 links_state = item[ 'state' ]
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800439 if links_state == "INACTIVE":
kelvin-onlab8a832582015-01-16 17:06:11 -0800440 main.log.info(
441 "Links state is inactive as expected due to one of the ports being down" )
442 main.log.report(
443 "Links state is inactive as expected due to one of the ports being down" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800444 links_state_result = main.TRUE
445 break
446 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800447 main.log.info(
448 "Links state is not inactive as expected" )
449 main.log.report(
450 "Links state is not inactive as expected" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800451 links_state_result = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800452
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800453 print "links_state_result = ", links_state_result
kelvin-onlab8a832582015-01-16 17:06:11 -0800454 time.sleep( 10 )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800455 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800456 main.log.info( "flows :" + flowHandle )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800457
kelvin-onlab8a832582015-01-16 17:06:11 -0800458 main.step( "Verify Rerouting by a ping test" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800459 Ping_Result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800460 count = 1
461 main.log.info( "\n\nh1 is Pinging h2" )
462 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800463 #ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800464 if ping == main.FALSE and count < 5:
465 count += 1
shahshreyae6c7cf42014-11-26 16:39:01 -0800466 Ping_Result = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800467 main.log.info(
468 "Ping between h1 and h2 failed. Making attempt number " +
469 str( count ) +
470 " in 2 seconds" )
471 time.sleep( 2 )
472 elif ping == main.FALSE:
473 main.log.info( "All ping attempts between h1 and h2 have failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800474 Ping_Result = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800475 elif ping == main.TRUE:
476 main.log.info( "Ping test between h1 and h2 passed!" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800477 Ping_Result = main.TRUE
478 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800479 main.log.info( "Unknown error" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800480 Ping_Result = main.ERROR
481
kelvin-onlab8a832582015-01-16 17:06:11 -0800482 if Ping_Result == main.TRUE:
483 main.log.report( "Ping test successful " )
484 if Ping_Result == main.FALSE:
485 main.log.report( "Ping test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800486
487 case24_result = Ping_Result and links_state_result
kelvin-onlab8a832582015-01-16 17:06:11 -0800488 utilities.assert_equals( expect=main.TRUE, actual=case24_result,
489 onpass="Packet optical rerouting successful",
490 onfail="Packet optical rerouting failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800491
kelvin-onlab8a832582015-01-16 17:06:11 -0800492 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800493 import re
494 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800495 main.log.report(
496 "This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode" )
497 main.log.report( "__________________________________" )
498 main.case( "Pingall Test" )
499 main.step( "Assigning switches to controllers" )
500 for i in range( 1, 29 ):
501 if i == 1:
502 main.Mininet1.assign_sw_controller(
503 sw=str( i ),
504 ip1=ONOS1_ip,
505 port1=ONOS1_port )
506 elif i >= 2 and i < 5:
507 main.Mininet1.assign_sw_controller(
508 sw=str( i ),
509 ip1=ONOS1_ip,
510 port1=ONOS1_port )
511 elif i >= 5 and i < 8:
512 main.Mininet1.assign_sw_controller(
513 sw=str( i ),
514 ip1=ONOS1_ip,
515 port1=ONOS1_port )
516 elif i >= 8 and i < 18:
517 main.Mininet1.assign_sw_controller(
518 sw=str( i ),
519 ip1=ONOS1_ip,
520 port1=ONOS1_port )
521 elif i >= 18 and i < 28:
522 main.Mininet1.assign_sw_controller(
523 sw=str( i ),
524 ip1=ONOS1_ip,
525 port1=ONOS1_port )
shahshreya4e13a062014-11-11 16:46:18 -0800526 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800527 main.Mininet1.assign_sw_controller(
528 sw=str( i ),
529 ip1=ONOS1_ip,
530 port1=ONOS1_port )
shahshreya4e13a062014-11-11 16:46:18 -0800531 Switch_Mastership = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800532 for i in range( 1, 29 ):
533 if i == 1:
534 response = main.Mininet1.get_sw_controller( "s" + str( i ) )
535 print( "Response is " + str( response ) )
536 if re.search( "tcp:" + ONOS1_ip, response ):
shahshreya4e13a062014-11-11 16:46:18 -0800537 Switch_Mastership = Switch_Mastership and main.TRUE
538 else:
539 Switch_Mastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800540 elif i >= 2 and i < 5:
541 response = main.Mininet1.get_sw_controller( "s" + str( i ) )
542 print( "Response is " + str( response ) )
543 if re.search( "tcp:" + ONOS1_ip, response ):
shahshreya4e13a062014-11-11 16:46:18 -0800544 Switch_Mastership = Switch_Mastership and main.TRUE
545 else:
546 Switch_Mastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800547 elif i >= 5 and i < 8:
548 response = main.Mininet1.get_sw_controller( "s" + str( i ) )
549 print( "Response is " + str( response ) )
550 if re.search( "tcp:" + ONOS1_ip, response ):
shahshreya4e13a062014-11-11 16:46:18 -0800551 Switch_Mastership = Switch_Mastership and main.TRUE
552 else:
553 Switch_Mastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800554 elif i >= 8 and i < 18:
555 response = main.Mininet1.get_sw_controller( "s" + str( i ) )
556 print( "Response is " + str( response ) )
557 if re.search( "tcp:" + ONOS1_ip, response ):
shahshreya4e13a062014-11-11 16:46:18 -0800558 Switch_Mastership = Switch_Mastership and main.TRUE
559 else:
560 Switch_Mastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800561 elif i >= 18 and i < 28:
562 response = main.Mininet1.get_sw_controller( "s" + str( i ) )
563 print( "Response is " + str( response ) )
564 if re.search( "tcp:" + ONOS1_ip, response ):
shahshreya4e13a062014-11-11 16:46:18 -0800565 Switch_Mastership = Switch_Mastership and main.TRUE
566 else:
567 Switch_Mastership = main.FALSE
568 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800569 response = main.Mininet1.get_sw_controller( "s" + str( i ) )
570 print( "Response is" + str( response ) )
571 if re.search( "tcp:" + ONOS1_ip, response ):
shahshreya4e13a062014-11-11 16:46:18 -0800572 Switch_Mastership = Switch_Mastership and main.TRUE
573 else:
574 Switch_Mastership = main.FALSE
575
576 if Switch_Mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800577 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800578 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800579 main.log.report( "Controller assignmnet failed" )
580 utilities.assert_equals(
581 expect=main.TRUE,
582 actual=Switch_Mastership,
583 onpass="MasterControllers assigned correctly" )
584 """
585 for i in range ( 1,29 ):
586 main.Mininet1.assign_sw_controller( sw=str( i ),count=5,
shahshreya4e13a062014-11-11 16:46:18 -0800587 ip1=ONOS1_ip,port1=ONOS1_port,
588 ip2=ONOS2_ip,port2=ONOS2_port,
589 ip3=ONOS3_ip,port3=ONOS3_port,
590 ip4=ONOS4_ip,port4=ONOS4_port,
kelvin-onlab8a832582015-01-16 17:06:11 -0800591 ip5=ONOS5_ip,port5=ONOS5_port )
592 """
593 # REACTIVE FWD test
shahshreya4e13a062014-11-11 16:46:18 -0800594
kelvin-onlab8a832582015-01-16 17:06:11 -0800595 main.step( "Get list of hosts from Mininet" )
shahshreya4e13a062014-11-11 16:46:18 -0800596 host_list = main.Mininet1.get_hosts()
kelvin-onlab8a832582015-01-16 17:06:11 -0800597 main.log.info( host_list )
shahshreya4e13a062014-11-11 16:46:18 -0800598
kelvin-onlab8a832582015-01-16 17:06:11 -0800599 main.step( "Get host list in ONOS format" )
600 host_onos_list = main.ONOS2.get_hosts_id( host_list )
601 main.log.info( host_onos_list )
602 # time.sleep( 5 )
603
604 main.step( "Pingall" )
shahshreya4e13a062014-11-11 16:46:18 -0800605 ping_result = main.FALSE
606 while ping_result == main.FALSE:
607 time1 = time.time()
608 ping_result = main.Mininet1.pingall()
609 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800610 print "Time for pingall: %2f seconds" % ( time2 - time1 )
611
612 # Start onos cli again because u might have dropped out of onos prompt to the shell prompt
613 # if there was no activity
614 main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800615
616 case4_result = Switch_Mastership and ping_result
617 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800618 main.log.report(
619 "Pingall Test in reactive mode to discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800620 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800621 main.log.report(
622 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800623
kelvin-onlab8a832582015-01-16 17:06:11 -0800624 utilities.assert_equals(
625 expect=main.TRUE,
626 actual=case4_result,
627 onpass="Controller assignment and Pingall Test successful",
628 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800629
kelvin-onlab8a832582015-01-16 17:06:11 -0800630 def CASE10( self ):
631 main.log.report(
632 "This testcase uninstalls the reactive forwarding app" )
633 main.log.report( "__________________________________" )
634 main.case( "Uninstalling reactive forwarding app" )
635 # Unistall onos-app-fwd app to disable reactive forwarding
636 appUninstall_result = main.ONOS2.feature_uninstall( "onos-app-fwd" )
637 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800638
kelvin-onlab8a832582015-01-16 17:06:11 -0800639 # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
640 # So sleep for 15s
641 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800642
643 flows = main.ONOS2.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800644 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800645
646 case10_result = appUninstall_result
kelvin-onlab8a832582015-01-16 17:06:11 -0800647 utilities.assert_equals(
648 expect=main.TRUE,
649 actual=case10_result,
650 onpass="Reactive forwarding app uninstallation successful",
651 onfail="Reactive forwarding app uninstallation failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800652
kelvin-onlab8a832582015-01-16 17:06:11 -0800653 def CASE6( self ):
654 main.log.report(
655 "This testcase is testing the addition of host intents and then does pingall" )
656 main.log.report( "__________________________________" )
657 main.case( "Obtaining host id's" )
658 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800659 hosts = main.ONOS2.hosts()
kelvin-onlab8a832582015-01-16 17:06:11 -0800660 # main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800661
kelvin-onlab8a832582015-01-16 17:06:11 -0800662 main.step( "Get all devices id" )
shahshreya4e13a062014-11-11 16:46:18 -0800663 devices_id_list = main.ONOS2.get_all_devices_id()
kelvin-onlab8a832582015-01-16 17:06:11 -0800664 # main.log.info( devices_id_list )
shahshreya4e13a062014-11-11 16:46:18 -0800665
kelvin-onlab8a832582015-01-16 17:06:11 -0800666 # ONOS displays the hosts in hex format unlike mininet which does in decimal format
667 # So take care while adding intents
668 """
669 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
670 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
671 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
672 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
673 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
674 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
675 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
676 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
677 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
678 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
679 hth_intent_result = main.ONOS2.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
680 print "_____________________________________________________________________________________"
681 """
682 for i in range( 8, 18 ):
683 main.log.info(
684 "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
685 host1 = "00:00:00:00:00:" + \
686 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
687 host2 = "00:00:00:00:00:" + \
688 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
689 # NOTE: get host can return None
690 # TODO: handle this
691 host1_id = main.ONOS2.get_host( host1 )[ 'id' ]
692 host2_id = main.ONOS2.get_host( host2 )[ 'id' ]
693 tmp_result = main.ONOS2.add_host_intent( host1_id, host2_id )
694
695 time.sleep( 10 )
696 h_intents = main.ONOS2.intents( json_format=False )
697 main.log.info( "intents:" + h_intents )
shahshreya4e13a062014-11-11 16:46:18 -0800698 flowHandle = main.ONOS2.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800699 #main.log.info( "flow:" +flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800700
701 count = 1
702 i = 8
703 Ping_Result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800704 # while i<10:
705 while i < 18:
706 main.log.info(
707 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
708 ping = main.Mininet1.pingHost(
709 src="h" + str( i ), target="h" + str( i + 10 ) )
710 if ping == main.FALSE and count < 5:
711 count += 1
shahshreya4e13a062014-11-11 16:46:18 -0800712 #i = 8
713 Ping_Result = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800714 main.log.report( "Ping between h" +
715 str( i ) +
716 " and h" +
717 str( i +
718 10 ) +
719 " failed. Making attempt number " +
720 str( count ) +
721 " in 2 seconds" )
722 time.sleep( 2 )
723 elif ping == main.FALSE:
724 main.log.report( "All ping attempts between h" +
725 str( i ) +
726 " and h" +
727 str( i +
728 10 ) +
729 "have failed" )
730 i = 19
shahshreya4e13a062014-11-11 16:46:18 -0800731 Ping_Result = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800732 elif ping == main.TRUE:
733 main.log.info( "Ping test between h" +
734 str( i ) +
735 " and h" +
736 str( i +
737 10 ) +
738 "passed!" )
739 i += 1
shahshreya4e13a062014-11-11 16:46:18 -0800740 Ping_Result = main.TRUE
741 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800742 main.log.info( "Unknown error" )
shahshreya4e13a062014-11-11 16:46:18 -0800743 Ping_Result = main.ERROR
kelvin-onlab8a832582015-01-16 17:06:11 -0800744 if Ping_Result == main.FALSE:
745 main.log.report(
746 "Ping all test after Host intent addition failed. Cleaning up" )
747 # main.cleanup()
748 # main.exit()
749 if Ping_Result == main.TRUE:
750 main.log.report(
751 "Ping all test after Host intent addition successful" )
752
shahshreya4e13a062014-11-11 16:46:18 -0800753 case6_result = Ping_Result
kelvin-onlab8a832582015-01-16 17:06:11 -0800754 utilities.assert_equals(
755 expect=main.TRUE,
756 actual=case6_result,
757 onpass="Pingall Test after Host intents addition successful",
758 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800759
kelvin-onlab8a832582015-01-16 17:06:11 -0800760 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800761 import json
762 from subprocess import Popen, PIPE
kelvin-onlab8a832582015-01-16 17:06:11 -0800763 # assumes that sts is already in you PYTHONPATH
764 from sts.topology.teston_topology import TestONTopology
765 # main.ONOS2.start_onos_cli( ONOS_ip=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800766 deviceResult = main.ONOS2.devices()
767 linksResult = main.ONOS2.links()
768 #portsResult = main.ONOS2.ports()
769 print "**************"
770
kelvin-onlab8a832582015-01-16 17:06:11 -0800771 main.log.report(
772 "This testcase is testing if all ONOS nodes are in topology sync with mininet" )
773 main.log.report( "__________________________________" )
774 main.case( "Comparing Mininet topology with the topology of ONOS" )
775 main.step( "Start continuous pings" )
776 main.Mininet2.pingLong(
777 src=main.params[ 'PING' ][ 'source1' ],
778 target=main.params[ 'PING' ][ 'target1' ],
779 pingTime=500 )
780 main.Mininet2.pingLong(
781 src=main.params[ 'PING' ][ 'source2' ],
782 target=main.params[ 'PING' ][ 'target2' ],
783 pingTime=500 )
784 main.Mininet2.pingLong(
785 src=main.params[ 'PING' ][ 'source3' ],
786 target=main.params[ 'PING' ][ 'target3' ],
787 pingTime=500 )
788 main.Mininet2.pingLong(
789 src=main.params[ 'PING' ][ 'source4' ],
790 target=main.params[ 'PING' ][ 'target4' ],
791 pingTime=500 )
792 main.Mininet2.pingLong(
793 src=main.params[ 'PING' ][ 'source5' ],
794 target=main.params[ 'PING' ][ 'target5' ],
795 pingTime=500 )
796 main.Mininet2.pingLong(
797 src=main.params[ 'PING' ][ 'source6' ],
798 target=main.params[ 'PING' ][ 'target6' ],
799 pingTime=500 )
800 main.Mininet2.pingLong(
801 src=main.params[ 'PING' ][ 'source7' ],
802 target=main.params[ 'PING' ][ 'target7' ],
803 pingTime=500 )
804 main.Mininet2.pingLong(
805 src=main.params[ 'PING' ][ 'source8' ],
806 target=main.params[ 'PING' ][ 'target8' ],
807 pingTime=500 )
808 main.Mininet2.pingLong(
809 src=main.params[ 'PING' ][ 'source9' ],
810 target=main.params[ 'PING' ][ 'target9' ],
811 pingTime=500 )
812 main.Mininet2.pingLong(
813 src=main.params[ 'PING' ][ 'source10' ],
814 target=main.params[ 'PING' ][ 'target10' ],
815 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800816
kelvin-onlab8a832582015-01-16 17:06:11 -0800817 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800818 global ctrls
819 ctrls = []
820 count = 1
821 while True:
822 temp = ()
kelvin-onlab8a832582015-01-16 17:06:11 -0800823 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
824 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
825 temp = temp + ( "ONOS" + str( count ), )
826 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
827 temp = temp + \
828 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
829 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800830 count = count + 1
831 else:
832 break
833 global MNTopo
kelvin-onlab8a832582015-01-16 17:06:11 -0800834 Topo = TestONTopology(
835 main.Mininet1,
836 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800837 MNTopo = Topo
838
839 Topology_Check = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800840 main.step( "Compare ONOS Topology to MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800841 devices_json = main.ONOS2.devices()
842 links_json = main.ONOS2.links()
843 #ports_json = main.ONOS2.ports()
844 print "devices_json= ", devices_json
kelvin-onlab8a832582015-01-16 17:06:11 -0800845
846 result1 = main.Mininet1.compare_switches(
847 MNTopo,
848 json.loads( devices_json ) )
849 result2 = main.Mininet1.compare_links(
850 MNTopo,
851 json.loads( links_json ) )
852 #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
853
shahshreya4e13a062014-11-11 16:46:18 -0800854 #result = result1 and result2 and result3
855 result = result1 and result2
kelvin-onlab8a832582015-01-16 17:06:11 -0800856
shahshreya4e13a062014-11-11 16:46:18 -0800857 print "***********************"
858 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800859 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800860 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800861 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800862
kelvin-onlab8a832582015-01-16 17:06:11 -0800863 utilities.assert_equals(
864 expect=main.TRUE,
865 actual=result,
866 onpass="ONOS" +
867 " Topology matches MN Topology",
868 onfail="ONOS" +
869 " Topology does not match MN Topology" )
870
shahshreya4e13a062014-11-11 16:46:18 -0800871 Topology_Check = Topology_Check and result
kelvin-onlab8a832582015-01-16 17:06:11 -0800872 utilities.assert_equals(
873 expect=main.TRUE,
874 actual=Topology_Check,
875 onpass="Topology checks passed",
876 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800877
kelvin-onlab8a832582015-01-16 17:06:11 -0800878 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800879
kelvin-onlab8a832582015-01-16 17:06:11 -0800880 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800881
kelvin-onlab8a832582015-01-16 17:06:11 -0800882 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800883
kelvin-onlab8a832582015-01-16 17:06:11 -0800884 main.log.report(
885 "This testscase is killing a link to ensure that link discovery is consistent" )
886 main.log.report( "__________________________________" )
887 main.log.report(
888 "Killing a link to ensure that link discovery is consistent" )
889 main.case(
890 "Killing a link to Ensure that Link Discovery is Working Properly" )
891 """
892 main.step( "Start continuous pings" )
893
894 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
895 target=main.params[ 'PING' ][ 'target1' ],pingTime=500 )
896 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
897 target=main.params[ 'PING' ][ 'target2' ],pingTime=500 )
898 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
899 target=main.params[ 'PING' ][ 'target3' ],pingTime=500 )
900 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
901 target=main.params[ 'PING' ][ 'target4' ],pingTime=500 )
902 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
903 target=main.params[ 'PING' ][ 'target5' ],pingTime=500 )
904 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
905 target=main.params[ 'PING' ][ 'target6' ],pingTime=500 )
906 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
907 target=main.params[ 'PING' ][ 'target7' ],pingTime=500 )
908 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
909 target=main.params[ 'PING' ][ 'target8' ],pingTime=500 )
910 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
911 target=main.params[ 'PING' ][ 'target9' ],pingTime=500 )
912 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
913 target=main.params[ 'PING' ][ 'target10' ],pingTime=500 )
914 """
915 main.step( "Determine the current number of switches and links" )
shahshreya4e13a062014-11-11 16:46:18 -0800916 topology_output = main.ONOS2.topology()
kelvin-onlab8a832582015-01-16 17:06:11 -0800917 topology_result = main.ONOS1.get_topology( topology_output )
918 activeSwitches = topology_result[ 'devices' ]
919 links = topology_result[ 'links' ]
920 print "activeSwitches = ", type( activeSwitches )
921 print "links = ", type( links )
922 main.log.info(
923 "Currently there are %s switches and %s links" %
924 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800925
kelvin-onlab8a832582015-01-16 17:06:11 -0800926 main.step( "Kill Link between s3 and s28" )
927 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
928 time.sleep( link_sleep )
shahshreya4e13a062014-11-11 16:46:18 -0800929 topology_output = main.ONOS2.topology()
kelvin-onlab8a832582015-01-16 17:06:11 -0800930 Link_Down = main.ONOS1.check_status(
931 topology_output, activeSwitches, str(
932 int( links ) - 2 ) )
shahshreya4e13a062014-11-11 16:46:18 -0800933 if Link_Down == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800934 main.log.report( "Link Down discovered properly" )
935 utilities.assert_equals(
936 expect=main.TRUE,
937 actual=Link_Down,
938 onpass="Link Down discovered properly",
939 onfail="Link down was not discovered in " +
940 str( link_sleep ) +
941 " seconds" )
942
943 # Check ping result here..add code for it
944
945 main.step( "Bring link between s3 and s28 back up" )
946 Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
947 time.sleep( link_sleep )
shahshreya4e13a062014-11-11 16:46:18 -0800948 topology_output = main.ONOS2.topology()
kelvin-onlab8a832582015-01-16 17:06:11 -0800949 Link_Up = main.ONOS1.check_status(
950 topology_output,
951 activeSwitches,
952 str( links ) )
shahshreya4e13a062014-11-11 16:46:18 -0800953 if Link_Up == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800954 main.log.report( "Link up discovered properly" )
955 utilities.assert_equals(
956 expect=main.TRUE,
957 actual=Link_Up,
958 onpass="Link up discovered properly",
959 onfail="Link up was not discovered in " +
960 str( link_sleep ) +
961 " seconds" )
962
963 # NOTE Check ping result here..add code for it
964
965 main.step( "Compare ONOS Topology to MN Topology" )
966 Topo = TestONTopology(
967 main.Mininet1,
968 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800969 MNTopo = Topo
970 Topology_Check = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800971
shahshreya4e13a062014-11-11 16:46:18 -0800972 devices_json = main.ONOS2.devices()
973 links_json = main.ONOS2.links()
974 ports_json = main.ONOS2.ports()
975 print "devices_json= ", devices_json
kelvin-onlab8a832582015-01-16 17:06:11 -0800976
977 result1 = main.Mininet1.compare_switches(
978 MNTopo,
979 json.loads( devices_json ) )
980 result2 = main.Mininet1.compare_links(
981 MNTopo,
982 json.loads( links_json ) )
983 #result3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports_json ) )
984
shahshreya4e13a062014-11-11 16:46:18 -0800985 #result = result1 and result2 and result3
986 result = result1 and result2
987 print "***********************"
kelvin-onlab8a832582015-01-16 17:06:11 -0800988
shahshreya4e13a062014-11-11 16:46:18 -0800989 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800990 main.log.report( "ONOS" + " Topology matches MN Topology" )
991 utilities.assert_equals(
992 expect=main.TRUE,
993 actual=result,
994 onpass="ONOS" +
995 " Topology matches MN Topology",
996 onfail="ONOS" +
997 " Topology does not match MN Topology" )
998
shahshreya4e13a062014-11-11 16:46:18 -0800999 Topology_Check = Topology_Check and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001000 utilities.assert_equals(
1001 expect=main.TRUE,
1002 actual=Topology_Check,
1003 onpass="Topology checks passed",
1004 onfail="Topology checks failed" )
1005
shahshreya4e13a062014-11-11 16:46:18 -08001006 result = Link_Down and Link_Up and Topology_Check
kelvin-onlab8a832582015-01-16 17:06:11 -08001007 utilities.assert_equals( expect=main.TRUE, actual=result,
1008 onpass="Link failure is discovered correctly",
1009 onfail="Link Discovery failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001010
kelvin-onlab8a832582015-01-16 17:06:11 -08001011 def CASE8( self ):
1012 """
shahshreya4e13a062014-11-11 16:46:18 -08001013 Host intents removal
kelvin-onlab8a832582015-01-16 17:06:11 -08001014 """
1015 main.log.report(
1016 "This testcase removes any previously added intents before adding the same intents or point intents" )
1017 main.log.report( "__________________________________" )
1018 main.log.info( "Host intents removal" )
1019 main.case( "Removing host intents" )
1020 main.step( "Obtain the intent id's" )
1021 intent_result = main.ONOS2.intents( json_format=False )
1022 main.log.info( "intent_result = " + intent_result )
1023
1024 intent_linewise = intent_result.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001025 intentList = []
shahshreya4e13a062014-11-11 16:46:18 -08001026 for line in intent_linewise:
kelvin-onlab8a832582015-01-16 17:06:11 -08001027 if line.startswith( "id=" ):
1028 intentList.append( line )
1029
shahshreyae6c7cf42014-11-26 16:39:01 -08001030 intentids = []
1031 for line in intentList:
kelvin-onlab8a832582015-01-16 17:06:11 -08001032 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -08001033 for id in intentids:
1034 print "id = ", id
kelvin-onlab8a832582015-01-16 17:06:11 -08001035
1036 main.step(
1037 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001038 for id in intentids:
kelvin-onlab8a832582015-01-16 17:06:11 -08001039 main.ONOS2.remove_intent( intent_id=id )
1040
1041 intent_result = main.ONOS2.intents( json_format=False )
1042 main.log.info( "intent_result = " + intent_result )
shahshreyae6c7cf42014-11-26 16:39:01 -08001043
shahshreya4e13a062014-11-11 16:46:18 -08001044 case8_result = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001045 if case8_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001046 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001047 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001048 main.log.report( "Intent removal failed" )
1049
shahshreyae6c7cf42014-11-26 16:39:01 -08001050 Ping_Result = main.TRUE
1051 if case8_result == main.TRUE:
1052 i = 8
kelvin-onlab8a832582015-01-16 17:06:11 -08001053 while i < 18:
1054 main.log.info(
1055 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1056 ping = main.Mininet1.pingHost(
1057 src="h" + str( i ), target="h" + str( i + 10 ) )
1058 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001059 i = 19
1060 Ping_Result = Ping_Result and main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001061 elif ping == main.FALSE:
1062 i += 1
shahshreyae6c7cf42014-11-26 16:39:01 -08001063 Ping_Result = Ping_Result and main.FALSE
1064 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001065 main.log.info( "Unknown error" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001066 Ping_Result = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001067
kelvin-onlab8a832582015-01-16 17:06:11 -08001068 # Note: If the ping result failed, that means the intents have been
1069 # withdrawn correctly.
1070 if Ping_Result == main.TRUE:
1071 main.log.report( "Host intents have not been withdrawn correctly" )
1072 # main.cleanup()
1073 # main.exit()
1074 if Ping_Result == main.FALSE:
1075 main.log.report( "Host intents have been withdrawn correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001076
shahshreyae6c7cf42014-11-26 16:39:01 -08001077 case8_result = case8_result and Ping_Result
1078
1079 if case8_result == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001080 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001081 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001082 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001083
kelvin-onlab8a832582015-01-16 17:06:11 -08001084 utilities.assert_equals( expect=main.FALSE, actual=case8_result,
1085 onpass="Intent removal test failed",
1086 onfail="Intent removal test passed" )
shahshreya4e13a062014-11-11 16:46:18 -08001087
kelvin-onlab8a832582015-01-16 17:06:11 -08001088 def CASE9( self ):
1089 main.log.report(
1090 "This testcase adds point intents and then does pingall" )
1091 main.log.report( "__________________________________" )
1092 main.log.info( "Adding point intents" )
1093 main.case(
1094 "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)" )
1095 main.step(
1096 "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
1097 ptp_intent_result = main.ONOS2.add_point_intent(
1098 "of:0000000000003008/1",
1099 "of:0000000000006018/1" )
1100 if ptp_intent_result == main.TRUE:
1101 get_intent_result = main.ONOS2.intents()
1102 main.log.info( "Point to point intent install successful" )
1103 # main.log.info( get_intent_result )
shahshreya4e13a062014-11-11 16:46:18 -08001104
kelvin-onlab8a832582015-01-16 17:06:11 -08001105 ptp_intent_result = main.ONOS2.add_point_intent(
1106 "of:0000000000006018/1",
1107 "of:0000000000003008/1" )
shahshreya4e13a062014-11-11 16:46:18 -08001108 if ptp_intent_result == main.TRUE:
1109 get_intent_result = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001110 main.log.info( "Point to point intent install successful" )
1111 # main.log.info( get_intent_result )
shahshreya4e13a062014-11-11 16:46:18 -08001112
kelvin-onlab8a832582015-01-16 17:06:11 -08001113 main.step(
1114 "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
1115 ptp_intent_result = main.ONOS2.add_point_intent(
1116 "of:0000000000003009/1",
1117 "of:0000000000006019/1" )
shahshreya4e13a062014-11-11 16:46:18 -08001118 if ptp_intent_result == main.TRUE:
1119 get_intent_result = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001120 main.log.info( "Point to point intent install successful" )
1121 # main.log.info( get_intent_result )
shahshreya4e13a062014-11-11 16:46:18 -08001122
kelvin-onlab8a832582015-01-16 17:06:11 -08001123 ptp_intent_result = main.ONOS2.add_point_intent(
1124 "of:0000000000006019/1",
1125 "of:0000000000003009/1" )
shahshreya4e13a062014-11-11 16:46:18 -08001126 if ptp_intent_result == main.TRUE:
1127 get_intent_result = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001128 main.log.info( "Point to point intent install successful" )
1129 # main.log.info( get_intent_result )
shahshreya4e13a062014-11-11 16:46:18 -08001130
kelvin-onlab8a832582015-01-16 17:06:11 -08001131 main.step(
1132 "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
1133 ptp_intent_result = main.ONOS2.add_point_intent(
1134 "of:0000000000003010/1",
1135 "of:0000000000006020/1" )
shahshreya4e13a062014-11-11 16:46:18 -08001136 if ptp_intent_result == main.TRUE:
1137 get_intent_result = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001138 main.log.info( "Point to point intent install successful" )
1139 # main.log.info( get_intent_result )
1140
1141 ptp_intent_result = main.ONOS2.add_point_intent(
1142 "of:0000000000006020/1",
1143 "of:0000000000003010/1" )
shahshreya4e13a062014-11-11 16:46:18 -08001144 if ptp_intent_result == main.TRUE:
1145 get_intent_result = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001146 main.log.info( "Point to point intent install successful" )
1147 # main.log.info( get_intent_result )
shahshreya4e13a062014-11-11 16:46:18 -08001148
kelvin-onlab8a832582015-01-16 17:06:11 -08001149 main.step(
1150 "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
1151 ptp_intent_result = main.ONOS2.add_point_intent(
1152 "of:0000000000003011/1",
1153 "of:0000000000006021/1" )
1154 if ptp_intent_result == main.TRUE:
1155 get_intent_result = main.ONOS2.intents()
1156 main.log.info( "Point to point intent install successful" )
1157 # main.log.info( get_intent_result )
1158
1159 ptp_intent_result = main.ONOS2.add_point_intent(
1160 "of:0000000000006021/1",
1161 "of:0000000000003011/1" )
1162 if ptp_intent_result == main.TRUE:
1163 get_intent_result = main.ONOS2.intents()
1164 main.log.info( "Point to point intent install successful" )
1165 # main.log.info( get_intent_result )
1166
1167 main.step(
1168 "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
1169 ptp_intent_result = main.ONOS2.add_point_intent(
1170 "of:0000000000003012/1",
1171 "of:0000000000006022/1" )
1172 if ptp_intent_result == main.TRUE:
1173 get_intent_result = main.ONOS2.intents()
1174 main.log.info( "Point to point intent install successful" )
1175 # main.log.info( get_intent_result )
1176
1177 ptp_intent_result = main.ONOS2.add_point_intent(
1178 "of:0000000000006022/1",
1179 "of:0000000000003012/1" )
1180 if ptp_intent_result == main.TRUE:
1181 get_intent_result = main.ONOS2.intents()
1182 main.log.info( "Point to point intent install successful" )
1183 # main.log.info( get_intent_result )
1184
1185 main.step(
1186 "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
1187 ptp_intent_result = main.ONOS2.add_point_intent(
1188 "of:0000000000003013/1",
1189 "of:0000000000006023/1" )
1190 if ptp_intent_result == main.TRUE:
1191 get_intent_result = main.ONOS2.intents()
1192 main.log.info( "Point to point intent install successful" )
1193 # main.log.info( get_intent_result )
1194
1195 ptp_intent_result = main.ONOS2.add_point_intent(
1196 "of:0000000000006023/1",
1197 "of:0000000000003013/1" )
1198 if ptp_intent_result == main.TRUE:
1199 get_intent_result = main.ONOS2.intents()
1200 main.log.info( "Point to point intent install successful" )
1201 # main.log.info( get_intent_result )
1202
1203 main.step(
1204 "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
1205 ptp_intent_result = main.ONOS2.add_point_intent(
1206 "of:0000000000003014/1",
1207 "of:0000000000006024/1" )
1208 if ptp_intent_result == main.TRUE:
1209 get_intent_result = main.ONOS2.intents()
1210 main.log.info( "Point to point intent install successful" )
1211 # main.log.info( get_intent_result )
1212
1213 ptp_intent_result = main.ONOS2.add_point_intent(
1214 "of:0000000000006024/1",
1215 "of:0000000000003014/1" )
1216 if ptp_intent_result == main.TRUE:
1217 get_intent_result = main.ONOS2.intents()
1218 main.log.info( "Point to point intent install successful" )
1219 # main.log.info( get_intent_result )
1220
1221 main.step(
1222 "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
1223 ptp_intent_result = main.ONOS2.add_point_intent(
1224 "of:0000000000003015/1",
1225 "of:0000000000006025/1" )
1226 if ptp_intent_result == main.TRUE:
1227 get_intent_result = main.ONOS2.intents()
1228 main.log.info( "Point to point intent install successful" )
1229 # main.log.info( get_intent_result )
1230
1231 ptp_intent_result = main.ONOS2.add_point_intent(
1232 "of:0000000000006025/1",
1233 "of:0000000000003015/1" )
1234 if ptp_intent_result == main.TRUE:
1235 get_intent_result = main.ONOS2.intents()
1236 main.log.info( "Point to point intent install successful" )
1237 # main.log.info( get_intent_result )
1238
1239 main.step(
1240 "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
1241 ptp_intent_result = main.ONOS2.add_point_intent(
1242 "of:0000000000003016/1",
1243 "of:0000000000006026/1" )
1244 if ptp_intent_result == main.TRUE:
1245 get_intent_result = main.ONOS2.intents()
1246 main.log.info( "Point to point intent install successful" )
1247 # main.log.info( get_intent_result )
1248
1249 ptp_intent_result = main.ONOS2.add_point_intent(
1250 "of:0000000000006026/1",
1251 "of:0000000000003016/1" )
1252 if ptp_intent_result == main.TRUE:
1253 get_intent_result = main.ONOS2.intents()
1254 main.log.info( "Point to point intent install successful" )
1255 # main.log.info( get_intent_result )
1256
1257 main.step(
1258 "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
1259 ptp_intent_result = main.ONOS2.add_point_intent(
1260 "of:0000000000003017/1",
1261 "of:0000000000006027/1" )
1262 if ptp_intent_result == main.TRUE:
1263 get_intent_result = main.ONOS2.intents()
1264 main.log.info( "Point to point intent install successful" )
1265 # main.log.info( get_intent_result )
1266
1267 ptp_intent_result = main.ONOS2.add_point_intent(
1268 "of:0000000000006027/1",
1269 "of:0000000000003017/1" )
1270 if ptp_intent_result == main.TRUE:
1271 get_intent_result = main.ONOS2.intents()
1272 main.log.info( "Point to point intent install successful" )
1273 # main.log.info( get_intent_result )
1274
1275 print(
1276 "_______________________________________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001277
1278 flowHandle = main.ONOS2.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -08001279 # print "flowHandle = ", flowHandle
1280 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001281
1282 count = 1
1283 i = 8
1284 Ping_Result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001285 while i < 18:
1286 main.log.info(
1287 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1288 ping = main.Mininet1.pingHost(
1289 src="h" + str( i ), target="h" + str( i + 10 ) )
1290 if ping == main.FALSE and count < 5:
1291 count += 1
shahshreya4e13a062014-11-11 16:46:18 -08001292 #i = 8
1293 Ping_Result = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001294 main.log.report( "Ping between h" +
1295 str( i ) +
1296 " and h" +
1297 str( i +
1298 10 ) +
1299 " failed. Making attempt number " +
1300 str( count ) +
1301 " in 2 seconds" )
1302 time.sleep( 2 )
1303 elif ping == main.FALSE:
1304 main.log.report( "All ping attempts between h" +
1305 str( i ) +
1306 " and h" +
1307 str( i +
1308 10 ) +
1309 "have failed" )
1310 i = 19
shahshreya4e13a062014-11-11 16:46:18 -08001311 Ping_Result = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001312 elif ping == main.TRUE:
1313 main.log.info( "Ping test between h" +
1314 str( i ) +
1315 " and h" +
1316 str( i +
1317 10 ) +
1318 "passed!" )
1319 i += 1
shahshreya4e13a062014-11-11 16:46:18 -08001320 Ping_Result = main.TRUE
1321 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001322 main.log.info( "Unknown error" )
shahshreya4e13a062014-11-11 16:46:18 -08001323 Ping_Result = main.ERROR
1324
kelvin-onlab8a832582015-01-16 17:06:11 -08001325 if Ping_Result == main.FALSE:
1326 main.log.report(
1327 "Point intents have not ben installed correctly. Cleaning up" )
1328 # main.cleanup()
1329 # main.exit()
1330 if Ping_Result == main.TRUE:
1331 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001332
1333 case9_result = Ping_Result
kelvin-onlab8a832582015-01-16 17:06:11 -08001334 utilities.assert_equals(
1335 expect=main.TRUE,
1336 actual=case9_result,
1337 onpass="Point intents addition and Pingall Test successful",
1338 onfail="Point intents addition and Pingall Test NOT successful" )