blob: daa1ae283f69716021b8e722354f1351e56d4f9c [file] [log] [blame]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001# Intent Performance Test for ONOS-next
andrewonlab92ea3672014-11-04 20:22:14 -05002#
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08003# andrew@onlab.us
andrewonlab8790abb2014-11-06 13:51:54 -05004#
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08005# November 5, 2014
6
andrewonlab92ea3672014-11-04 20:22:14 -05007
8class IntentPerfNext:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08009
10 def __init__( self ):
andrewonlab92ea3672014-11-04 20:22:14 -050011 self.default = ""
12
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080013 def CASE1( self, main ):
14 """
andrewonlab92ea3672014-11-04 20:22:14 -050015 ONOS startup sequence
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080016 """
andrewonlab92ea3672014-11-04 20:22:14 -050017 import time
andrewonlab4293dcb2014-12-02 15:48:05 -050018 global cluster_count
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080019 cluster_count = 1
andrewonlab92ea3672014-11-04 20:22:14 -050020
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080021 cell_name = main.params[ 'ENV' ][ 'cellName' ]
andrewonlab92ea3672014-11-04 20:22:14 -050022
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080023 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
24 checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
andrewonlab92ea3672014-11-04 20:22:14 -050025
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080026 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
27 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
28 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
29 ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
30 ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
31 ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
32 ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlab4293dcb2014-12-02 15:48:05 -050033
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080034 main.ONOSbench.onos_uninstall( node_ip=ONOS1_ip )
35 main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip )
36 main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip )
37 main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
38 main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
39 main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
40 main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
andrewonlab4293dcb2014-12-02 15:48:05 -050041
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080042 MN1_ip = main.params[ 'MN' ][ 'ip1' ]
43 BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
andrewonlab92ea3672014-11-04 20:22:14 -050044
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080045 main.case( "Setting up test environment" )
46
47 main.step( "Creating cell file" )
andrewonlab92ea3672014-11-04 20:22:14 -050048 cell_file_result = main.ONOSbench.create_cell_file(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080049 BENCH_ip, cell_name, MN1_ip,
50 "onos-core,onos-app-metrics,onos-gui",
51 # ONOS1_ip, ONOS2_ip, ONOS3_ip )
52 ONOS1_ip )
andrewonlab92ea3672014-11-04 20:22:14 -050053
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080054 main.step( "Applying cell file to environment" )
55 cell_apply_result = main.ONOSbench.set_cell( cell_name )
andrewonlab92ea3672014-11-04 20:22:14 -050056 verify_cell_result = main.ONOSbench.verify_cell()
57
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080058 main.step( "Removing raft logs" )
andrewonlab4293dcb2014-12-02 15:48:05 -050059 main.ONOSbench.onos_remove_raft_logs()
60
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080061 main.step( "Git checkout and pull " + checkout_branch )
andrewonlab92ea3672014-11-04 20:22:14 -050062 if git_pull == 'on':
63 checkout_result = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080064 main.ONOSbench.git_checkout( checkout_branch )
andrewonlab92ea3672014-11-04 20:22:14 -050065 pull_result = main.ONOSbench.git_pull()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080066
67 # If you used git pull, auto compile
68 main.step( "Using onos-build to compile ONOS" )
andrewonlab92ea3672014-11-04 20:22:14 -050069 build_result = main.ONOSbench.onos_build()
70 else:
71 checkout_result = main.TRUE
72 pull_result = main.TRUE
73 build_result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080074 main.log.info( "Git pull skipped by configuration" )
andrewonlab92ea3672014-11-04 20:22:14 -050075
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080076 main.log.report( "Commit information - " )
77 main.ONOSbench.get_version( report=True )
andrewonlab4cf9dd22014-11-18 21:28:38 -050078
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080079 main.step( "Creating ONOS package" )
andrewonlab92ea3672014-11-04 20:22:14 -050080 package_result = main.ONOSbench.onos_package()
81
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080082 main.step( "Installing ONOS package" )
83 install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
84 #install2_result = main.ONOSbench.onos_install( node=ONOS2_ip )
85 #install3_result = main.ONOSbench.onos_install( node=ONOS3_ip )
andrewonlab92ea3672014-11-04 20:22:14 -050086
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080087 main.step( "Set cell for ONOScli env" )
88 main.ONOS1cli.set_cell( cell_name )
89 # main.ONOS2cli.set_cell( cell_name )
90 # main.ONOS3cli.set_cell( cell_name )
andrewonlab92ea3672014-11-04 20:22:14 -050091
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080092 time.sleep( 5 )
andrewonlab92ea3672014-11-04 20:22:14 -050093
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080094 main.step( "Start onos cli" )
95 cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
96 #cli2 = main.ONOS2cli.start_onos_cli( ONOS2_ip )
97 #cli3 = main.ONOS3cli.start_onos_cli( ONOS3_ip )
andrewonlab92ea3672014-11-04 20:22:14 -050098
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080099 utilities.assert_equals( expect=main.TRUE,
100 actual=cell_file_result and cell_apply_result and
101 verify_cell_result and checkout_result and
102 pull_result and build_result and
103 install1_result, # and install2_result and
104 # install3_result,
105 onpass="ONOS started successfully",
106 onfail="Failed to start ONOS" )
andrewonlab92ea3672014-11-04 20:22:14 -0500107
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800108 def CASE2( self, main ):
109 """
andrewonlab92ea3672014-11-04 20:22:14 -0500110 Single intent add latency
111
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800112 """
andrewonlab92ea3672014-11-04 20:22:14 -0500113 import time
114 import json
115 import requests
116 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500117 import numpy
andrewonlab92ea3672014-11-04 20:22:14 -0500118
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800119 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
120 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
121 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
122 ONOS_user = main.params[ 'CTRL' ][ 'user' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500123
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800124 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500125
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800126 # number of iterations of case
127 num_iter = main.params[ 'TEST' ][ 'numIter' ]
128 num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500129
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800130 # Timestamp keys for json metrics output
131 submit_time = main.params[ 'JSON' ][ 'submittedTime' ]
132 install_time = main.params[ 'JSON' ][ 'installedTime' ]
133 wdRequest_time = main.params[ 'JSON' ][ 'wdRequestTime' ]
134 withdrawn_time = main.params[ 'JSON' ][ 'withdrawnTime' ]
135
andrewonlab70decc02014-11-19 18:50:23 -0500136 intent_add_lat_list = []
137
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800138 # Assign 'linear' switch format for basic intent testing
andrewonlab70decc02014-11-19 18:50:23 -0500139 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800140 sw="1", ip1=ONOS1_ip, port1=default_sw_port )
andrewonlab70decc02014-11-19 18:50:23 -0500141 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800142 sw="2", ip1=ONOS2_ip, port1=default_sw_port )
andrewonlab70decc02014-11-19 18:50:23 -0500143 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800144 sw="3", ip1=ONOS2_ip, port1=default_sw_port )
andrewonlab70decc02014-11-19 18:50:23 -0500145 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800146 sw="4", ip1=ONOS2_ip, port1=default_sw_port )
andrewonlab70decc02014-11-19 18:50:23 -0500147 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800148 sw="5", ip1=ONOS3_ip, port1=default_sw_port )
andrewonlab70decc02014-11-19 18:50:23 -0500149
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800150 time.sleep( 10 )
andrewonlab92ea3672014-11-04 20:22:14 -0500151
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800152 main.log.report( "Single intent add latency test" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500153
andrewonlab8790abb2014-11-06 13:51:54 -0500154 devices_json_str = main.ONOS1cli.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800155 devices_json_obj = json.loads( devices_json_str )
andrewonlab92ea3672014-11-04 20:22:14 -0500156 device_id_list = []
157
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800158 # Obtain device id list in ONOS format.
159 # They should already be in order ( 1,2,3,10,11,12,13, etc )
andrewonlab92ea3672014-11-04 20:22:14 -0500160 for device in devices_json_obj:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800161 device_id_list.append( device[ 'id' ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500162
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800163 for i in range( 0, int( num_iter ) ):
164 # add_point_intent( ingr_device, egr_device,
165 # ingr_port, egr_port )
andrewonlab8790abb2014-11-06 13:51:54 -0500166 main.ONOS1cli.add_point_intent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800167 device_id_list[ 0 ] + "/1", device_id_list[ 4 ] + "/1" )
andrewonlab92ea3672014-11-04 20:22:14 -0500168
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800169 # Allow some time for intents to propagate
170 time.sleep( 5 )
171
172 # Obtain metrics from ONOS 1, 2, 3
andrewonlab8790abb2014-11-06 13:51:54 -0500173 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
174 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
175 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
176
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800177 intents_json_obj_1 = json.loads( intents_json_str_1 )
178 intents_json_obj_2 = json.loads( intents_json_str_2 )
179 intents_json_obj_3 = json.loads( intents_json_str_3 )
andrewonlab8790abb2014-11-06 13:51:54 -0500180
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800181 # Parse values from the json object
andrewonlab8790abb2014-11-06 13:51:54 -0500182 intent_submit_1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800183 intents_json_obj_1[ submit_time ][ 'value' ]
andrewonlab8790abb2014-11-06 13:51:54 -0500184 intent_submit_2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800185 intents_json_obj_2[ submit_time ][ 'value' ]
andrewonlab8790abb2014-11-06 13:51:54 -0500186 intent_submit_3 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800187 intents_json_obj_3[ submit_time ][ 'value' ]
andrewonlab8790abb2014-11-06 13:51:54 -0500188
189 intent_install_1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800190 intents_json_obj_1[ install_time ][ 'value' ]
andrewonlab8790abb2014-11-06 13:51:54 -0500191 intent_install_2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800192 intents_json_obj_2[ install_time ][ 'value' ]
andrewonlab8790abb2014-11-06 13:51:54 -0500193 intent_install_3 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800194 intents_json_obj_3[ install_time ][ 'value' ]
andrewonlab8790abb2014-11-06 13:51:54 -0500195
196 intent_install_lat_1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800197 int( intent_install_1 ) - int( intent_submit_1 )
andrewonlab8790abb2014-11-06 13:51:54 -0500198 intent_install_lat_2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800199 int( intent_install_2 ) - int( intent_submit_2 )
andrewonlab8790abb2014-11-06 13:51:54 -0500200 intent_install_lat_3 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800201 int( intent_install_3 ) - int( intent_submit_3 )
andrewonlab8790abb2014-11-06 13:51:54 -0500202
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800203 intent_install_lat_avg = \
204 ( intent_install_lat_1 +
205 intent_install_lat_2 +
206 intent_install_lat_3 ) / 3
207
208 main.log.info( "Intent add latency avg for iteration " + str( i ) +
209 ": " + str( intent_install_lat_avg ) + " ms" )
andrewonlab8790abb2014-11-06 13:51:54 -0500210
211 if intent_install_lat_avg > 0.0 and \
andrewonlabeb1d0542014-12-03 20:12:01 -0500212 intent_install_lat_avg < 1000 and i > num_ignore:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800213 intent_add_lat_list.append( intent_install_lat_avg )
andrewonlab8790abb2014-11-06 13:51:54 -0500214 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800215 main.log.info( "Intent add latency exceeded " +
216 "threshold. Skipping iteration " + str( i ) )
andrewonlab8790abb2014-11-06 13:51:54 -0500217
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800218 time.sleep( 3 )
219
220 # TODO: Possibly put this in the driver function
221 main.log.info( "Removing intents for next iteration" )
andrewonlab8790abb2014-11-06 13:51:54 -0500222 json_temp = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800223 main.ONOS1cli.intents( json_format=True )
224 json_obj_intents = json.loads( json_temp )
andrewonlab8790abb2014-11-06 13:51:54 -0500225 if json_obj_intents:
226 for intents in json_obj_intents:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800227 temp_id = intents[ 'id' ]
228 main.ONOS1cli.remove_intent( temp_id )
229 main.log.info( "Removing intent id: " +
230 str( temp_id ) )
231 main.ONOS1cli.remove_intent( temp_id )
andrewonlab8790abb2014-11-06 13:51:54 -0500232 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800233 main.log.info( "Intents were not installed correctly" )
andrewonlab8790abb2014-11-06 13:51:54 -0500234
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800235 time.sleep( 5 )
andrewonlab8790abb2014-11-06 13:51:54 -0500236
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800237 intent_add_lat_avg = sum( intent_add_lat_list ) /\
238 len( intent_add_lat_list )
andrewonlabeb1d0542014-12-03 20:12:01 -0500239 intent_add_lat_std = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800240 round( numpy.std( intent_add_lat_list ), 1 )
241 # END ITERATION FOR LOOP
242 main.log.report( "Single intent add latency - " )
243 main.log.report( "Avg: " + str( intent_add_lat_avg ) + " ms" )
244 main.log.report(
245 "Std Deviation: " +
246 str( intent_add_lat_std ) +
247 " ms" )
andrewonlab92ea3672014-11-04 20:22:14 -0500248
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800249 def CASE3( self, main ):
250 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500251 Intent Reroute latency
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800252 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500253 import time
254 import json
255 import requests
256 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500257 import numpy
andrewonlab4cf9dd22014-11-18 21:28:38 -0500258
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800259 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
260 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
261 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
262 ONOS_user = main.params[ 'CTRL' ][ 'user' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500263
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800264 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500265
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800266 # number of iterations of case
267 num_iter = main.params[ 'TEST' ][ 'numIter' ]
268 num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500269
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800270 # Timestamp keys for json metrics output
271 submit_time = main.params[ 'JSON' ][ 'submittedTime' ]
272 install_time = main.params[ 'JSON' ][ 'installedTime' ]
273 wdRequest_time = main.params[ 'JSON' ][ 'wdRequestTime' ]
274 withdrawn_time = main.params[ 'JSON' ][ 'withdrawnTime' ]
andrewonlab70decc02014-11-19 18:50:23 -0500275
andrewonlab4cf9dd22014-11-18 21:28:38 -0500276 devices_json_str = main.ONOS1cli.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800277 devices_json_obj = json.loads( devices_json_str )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500278
279 device_id_list = []
280
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800281 # Obtain device id list in ONOS format.
282 # They should already be in order ( 1,2,3,10,11,12,13, etc )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500283 for device in devices_json_obj:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800284 device_id_list.append( device[ 'id' ] )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500285
andrewonlab4cf9dd22014-11-18 21:28:38 -0500286 intent_reroute_lat_list = []
287
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800288 for i in range( 0, int( num_iter ) ):
289 # add_point_intent( ingr_device, ingr_port,
290 # egr_device, egr_port )
291 if len( device_id_list ) > 0:
andrewonlabeb1d0542014-12-03 20:12:01 -0500292 main.ONOS1cli.add_point_intent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800293 device_id_list[ 0 ] + "/2", device_id_list[ 4 ] + "/1" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500294 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800295 main.log.info( "Failed to fetch devices from ONOS" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500296
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800297 time.sleep( 5 )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500298
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800299 intents_str = main.ONOS1cli.intents( json_format=True )
300 intents_obj = json.loads( intents_str )
andrewonlab70decc02014-11-19 18:50:23 -0500301 for intent in intents_obj:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800302 if intent[ 'state' ] == "INSTALLED":
303 main.log.info( "Intent installed successfully" )
304 intent_id = intent[ 'id' ]
andrewonlab70decc02014-11-19 18:50:23 -0500305 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800306 # TODO: Add error handling
307 main.log.info( "Intent installation failed" )
andrewonlab70decc02014-11-19 18:50:23 -0500308 intent_id = ""
309
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800310 # NOTE: this interface is specific to
andrewonlab4cf9dd22014-11-18 21:28:38 -0500311 # topo-intentFlower.py topology
312 # reroute case.
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800313 main.log.info( "Disabling interface s2-eth3" )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500314 main.Mininet1.handle.sendline(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800315 "sh ifconfig s2-eth3 down" )
316 t0_system = time.time() * 1000
andrewonlab4cf9dd22014-11-18 21:28:38 -0500317
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800318 # TODO: Check for correct intent reroute
319 time.sleep( 5 )
320
321 # Obtain metrics from ONOS 1, 2, 3
andrewonlab4cf9dd22014-11-18 21:28:38 -0500322 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
323 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
324 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
325
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800326 intents_json_obj_1 = json.loads( intents_json_str_1 )
327 intents_json_obj_2 = json.loads( intents_json_str_2 )
328 intents_json_obj_3 = json.loads( intents_json_str_3 )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500329
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800330 # Parse values from the json object
andrewonlab4cf9dd22014-11-18 21:28:38 -0500331 intent_install_1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800332 intents_json_obj_1[ install_time ][ 'value' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500333 intent_install_2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800334 intents_json_obj_2[ install_time ][ 'value' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500335 intent_install_3 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800336 intents_json_obj_3[ install_time ][ 'value' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500337
338 intent_reroute_lat_1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800339 int( intent_install_1 ) - int( t0_system )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500340 intent_reroute_lat_2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800341 int( intent_install_2 ) - int( t0_system )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500342 intent_reroute_lat_3 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800343 int( intent_install_3 ) - int( t0_system )
344
andrewonlab4cf9dd22014-11-18 21:28:38 -0500345 intent_reroute_lat_avg = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800346 ( intent_reroute_lat_1 +
347 intent_reroute_lat_2 +
348 intent_reroute_lat_3 ) / 3
349
350 main.log.info( "Intent reroute latency avg for iteration " +
351 str( i ) + ": " + str( intent_reroute_lat_avg ) )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500352
353 if intent_reroute_lat_avg > 0.0 and \
andrewonlabeb1d0542014-12-03 20:12:01 -0500354 intent_reroute_lat_avg < 1000 and i > num_ignore:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800355 intent_reroute_lat_list.append( intent_reroute_lat_avg )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500356 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800357 main.log.info( "Intent reroute latency exceeded " +
358 "threshold. Skipping iteration " + str( i ) )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500359
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800360 main.log.info( "Removing intents for next iteration" )
361 main.ONOS1cli.remove_intent( intent_id )
362
363 main.log.info( "Bringing Mininet interface up for next " +
364 "iteration" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500365 main.Mininet1.handle.sendline(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800366 "sh ifconfig s2-eth3 up" )
367
368 intent_reroute_lat_avg = sum( intent_reroute_lat_list ) /\
369 len( intent_reroute_lat_list )
andrewonlabeb1d0542014-12-03 20:12:01 -0500370 intent_reroute_lat_std = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800371 round( numpy.std( intent_reroute_lat_list ), 1 )
372 # END ITERATION FOR LOOP
373 main.log.report( "Single intent reroute latency - " )
374 main.log.report( "Avg: " + str( intent_reroute_lat_avg ) + " ms" )
375 main.log.report(
376 "Std Deviation: " +
377 str( intent_reroute_lat_std ) +
378 " ms" )
379
380 def CASE7( self, main ):
381 """
andrewonlab042b3912014-12-10 16:40:50 -0500382 Batch intent reroute latency
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800383 """
andrewonlab042b3912014-12-10 16:40:50 -0500384 import time
385 import json
386 import requests
387 import os
388 import numpy
389
390 ONOS_ip_list = []
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800391 for i in range( 1, 8 ):
392 ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab042b3912014-12-10 16:40:50 -0500393
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800394 ONOS_user = main.params[ 'CTRL' ][ 'user' ]
395 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab042b3912014-12-10 16:40:50 -0500396
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800397 batch_intent_size = main.params[ 'TEST' ][ 'batchIntentSize' ]
398 batch_thresh_min = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
399 batch_thresh_max = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
400 install_time = main.params[ 'JSON' ][ 'installedTime' ]
andrewonlab042b3912014-12-10 16:40:50 -0500401
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800402 # number of iterations of case
403 num_iter = main.params[ 'TEST' ][ 'numIter' ]
404 num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
405 num_switch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
406 n_thread = main.params[ 'TEST' ][ 'numMult' ]
407
408 main.log.report( "Batch intent installation test of " +
409 batch_intent_size + " intents" )
andrewonlab042b3912014-12-10 16:40:50 -0500410
411 batch_result_list = []
412
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800413 # Assign 'linear' switch format for basic intent testing
andrewonlab042b3912014-12-10 16:40:50 -0500414 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800415 sw="1", ip1=ONOS1_ip, port1=default_sw_port )
andrewonlab042b3912014-12-10 16:40:50 -0500416 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800417 sw="2", ip1=ONOS2_ip, port1=default_sw_port )
andrewonlab042b3912014-12-10 16:40:50 -0500418 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800419 sw="3", ip1=ONOS2_ip, port1=default_sw_port )
andrewonlab042b3912014-12-10 16:40:50 -0500420 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800421 sw="4", ip1=ONOS2_ip, port1=default_sw_port )
andrewonlab042b3912014-12-10 16:40:50 -0500422 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800423 sw="5", ip1=ONOS3_ip, port1=default_sw_port )
andrewonlab042b3912014-12-10 16:40:50 -0500424
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800425 time.sleep( 10 )
andrewonlab042b3912014-12-10 16:40:50 -0500426
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800427 main.log.info( "Getting list of available devices" )
andrewonlab042b3912014-12-10 16:40:50 -0500428 device_id_list = []
429 json_str = main.ONOS1cli.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800430 json_obj = json.loads( json_str )
andrewonlab042b3912014-12-10 16:40:50 -0500431 for device in json_obj:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800432 device_id_list.append( device[ 'id' ] )
andrewonlab042b3912014-12-10 16:40:50 -0500433
434 batch_install_lat = []
435 batch_withdraw_lat = []
436 sleep_time = 10
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800437
andrewonlab042b3912014-12-10 16:40:50 -0500438 base_dir = "/tmp/"
439 max_install_lat = []
440
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800441 for i in range( 0, int( num_iter ) ):
442 main.log.info( "Pushing " +
443 str( int( batch_intent_size ) * int( n_thread ) ) +
444 " intents. Iteration " + str( i ) )
445
andrewonlab042b3912014-12-10 16:40:50 -0500446 main.ONOS1cli.push_test_intents(
447 "of:0000000000000001/1",
448 "of:0000000000000005/1",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800449 1000, num_mult="1", app_id="1" )
450
451 # TODO: Check for installation success then proceed
452 time.sleep( 30 )
453
454 # NOTE: this interface is specific to
andrewonlab042b3912014-12-10 16:40:50 -0500455 # topo-intentFlower.py topology
456 # reroute case.
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800457 main.log.info( "Disabling interface s2-eth3" )
andrewonlab042b3912014-12-10 16:40:50 -0500458 main.Mininet1.handle.sendline(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800459 "sh ifconfig s2-eth3 down" )
460 t0_system = time.time() * 1000
andrewonlab042b3912014-12-10 16:40:50 -0500461
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800462 # TODO: Wait sufficient time for intents to install
463 time.sleep( 10 )
andrewonlab042b3912014-12-10 16:40:50 -0500464
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800465 # TODO: get intent installation time
466
467 # Obtain metrics from ONOS 1, 2, 3
andrewonlab042b3912014-12-10 16:40:50 -0500468 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
469 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
470 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
471
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800472 intents_json_obj_1 = json.loads( intents_json_str_1 )
473 intents_json_obj_2 = json.loads( intents_json_str_2 )
474 intents_json_obj_3 = json.loads( intents_json_str_3 )
andrewonlab042b3912014-12-10 16:40:50 -0500475
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800476 # Parse values from the json object
andrewonlab042b3912014-12-10 16:40:50 -0500477 intent_install_1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800478 intents_json_obj_1[ install_time ][ 'value' ]
andrewonlab042b3912014-12-10 16:40:50 -0500479 intent_install_2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800480 intents_json_obj_2[ install_time ][ 'value' ]
andrewonlab042b3912014-12-10 16:40:50 -0500481 intent_install_3 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800482 intents_json_obj_3[ install_time ][ 'value' ]
andrewonlab042b3912014-12-10 16:40:50 -0500483
484 intent_reroute_lat_1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800485 int( intent_install_1 ) - int( t0_system )
andrewonlab042b3912014-12-10 16:40:50 -0500486 intent_reroute_lat_2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800487 int( intent_install_2 ) - int( t0_system )
andrewonlab042b3912014-12-10 16:40:50 -0500488 intent_reroute_lat_3 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800489 int( intent_install_3 ) - int( t0_system )
490
andrewonlab042b3912014-12-10 16:40:50 -0500491 intent_reroute_lat_avg = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800492 ( intent_reroute_lat_1 +
493 intent_reroute_lat_2 +
494 intent_reroute_lat_3 ) / 3
495
496 main.log.info( "Intent reroute latency avg for iteration " +
497 str( i ) + ": " + str( intent_reroute_lat_avg ) )
498 # TODO: Remove intents for next iteration
499
500 time.sleep( 5 )
andrewonlab042b3912014-12-10 16:40:50 -0500501
502 intents_str = main.ONOS1cli.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800503 intents_json = json.loads( intents_str )
andrewonlab042b3912014-12-10 16:40:50 -0500504 for intents in intents_json:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800505 intent_id = intents[ 'id' ]
andrewonlab042b3912014-12-10 16:40:50 -0500506 if intent_id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800507 main.ONOS1cli.remove_intent( intent_id )
andrewonlab042b3912014-12-10 16:40:50 -0500508
509 main.Mininet1.handle.sendline(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800510 "sh ifconfig s2-eth3 up" )
andrewonlab042b3912014-12-10 16:40:50 -0500511
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800512 main.log.info( "Intents removed and port back up" )
andrewonlab042b3912014-12-10 16:40:50 -0500513
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800514 def CASE4( self, main ):
515 """
andrewonlab042b3912014-12-10 16:40:50 -0500516 Batch intent install
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800517 """
andrewonlab70decc02014-11-19 18:50:23 -0500518 import time
519 import json
520 import requests
521 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500522 import numpy
andrewonlab70decc02014-11-19 18:50:23 -0500523
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800524 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
525 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
526 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
527 ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
528 ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
529 ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
530 ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
531
andrewonlab4293dcb2014-12-02 15:48:05 -0500532 ONOS_ip_list = []
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800533 for i in range( 1, 8 ):
534 ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500535
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800536 ONOS_user = main.params[ 'CTRL' ][ 'user' ]
andrewonlab70decc02014-11-19 18:50:23 -0500537
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800538 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab70decc02014-11-19 18:50:23 -0500539
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800540 batch_intent_size = main.params[ 'TEST' ][ 'batchIntentSize' ]
541 batch_thresh_min = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
542 batch_thresh_max = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
543
544 # number of iterations of case
545 num_iter = main.params[ 'TEST' ][ 'numIter' ]
546 num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
547 num_switch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
548 n_thread = main.params[ 'TEST' ][ 'numMult' ]
andrewonlabeb1d0542014-12-03 20:12:01 -0500549 #n_thread = 105
andrewonlab4293dcb2014-12-02 15:48:05 -0500550
551 #*****
552 global cluster_count
553 #*****
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800554
555 # Switch assignment NOTE: hardcoded
andrewonlab4293dcb2014-12-02 15:48:05 -0500556 if cluster_count == 1:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800557 for i in range( 1, num_switch + 1 ):
andrewonlab4293dcb2014-12-02 15:48:05 -0500558 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800559 sw=str( i ),
andrewonlab4293dcb2014-12-02 15:48:05 -0500560 ip1=ONOS1_ip,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800561 port1=default_sw_port )
andrewonlab4293dcb2014-12-02 15:48:05 -0500562 if cluster_count == 3:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800563 for i in range( 1, 3 ):
andrewonlab4293dcb2014-12-02 15:48:05 -0500564 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800565 sw=str( i ),
andrewonlab4293dcb2014-12-02 15:48:05 -0500566 ip1=ONOS1_ip,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800567 port1=default_sw_port )
568 for i in range( 3, 6 ):
andrewonlab4293dcb2014-12-02 15:48:05 -0500569 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800570 sw=str( i ),
andrewonlab4293dcb2014-12-02 15:48:05 -0500571 ip1=ONOS2_ip,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800572 port1=default_sw_port )
573 for i in range( 6, 9 ):
andrewonlab4293dcb2014-12-02 15:48:05 -0500574 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800575 sw=str( i ),
andrewonlab4293dcb2014-12-02 15:48:05 -0500576 ip1=ONOS3_ip,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800577 port1=default_sw_port )
andrewonlab4293dcb2014-12-02 15:48:05 -0500578 if cluster_count == 5:
579 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800580 sw="1",
581 ip1=ONOS1_ip,
582 port1=default_sw_port )
andrewonlab4293dcb2014-12-02 15:48:05 -0500583 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800584 sw="2",
585 ip1=ONOS2_ip,
586 port1=default_sw_port )
587 for i in range( 3, 6 ):
andrewonlab4293dcb2014-12-02 15:48:05 -0500588 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800589 sw=str( i ),
andrewonlab4293dcb2014-12-02 15:48:05 -0500590 ip1=ONOS3_ip,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800591 port1=default_sw_port )
andrewonlab4293dcb2014-12-02 15:48:05 -0500592 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800593 sw="6",
594 ip1=ONOS4_ip,
595 port1=default_sw_port )
andrewonlab4293dcb2014-12-02 15:48:05 -0500596 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800597 sw="7",
598 ip1=ONOS5_ip,
599 port1=default_sw_port )
andrewonlab4293dcb2014-12-02 15:48:05 -0500600 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800601 sw="8",
602 ip1=ONOS5_ip,
603 port1=default_sw_port )
604
andrewonlab4293dcb2014-12-02 15:48:05 -0500605 if cluster_count == 7:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800606 for i in range( 1, 9 ):
andrewonlabeb1d0542014-12-03 20:12:01 -0500607 if i < 8:
andrewonlab4293dcb2014-12-02 15:48:05 -0500608 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800609 sw=str( i ),
610 ip1=ONOS_ip_list[ i - 1 ],
611 port1=default_sw_port )
612 elif i >= 8:
andrewonlab4293dcb2014-12-02 15:48:05 -0500613 main.Mininet1.assign_sw_controller(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800614 sw=str( i ),
615 ip1=ONOS_ip_list[ 6 ],
616 port1=default_sw_port )
andrewonlab70decc02014-11-19 18:50:23 -0500617
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800618 time.sleep( 30 )
andrewonlabeb1d0542014-12-03 20:12:01 -0500619
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800620 main.log.report( "Batch intent installation test of " +
621 batch_intent_size + " intents" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500622
623 batch_result_list = []
andrewonlab70decc02014-11-19 18:50:23 -0500624
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800625 main.log.info( "Getting list of available devices" )
andrewonlab70decc02014-11-19 18:50:23 -0500626 device_id_list = []
627 json_str = main.ONOS1cli.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800628 json_obj = json.loads( json_str )
andrewonlab70decc02014-11-19 18:50:23 -0500629 for device in json_obj:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800630 device_id_list.append( device[ 'id' ] )
andrewonlab70decc02014-11-19 18:50:23 -0500631
andrewonlab4293dcb2014-12-02 15:48:05 -0500632 batch_install_lat = []
633 batch_withdraw_lat = []
andrewonlabeb1d0542014-12-03 20:12:01 -0500634 sleep_time = 10
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800635
andrewonlab4293dcb2014-12-02 15:48:05 -0500636 base_dir = "/tmp/"
andrewonlabeb1d0542014-12-03 20:12:01 -0500637 max_install_lat = []
andrewonlab70decc02014-11-19 18:50:23 -0500638
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800639 for i in range( 0, int( num_iter ) ):
640 main.log.info( "Pushing " +
641 str( int( batch_intent_size ) * int( n_thread ) ) +
642 " intents. Iteration " + str( i ) )
643
644 for node in range( 1, cluster_count + 1 ):
645 save_dir = base_dir + "batch_intent_" + str( node ) + ".txt"
andrewonlab4293dcb2014-12-02 15:48:05 -0500646 main.ONOSbench.push_test_intents_shell(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800647 "of:0000000000000001/" + str( node ),
648 "of:0000000000000008/" + str( node ),
649 int( batch_intent_size ),
650 save_dir, ONOS_ip_list[ node - 1 ],
651 num_mult=n_thread, app_id=node )
652
653 # Wait sufficient time for intents to start
654 # installing
655
656 time.sleep( sleep_time )
657 print sleep_time
andrewonlabeb1d0542014-12-03 20:12:01 -0500658
659 intent = ""
660 counter = 300
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800661 while len( intent ) > 0 and counter > 0:
andrewonlabeb1d0542014-12-03 20:12:01 -0500662 main.ONOS1cli.handle.sendline(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800663 "intents | wc -l" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500664 main.ONOS1cli.handle.expect(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800665 "intents | wc -l" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500666 main.ONOS1cli.handle.expect(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800667 "onos>" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500668 intent_temp = main.ONOS1cli.handle.before()
669 print intent_temp
670
671 intent = main.ONOS1cli.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800672 intent = json.loads( intent )
673 counter = counter - 1
674 time.sleep( 1 )
andrewonlabeb1d0542014-12-03 20:12:01 -0500675
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800676 time.sleep( 5 )
andrewonlabeb1d0542014-12-03 20:12:01 -0500677
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800678 for node in range( 1, cluster_count + 1 ):
679 save_dir = base_dir + "batch_intent_" + str( node ) + ".txt"
680 with open( save_dir ) as f_onos:
andrewonlab28b84eb2014-12-02 15:53:35 -0500681 line_count = 0
andrewonlab4293dcb2014-12-02 15:48:05 -0500682 for line in f_onos:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800683 line = line[ 1: ]
684 line = line.split( ": " )
685 result = line[ 1 ].split( " " )[ 0 ]
686 # TODO: add parameters before appending latency
andrewonlab4293dcb2014-12-02 15:48:05 -0500687 if line_count == 0:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800688 batch_install_lat.append( int( result ) )
andrewonlab4293dcb2014-12-02 15:48:05 -0500689 elif line_count == 1:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800690 batch_withdraw_lat.append( int( result ) )
andrewonlab4293dcb2014-12-02 15:48:05 -0500691 line_count += 1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800692 main.log.info( "Batch install latency for ONOS" +
693 str( node ) + " with " +
694 str( batch_intent_size ) + "intents: " +
695 str( batch_install_lat ) )
696
697 if len( batch_install_lat ) > 0 and int( i ) > num_ignore:
698 max_install_lat.append( max( batch_install_lat ) )
699 elif len( batch_install_lat ) == 0:
700 # If I failed to read anything from the file,
701 # increase the wait time before checking intents
andrewonlabeb1d0542014-12-03 20:12:01 -0500702 sleep_time += 30
703 batch_install_lat = []
704
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800705 # Sleep in between iterations
706 time.sleep( 5 )
andrewonlab70decc02014-11-19 18:50:23 -0500707
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800708 main.log.report( "Avg of batch installation latency " +
709 ": " +
710 str( sum( max_install_lat ) /
711 len( max_install_lat ) ) )
712 main.log.report( "Std Deviation of batch installation latency " +
713 ": " +
714 str( numpy.std( max_install_lat ) ) )
andrewonlabeb1d0542014-12-03 20:12:01 -0500715
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800716 def CASE5( self, main ):
717 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500718 Increase number of nodes and initiate CLI
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800719 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500720 import time
721 import json
722
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800723 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
724 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
725 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
726 ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
727 ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
728 ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
729 ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlab4293dcb2014-12-02 15:48:05 -0500730
731 global cluster_count
732 cluster_count += 2
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800733 main.log.report( "Increasing cluster size to " +
734 str( cluster_count ) )
andrewonlab4293dcb2014-12-02 15:48:05 -0500735
736 install_result = main.FALSE
737
738 if cluster_count == 3:
739 install_result1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800740 main.ONOSbench.onos_install( node=ONOS2_ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500741 install_result2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800742 main.ONOSbench.onos_install( node=ONOS3_ip )
743 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500744
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800745 main.log.info( "Starting ONOS CLI" )
746 main.ONOS2cli.start_onos_cli( ONOS2_ip )
747 main.ONOS3cli.start_onos_cli( ONOS3_ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500748
749 install_result = install_result1 and install_result2
750
751 if cluster_count == 5:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800752 main.log.info( "Installing ONOS on node 4 and 5" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500753 install_result1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800754 main.ONOSbench.onos_install( node=ONOS4_ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500755 install_result2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800756 main.ONOSbench.onos_install( node=ONOS5_ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500757
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800758 main.log.info( "Starting ONOS CLI" )
759 main.ONOS4cli.start_onos_cli( ONOS4_ip )
760 main.ONOS5cli.start_onos_cli( ONOS5_ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500761
762 install_result = install_result1 and install_result2
763
764 if cluster_count == 7:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800765 main.log.info( "Installing ONOS on node 6 and 7" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500766 install_result1 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800767 main.ONOSbench.onos_install( node=ONOS6_ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500768 install_result2 = \
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800769 main.ONOSbench.onos_install( node=ONOS7_ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500770
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800771 main.log.info( "Starting ONOS CLI" )
772 main.ONOS6cli.start_onos_cli( ONOS6_ip )
773 main.ONOS7cli.start_onos_cli( ONOS7_ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500774
775 install_result = install_result1 and install_result2
776
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800777 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500778
779 if install_result == main.TRUE:
780 assertion = main.TRUE
781 else:
782 assertion = main.FALSE
783
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800784 utilities.assert_equals(
785 expect=main.TRUE,
786 actual=assertion,
787 onpass="Scale out to " +
788 str( cluster_count ) +
789 " nodes successful",
790 onfail="Scale out to " +
791 str( cluster_count ) +
792 " nodes failed" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500793
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800794 def CASE9( self, main ):
andrewonlabeb1d0542014-12-03 20:12:01 -0500795 count = 0
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800796 sw_num1 = 1
andrewonlabeb1d0542014-12-03 20:12:01 -0500797 sw_num2 = 1
798 appid = 0
799 port_num1 = 1
800 port_num2 = 1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800801
802 time.sleep( 30 )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500803
andrewonlabeb1d0542014-12-03 20:12:01 -0500804 while True:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800805 # main.ONOS1cli.push_test_intents(
andrewonlabeb1d0542014-12-03 20:12:01 -0500806 #"of:0000000000001001/1",
807 #"of:0000000000002001/1",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800808 # 100, num_mult="10", app_id="1" )
809 # main.ONOS2cli.push_test_intents(
andrewonlabeb1d0542014-12-03 20:12:01 -0500810 # "of:0000000000001002/1",
811 # "of:0000000000002002/1",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800812 # 100, num_mult="10", app_id="2" )
813 # main.ONOS2cli.push_test_intents(
andrewonlabeb1d0542014-12-03 20:12:01 -0500814 # "of:0000000000001003/1",
815 # "of:0000000000002003/1",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800816 # 100, num_mult="10", app_id="3" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500817 count += 1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800818
andrewonlabeb1d0542014-12-03 20:12:01 -0500819 if count >= 100:
820 main.ONOSbench.handle.sendline(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800821 "onos 10.128.174.1 intents-events-metrics >>" +
822 " /tmp/metrics_intents_temp.txt &" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500823 count = 0
824
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800825 arg1 = "of:000000000000100" + \
826 str( sw_num1 ) + "/" + str( port_num1 )
827 arg2 = "of:000000000000200" + \
828 str( sw_num2 ) + "/" + str( port_num2 )
829
andrewonlabeb1d0542014-12-03 20:12:01 -0500830 sw_num1 += 1
831
832 if sw_num1 > 7:
833 sw_num1 = 1
834 sw_num2 += 1
835 if sw_num2 > 7:
836 appid += 1
837
838 if sw_num2 > 7:
839 sw_num2 = 1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800840
andrewonlabeb1d0542014-12-03 20:12:01 -0500841 main.ONOSbench.push_test_intents_shell(
842 arg1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800843 arg2,
andrewonlab042b3912014-12-10 16:40:50 -0500844 100, "/tmp/temp.txt", "10.128.174.1",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800845 num_mult="10", app_id=appid, report=False )
846 # main.ONOSbench.push_test_intents_shell(
andrewonlabeb1d0542014-12-03 20:12:01 -0500847 # "of:0000000000001002/1",
848 # "of:0000000000002002/1",
849 # 133, "/tmp/temp2.txt", "10.128.174.2",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800850 # num_mult="6", app_id="2",report=False )
851 # main.ONOSbench.push_test_intents_shell(
andrewonlabeb1d0542014-12-03 20:12:01 -0500852 # "of:0000000000001003/1",
853 # "of:0000000000002003/1",
854 # 133, "/tmp/temp3.txt", "10.128.174.3",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800855 # num_mult="6", app_id="3",report=False )
andrewonlab92ea3672014-11-04 20:22:14 -0500856
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800857 time.sleep( 0.2 )