blob: c114e48daf5591f968723495c7446d759917f7a7 [file] [log] [blame]
kelvin-onlab8a832582015-01-16 17:06:11 -08001# TopoPerfNext
andrewonlabadd2fd62014-11-11 18:37:35 -05002#
kelvin-onlab8a832582015-01-16 17:06:11 -08003# Topology Convergence scale-out test for ONOS-next
4# NOTE: This test supports up to 7 nodes scale-out scenario
andrewonlabadd2fd62014-11-11 18:37:35 -05005#
kelvin-onlab8a832582015-01-16 17:06:11 -08006# NOTE: Ensure that you have 'tablet.json' file
andrewonlaba036b402014-11-17 13:47:46 -05007# in the onos/tools/package/config directory
kelvin-onlab8a832582015-01-16 17:06:11 -08008# NOTE: You must start this test initially with 3 nodes
andrewonlaba036b402014-11-17 13:47:46 -05009#
kelvin-onlab8a832582015-01-16 17:06:11 -080010# andrew@onlab.us
andrewonlabadd2fd62014-11-11 18:37:35 -050011
12import time
13import sys
14import os
15import re
16
kelvin-onlab8a832582015-01-16 17:06:11 -080017
andrewonlabadd2fd62014-11-11 18:37:35 -050018class TopoConvNext:
kelvin-onlab8a832582015-01-16 17:06:11 -080019
20 def __init__( self ):
andrewonlabadd2fd62014-11-11 18:37:35 -050021 self.default = ''
22
kelvin-onlab8a832582015-01-16 17:06:11 -080023 def CASE1( self, main ):
24 """
andrewonlabadd2fd62014-11-11 18:37:35 -050025 ONOS startup sequence
kelvin-onlab8a832582015-01-16 17:06:11 -080026 """
andrewonlabadd2fd62014-11-11 18:37:35 -050027 import time
andrewonlab54cec4b2014-11-12 13:30:23 -050028
29 #******
kelvin-onlab8a832582015-01-16 17:06:11 -080030 # Global cluster count for scale-out purposes
31 global cluster_count
andrewonlab7b4e8ba2014-11-20 17:45:04 -050032 global topo_iteration
33 topo_iteration = 1
kelvin-onlab8a832582015-01-16 17:06:11 -080034 cluster_count = 1
andrewonlab54cec4b2014-11-12 13:30:23 -050035 #******
kelvin-onlab8a832582015-01-16 17:06:11 -080036 cell_name = main.params[ 'ENV' ][ 'cellName' ]
andrewonlabadd2fd62014-11-11 18:37:35 -050037
kelvin-onlab8a832582015-01-16 17:06:11 -080038 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
39 checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
andrewonlabadd2fd62014-11-11 18:37:35 -050040
kelvin-onlab8a832582015-01-16 17:06:11 -080041 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
42 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
43 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
44 ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
45 ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
46 ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
47 ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
48 MN1_ip = main.params[ 'MN' ][ 'ip1' ]
49 BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
andrewonlabadd2fd62014-11-11 18:37:35 -050050
kelvin-onlab8a832582015-01-16 17:06:11 -080051 main.case( "Setting up test environment" )
52 main.log.info( "copying topology event accumulator config file" +
53 " to ONOS package/etc/ directory" )
54 topo_config_name = main.params[ 'TEST' ][ 'topo_config_name' ]
andrewonlab0e1825c2014-11-20 20:07:00 -050055 topo_config =\
kelvin-onlab8a832582015-01-16 17:06:11 -080056 main.params[ 'TEST' ][ 'topo_accumulator_config' ]
57 main.ONOSbench.handle.sendline( "cp ~/" + topo_config +
58 " ~/ONOS/tools/package/etc/" +
59 topo_config_name )
60 main.ONOSbench.handle.expect( "\$" )
andrewonlab0e1825c2014-11-20 20:07:00 -050061
kelvin-onlab8a832582015-01-16 17:06:11 -080062 main.log.info( "Uninstalling previous instances" )
63 #main.ONOSbench.onos_uninstall( node_ip=ONOS1_ip )
64 main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip )
65 main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip )
66 main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
67 main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
68 main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
69 main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
andrewonlabadd2fd62014-11-11 18:37:35 -050070
kelvin-onlab8a832582015-01-16 17:06:11 -080071 main.log.report( "Setting up test environment" )
72
73 main.step( "Creating cell file" )
andrewonlabadd2fd62014-11-11 18:37:35 -050074 cell_file_result = main.ONOSbench.create_cell_file(
kelvin-onlab8a832582015-01-16 17:06:11 -080075 BENCH_ip, cell_name, MN1_ip,
76 "onos-core,onos-app-metrics",
77 # ONOS1_ip, ONOS2_ip, ONOS3_ip )
78 ONOS1_ip )
andrewonlabbdc3d862014-11-25 12:40:41 -050079
kelvin-onlab8a832582015-01-16 17:06:11 -080080 main.step( "Applying cell file to environment" )
81 cell_apply_result = main.ONOSbench.set_cell( cell_name )
82 verify_cell_result = main.ONOSbench.verify_cell()
83
84 main.step( "Removing raft logs" )
85 main.ONOSbench.onos_remove_raft_logs()
86 time.sleep( 10 )
87
88 main.step( "Git checkout and pull " + checkout_branch )
andrewonlabadd2fd62014-11-11 18:37:35 -050089 if git_pull == 'on':
90 checkout_result = \
kelvin-onlab8a832582015-01-16 17:06:11 -080091 main.ONOSbench.git_checkout( checkout_branch )
andrewonlabadd2fd62014-11-11 18:37:35 -050092 pull_result = main.ONOSbench.git_pull()
93 else:
94 checkout_result = main.TRUE
95 pull_result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -080096 main.log.info( "Skipped git checkout and pull" )
andrewonlabadd2fd62014-11-11 18:37:35 -050097
kelvin-onlab8a832582015-01-16 17:06:11 -080098 main.log.report( "Commit information - " )
andrewonlab62749022014-11-19 19:19:58 -050099 main.ONOSbench.get_version()
100
kelvin-onlab8a832582015-01-16 17:06:11 -0800101 main.step( "Using mvn clean & install" )
andrewonlabadd2fd62014-11-11 18:37:35 -0500102 #mvn_result = main.ONOSbench.clean_install()
103 mvn_result = main.TRUE
104
kelvin-onlab8a832582015-01-16 17:06:11 -0800105 main.step( "Set cell for ONOS cli env" )
106 main.ONOS1cli.set_cell( cell_name )
107 # main.ONOS2cli.set_cell( cell_name )
108 # main.ONOS3cli.set_cell( cell_name )
109
110 main.step( "Creating ONOS package" )
andrewonlabadd2fd62014-11-11 18:37:35 -0500111 package_result = main.ONOSbench.onos_package()
112
kelvin-onlab8a832582015-01-16 17:06:11 -0800113 # Start test with single node only
114 main.step( "Installing ONOS package" )
115 install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
116 #install2_result = main.ONOSbench.onos_install( node=ONOS2_ip )
117 #install3_result = main.ONOSbench.onos_install( node=ONOS3_ip )
andrewonlabadd2fd62014-11-11 18:37:35 -0500118
kelvin-onlab8a832582015-01-16 17:06:11 -0800119 time.sleep( 10 )
andrewonlabadd2fd62014-11-11 18:37:35 -0500120
kelvin-onlab8a832582015-01-16 17:06:11 -0800121 main.step( "Start onos cli" )
122 cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
123 #cli2 = main.ONOS2cli.start_onos_cli( ONOS2_ip )
124 #cli3 = main.ONOS3cli.start_onos_cli( ONOS3_ip )
andrewonlabadd2fd62014-11-11 18:37:35 -0500125
kelvin-onlab8a832582015-01-16 17:06:11 -0800126 main.step( "Enable metrics feature" )
127 # main.ONOS1cli.feature_install( "onos-app-metrics" )
andrewonlabadd2fd62014-11-11 18:37:35 -0500128
kelvin-onlab8a832582015-01-16 17:06:11 -0800129 utilities.assert_equals( expect=main.TRUE,
130 actual=cell_file_result and cell_apply_result and
131 verify_cell_result and checkout_result and
132 pull_result and mvn_result and
133 install1_result, # and install2_result and
134 # install3_result,
135 onpass="Test Environment setup successful",
136 onfail="Failed to setup test environment" )
137
138 def CASE2( self, main ):
139 """
andrewonlabadd2fd62014-11-11 18:37:35 -0500140 100 Switch discovery latency
141
142 Important:
kelvin-onlab8a832582015-01-16 17:06:11 -0800143 This test case can be potentially dangerous if
andrewonlabadd2fd62014-11-11 18:37:35 -0500144 your machine has previously set iptables rules.
145 One of the steps of the test case will flush
146 all existing iptables rules.
147 Note:
kelvin-onlab8a832582015-01-16 17:06:11 -0800148 You can specify the number of switches in the
andrewonlabadd2fd62014-11-11 18:37:35 -0500149 params file to adjust the switch discovery size
kelvin-onlab8a832582015-01-16 17:06:11 -0800150 ( and specify the corresponding topology in Mininet1
151 .topo file )
152 """
andrewonlabadd2fd62014-11-11 18:37:35 -0500153 import time
154 import subprocess
155 import os
156 import requests
157 import json
andrewonlab51b180b2014-11-12 18:19:28 -0500158 import numpy
andrewonlabadd2fd62014-11-11 18:37:35 -0500159
160 ONOS_ip_list = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800161 ONOS_ip_list.append( '0' )
162 ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip1' ] )
163 ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip2' ] )
164 ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip3' ] )
165 ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip4' ] )
166 ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip5' ] )
167 ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip6' ] )
168 ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip7' ] )
169 MN1_ip = main.params[ 'MN' ][ 'ip1' ]
170 ONOS_user = main.params[ 'CTRL' ][ 'user' ]
andrewonlabadd2fd62014-11-11 18:37:35 -0500171
kelvin-onlab8a832582015-01-16 17:06:11 -0800172 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
173
174 # Number of iterations of case
175 num_iter = main.params[ 'TEST' ][ 'numIter' ]
176 iter_ignore = int( main.params[ 'TEST' ][ 'iterIgnore' ] )
andrewonlab0e1825c2014-11-20 20:07:00 -0500177
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500178 #***********
kelvin-onlab8a832582015-01-16 17:06:11 -0800179 # Global number of switches that change
180 # throughout the test
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500181 global num_sw
kelvin-onlab8a832582015-01-16 17:06:11 -0800182 global topo_iteration
andrewonlabbdc3d862014-11-25 12:40:41 -0500183 global cluster_count
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500184 if topo_iteration == 1:
kelvin-onlab8a832582015-01-16 17:06:11 -0800185 num_sw = main.params[ 'TEST' ][ 'numSwitch1' ]
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500186 elif topo_iteration == 2:
kelvin-onlab8a832582015-01-16 17:06:11 -0800187 num_sw = main.params[ 'TEST' ][ 'numSwitch2' ]
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500188 elif topo_iteration == 3:
kelvin-onlab8a832582015-01-16 17:06:11 -0800189 num_sw = main.params[ 'TEST' ][ 'numSwitch3' ]
andrewonlab28b84eb2014-12-02 15:53:35 -0500190 elif topo_iteration == 4:
kelvin-onlab8a832582015-01-16 17:06:11 -0800191 num_sw = main.params[ 'TEST' ][ 'numSwitch4' ]
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500192 #***********
andrewonlabadd2fd62014-11-11 18:37:35 -0500193
kelvin-onlab8a832582015-01-16 17:06:11 -0800194 # Timestamp 'keys' for json metrics output.
195 # These are subject to change, hence moved into params
196 deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
197 graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
198
199 # Threshold for this test case
200 sw_disc_threshold_str = main.params[ 'TEST' ][ 'swDisc100Threshold' ]
201 sw_disc_threshold_obj = sw_disc_threshold_str.split( "," )
202 sw_disc_threshold_min = int( sw_disc_threshold_obj[ 0 ] )
203 sw_disc_threshold_max = int( sw_disc_threshold_obj[ 1 ] )
andrewonlabadd2fd62014-11-11 18:37:35 -0500204
andrewonlab51b180b2014-11-12 18:19:28 -0500205 assertion = main.TRUE
andrewonlabadd2fd62014-11-11 18:37:35 -0500206 sw_discovery_lat_list = []
andrewonlaba1272172014-11-17 17:30:35 -0500207 syn_ack_delta_list = []
andrewonlabadd2fd62014-11-11 18:37:35 -0500208
kelvin-onlab8a832582015-01-16 17:06:11 -0800209 main.case( str( num_sw ) + " switches distributed across " +
210 str( cluster_count ) + " nodes convergence latency" )
211
212 main.log.report( "Large topology convergence and scale-out test" )
213 main.log.report( "Currently active ONOS node(s): " )
andrewonlab0d4478f2014-11-11 20:31:20 -0500214 report_str = "Node "
kelvin-onlab8a832582015-01-16 17:06:11 -0800215 for node in range( 1, cluster_count + 1 ):
216 report_str += ( str( node ) + " " )
217 main.log.report( report_str )
218 main.log.report( "Topology size: " + str( num_sw ) + " switches" )
andrewonlab0e1825c2014-11-20 20:07:00 -0500219
kelvin-onlab8a832582015-01-16 17:06:11 -0800220 main.step( "Distributing " + num_sw + " switches to each ONOS" )
221 index = 1
222 for node in range( 1, cluster_count + 1 ):
223 for i in range( index, ( int( num_sw ) / cluster_count ) + index ):
andrewonlab0d4478f2014-11-11 20:31:20 -0500224 main.Mininet1.assign_sw_controller(
kelvin-onlab8a832582015-01-16 17:06:11 -0800225 sw=str( i ),
226 ip1=ONOS_ip_list[ node ],
227 port1=default_sw_port )
228 index = i + 1
229 # for i in range( 1, int( num_sw )+1 ):
230 # main.Mininet1.assign_sw_controller(
231 # sw=str( i ),
232 # ip1="10.128.174.1",
233 # port1="6633" )
andrewonlab54cec4b2014-11-12 13:30:23 -0500234
kelvin-onlab8a832582015-01-16 17:06:11 -0800235 main.log.info( "Please check ptpd configuration to ensure " +
236 "all nodes' system times are in sync" )
andrewonlab54cec4b2014-11-12 13:30:23 -0500237
kelvin-onlab8a832582015-01-16 17:06:11 -0800238 time.sleep( 10 )
andrewonlab54cec4b2014-11-12 13:30:23 -0500239
kelvin-onlab8a832582015-01-16 17:06:11 -0800240 for i in range( 0, int( num_iter ) ):
241 main.step( "Set iptables rule to block sw connections" )
242
243 # INPUT rules
andrewonlab51b180b2014-11-12 18:19:28 -0500244 main.ONOS1.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800245 "sudo iptables -A INPUT -p tcp -s " +
246 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500247 main.ONOS2.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800248 "sudo iptables -A INPUT -p tcp -s " +
249 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500250 main.ONOS3.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800251 "sudo iptables -A INPUT -p tcp -s " +
252 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500253 main.ONOS4.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800254 "sudo iptables -A INPUT -p tcp -s " +
255 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500256 main.ONOS5.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800257 "sudo iptables -A INPUT -p tcp -s " +
258 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500259 main.ONOS6.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800260 "sudo iptables -A INPUT -p tcp -s " +
261 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500262 main.ONOS7.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800263 "sudo iptables -A INPUT -p tcp -s " +
264 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
265
266 # OUTPUT rules
andrewonlab51b180b2014-11-12 18:19:28 -0500267 main.ONOS1.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800268 "sudo iptables -A OUTPUT -p tcp -s " +
269 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500270 main.ONOS2.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800271 "sudo iptables -A OUTPUT -p tcp -s " +
272 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500273 main.ONOS3.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800274 "sudo iptables -A OUTPUT -p tcp -s " +
275 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500276 main.ONOS4.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800277 "sudo iptables -A OUTPUT -p tcp -s " +
278 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500279 main.ONOS5.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800280 "sudo iptables -A OUTPUT -p tcp -s " +
281 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500282 main.ONOS6.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800283 "sudo iptables -A OUTPUT -p tcp -s " +
284 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab51b180b2014-11-12 18:19:28 -0500285 main.ONOS7.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -0800286 "sudo iptables -A OUTPUT -p tcp -s " +
287 MN1_ip + " --dport " + default_sw_port + " -j DROP" )
andrewonlab0d4478f2014-11-11 20:31:20 -0500288
kelvin-onlab8a832582015-01-16 17:06:11 -0800289 main.log.info( "Please wait for switch connection to timeout" )
andrewonlab62749022014-11-19 19:19:58 -0500290
kelvin-onlab8a832582015-01-16 17:06:11 -0800291 # time.sleep( 60 )
292 # if cluster_count >= 3:
293 # time.sleep( 60 )
294 # if cluster_count >= 5:
295 # time.sleep( 30 )
296 # if cluster_count >= 6:
297 # time.sleep( 30 )
andrewonlaba036b402014-11-17 13:47:46 -0500298
299 if cluster_count >= 3:
kelvin-onlab8a832582015-01-16 17:06:11 -0800300 main.ONOS1.handle.sendline(
301 "tshark -i eth0 -t e | " +
302 "grep 'SYN, ACK' | grep '6633' >" +
303 "/tmp/syn_ack_onos1_iter" +
304 str( i ) +
305 ".txt &" )
306 main.ONOS2.handle.sendline(
307 "tshark -i eth0 -t e | " +
308 "grep 'SYN, ACK' | grep '6633' >" +
309 "/tmp/syn_ack_onos2_iter" +
310 str( i ) +
311 ".txt &" )
312 main.ONOS3.handle.sendline(
313 "tshark -i eth0 -t e | " +
314 "grep 'SYN, ACK' | grep '6633' >" +
315 "/tmp/syn_ack_onos3_iter" +
316 str( i ) +
317 ".txt &" )
andrewonlaba036b402014-11-17 13:47:46 -0500318 if cluster_count >= 4:
kelvin-onlab8a832582015-01-16 17:06:11 -0800319 main.ONOS4.handle.sendline(
320 "tshark -i eth0 -t e | " +
321 "grep 'SYN, ACK' | grep '6633' >" +
322 "/tmp/syn_ack_onos4_iter" +
323 str( i ) +
324 ".txt &" )
andrewonlaba036b402014-11-17 13:47:46 -0500325 if cluster_count >= 5:
kelvin-onlab8a832582015-01-16 17:06:11 -0800326 main.ONOS5.handle.sendline(
327 "tshark -i eth0 -t e | " +
328 "grep 'SYN, ACK' | grep '6633' >" +
329 "/tmp/syn_ack_onos5_iter" +
330 str( i ) +
331 ".txt &" )
andrewonlaba036b402014-11-17 13:47:46 -0500332 if cluster_count >= 6:
kelvin-onlab8a832582015-01-16 17:06:11 -0800333 main.ONOS6.handle.sendline(
334 "tshark -i eth0 -t e | " +
335 "grep 'SYN, ACK' | grep '6633' >" +
336 "/tmp/syn_ack_onos6_iter" +
337 str( i ) +
338 ".txt &" )
andrewonlaba036b402014-11-17 13:47:46 -0500339 if cluster_count == 7:
kelvin-onlab8a832582015-01-16 17:06:11 -0800340 main.ONOS7.handle.sendline(
341 "tshark -i eth0 -t e | " +
342 "grep 'SYN, ACK' | grep '6633' >" +
343 "/tmp/syn_ack_onos6_iter" +
344 str( i ) +
345 ".txt &" )
346
347 # NOTE:
348 # Delay before checking devices to
andrewonlabf50ad012014-11-25 15:48:37 -0500349 # help prevent timing out from CLI
kelvin-onlab8a832582015-01-16 17:06:11 -0800350 # due to multiple command issuing
351 time.sleep( 20 )
andrewonlabf50ad012014-11-25 15:48:37 -0500352
353 loop = True
andrewonlab62749022014-11-19 19:19:58 -0500354 loop_count = 0
andrewonlabbdc3d862014-11-25 12:40:41 -0500355 device_count = 0
kelvin-onlab8a832582015-01-16 17:06:11 -0800356 while loop_count < 60 and loop:
357 main.log.info( "Checking devices for device down" )
358
andrewonlabf50ad012014-11-25 15:48:37 -0500359 temp_len = 0
andrewonlabbdc3d862014-11-25 12:40:41 -0500360 device_str1 = main.ONOS1cli.devices(
kelvin-onlab8a832582015-01-16 17:06:11 -0800361 node_ip=ONOS_ip_list[ 1 ] )
362 device_json1 = json.loads( device_str1 )
363 json_len = len( device_json1 )
364
365 # NOTE: May want to check the rest of
andrewonlab28b84eb2014-12-02 15:53:35 -0500366 # the ONOS instances for device down as well
367
kelvin-onlab8a832582015-01-16 17:06:11 -0800368 for device1 in device_json1:
andrewonlabf50ad012014-11-25 15:48:37 -0500369 temp_len = temp_len + 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800370 if device1[ 'available' ]:
andrewonlabf50ad012014-11-25 15:48:37 -0500371 loop = True
372 break
kelvin-onlab8a832582015-01-16 17:06:11 -0800373 # if I'm on the last json object and I still haven't
374 # broken out of the loop, it means there were
375 # no available devices
376 elif temp_len == json_len - 1:
377 main.log.info( "Temp length: " + str( temp_len ) )
378 main.step( "Flushing iptables and obtaining t0" )
379 t0_system = time.time() * 1000
380
381 main.ONOS1.handle.sendline( "sudo iptables -F" )
382 main.ONOS2.handle.sendline( "sudo iptables -F" )
383 main.ONOS3.handle.sendline( "sudo iptables -F" )
384 main.ONOS4.handle.sendline( "sudo iptables -F" )
385 main.ONOS5.handle.sendline( "sudo iptables -F" )
386 main.ONOS6.handle.sendline( "sudo iptables -F" )
387 main.ONOS7.handle.sendline( "sudo iptables -F" )
388
andrewonlabf50ad012014-11-25 15:48:37 -0500389 loop = False
390 break
andrewonlabadd2fd62014-11-11 18:37:35 -0500391
kelvin-onlab8a832582015-01-16 17:06:11 -0800392 loop_count += 1
393 time.sleep( 1 )
394
395 main.log.info( "System time t0: " + str( t0_system ) )
andrewonlab51b180b2014-11-12 18:19:28 -0500396
397 counter_loop = 0
398 counter_avail1 = 0
399 counter_avail2 = 0
400 counter_avail3 = 0
401 counter_avail4 = 0
402 counter_avail5 = 0
403 counter_avail6 = 0
404 counter_avail7 = 0
405 onos1_dev = False
406 onos2_dev = False
407 onos3_dev = False
408 onos4_dev = False
409 onos5_dev = False
410 onos6_dev = False
411 onos7_dev = False
412
kelvin-onlab8a832582015-01-16 17:06:11 -0800413 # TODO: Think of a more elegant way to check all
andrewonlab51b180b2014-11-12 18:19:28 -0500414 # switches across all nodes
kelvin-onlab8a832582015-01-16 17:06:11 -0800415 # Goodluck debugging this loop
andrewonlab51b180b2014-11-12 18:19:28 -0500416 while counter_loop < 60:
kelvin-onlab8a832582015-01-16 17:06:11 -0800417 for node in range( 1, cluster_count + 1 ):
andrewonlab51b180b2014-11-12 18:19:28 -0500418 if node == 1 and not onos1_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800419 main.log.info( "Checking node 1 for device " +
420 "discovery" )
andrewonlab5b8c02f2014-11-21 17:56:10 -0500421 device_str_obj1 = main.ONOS1cli.devices(
kelvin-onlab8a832582015-01-16 17:06:11 -0800422 node_ip=ONOS_ip_list[ 1 ] )
423 device_json1 = json.loads( device_str_obj1 )
andrewonlab51b180b2014-11-12 18:19:28 -0500424 for device1 in device_json1:
kelvin-onlab8a832582015-01-16 17:06:11 -0800425 if device1[ 'available' ]:
andrewonlab51b180b2014-11-12 18:19:28 -0500426 counter_avail1 += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 if counter_avail1 == int( num_sw ):
andrewonlab51b180b2014-11-12 18:19:28 -0500428 onos1_dev = True
kelvin-onlab8a832582015-01-16 17:06:11 -0800429 main.log.info( "All devices have been" +
430 " discovered on ONOS1" )
andrewonlabfd8325f2014-11-12 19:14:06 -0500431 else:
432 counter_avail1 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500433 if node == 2 and not onos2_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800434 main.log.info( "Checking node 2 for device " +
435 "discovery" )
andrewonlab5b8c02f2014-11-21 17:56:10 -0500436 device_str_obj2 = main.ONOS2cli.devices(
kelvin-onlab8a832582015-01-16 17:06:11 -0800437 node_ip=ONOS_ip_list[ 2 ] )
438 device_json2 = json.loads( device_str_obj2 )
andrewonlab51b180b2014-11-12 18:19:28 -0500439 for device2 in device_json2:
kelvin-onlab8a832582015-01-16 17:06:11 -0800440 if device2[ 'available' ]:
andrewonlab51b180b2014-11-12 18:19:28 -0500441 counter_avail2 += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800442 if counter_avail2 == int( num_sw ):
andrewonlab51b180b2014-11-12 18:19:28 -0500443 onos2_dev = True
kelvin-onlab8a832582015-01-16 17:06:11 -0800444 main.log.info( "All devices have been" +
445 " discovered on ONOS2" )
andrewonlabfd8325f2014-11-12 19:14:06 -0500446 else:
447 counter_avail2 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500448 if node == 3 and not onos3_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800449 main.log.info( "Checking node 3 for device " +
450 "discovery" )
andrewonlab5b8c02f2014-11-21 17:56:10 -0500451 device_str_obj3 = main.ONOS3cli.devices(
kelvin-onlab8a832582015-01-16 17:06:11 -0800452 node_ip=ONOS_ip_list[ 3 ] )
453 device_json3 = json.loads( device_str_obj3 )
andrewonlab51b180b2014-11-12 18:19:28 -0500454 for device3 in device_json3:
kelvin-onlab8a832582015-01-16 17:06:11 -0800455 if device3[ 'available' ]:
andrewonlab51b180b2014-11-12 18:19:28 -0500456 counter_avail3 += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800457 if counter_avail3 == int( num_sw ):
andrewonlab51b180b2014-11-12 18:19:28 -0500458 onos3_dev = True
kelvin-onlab8a832582015-01-16 17:06:11 -0800459 main.log.info( "All devices have been" +
460 " discovered on ONOS3" )
andrewonlabfd8325f2014-11-12 19:14:06 -0500461 else:
462 counter_avail3 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500463 if node == 4 and not onos4_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800464 main.log.info( "Checking node 4 for device " +
465 "discovery" )
andrewonlab5b8c02f2014-11-21 17:56:10 -0500466 device_str_obj4 = main.ONOS4cli.devices(
kelvin-onlab8a832582015-01-16 17:06:11 -0800467 node_ip=ONOS_ip_list[ 4 ] )
468 device_json4 = json.loads( device_str_obj4 )
andrewonlab51b180b2014-11-12 18:19:28 -0500469 for device4 in device_json4:
kelvin-onlab8a832582015-01-16 17:06:11 -0800470 if device4[ 'available' ]:
andrewonlab51b180b2014-11-12 18:19:28 -0500471 counter_avail4 += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800472 if counter_avail4 == int( num_sw ):
andrewonlab51b180b2014-11-12 18:19:28 -0500473 onos4_dev = True
kelvin-onlab8a832582015-01-16 17:06:11 -0800474 main.log.info( "All devices have been" +
475 " discovered on ONOS4" )
andrewonlabfd8325f2014-11-12 19:14:06 -0500476 else:
477 counter_avail4 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500478 if node == 5 and not onos5_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800479 main.log.info( "Checking node 5 for device " +
480 "discovery" )
andrewonlab5b8c02f2014-11-21 17:56:10 -0500481 device_str_obj5 = main.ONOS5cli.devices(
kelvin-onlab8a832582015-01-16 17:06:11 -0800482 node_ip=ONOS_ip_list[ 5 ] )
483 device_json5 = json.loads( device_str_obj5 )
andrewonlab51b180b2014-11-12 18:19:28 -0500484 for device5 in device_json5:
kelvin-onlab8a832582015-01-16 17:06:11 -0800485 if device5[ 'available' ]:
andrewonlab51b180b2014-11-12 18:19:28 -0500486 counter_avail5 += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800487 if counter_avail5 == int( num_sw ):
andrewonlab51b180b2014-11-12 18:19:28 -0500488 onos5_dev = True
kelvin-onlab8a832582015-01-16 17:06:11 -0800489 main.log.info( "All devices have been" +
490 " discovered on ONOS5" )
andrewonlabfd8325f2014-11-12 19:14:06 -0500491 else:
492 counter_avail5 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500493 if node == 6 and not onos6_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800494 main.log.info( "Checking node 6 for device " +
495 "discovery" )
andrewonlab5b8c02f2014-11-21 17:56:10 -0500496 device_str_obj6 = main.ONOS6cli.devices(
kelvin-onlab8a832582015-01-16 17:06:11 -0800497 node_ip=ONOS_ip_list[ 6 ] )
498 device_json6 = json.loads( device_str_obj6 )
andrewonlab51b180b2014-11-12 18:19:28 -0500499 for device6 in device_json6:
kelvin-onlab8a832582015-01-16 17:06:11 -0800500 if device6[ 'available' ]:
andrewonlab51b180b2014-11-12 18:19:28 -0500501 counter_avail6 += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800502 if counter_avail6 == int( num_sw ):
andrewonlab51b180b2014-11-12 18:19:28 -0500503 onos6_dev = True
kelvin-onlab8a832582015-01-16 17:06:11 -0800504 main.log.info( "All devices have been" +
505 " discovered on ONOS6" )
andrewonlabfd8325f2014-11-12 19:14:06 -0500506 else:
507 counter_avail6 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500508 if node == 7 and not onos7_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800509 main.log.info( "Checking node 7 for device " +
510 "discovery" )
andrewonlab5b8c02f2014-11-21 17:56:10 -0500511 device_str_obj7 = main.ONOS7cli.devices(
kelvin-onlab8a832582015-01-16 17:06:11 -0800512 node_ip=ONOS_ip_list[ 7 ] )
513 device_json7 = json.loads( device_str_obj7 )
andrewonlab51b180b2014-11-12 18:19:28 -0500514 for device7 in device_json7:
kelvin-onlab8a832582015-01-16 17:06:11 -0800515 if device7[ 'available' ]:
andrewonlab51b180b2014-11-12 18:19:28 -0500516 counter_avail7 += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800517 if counter_avail7 == int( num_sw ):
andrewonlab51b180b2014-11-12 18:19:28 -0500518 onos7_dev = True
kelvin-onlab8a832582015-01-16 17:06:11 -0800519 main.log.info( "All devices have been" +
520 " discovered on ONOS7" )
andrewonlabfd8325f2014-11-12 19:14:06 -0500521 else:
522 counter_avail7 = 0
kelvin-onlab8a832582015-01-16 17:06:11 -0800523 # END node loop
524
525 # TODO: clean up this mess of an if statements if possible
526 # Treat each if as a separate test case with the given
andrewonlab51b180b2014-11-12 18:19:28 -0500527 # cluster count. Hence when the cluster count changes
528 # the desired calculations will be made
529 if cluster_count == 1:
530 if onos1_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800531 main.log.info( "All devices have been discovered" +
532 " on all ONOS instances" )
533 time.sleep( 5 )
andrewonlab51b180b2014-11-12 18:19:28 -0500534 json_str_metrics_1 =\
535 main.ONOS1cli.topology_events_metrics()
kelvin-onlab8a832582015-01-16 17:06:11 -0800536 json_obj_1 = json.loads( json_str_metrics_1 )
andrewonlab51b180b2014-11-12 18:19:28 -0500537 graph_timestamp_1 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800538 json_obj_1[ graphTimestamp ][ 'value' ]
539
andrewonlab51b180b2014-11-12 18:19:28 -0500540 graph_lat_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800541 int( graph_timestamp_1 ) - int( t0_system )
542
543 main.log.info( "Graph Timestamp ONOS1: " +
544 str( graph_timestamp_1 ) )
andrewonlabbdc3d862014-11-25 12:40:41 -0500545
andrewonlab51b180b2014-11-12 18:19:28 -0500546 if graph_lat_1 > sw_disc_threshold_min\
kelvin-onlab8a832582015-01-16 17:06:11 -0800547 and graph_lat_1 < sw_disc_threshold_max\
548 and int( i ) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500549 sw_discovery_lat_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800550 graph_lat_1 )
551 main.log.info(
552 "Sw discovery latency of " +
553 str( cluster_count ) +
554 " node(s): " +
555 str( graph_lat_1 ) +
556 " ms" )
andrewonlab51b180b2014-11-12 18:19:28 -0500557 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800558 main.log.info( "Switch discovery latency " +
559 "exceeded the threshold." )
560 main.log.info( str( graph_lat_1 ) + " ms" )
561 # Break while loop
andrewonlab51b180b2014-11-12 18:19:28 -0500562 break
563 if cluster_count == 2:
564 if onos1_dev and onos2_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800565 main.log.info( "All devices have been discovered" +
566 " on all " + str( cluster_count ) +
567 " ONOS instances" )
568 time.sleep( 5 )
andrewonlab5b8c02f2014-11-21 17:56:10 -0500569
andrewonlab51b180b2014-11-12 18:19:28 -0500570 json_str_metrics_1 =\
571 main.ONOS1cli.topology_events_metrics()
572 json_str_metrics_2 =\
573 main.ONOS2cli.topology_events_metrics()
kelvin-onlab8a832582015-01-16 17:06:11 -0800574 json_obj_1 = json.loads( json_str_metrics_1 )
575 json_obj_2 = json.loads( json_str_metrics_2 )
andrewonlab51b180b2014-11-12 18:19:28 -0500576 graph_timestamp_1 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800577 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500578 graph_timestamp_2 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800579 json_obj_2[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500580
kelvin-onlab8a832582015-01-16 17:06:11 -0800581 graph_lat_1 = \
582 int( graph_timestamp_1 ) - int( t0_system )
583 graph_lat_2 = \
584 int( graph_timestamp_2 ) - int( t0_system )
585
586 main.log.info( "Graph Timestamp ONOS1: " +
587 str( graph_timestamp_1 ) )
588 main.log.info( "Graph Timestamp ONOS2: " +
589 str( graph_timestamp_2 ) )
590
591 max_graph_lat = max( graph_lat_1,
592 graph_lat_2, graph_lat_3 )
andrewonlab51b180b2014-11-12 18:19:28 -0500593
andrewonlabbdc3d862014-11-25 12:40:41 -0500594 if max_graph_lat > sw_disc_threshold_min\
kelvin-onlab8a832582015-01-16 17:06:11 -0800595 and max_graph_lat < sw_disc_threshold_max\
596 and int( i ) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500597 sw_discovery_lat_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800598 max_graph_lat )
599 main.log.info(
600 "Sw discovery latency of " +
601 str( cluster_count ) +
602 " node(s): " +
603 str( max_graph_lat ) +
604 " ms" )
andrewonlab51b180b2014-11-12 18:19:28 -0500605 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800606 main.log.info( "Switch discovery latency " +
607 "exceeded the threshold." )
608 main.log.info( str( max_graph_lat ) + " ms" )
andrewonlab51b180b2014-11-12 18:19:28 -0500609 break
610 if cluster_count == 3:
611 if onos1_dev and onos2_dev and onos3_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800612 main.log.info( "All devices have been discovered" +
613 " on all " + str( cluster_count ) +
614 " ONOS instances" )
615
616 # TODO: Investigate this sleep
617 # added to 'pad' the results with
andrewonlaba036b402014-11-17 13:47:46 -0500618 # plenty of time to 'catch up'
kelvin-onlab8a832582015-01-16 17:06:11 -0800619 time.sleep( 5 )
andrewonlaba036b402014-11-17 13:47:46 -0500620
andrewonlab51b180b2014-11-12 18:19:28 -0500621 json_str_metrics_1 =\
622 main.ONOS1cli.topology_events_metrics()
623 json_str_metrics_2 =\
624 main.ONOS2cli.topology_events_metrics()
625 json_str_metrics_3 =\
626 main.ONOS3cli.topology_events_metrics()
kelvin-onlab8a832582015-01-16 17:06:11 -0800627 json_obj_1 = json.loads( json_str_metrics_1 )
628 json_obj_2 = json.loads( json_str_metrics_2 )
629 json_obj_3 = json.loads( json_str_metrics_3 )
andrewonlab51b180b2014-11-12 18:19:28 -0500630 graph_timestamp_1 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800631 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500632 graph_timestamp_2 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800633 json_obj_2[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500634 graph_timestamp_3 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800635 json_obj_3[ graphTimestamp ][ 'value' ]
636
andrewonlab51b180b2014-11-12 18:19:28 -0500637 graph_lat_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800638 int( graph_timestamp_1 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500639 graph_lat_2 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800640 int( graph_timestamp_2 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500641 graph_lat_3 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800642 int( graph_timestamp_3 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500643
kelvin-onlab8a832582015-01-16 17:06:11 -0800644 main.log.info( "Graph Timestamp ONOS1: " +
645 str( graph_timestamp_1 ) )
646 main.log.info( "Graph Timestamp ONOS2: " +
647 str( graph_timestamp_2 ) )
648 main.log.info( "Graph Timestamp ONOS3: " +
649 str( graph_timestamp_3 ) )
andrewonlab62749022014-11-19 19:19:58 -0500650
kelvin-onlab8a832582015-01-16 17:06:11 -0800651 max_graph_lat = max( graph_lat_1,
652 graph_lat_2,
653 graph_lat_3 )
andrewonlabbdc3d862014-11-25 12:40:41 -0500654
655 if max_graph_lat > sw_disc_threshold_min\
kelvin-onlab8a832582015-01-16 17:06:11 -0800656 and max_graph_lat < sw_disc_threshold_max\
657 and int( i ) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500658 sw_discovery_lat_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800659 max_graph_lat )
660 main.log.info(
661 "Sw discovery latency of " +
662 str( cluster_count ) +
663 " node(s): " +
664 str( max_graph_lat ) +
665 " ms" )
andrewonlab51b180b2014-11-12 18:19:28 -0500666 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800667 main.log.info( "Switch discovery latency " +
668 "exceeded the threshold." )
669 main.log.info( str( max_graph_lat ) + " ms" )
670
andrewonlab51b180b2014-11-12 18:19:28 -0500671 break
672 if cluster_count == 4:
673 if onos1_dev and onos2_dev and onos3_dev and\
674 onos4_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800675 main.log.info( "All devices have been discovered" +
676 " on all ONOS instances" )
andrewonlab51b180b2014-11-12 18:19:28 -0500677 json_str_metrics_1 =\
678 main.ONOS1cli.topology_events_metrics()
679 json_str_metrics_2 =\
680 main.ONOS2cli.topology_events_metrics()
681 json_str_metrics_3 =\
682 main.ONOS3cli.topology_events_metrics()
683 json_str_metrics_4 =\
684 main.ONOS4cli.topology_events_metrics()
kelvin-onlab8a832582015-01-16 17:06:11 -0800685 json_obj_1 = json.loads( json_str_metrics_1 )
686 json_obj_2 = json.loads( json_str_metrics_2 )
687 json_obj_3 = json.loads( json_str_metrics_3 )
688 json_obj_4 = json.loads( json_str_metrics_4 )
andrewonlab51b180b2014-11-12 18:19:28 -0500689 graph_timestamp_1 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800690 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500691 graph_timestamp_2 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800692 json_obj_2[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500693 graph_timestamp_3 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800694 json_obj_3[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500695 graph_timestamp_4 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800696 json_obj_4[ graphTimestamp ][ 'value' ]
andrewonlabbdc3d862014-11-25 12:40:41 -0500697
kelvin-onlab8a832582015-01-16 17:06:11 -0800698 graph_lat_1 = \
699 int( graph_timestamp_1 ) - int( t0_system )
700 graph_lat_2 = \
701 int( graph_timestamp_2 ) - int( t0_system )
702 graph_lat_3 = \
703 int( graph_timestamp_3 ) - int( t0_system )
704 graph_lat_4 = \
705 int( graph_timestamp_4 ) - int( t0_system )
706
707 main.log.info( "Graph Timestamp ONOS1: " +
708 str( graph_timestamp_1 ) )
709 main.log.info( "Graph Timestamp ONOS2: " +
710 str( graph_timestamp_2 ) )
711 main.log.info( "Graph Timestamp ONOS3: " +
712 str( graph_timestamp_3 ) )
713 main.log.info( "Graph Timestamp ONOS4: " +
714 str( graph_timestamp_4 ) )
715
716 max_graph_lat = max( graph_lat_1,
717 graph_lat_2,
718 graph_lat_3,
719 graph_lat_4 )
720
andrewonlabbdc3d862014-11-25 12:40:41 -0500721 if max_graph_lat > sw_disc_threshold_min\
kelvin-onlab8a832582015-01-16 17:06:11 -0800722 and max_graph_lat < sw_disc_threshold_max\
723 and int( i ) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500724 sw_discovery_lat_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800725 max_graph_lat )
726 main.log.info(
727 "Sw discovery latency of " +
728 str( cluster_count ) +
729 " node(s): " +
730 str( max_graph_lat ) +
731 " ms" )
andrewonlab51b180b2014-11-12 18:19:28 -0500732 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800733 main.log.info( "Switch discovery latency " +
734 "exceeded the threshold." )
735 main.log.info( str( max_graph_lat ) + " ms" )
736
andrewonlab51b180b2014-11-12 18:19:28 -0500737 break
738 if cluster_count == 5:
739 if onos1_dev and onos2_dev and onos3_dev and\
740 onos4_dev and onos5_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800741 main.log.info( "All devices have been discovered" +
742 " on all ONOS instances" )
743
744 # TODO: Investigate this sleep
745 # added to 'pad' the results with
andrewonlaba036b402014-11-17 13:47:46 -0500746 # plenty of time to 'catch up'
kelvin-onlab8a832582015-01-16 17:06:11 -0800747 time.sleep( 5 )
748
andrewonlab51b180b2014-11-12 18:19:28 -0500749 json_str_metrics_1 =\
750 main.ONOS1cli.topology_events_metrics()
751 json_str_metrics_2 =\
752 main.ONOS2cli.topology_events_metrics()
753 json_str_metrics_3 =\
754 main.ONOS3cli.topology_events_metrics()
755 json_str_metrics_4 =\
756 main.ONOS4cli.topology_events_metrics()
757 json_str_metrics_5 =\
758 main.ONOS5cli.topology_events_metrics()
kelvin-onlab8a832582015-01-16 17:06:11 -0800759 json_obj_1 = json.loads( json_str_metrics_1 )
760 json_obj_2 = json.loads( json_str_metrics_2 )
761 json_obj_3 = json.loads( json_str_metrics_3 )
762 json_obj_4 = json.loads( json_str_metrics_4 )
763 json_obj_5 = json.loads( json_str_metrics_5 )
andrewonlab51b180b2014-11-12 18:19:28 -0500764 graph_timestamp_1 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800765 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500766 graph_timestamp_2 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800767 json_obj_2[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500768 graph_timestamp_3 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800769 json_obj_3[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500770 graph_timestamp_4 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800771 json_obj_4[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500772 graph_timestamp_5 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800773 json_obj_5[ graphTimestamp ][ 'value' ]
andrewonlabbdc3d862014-11-25 12:40:41 -0500774
kelvin-onlab8a832582015-01-16 17:06:11 -0800775 graph_lat_1 = \
776 int( graph_timestamp_1 ) - int( t0_system )
777 graph_lat_2 = \
778 int( graph_timestamp_2 ) - int( t0_system )
779 graph_lat_3 = \
780 int( graph_timestamp_3 ) - int( t0_system )
781 graph_lat_4 = \
782 int( graph_timestamp_4 ) - int( t0_system )
783 graph_lat_5 = \
784 int( graph_timestamp_5 ) - int( t0_system )
785
786 main.log.info( "Graph Timestamp ONOS1: " +
787 str( graph_timestamp_1 ) )
788 main.log.info( "Graph Timestamp ONOS2: " +
789 str( graph_timestamp_2 ) )
790 main.log.info( "Graph Timestamp ONOS3: " +
791 str( graph_timestamp_3 ) )
792 main.log.info( "Graph Timestamp ONOS4: " +
793 str( graph_timestamp_4 ) )
794 main.log.info( "Graph Timestamp ONOS5: " +
795 str( graph_timestamp_5 ) )
796
797 max_graph_lat = max( graph_lat_1,
798 graph_lat_2,
799 graph_lat_3,
800 graph_lat_4,
801 graph_lat_5 )
802
andrewonlabbdc3d862014-11-25 12:40:41 -0500803 if max_graph_lat > sw_disc_threshold_min\
kelvin-onlab8a832582015-01-16 17:06:11 -0800804 and max_graph_lat < sw_disc_threshold_max\
805 and int( i ) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500806 sw_discovery_lat_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800807 max_graph_lat )
808 main.log.info(
809 "Sw discovery latency of " +
810 str( cluster_count ) +
811 " node(s): " +
812 str( max_graph_lat ) +
813 " ms" )
andrewonlab51b180b2014-11-12 18:19:28 -0500814 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800815 main.log.info( "Switch discovery latency " +
816 "exceeded the threshold." )
817 main.log.info( str( max_graph_lat ) + " ms" )
818
andrewonlab51b180b2014-11-12 18:19:28 -0500819 break
820 if cluster_count == 6:
821 if onos1_dev and onos2_dev and onos3_dev and\
822 onos4_dev and onos5_dev and onos6_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800823 main.log.info( "All devices have been discovered" +
824 " on all ONOS instances" )
andrewonlab51b180b2014-11-12 18:19:28 -0500825 json_str_metrics_1 =\
826 main.ONOS1cli.topology_events_metrics()
827 json_str_metrics_2 =\
828 main.ONOS2cli.topology_events_metrics()
829 json_str_metrics_3 =\
830 main.ONOS3cli.topology_events_metrics()
831 json_str_metrics_4 =\
832 main.ONOS4cli.topology_events_metrics()
833 json_str_metrics_5 =\
834 main.ONOS5cli.topology_events_metrics()
835 json_str_metrics_6 =\
836 main.ONOS6cli.topology_events_metrics()
kelvin-onlab8a832582015-01-16 17:06:11 -0800837 json_obj_1 = json.loads( json_str_metrics_1 )
838 json_obj_2 = json.loads( json_str_metrics_2 )
839 json_obj_3 = json.loads( json_str_metrics_3 )
840 json_obj_4 = json.loads( json_str_metrics_4 )
841 json_obj_5 = json.loads( json_str_metrics_5 )
842 json_obj_6 = json.loads( json_str_metrics_6 )
andrewonlab51b180b2014-11-12 18:19:28 -0500843 graph_timestamp_1 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800844 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500845 graph_timestamp_2 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800846 json_obj_2[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500847 graph_timestamp_3 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800848 json_obj_3[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500849 graph_timestamp_4 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800850 json_obj_4[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500851 graph_timestamp_5 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800852 json_obj_5[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500853 graph_timestamp_6 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800854 json_obj_6[ graphTimestamp ][ 'value' ]
andrewonlabbdc3d862014-11-25 12:40:41 -0500855
kelvin-onlab8a832582015-01-16 17:06:11 -0800856 graph_lat_1 = \
857 int( graph_timestamp_1 ) - int( t0_system )
858 graph_lat_2 = \
859 int( graph_timestamp_2 ) - int( t0_system )
860 graph_lat_3 = \
861 int( graph_timestamp_3 ) - int( t0_system )
862 graph_lat_4 = \
863 int( graph_timestamp_4 ) - int( t0_system )
864 graph_lat_5 = \
865 int( graph_timestamp_5 ) - int( t0_system )
866 graph_lat_6 = \
867 int( graph_timestamp_6 ) - int( t0_system )
868
869 main.log.info( "Graph Timestamp ONOS1: " +
870 str( graph_timestamp_1 ) )
871 main.log.info( "Graph Timestamp ONOS2: " +
872 str( graph_timestamp_2 ) )
873 main.log.info( "Graph Timestamp ONOS3: " +
874 str( graph_timestamp_3 ) )
875 main.log.info( "Graph Timestamp ONOS4: " +
876 str( graph_timestamp_4 ) )
877 main.log.info( "Graph Timestamp ONOS5: " +
878 str( graph_timestamp_5 ) )
879 main.log.info( "Graph Timestamp ONOS6: " +
880 str( graph_timestamp_6 ) )
881
882 max_graph_lat = max( graph_lat_1,
883 graph_lat_2,
884 graph_lat_3,
885 graph_lat_4,
886 graph_lat_5,
887 graph_lat_6 )
888
andrewonlabbdc3d862014-11-25 12:40:41 -0500889 if max_graph_lat > sw_disc_threshold_min\
kelvin-onlab8a832582015-01-16 17:06:11 -0800890 and max_graph_lat < sw_disc_threshold_max\
891 and int( i ) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500892 sw_discovery_lat_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800893 max_graph_lat )
894 main.log.info(
895 "Sw discovery latency of " +
896 str( cluster_count ) +
897 " node(s): " +
898 str( max_graph_lat ) +
899 " ms" )
andrewonlab51b180b2014-11-12 18:19:28 -0500900 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800901 main.log.info( "Switch discovery latency " +
902 "exceeded the threshold." )
903 main.log.info( str( max_graph_lat ) + " ms" )
904
andrewonlab51b180b2014-11-12 18:19:28 -0500905 break
906 if cluster_count == 7:
907 if onos1_dev and onos2_dev and onos3_dev and\
908 onos4_dev and onos5_dev and onos6_dev and\
909 onos7_dev:
kelvin-onlab8a832582015-01-16 17:06:11 -0800910 main.log.info( "All devices have been discovered" +
911 " on all ONOS instances" )
912
913 # TODO: Investigate this sleep
914 # added to 'pad' the results with
andrewonlaba036b402014-11-17 13:47:46 -0500915 # plenty of time to 'catch up'
kelvin-onlab8a832582015-01-16 17:06:11 -0800916 time.sleep( 5 )
917
andrewonlab51b180b2014-11-12 18:19:28 -0500918 json_str_metrics_1 =\
919 main.ONOS1cli.topology_events_metrics()
920 json_str_metrics_2 =\
921 main.ONOS2cli.topology_events_metrics()
922 json_str_metrics_3 =\
923 main.ONOS3cli.topology_events_metrics()
924 json_str_metrics_4 =\
925 main.ONOS4cli.topology_events_metrics()
926 json_str_metrics_5 =\
927 main.ONOS5cli.topology_events_metrics()
928 json_str_metrics_6 =\
929 main.ONOS6cli.topology_events_metrics()
930 json_str_metrics_7 =\
931 main.ONOS7cli.topology_events_metrics()
kelvin-onlab8a832582015-01-16 17:06:11 -0800932 json_obj_1 = json.loads( json_str_metrics_1 )
933 json_obj_2 = json.loads( json_str_metrics_2 )
934 json_obj_3 = json.loads( json_str_metrics_3 )
935 json_obj_4 = json.loads( json_str_metrics_4 )
936 json_obj_5 = json.loads( json_str_metrics_5 )
937 json_obj_6 = json.loads( json_str_metrics_6 )
938 json_obj_7 = json.loads( json_str_metrics_7 )
andrewonlab51b180b2014-11-12 18:19:28 -0500939 graph_timestamp_1 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800940 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500941 graph_timestamp_2 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800942 json_obj_2[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500943 graph_timestamp_3 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800944 json_obj_3[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500945 graph_timestamp_4 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800946 json_obj_4[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500947 graph_timestamp_5 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800948 json_obj_5[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500949 graph_timestamp_6 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800950 json_obj_6[ graphTimestamp ][ 'value' ]
andrewonlab51b180b2014-11-12 18:19:28 -0500951 graph_timestamp_7 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800952 json_obj_7[ graphTimestamp ][ 'value' ]
953
andrewonlab51b180b2014-11-12 18:19:28 -0500954 graph_lat_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800955 int( graph_timestamp_1 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500956 graph_lat_2 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800957 int( graph_timestamp_2 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500958 graph_lat_3 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800959 int( graph_timestamp_3 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500960 graph_lat_4 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800961 int( graph_timestamp_4 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500962 graph_lat_5 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800963 int( graph_timestamp_5 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500964 graph_lat_6 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800965 int( graph_timestamp_6 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500966 graph_lat_7 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800967 int( graph_timestamp_7 ) - int( t0_system )
andrewonlab51b180b2014-11-12 18:19:28 -0500968
kelvin-onlab8a832582015-01-16 17:06:11 -0800969 main.log.info( "Graph Timestamp ONOS1: " +
970 str( graph_timestamp_1 ) )
971 main.log.info( "Graph Timestamp ONOS2: " +
972 str( graph_timestamp_2 ) )
973 main.log.info( "Graph Timestamp ONOS3: " +
974 str( graph_timestamp_3 ) )
975 main.log.info( "Graph Timestamp ONOS4: " +
976 str( graph_timestamp_4 ) )
977 main.log.info( "Graph Timestamp ONOS5: " +
978 str( graph_timestamp_5 ) )
979 main.log.info( "Graph Timestamp ONOS6: " +
980 str( graph_timestamp_6 ) )
981 main.log.info( "Graph Timestamp ONOS7: " +
982 str( graph_timestamp_7 ) )
andrewonlabbdc3d862014-11-25 12:40:41 -0500983
kelvin-onlab8a832582015-01-16 17:06:11 -0800984 max_graph_lat = max( graph_lat_1,
985 graph_lat_2,
986 graph_lat_3,
987 graph_lat_4,
988 graph_lat_5,
989 graph_lat_6,
990 graph_lat_7 )
991
andrewonlabbdc3d862014-11-25 12:40:41 -0500992 if max_graph_lat > sw_disc_threshold_min\
kelvin-onlab8a832582015-01-16 17:06:11 -0800993 and max_graph_lat < sw_disc_threshold_max\
994 and int( i ) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500995 sw_discovery_lat_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800996 max_graph_lat )
997 main.log.info(
998 "Sw discovery latency of " +
999 str( cluster_count ) +
1000 " node(s): " +
1001 str( max_graph_lat ) +
1002 " ms" )
andrewonlab51b180b2014-11-12 18:19:28 -05001003 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001004 main.log.info( "Switch discovery latency " +
1005 "exceeded the threshold." )
1006 main.log.info( str( max_graph_lat ) + " ms" )
1007
andrewonlab51b180b2014-11-12 18:19:28 -05001008 break
kelvin-onlab8a832582015-01-16 17:06:11 -08001009
andrewonlab51b180b2014-11-12 18:19:28 -05001010 counter_loop += 1
kelvin-onlab8a832582015-01-16 17:06:11 -08001011 time.sleep( 3 )
1012 # END WHILE LOOP
1013
1014 # Below is used for reporting SYN / ACK timing
1015 # of all switches
andrewonlaba036b402014-11-17 13:47:46 -05001016 main.ONOS1.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -05001017 syn_ack_timestamp_list = []
andrewonlabbdc3d862014-11-25 12:40:41 -05001018 if cluster_count < 3:
kelvin-onlab8a832582015-01-16 17:06:11 -08001019 # TODO: capture synack on nodes less than 3
1020 syn_ack_timestamp_list.append( 0 )
andrewonlaba036b402014-11-17 13:47:46 -05001021
1022 if cluster_count >= 3:
kelvin-onlab8a832582015-01-16 17:06:11 -08001023 main.ONOS2.tshark_stop()
andrewonlaba036b402014-11-17 13:47:46 -05001024 main.ONOS3.tshark_stop()
kelvin-onlab8a832582015-01-16 17:06:11 -08001025 time.sleep( 5 )
1026 os.system(
1027 "scp " +
1028 ONOS_user +
1029 "@" +
1030 ONOS1_ip +
1031 ":" +
1032 "/tmp/syn_ack_onos1_iter" +
1033 str( i ) +
1034 ".txt /tmp/" )
1035 os.system(
1036 "scp " +
1037 ONOS_user +
1038 "@" +
1039 ONOS2_ip +
1040 ":" +
1041 "/tmp/syn_ack_onos2_iter" +
1042 str( i ) +
1043 ".txt /tmp/" )
1044 os.system(
1045 "scp " +
1046 ONOS_user +
1047 "@" +
1048 ONOS3_ip +
1049 ":" +
1050 "/tmp/syn_ack_onos3_iter" +
1051 str( i ) +
1052 ".txt /tmp/" )
1053 time.sleep( 5 )
1054 # Read each of the files and append all
1055 # SYN / ACK timestamps to the list
1056 with open( "/tmp/syn_ack_onos1_iter" + str( i ) + ".txt" ) as\
1057 f_onos1:
andrewonlaba036b402014-11-17 13:47:46 -05001058 for line in f_onos1:
kelvin-onlab8a832582015-01-16 17:06:11 -08001059 line = line.split( " " )
andrewonlabf50ad012014-11-25 15:48:37 -05001060 try:
kelvin-onlab8a832582015-01-16 17:06:11 -08001061 float( line[ 1 ] )
1062 syn_ack_timestamp_list.append( line[ 1 ] )
andrewonlabf50ad012014-11-25 15:48:37 -05001063 except ValueError:
kelvin-onlab8a832582015-01-16 17:06:11 -08001064 main.log.info( "String cannot be converted" )
1065 with open( "/tmp/syn_ack_onos2_iter" + str( i ) + ".txt" ) as\
1066 f_onos2:
andrewonlaba036b402014-11-17 13:47:46 -05001067 for line in f_onos2:
kelvin-onlab8a832582015-01-16 17:06:11 -08001068 line = line.split( " " )
andrewonlabf50ad012014-11-25 15:48:37 -05001069 try:
kelvin-onlab8a832582015-01-16 17:06:11 -08001070 float( line[ 1 ] )
1071 syn_ack_timestamp_list.append( line[ 1 ] )
andrewonlabf50ad012014-11-25 15:48:37 -05001072 except ValueError:
kelvin-onlab8a832582015-01-16 17:06:11 -08001073 main.log.info( "String cannot be converted" )
1074 with open( "/tmp/syn_ack_onos3_iter" + str( i ) + ".txt" ) as\
1075 f_onos3:
andrewonlaba036b402014-11-17 13:47:46 -05001076 for line in f_onos3:
kelvin-onlab8a832582015-01-16 17:06:11 -08001077 line = line.split( " " )
andrewonlabf50ad012014-11-25 15:48:37 -05001078 try:
kelvin-onlab8a832582015-01-16 17:06:11 -08001079 float( line[ 1 ] )
1080 syn_ack_timestamp_list.append( line[ 1 ] )
andrewonlabf50ad012014-11-25 15:48:37 -05001081 except ValueError:
kelvin-onlab8a832582015-01-16 17:06:11 -08001082 main.log.info( "String cannot be converted" )
andrewonlaba036b402014-11-17 13:47:46 -05001083 if cluster_count >= 4:
kelvin-onlab8a832582015-01-16 17:06:11 -08001084 main.ONOS4.tshark_stop()
1085 time.sleep( 5 )
1086 os.system(
1087 "scp " +
1088 ONOS_user +
1089 "@" +
1090 ONOS4_ip +
1091 ":" +
1092 "/tmp/syn_ack_onos4_iter" +
1093 str( i ) +
1094 ".txt /tmp/" )
1095 time.sleep( 5 )
1096 with open( "/tmp/syn_ack_onos4_iter" + str( i ) + ".txt" ) as\
1097 f_onos4:
andrewonlaba036b402014-11-17 13:47:46 -05001098 for line in f_onos4:
kelvin-onlab8a832582015-01-16 17:06:11 -08001099 line = line.split( " " )
andrewonlabf50ad012014-11-25 15:48:37 -05001100 try:
kelvin-onlab8a832582015-01-16 17:06:11 -08001101 float( line[ 1 ] )
1102 syn_ack_timestamp_list.append( line[ 1 ] )
andrewonlabf50ad012014-11-25 15:48:37 -05001103 except ValueError:
kelvin-onlab8a832582015-01-16 17:06:11 -08001104 main.log.info( "String cannot be converted" )
andrewonlaba036b402014-11-17 13:47:46 -05001105 if cluster_count >= 5:
1106 main.ONOS5.tshark_stop()
kelvin-onlab8a832582015-01-16 17:06:11 -08001107 time.sleep( 5 )
1108 os.system(
1109 "scp " +
1110 ONOS_user +
1111 "@" +
1112 ONOS5_ip +
1113 ":" +
1114 "/tmp/syn_ack_onos5_iter" +
1115 str( i ) +
1116 ".txt /tmp/" )
1117 time.sleep( 5 )
1118 with open( "/tmp/syn_ack_onos5_iter" + str( i ) + ".txt" ) as\
1119 f_onos5:
andrewonlaba036b402014-11-17 13:47:46 -05001120 for line in f_onos5:
kelvin-onlab8a832582015-01-16 17:06:11 -08001121 line = line.split( " " )
andrewonlabf50ad012014-11-25 15:48:37 -05001122 try:
kelvin-onlab8a832582015-01-16 17:06:11 -08001123 float( line[ 1 ] )
1124 syn_ack_timestamp_list.append( line[ 1 ] )
andrewonlabf50ad012014-11-25 15:48:37 -05001125 except ValueError:
kelvin-onlab8a832582015-01-16 17:06:11 -08001126 main.log.info( "String cannot be converted" )
andrewonlaba036b402014-11-17 13:47:46 -05001127 if cluster_count >= 6:
1128 main.ONOS6.tshark_stop()
kelvin-onlab8a832582015-01-16 17:06:11 -08001129 time.sleep( 5 )
1130 os.system(
1131 "scp " +
1132 ONOS_user +
1133 "@" +
1134 ONOS6_ip +
1135 ":" +
1136 "/tmp/syn_ack_onos6_iter" +
1137 str( i ) +
1138 ".txt /tmp/" )
1139 time.sleep( 5 )
1140 with open( "/tmp/syn_ack_onos6_iter" + str( i ) + ".txt" ) as\
1141 f_onos6:
andrewonlaba036b402014-11-17 13:47:46 -05001142 for line in f_onos6:
kelvin-onlab8a832582015-01-16 17:06:11 -08001143 line = line.split( " " )
andrewonlabf50ad012014-11-25 15:48:37 -05001144 try:
kelvin-onlab8a832582015-01-16 17:06:11 -08001145 float( line[ 1 ] )
1146 syn_ack_timestamp_list.append( line[ 1 ] )
andrewonlabf50ad012014-11-25 15:48:37 -05001147 except ValueError:
kelvin-onlab8a832582015-01-16 17:06:11 -08001148 main.log.info( "String cannot be converted" )
andrewonlaba036b402014-11-17 13:47:46 -05001149 if cluster_count == 7:
1150 main.ONOS7.tshark_stop()
kelvin-onlab8a832582015-01-16 17:06:11 -08001151 time.sleep( 5 )
1152 os.system(
1153 "scp " +
1154 ONOS_user +
1155 "@" +
1156 ONOS7_ip +
1157 ":" +
1158 "/tmp/syn_ack_onos7_iter" +
1159 str( i ) +
1160 ".txt /tmp/" )
1161 time.sleep( 5 )
1162 with open( "/tmp/syn_ack_onos7_iter" + str( i ) + ".txt" ) as\
1163 f_onos7:
andrewonlaba036b402014-11-17 13:47:46 -05001164 for line in f_onos7:
kelvin-onlab8a832582015-01-16 17:06:11 -08001165 line = line.split( " " )
andrewonlabf50ad012014-11-25 15:48:37 -05001166 try:
kelvin-onlab8a832582015-01-16 17:06:11 -08001167 float( line[ 1 ] )
1168 syn_ack_timestamp_list.append( line[ 1 ] )
andrewonlabf50ad012014-11-25 15:48:37 -05001169 except ValueError:
kelvin-onlab8a832582015-01-16 17:06:11 -08001170 main.log.info( "String cannot be converted" )
1171
1172 # Sort the list by timestamp
1173 syn_ack_timestamp_list = sorted( syn_ack_timestamp_list )
1174 print "syn_ack_-1 " + str( syn_ack_timestamp_list )
andrewonlabbdc3d862014-11-25 12:40:41 -05001175
andrewonlaba1272172014-11-17 17:30:35 -05001176 syn_ack_delta =\
kelvin-onlab8a832582015-01-16 17:06:11 -08001177 int( float( syn_ack_timestamp_list[ -1 ] ) * 1000 ) -\
1178 int( float( syn_ack_timestamp_list[ 0 ] ) * 1000 )
andrewonlaba036b402014-11-17 13:47:46 -05001179
kelvin-onlab8a832582015-01-16 17:06:11 -08001180 main.log.info( "Switch connection attempt delta iteration " +
1181 str( i ) + ": " + str( syn_ack_delta ) )
1182 syn_ack_delta_list.append( syn_ack_delta )
1183 # END ITERATION LOOP
1184 # REPORT HERE
andrewonlab51b180b2014-11-12 18:19:28 -05001185
kelvin-onlab8a832582015-01-16 17:06:11 -08001186 if len( sw_discovery_lat_list ) > 0:
1187 sw_lat_avg = sum( sw_discovery_lat_list ) / \
1188 len( sw_discovery_lat_list )
1189 sw_lat_dev = numpy.std( sw_discovery_lat_list )
andrewonlab28b84eb2014-12-02 15:53:35 -05001190 else:
1191 sw_lat_avg = 0
1192 sw_lat_dev = 0
andrewonlab51b180b2014-11-12 18:19:28 -05001193 assertion = main.FALSE
andrewonlab51b180b2014-11-12 18:19:28 -05001194
kelvin-onlab8a832582015-01-16 17:06:11 -08001195 main.log.report( "Switch connection attempt time avg " +
1196 "(last sw SYN/ACK time - first sw SYN/ACK time) " +
1197 str( sum( syn_ack_delta_list ) /
1198 len( syn_ack_delta_list ) ) +
1199 " ms" )
1200 main.log.report( str( num_sw ) + " Switch discovery lat for " +
1201 str( cluster_count ) + " instance(s): " )
1202 main.log.report( "Avg: " +
1203 str( sw_lat_avg ) +
1204 " ms " +
1205 "Std Deviation: " +
1206 str( round( sw_lat_dev, 1 ) ) +
1207 " ms" )
1208
1209 utilities.assert_equals(
1210 expect=main.TRUE,
1211 actual=assertion,
1212 onpass="Switch discovery convergence latency" +
1213 " for " +
1214 str( cluster_count ) +
1215 " nodes successful",
1216 onfail="Switch discovery convergence latency" +
1217 " test failed" )
1218
1219 def CASE3( self, main ):
1220 """
andrewonlab54cec4b2014-11-12 13:30:23 -05001221 Increase number of nodes and initiate CLI
kelvin-onlab8a832582015-01-16 17:06:11 -08001222 """
andrewonlabadd2fd62014-11-11 18:37:35 -05001223 import time
1224 import subprocess
1225 import os
1226 import requests
1227 import json
andrewonlab0cfc7ad2014-11-13 16:29:26 -05001228
kelvin-onlab8a832582015-01-16 17:06:11 -08001229 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
1230 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
1231 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
1232 ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
1233 ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
1234 ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
1235 ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
1236
1237 cell_name = main.params[ 'ENV' ][ 'cellName' ]
1238
1239 MN1_ip = main.params[ 'MN' ][ 'ip1' ]
1240 BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
1241
1242 # NOTE:We start with cluster_count at 3. The first
1243 # case already initialized ONOS1. Increase the
1244 # cluster count and start from 3.
1245 # You can optionally change the increment to
1246 # test steps of node sizes, such as 3,5,7
1247
andrewonlabadd2fd62014-11-11 18:37:35 -05001248 global cluster_count
kelvin-onlab8a832582015-01-16 17:06:11 -08001249 cluster_count += 2
1250 main.log.report( "Increasing cluster size to " +
1251 str( cluster_count ) )
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001252
andrewonlaba036b402014-11-17 13:47:46 -05001253 install_result = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001254 # Supports up to 7 node configuration
1255 # TODO: Cleanup this ridiculous repetitive code
andrewonlab5b8c02f2014-11-21 17:56:10 -05001256 if cluster_count == 3:
1257 install_result = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001258 main.ONOSbench.onos_install( node=ONOS2_ip )
andrewonlabbdc3d862014-11-25 12:40:41 -05001259 install_result = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001260 main.ONOSbench.onos_install( node=ONOS3_ip )
1261 time.sleep( 5 )
1262 main.log.info( "Starting CLI" )
1263 main.ONOS2cli.start_onos_cli( ONOS2_ip )
1264 main.ONOS3cli.start_onos_cli( ONOS3_ip )
1265 main.ONOS1cli.add_node( ONOS2_ip, ONOS2_ip )
1266 main.ONOS1cli.add_node( ONOS3_ip, ONOS3_ip )
1267
andrewonlaba036b402014-11-17 13:47:46 -05001268 if cluster_count == 4:
kelvin-onlab8a832582015-01-16 17:06:11 -08001269 main.log.info( "Installing ONOS on node 4" )
andrewonlaba036b402014-11-17 13:47:46 -05001270 install_result = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001271 main.ONOSbench.onos_install( node=ONOS4_ip )
1272 time.sleep( 5 )
1273 main.log.info( "Starting CLI" )
1274 main.ONOS4cli.start_onos_cli( ONOS4_ip )
1275 main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
1276
andrewonlab81763ee2014-11-13 17:31:34 -05001277 elif cluster_count == 5:
kelvin-onlab8a832582015-01-16 17:06:11 -08001278 main.log.info( "Installing ONOS on nodes 4 and 5" )
andrewonlaba036b402014-11-17 13:47:46 -05001279 install_result2 = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001280 main.ONOSbench.onos_install( options="", node=ONOS4_ip )
andrewonlab5b8c02f2014-11-21 17:56:10 -05001281 install_result3 = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001282 main.ONOSbench.onos_install( options="", node=ONOS5_ip )
1283 time.sleep( 5 )
1284 main.log.info( "Starting CLI" )
1285 main.ONOS4cli.start_onos_cli( ONOS4_ip )
1286 main.ONOS5cli.start_onos_cli( ONOS5_ip )
1287 main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
1288 main.ONOS1cli.add_node( ONOS5_ip, ONOS5_ip )
andrewonlabbdc3d862014-11-25 12:40:41 -05001289 install_result = install_result2 and install_result3
andrewonlaba036b402014-11-17 13:47:46 -05001290
andrewonlab81763ee2014-11-13 17:31:34 -05001291 elif cluster_count == 6:
kelvin-onlab8a832582015-01-16 17:06:11 -08001292 main.log.info( "Installing ONOS on nodes 4, 5,and 6" )
andrewonlaba036b402014-11-17 13:47:46 -05001293 install_result1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001294 main.ONOSbench.onos_install( options="", node=ONOS4_ip )
andrewonlaba036b402014-11-17 13:47:46 -05001295 install_result2 = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001296 main.ONOSbench.onos_install( options="", node=ONOS5_ip )
andrewonlaba036b402014-11-17 13:47:46 -05001297 install_result3 = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001298 main.ONOSbench.onos_install( node=ONOS6_ip )
1299 time.sleep( 5 )
1300 main.log.info( "Starting CLI" )
1301 main.ONOS4cli.start_onos_cli( ONOS4_ip )
1302 main.ONOS5cli.start_onos_cli( ONOS5_ip )
1303 main.ONOS6cli.start_onos_cli( ONOS6_ip )
1304 main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
1305 main.ONOS1cli.add_node( ONOS5_ip, ONOS5_ip )
1306 main.ONOS1cli.add_node( ONOS6_ip, ONOS6_ip )
andrewonlaba036b402014-11-17 13:47:46 -05001307 install_result = install_result1 and install_result2 and\
kelvin-onlab8a832582015-01-16 17:06:11 -08001308 install_result3
andrewonlaba036b402014-11-17 13:47:46 -05001309
andrewonlab81763ee2014-11-13 17:31:34 -05001310 elif cluster_count == 7:
kelvin-onlab8a832582015-01-16 17:06:11 -08001311 main.log.info( "Installing ONOS on nodes 4, 5, 6,and 7" )
andrewonlaba036b402014-11-17 13:47:46 -05001312 install_result3 = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001313 main.ONOSbench.onos_install( node=ONOS6_ip )
andrewonlaba036b402014-11-17 13:47:46 -05001314 install_result4 = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001315 main.ONOSbench.onos_install( node=ONOS7_ip )
1316 main.log.info( "Starting CLI" )
1317 main.ONOS4cli.start_onos_cli( ONOS4_ip )
1318 main.ONOS5cli.start_onos_cli( ONOS5_ip )
1319 main.ONOS6cli.start_onos_cli( ONOS6_ip )
1320 main.ONOS7cli.start_onos_cli( ONOS7_ip )
1321 main.ONOS1cli.add_node( ONOS4_ip, ONOS4_ip )
1322 main.ONOS1cli.add_node( ONOS5_ip, ONOS5_ip )
1323 main.ONOS1cli.add_node( ONOS6_ip, ONOS6_ip )
1324 main.ONOS1cli.add_node( ONOS7_ip, ONOS7_ip )
andrewonlab81763ee2014-11-13 17:31:34 -05001325
andrewonlabbdc3d862014-11-25 12:40:41 -05001326 install_result = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001327 install_result3 and install_result4
andrewonlab81763ee2014-11-13 17:31:34 -05001328
kelvin-onlab8a832582015-01-16 17:06:11 -08001329 time.sleep( 5 )
andrewonlabadd2fd62014-11-11 18:37:35 -05001330
andrewonlab0cfc7ad2014-11-13 16:29:26 -05001331 if install_result == main.TRUE:
1332 assertion = main.TRUE
1333 else:
1334 assertion = main.FALSE
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001335
kelvin-onlab8a832582015-01-16 17:06:11 -08001336 utilities.assert_equals(
1337 expect=main.TRUE,
1338 actual=assertion,
1339 onpass="Scale out to " +
1340 str( cluster_count ) +
1341 " nodes successful",
1342 onfail="Scale out to " +
1343 str( cluster_count ) +
1344 " nodes failed" )
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001345
kelvin-onlab8a832582015-01-16 17:06:11 -08001346 def CASE4( self, main ):
1347 """
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001348 Cleanup ONOS nodes and Increase topology size
kelvin-onlab8a832582015-01-16 17:06:11 -08001349 """
1350 # TODO: use meaningful assertion
1351 assertion = main.TRUE
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001352
kelvin-onlab8a832582015-01-16 17:06:11 -08001353 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
1354 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
1355 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
1356 ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
1357 ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
1358 ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ]
1359 ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ]
1360 MN1_ip = main.params[ 'MN' ][ 'ip1' ]
1361 BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001362
kelvin-onlab8a832582015-01-16 17:06:11 -08001363 main.log.info( "Uninstalling previous instances" )
1364 main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip )
1365 main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip )
1366 main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip )
1367 main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip )
1368 main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip )
1369 main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip )
1370
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001371 global topo_iteration
1372 global cluster_count
kelvin-onlab8a832582015-01-16 17:06:11 -08001373 cluster_count = 1
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001374 topo_iteration += 1
1375
kelvin-onlab8a832582015-01-16 17:06:11 -08001376 main.log.report( "Increasing topology size" )
1377 utilities.assert_equals( expect=main.TRUE, actual=assertion,
1378 onpass="Topology size increased successfully",
1379 onfail="Topology size was not increased" )