blob: e81d9058b6def2988f4b616a051c34287e539f83 [file] [log] [blame]
kelvin-onlab8a832582015-01-16 17:06:11 -08001# TopoPerfNext
andrewonlab47eddf22014-11-06 17:10:54 -05002#
kelvin-onlab8a832582015-01-16 17:06:11 -08003# Topology Performance test for ONOS-next
andrewonlab47eddf22014-11-06 17:10:54 -05004#*** Revised for single node operation ***
5#
kelvin-onlab8a832582015-01-16 17:06:11 -08006# andrew@onlab.us
andrewonlab47eddf22014-11-06 17:10:54 -05007
8import time
9import sys
10import os
11import re
12
kelvin-onlab8a832582015-01-16 17:06:11 -080013
andrewonlab47eddf22014-11-06 17:10:54 -050014class TopoPerfNextSingleNode:
kelvin-onlab8a832582015-01-16 17:06:11 -080015
16 def __init__( self ):
andrewonlab47eddf22014-11-06 17:10:54 -050017 self.default = ''
18
kelvin-onlab8a832582015-01-16 17:06:11 -080019 def CASE1( self, main ):
20 """
andrewonlab47eddf22014-11-06 17:10:54 -050021 ONOS startup sequence
kelvin-onlab8a832582015-01-16 17:06:11 -080022 """
andrewonlab47eddf22014-11-06 17:10:54 -050023 import time
andrewonlab47eddf22014-11-06 17:10:54 -050024
kelvin-onlab8a832582015-01-16 17:06:11 -080025 cell_name = main.params[ 'ENV' ][ 'cellName' ]
andrewonlab47eddf22014-11-06 17:10:54 -050026
kelvin-onlab8a832582015-01-16 17:06:11 -080027 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
28 checkout_branch = main.params[ 'GIT' ][ 'checkout' ]
andrewonlab47eddf22014-11-06 17:10:54 -050029
kelvin-onlab8a832582015-01-16 17:06:11 -080030 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
31 MN1_ip = main.params[ 'MN' ][ 'ip1' ]
32 BENCH_ip = main.params[ 'BENCH' ][ 'ip' ]
andrewonlab47eddf22014-11-06 17:10:54 -050033
kelvin-onlab8a832582015-01-16 17:06:11 -080034 main.case( "Setting up test environment" )
35
36 main.step( "Creating cell file" )
andrewonlab47eddf22014-11-06 17:10:54 -050037 cell_file_result = main.ONOSbench.create_cell_file(
kelvin-onlab8a832582015-01-16 17:06:11 -080038 BENCH_ip, cell_name, MN1_ip, "onos-core",
39 ONOS1_ip )
andrewonlab47eddf22014-11-06 17:10:54 -050040
kelvin-onlab8a832582015-01-16 17:06:11 -080041 main.step( "Applying cell file to environment" )
42 cell_apply_result = main.ONOSbench.set_cell( cell_name )
andrewonlab47eddf22014-11-06 17:10:54 -050043 verify_cell_result = main.ONOSbench.verify_cell()
kelvin-onlab8a832582015-01-16 17:06:11 -080044
45 main.step( "Git checkout and pull " + checkout_branch )
andrewonlab47eddf22014-11-06 17:10:54 -050046 if git_pull == 'on':
47 checkout_result = \
kelvin-onlab8a832582015-01-16 17:06:11 -080048 main.ONOSbench.git_checkout( checkout_branch )
andrewonlab47eddf22014-11-06 17:10:54 -050049 pull_result = main.ONOSbench.git_pull()
50 else:
51 checkout_result = main.TRUE
52 pull_result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -080053 main.log.info( "Skipped git checkout and pull" )
andrewonlab47eddf22014-11-06 17:10:54 -050054
kelvin-onlab8a832582015-01-16 17:06:11 -080055 main.step( "Using mvn clean & install" )
andrewonlab47eddf22014-11-06 17:10:54 -050056 #mvn_result = main.ONOSbench.clean_install()
57 mvn_result = main.TRUE
58
kelvin-onlab8a832582015-01-16 17:06:11 -080059 main.step( "Creating ONOS package" )
andrewonlab47eddf22014-11-06 17:10:54 -050060 package_result = main.ONOSbench.onos_package()
61
kelvin-onlab8a832582015-01-16 17:06:11 -080062 main.step( "Installing ONOS package" )
63 install1_result = main.ONOSbench.onos_install( node=ONOS1_ip )
andrewonlab47eddf22014-11-06 17:10:54 -050064
kelvin-onlab8a832582015-01-16 17:06:11 -080065 # NOTE: This step may be unnecessary
66 #main.step( "Starting ONOS service" )
67 #start_result = main.ONOSbench.onos_start( ONOS1_ip )
andrewonlab47eddf22014-11-06 17:10:54 -050068
kelvin-onlab8a832582015-01-16 17:06:11 -080069 main.step( "Set cell for ONOS cli env" )
70 main.ONOS1cli.set_cell( cell_name )
andrewonlab47eddf22014-11-06 17:10:54 -050071
kelvin-onlab8a832582015-01-16 17:06:11 -080072 time.sleep( 10 )
andrewonlab47eddf22014-11-06 17:10:54 -050073
kelvin-onlab8a832582015-01-16 17:06:11 -080074 main.step( "Start onos cli" )
75 cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip )
andrewonlab47eddf22014-11-06 17:10:54 -050076
kelvin-onlab8a832582015-01-16 17:06:11 -080077 main.step( "Enable metrics feature" )
78 main.ONOS1cli.feature_install( "onos-app-metrics" )
andrewonlab47eddf22014-11-06 17:10:54 -050079
kelvin-onlab8a832582015-01-16 17:06:11 -080080 utilities.assert_equals( expect=main.TRUE,
81 actual=cell_file_result and cell_apply_result and
82 verify_cell_result and checkout_result and
83 pull_result and mvn_result and
84 install1_result,
85 onpass="ONOS started successfully",
86 onfail="Failed to start ONOS" )
andrewonlab47eddf22014-11-06 17:10:54 -050087
kelvin-onlab8a832582015-01-16 17:06:11 -080088 def CASE2( self, main ):
89 """
andrewonlab47eddf22014-11-06 17:10:54 -050090 Assign s1 to ONOS1 and measure latency
kelvin-onlab8a832582015-01-16 17:06:11 -080091
andrewonlab47eddf22014-11-06 17:10:54 -050092 There are 4 levels of latency measurements to this test:
kelvin-onlab8a832582015-01-16 17:06:11 -080093 1 ) End-to-end measurement: Complete end-to-end measurement
94 from TCP ( SYN/ACK ) handshake to Graph change
95 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
andrewonlab47eddf22014-11-06 17:10:54 -050096 measurement from OFP Vendor message to Graph change
kelvin-onlab8a832582015-01-16 17:06:11 -080097 3 ) OFP-to-device measurement: 'ONOS processing without
andrewonlab47eddf22014-11-06 17:10:54 -050098 graph change' snippet of measurement from OFP vendor
99 message to Device change timestamp
kelvin-onlab8a832582015-01-16 17:06:11 -0800100 4 ) T0-to-device measurement: Measurement that includes
101 the switch handshake to devices timestamp without
102 the graph view change. ( TCP handshake -> Device
103 change )
104 """
andrewonlab47eddf22014-11-06 17:10:54 -0500105 import time
106 import subprocess
107 import json
108 import requests
109 import os
110
kelvin-onlab8a832582015-01-16 17:06:11 -0800111 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
112 ONOS_user = main.params[ 'CTRL' ][ 'user' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500113
kelvin-onlab8a832582015-01-16 17:06:11 -0800114 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500115
kelvin-onlab8a832582015-01-16 17:06:11 -0800116 # Number of iterations of case
117 num_iter = main.params[ 'TEST' ][ 'numIter' ]
118
119 # Timestamp 'keys' for json metrics output.
120 # These are subject to change, hence moved into params
121 deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
122 graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
123
124 # List of switch add latency collected from
125 # all iterations
andrewonlab47eddf22014-11-06 17:10:54 -0500126 latency_end_to_end_list = []
127 latency_ofp_to_graph_list = []
128 latency_ofp_to_device_list = []
129 latency_t0_to_device_list = []
130
kelvin-onlab8a832582015-01-16 17:06:11 -0800131 # Directory/file to store tshark results
andrewonlab47eddf22014-11-06 17:10:54 -0500132 tshark_of_output = "/tmp/tshark_of_topo.txt"
133 tshark_tcp_output = "/tmp/tshark_tcp_topo.txt"
134
kelvin-onlab8a832582015-01-16 17:06:11 -0800135 # String to grep in tshark output
136 tshark_tcp_string = "TCP 74 " + default_sw_port
andrewonlab47eddf22014-11-06 17:10:54 -0500137 tshark_of_string = "OFP 86 Vendor"
kelvin-onlab8a832582015-01-16 17:06:11 -0800138
139 # Initialize assertion to TRUE
andrewonlab47eddf22014-11-06 17:10:54 -0500140 assertion = main.TRUE
andrewonlab47eddf22014-11-06 17:10:54 -0500141
kelvin-onlab8a832582015-01-16 17:06:11 -0800142 main.log.report( "Latency of adding one switch" )
andrewonlab47eddf22014-11-06 17:10:54 -0500143
kelvin-onlab8a832582015-01-16 17:06:11 -0800144 for i in range( 0, int( num_iter ) ):
145 main.log.info( "Starting tshark capture" )
146
147 #* TCP [ ACK, SYN ] is used as t0_a, the
148 # very first "exchange" between ONOS and
andrewonlab47eddf22014-11-06 17:10:54 -0500149 # the switch for end-to-end measurement
kelvin-onlab8a832582015-01-16 17:06:11 -0800150 #* OFP [ Stats Reply ] is used for t0_b
andrewonlab47eddf22014-11-06 17:10:54 -0500151 # the very last OFP message between ONOS
152 # and the switch for ONOS measurement
kelvin-onlab8a832582015-01-16 17:06:11 -0800153 main.ONOS1.tshark_grep( tshark_tcp_string,
154 tshark_tcp_output )
155 main.ONOS1.tshark_grep( tshark_of_string,
156 tshark_of_output )
andrewonlab47eddf22014-11-06 17:10:54 -0500157
kelvin-onlab8a832582015-01-16 17:06:11 -0800158 # Wait and ensure tshark is started and
159 # capturing
160 time.sleep( 10 )
andrewonlab47eddf22014-11-06 17:10:54 -0500161
kelvin-onlab8a832582015-01-16 17:06:11 -0800162 main.log.info( "Assigning s1 to controller" )
andrewonlab47eddf22014-11-06 17:10:54 -0500163
kelvin-onlab8a832582015-01-16 17:06:11 -0800164 main.Mininet1.assign_sw_controller(
165 sw="1",
166 ip1=ONOS1_ip,
167 port1=default_sw_port )
andrewonlab47eddf22014-11-06 17:10:54 -0500168
kelvin-onlab8a832582015-01-16 17:06:11 -0800169 # Wait and ensure switch is assigned
170 # before stopping tshark
171 time.sleep( 30 )
172
173 main.log.info( "Stopping all Tshark processes" )
andrewonlab47eddf22014-11-06 17:10:54 -0500174 main.ONOS1.stop_tshark()
175
kelvin-onlab8a832582015-01-16 17:06:11 -0800176 # tshark output is saved in ONOS. Use subprocess
177 # to copy over files to TestON for parsing
178 main.log.info( "Copying over tshark files" )
andrewonlab47eddf22014-11-06 17:10:54 -0500179
kelvin-onlab8a832582015-01-16 17:06:11 -0800180 # TCP CAPTURE ****
181 # Copy the tshark output from ONOS machine to
182 # TestON machine in tshark_tcp_output directory>file
183 os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
184 tshark_tcp_output + " /tmp/" )
185 tcp_file = open( tshark_tcp_output, 'r' )
186 temp_text = tcp_file.readline()
187 temp_text = temp_text.split( " " )
188
189 main.log.info( "Object read in from TCP capture: " +
190 str( temp_text ) )
191 if len( temp_text ) > 1:
192 t0_tcp = float( temp_text[ 1 ] ) * 1000.0
andrewonlab47eddf22014-11-06 17:10:54 -0500193 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800194 main.log.error( "Tshark output file for TCP" +
195 " returned unexpected results" )
andrewonlab47eddf22014-11-06 17:10:54 -0500196 t0_tcp = 0
197 assertion = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800198
andrewonlab47eddf22014-11-06 17:10:54 -0500199 tcp_file.close()
200 #****************
201
kelvin-onlab8a832582015-01-16 17:06:11 -0800202 # OF CAPTURE ****
203 os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
204 tshark_of_output + " /tmp/" )
205 of_file = open( tshark_of_output, 'r' )
206
andrewonlab47eddf22014-11-06 17:10:54 -0500207 line_ofp = ""
kelvin-onlab8a832582015-01-16 17:06:11 -0800208 # Read until last line of file
andrewonlab47eddf22014-11-06 17:10:54 -0500209 while True:
210 temp_text = of_file.readline()
kelvin-onlab8a832582015-01-16 17:06:11 -0800211 if temp_text != '':
andrewonlab47eddf22014-11-06 17:10:54 -0500212 line_ofp = temp_text
213 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800214 break
215 obj = line_ofp.split( " " )
216
217 main.log.info( "Object read in from OFP capture: " +
218 str( line_ofp ) )
219
220 if len( line_ofp ) > 1:
221 t0_ofp = float( obj[ 1 ] ) * 1000.0
andrewonlab47eddf22014-11-06 17:10:54 -0500222 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800223 main.log.error( "Tshark output file for OFP" +
224 " returned unexpected results" )
andrewonlab47eddf22014-11-06 17:10:54 -0500225 t0_ofp = 0
226 assertion = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800227
andrewonlab47eddf22014-11-06 17:10:54 -0500228 of_file.close()
229 #****************
kelvin-onlab8a832582015-01-16 17:06:11 -0800230
andrewonlab47eddf22014-11-06 17:10:54 -0500231 json_str_1 = main.ONOS1cli.topology_events_metrics()
232
kelvin-onlab8a832582015-01-16 17:06:11 -0800233 json_obj_1 = json.loads( json_str_1 )
andrewonlab47eddf22014-11-06 17:10:54 -0500234
kelvin-onlab8a832582015-01-16 17:06:11 -0800235 # Obtain graph timestamp. This timestsamp captures
236 # the epoch time at which the topology graph was updated.
andrewonlab47eddf22014-11-06 17:10:54 -0500237 graph_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800238 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500239
kelvin-onlab8a832582015-01-16 17:06:11 -0800240 # Obtain device timestamp. This timestamp captures
241 # the epoch time at which the device event happened
andrewonlab47eddf22014-11-06 17:10:54 -0500242 device_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800243 json_obj_1[ deviceTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500244
kelvin-onlab8a832582015-01-16 17:06:11 -0800245 # t0 to device processing latency
246 delta_device_1 = int( device_timestamp_1 ) - int( t0_tcp )
247
248 # Get average of delta from all instances
249 avg_delta_device = ( int( delta_device_1 ) )
250
251 # Ensure avg delta meets the threshold before appending
andrewonlab47eddf22014-11-06 17:10:54 -0500252 if avg_delta_device > 0.0 and avg_delta_device < 10000:
kelvin-onlab8a832582015-01-16 17:06:11 -0800253 latency_t0_to_device_list.append( avg_delta_device )
andrewonlab47eddf22014-11-06 17:10:54 -0500254 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800255 main.log.info( "Results for t0-to-device ignored" +
256 "due to excess in threshold" )
andrewonlab47eddf22014-11-06 17:10:54 -0500257
kelvin-onlab8a832582015-01-16 17:06:11 -0800258 # t0 to graph processing latency ( end-to-end )
259 delta_graph_1 = int( graph_timestamp_1 ) - int( t0_tcp )
andrewonlab47eddf22014-11-06 17:10:54 -0500260
kelvin-onlab8a832582015-01-16 17:06:11 -0800261 # Get average of delta from all instances
262 avg_delta_graph = int( delta_graph_1 )
263
264 # Ensure avg delta meets the threshold before appending
andrewonlab47eddf22014-11-06 17:10:54 -0500265 if avg_delta_graph > 0.0 and avg_delta_graph < 10000:
kelvin-onlab8a832582015-01-16 17:06:11 -0800266 latency_end_to_end_list.append( avg_delta_graph )
andrewonlab47eddf22014-11-06 17:10:54 -0500267 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800268 main.log.info( "Results for end-to-end ignored" +
269 "due to excess in threshold" )
andrewonlab47eddf22014-11-06 17:10:54 -0500270
kelvin-onlab8a832582015-01-16 17:06:11 -0800271 # ofp to graph processing latency ( ONOS processing )
272 delta_ofp_graph_1 = int( graph_timestamp_1 ) - int( t0_ofp )
273
274 avg_delta_ofp_graph = int( delta_ofp_graph_1 )
275
andrewonlab47eddf22014-11-06 17:10:54 -0500276 if avg_delta_ofp_graph > 0.0 and avg_delta_ofp_graph < 10000:
kelvin-onlab8a832582015-01-16 17:06:11 -0800277 latency_ofp_to_graph_list.append( avg_delta_ofp_graph )
andrewonlab47eddf22014-11-06 17:10:54 -0500278 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800279 main.log.info( "Results for ofp-to-graph " +
280 "ignored due to excess in threshold" )
andrewonlab47eddf22014-11-06 17:10:54 -0500281
kelvin-onlab8a832582015-01-16 17:06:11 -0800282 # ofp to device processing latency ( ONOS processing )
283 delta_ofp_device_1 = float( device_timestamp_1 ) - float( t0_ofp )
284
285 avg_delta_ofp_device = float( delta_ofp_device_1 )
286
287 # NOTE: ofp - delta measurements are occasionally negative
andrewonlab47eddf22014-11-06 17:10:54 -0500288 # due to system time misalignment.
kelvin-onlab8a832582015-01-16 17:06:11 -0800289 latency_ofp_to_device_list.append( avg_delta_ofp_device )
andrewonlab47eddf22014-11-06 17:10:54 -0500290
kelvin-onlab8a832582015-01-16 17:06:11 -0800291 # TODO:
292 # Fetch logs upon threshold excess
andrewonlab47eddf22014-11-06 17:10:54 -0500293
kelvin-onlab8a832582015-01-16 17:06:11 -0800294 main.log.info( "ONOS1 delta end-to-end: " +
295 str( delta_graph_1 ) + " ms" )
andrewonlab47eddf22014-11-06 17:10:54 -0500296
kelvin-onlab8a832582015-01-16 17:06:11 -0800297 main.log.info( "ONOS1 delta OFP - graph: " +
298 str( delta_ofp_graph_1 ) + " ms" )
andrewonlab47eddf22014-11-06 17:10:54 -0500299
kelvin-onlab8a832582015-01-16 17:06:11 -0800300 main.log.info( "ONOS1 delta device - t0: " +
301 str( delta_device_1 ) + " ms" )
andrewonlab47eddf22014-11-06 17:10:54 -0500302
kelvin-onlab8a832582015-01-16 17:06:11 -0800303 main.step( "Remove switch from controller" )
304 main.Mininet1.delete_sw_controller( "s1" )
andrewonlab47eddf22014-11-06 17:10:54 -0500305
kelvin-onlab8a832582015-01-16 17:06:11 -0800306 time.sleep( 5 )
307
308 # END of for loop iteration
309
310 # If there is at least 1 element in each list,
311 # pass the test case
312 if len( latency_end_to_end_list ) > 0 and\
313 len( latency_ofp_to_graph_list ) > 0 and\
314 len( latency_ofp_to_device_list ) > 0 and\
315 len( latency_t0_to_device_list ) > 0:
andrewonlab47eddf22014-11-06 17:10:54 -0500316 assertion = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800317 elif len( latency_end_to_end_list ) == 0:
318 # The appending of 0 here is to prevent
319 # the min,max,sum functions from failing
320 # below
321 latency_end_to_end_list.append( 0 )
andrewonlab47eddf22014-11-06 17:10:54 -0500322 assertion = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800323 elif len( latency_ofp_to_graph_list ) == 0:
324 latency_ofp_to_graph_list.append( 0 )
andrewonlab47eddf22014-11-06 17:10:54 -0500325 assertion = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800326 elif len( latency_ofp_to_device_list ) == 0:
327 latency_ofp_to_device_list.append( 0 )
andrewonlab47eddf22014-11-06 17:10:54 -0500328 assertion = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800329 elif len( latency_t0_to_device_list ) == 0:
330 latency_t0_to_device_list.append( 0 )
andrewonlab47eddf22014-11-06 17:10:54 -0500331 assertion = main.FALSE
332
kelvin-onlab8a832582015-01-16 17:06:11 -0800333 # Calculate min, max, avg of latency lists
andrewonlab47eddf22014-11-06 17:10:54 -0500334 latency_end_to_end_max = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800335 int( max( latency_end_to_end_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500336 latency_end_to_end_min = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800337 int( min( latency_end_to_end_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500338 latency_end_to_end_avg = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800339 ( int( sum( latency_end_to_end_list ) ) /
340 len( latency_end_to_end_list ) )
341
andrewonlab47eddf22014-11-06 17:10:54 -0500342 latency_ofp_to_graph_max = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800343 int( max( latency_ofp_to_graph_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500344 latency_ofp_to_graph_min = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800345 int( min( latency_ofp_to_graph_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500346 latency_ofp_to_graph_avg = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800347 ( int( sum( latency_ofp_to_graph_list ) ) /
348 len( latency_ofp_to_graph_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500349
350 latency_ofp_to_device_max = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800351 int( max( latency_ofp_to_device_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500352 latency_ofp_to_device_min = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800353 int( min( latency_ofp_to_device_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500354 latency_ofp_to_device_avg = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800355 ( int( sum( latency_ofp_to_device_list ) ) /
356 len( latency_ofp_to_device_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500357
358 latency_t0_to_device_max = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800359 float( max( latency_t0_to_device_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500360 latency_t0_to_device_min = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800361 float( min( latency_t0_to_device_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500362 latency_t0_to_device_avg = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800363 ( float( sum( latency_t0_to_device_list ) ) /
364 len( latency_ofp_to_device_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500365
kelvin-onlab8a832582015-01-16 17:06:11 -0800366 main.log.report( "Switch add - End-to-end latency: \n" +
367 "Min: " + str( latency_end_to_end_min ) + "\n" +
368 "Max: " + str( latency_end_to_end_max ) + "\n" +
369 "Avg: " + str( latency_end_to_end_avg ) )
370 main.log.report( "Switch add - OFP-to-Graph latency: \n" +
371 "Min: " + str( latency_ofp_to_graph_min ) + "\n" +
372 "Max: " + str( latency_ofp_to_graph_max ) + "\n" +
373 "Avg: " + str( latency_ofp_to_graph_avg ) )
374 main.log.report( "Switch add - t0-to-Device latency: \n" +
375 "Min: " + str( latency_t0_to_device_min ) + "\n" +
376 "Max: " + str( latency_t0_to_device_max ) + "\n" +
377 "Avg: " + str( latency_t0_to_device_avg ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500378
kelvin-onlab8a832582015-01-16 17:06:11 -0800379 utilities.assert_equals( expect=main.TRUE, actual=assertion,
380 onpass="Switch latency test successful",
381 onfail="Switch latency test failed" )
andrewonlab47eddf22014-11-06 17:10:54 -0500382
kelvin-onlab8a832582015-01-16 17:06:11 -0800383 def CASE3( self, main ):
384 """
andrewonlab47eddf22014-11-06 17:10:54 -0500385 Bring port up / down and measure latency.
386 Port enable / disable is simulated by ifconfig up / down
kelvin-onlab8a832582015-01-16 17:06:11 -0800387
388 In ONOS-next, we must ensure that the port we are
andrewonlab47eddf22014-11-06 17:10:54 -0500389 manipulating is connected to another switch with a valid
390 connection. Otherwise, graph view will not be updated.
kelvin-onlab8a832582015-01-16 17:06:11 -0800391 """
andrewonlab47eddf22014-11-06 17:10:54 -0500392 import time
393 import subprocess
394 import os
395 import requests
396 import json
397
kelvin-onlab8a832582015-01-16 17:06:11 -0800398 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
399 ONOS_user = main.params[ 'CTRL' ][ 'user' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500400
kelvin-onlab8a832582015-01-16 17:06:11 -0800401 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
402
andrewonlab47eddf22014-11-06 17:10:54 -0500403 assertion = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800404 # Number of iterations of case
405 num_iter = main.params[ 'TEST' ][ 'numIter' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500406
kelvin-onlab8a832582015-01-16 17:06:11 -0800407 # Timestamp 'keys' for json metrics output.
408 # These are subject to change, hence moved into params
409 deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
410 graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
411
412 # NOTE: Some hardcoded variables you may need to configure
andrewonlab47eddf22014-11-06 17:10:54 -0500413 # besides the params
kelvin-onlab8a832582015-01-16 17:06:11 -0800414
andrewonlab47eddf22014-11-06 17:10:54 -0500415 tshark_port_status = "OFP 130 Port Status"
416
417 tshark_port_up = "/tmp/tshark_port_up.txt"
418 tshark_port_down = "/tmp/tshark_port_down.txt"
419 interface_config = "s1-eth1"
420
kelvin-onlab8a832582015-01-16 17:06:11 -0800421 main.log.report( "Port enable / disable latency" )
andrewonlab47eddf22014-11-06 17:10:54 -0500422
kelvin-onlab8a832582015-01-16 17:06:11 -0800423 main.step( "Assign switches s1 and s2 to controller 1" )
424 main.Mininet1.assign_sw_controller( sw="1", ip1=ONOS1_ip,
425 port1=default_sw_port )
426 main.Mininet1.assign_sw_controller( sw="2", ip1=ONOS1_ip,
427 port1=default_sw_port )
andrewonlab47eddf22014-11-06 17:10:54 -0500428
kelvin-onlab8a832582015-01-16 17:06:11 -0800429 # Give enough time for metrics to propagate the
430 # assign controller event. Otherwise, these events may
431 # carry over to our measurements
432 time.sleep( 10 )
andrewonlab47eddf22014-11-06 17:10:54 -0500433
kelvin-onlab8a832582015-01-16 17:06:11 -0800434 main.step( "Verify switch is assigned correctly" )
435 result_s1 = main.Mininet1.get_sw_controller( sw="s1" )
436 result_s2 = main.Mininet1.get_sw_controller( sw="s2" )
andrewonlab47eddf22014-11-06 17:10:54 -0500437 if result_s1 == main.FALSE or result_s2 == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800438 main.log.info( "Switch s1 was not assigned correctly" )
andrewonlab47eddf22014-11-06 17:10:54 -0500439 assertion = main.FALSE
440 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800441 main.log.info( "Switch s1 was assigned correctly" )
andrewonlab47eddf22014-11-06 17:10:54 -0500442
443 port_up_device_to_ofp_list = []
444 port_up_graph_to_ofp_list = []
445 port_down_device_to_ofp_list = []
446 port_down_graph_to_ofp_list = []
447
kelvin-onlab8a832582015-01-16 17:06:11 -0800448 for i in range( 0, int( num_iter ) ):
449 main.step( "Starting wireshark capture for port status down" )
450 main.ONOS1.tshark_grep( tshark_port_status,
451 tshark_port_down )
andrewonlab47eddf22014-11-06 17:10:54 -0500452
kelvin-onlab8a832582015-01-16 17:06:11 -0800453 time.sleep( 10 )
454
455 # Disable interface that is connected to switch 2
456 main.step( "Disable port: " + interface_config )
457 main.Mininet2.handle.sendline( "sudo ifconfig " +
458 interface_config + " down" )
459 main.Mininet2.handle.expect( "\$" )
460 time.sleep( 10 )
andrewonlab47eddf22014-11-06 17:10:54 -0500461
462 main.ONOS1.tshark_stop()
kelvin-onlab8a832582015-01-16 17:06:11 -0800463 time.sleep( 5 )
andrewonlab47eddf22014-11-06 17:10:54 -0500464
kelvin-onlab8a832582015-01-16 17:06:11 -0800465 # Copy tshark output file from ONOS to TestON instance
466 #/tmp directory
467 os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
468 tshark_port_down + " /tmp/" )
469
470 f_port_down = open( tshark_port_down, 'r' )
471 # Get first line of port down event from tshark
andrewonlab47eddf22014-11-06 17:10:54 -0500472 f_line = f_port_down.readline()
kelvin-onlab8a832582015-01-16 17:06:11 -0800473 obj_down = f_line.split( " " )
474 if len( f_line ) > 0:
475 timestamp_begin_pt_down = int( float( obj_down[ 1 ] ) ) * 1000
476 main.log.info( "Port down begin timestamp: " +
477 str( timestamp_begin_pt_down ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500478 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800479 main.log.info( "Tshark output file returned unexpected" +
480 " results: " + str( obj_down ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500481 timestamp_begin_pt_down = 0
kelvin-onlab8a832582015-01-16 17:06:11 -0800482
andrewonlab47eddf22014-11-06 17:10:54 -0500483 f_port_down.close()
484
kelvin-onlab8a832582015-01-16 17:06:11 -0800485 main.log.info( "TEST tshark obj: " + str( obj_down ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500486
kelvin-onlab8a832582015-01-16 17:06:11 -0800487 main.step( "Obtain t1 by REST call" )
andrewonlab47eddf22014-11-06 17:10:54 -0500488 json_str_1 = main.ONOS1cli.topology_events_metrics()
489
kelvin-onlab8a832582015-01-16 17:06:11 -0800490 main.log.info( "TEST json_str 1: " + str( json_str_1 ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500491
kelvin-onlab8a832582015-01-16 17:06:11 -0800492 json_obj_1 = json.loads( json_str_1 )
andrewonlab47eddf22014-11-06 17:10:54 -0500493
kelvin-onlab8a832582015-01-16 17:06:11 -0800494 time.sleep( 5 )
495
496 # Obtain graph timestamp. This timestsamp captures
497 # the epoch time at which the topology graph was updated.
andrewonlab47eddf22014-11-06 17:10:54 -0500498 graph_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800499 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500500
kelvin-onlab8a832582015-01-16 17:06:11 -0800501 # Obtain device timestamp. This timestamp captures
502 # the epoch time at which the device event happened
andrewonlab47eddf22014-11-06 17:10:54 -0500503 device_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800504 json_obj_1[ deviceTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500505
kelvin-onlab8a832582015-01-16 17:06:11 -0800506 # Get delta between graph event and OFP
507 pt_down_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
508 int( timestamp_begin_pt_down )
andrewonlab47eddf22014-11-06 17:10:54 -0500509
kelvin-onlab8a832582015-01-16 17:06:11 -0800510 # Get delta between device event and OFP
511 pt_down_device_to_ofp_1 = int( device_timestamp_1 ) -\
512 int( timestamp_begin_pt_down )
513
514 # Caluclate average across clusters
515 pt_down_graph_to_ofp_avg = int( pt_down_graph_to_ofp_1 )
516 pt_down_device_to_ofp_avg = int( pt_down_device_to_ofp_1 )
andrewonlab47eddf22014-11-06 17:10:54 -0500517
518 if pt_down_graph_to_ofp_avg > 0.0 and \
519 pt_down_graph_to_ofp_avg < 1000:
520 port_down_graph_to_ofp_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800521 pt_down_graph_to_ofp_avg )
522 main.log.info( "Port down: graph to ofp avg: " +
523 str( pt_down_graph_to_ofp_avg ) + " ms" )
andrewonlab47eddf22014-11-06 17:10:54 -0500524 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800525 main.log.info( "Average port down graph-to-ofp result" +
526 " exceeded the threshold: " +
527 str( pt_down_graph_to_ofp_avg ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500528
529 if pt_down_device_to_ofp_avg > 0 and \
530 pt_down_device_to_ofp_avg < 1000:
531 port_down_device_to_ofp_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800532 pt_down_device_to_ofp_avg )
533 main.log.info( "Port down: device to ofp avg: " +
534 str( pt_down_device_to_ofp_avg ) + " ms" )
andrewonlab47eddf22014-11-06 17:10:54 -0500535 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800536 main.log.info( "Average port down device-to-ofp result" +
537 " exceeded the threshold: " +
538 str( pt_down_device_to_ofp_avg ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500539
kelvin-onlab8a832582015-01-16 17:06:11 -0800540 # Port up events
541 main.step( "Enable port and obtain timestamp" )
542 main.step( "Starting wireshark capture for port status up" )
543 main.ONOS1.tshark_grep( "OFP 130 Port Status", tshark_port_up )
544 time.sleep( 5 )
andrewonlab47eddf22014-11-06 17:10:54 -0500545
kelvin-onlab8a832582015-01-16 17:06:11 -0800546 main.Mininet2.handle.sendline( "sudo ifconfig " +
547 interface_config + " up" )
548 main.Mininet2.handle.expect( "\$" )
549 time.sleep( 10 )
550
andrewonlab47eddf22014-11-06 17:10:54 -0500551 main.ONOS1.tshark_stop()
552
kelvin-onlab8a832582015-01-16 17:06:11 -0800553 os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
554 tshark_port_up + " /tmp/" )
andrewonlab47eddf22014-11-06 17:10:54 -0500555
kelvin-onlab8a832582015-01-16 17:06:11 -0800556 f_port_up = open( tshark_port_up, 'r' )
andrewonlab47eddf22014-11-06 17:10:54 -0500557 f_line = f_port_up.readline()
kelvin-onlab8a832582015-01-16 17:06:11 -0800558 obj_up = f_line.split( " " )
559 if len( f_line ) > 0:
560 timestamp_begin_pt_up = int( float( obj_up[ 1 ] ) ) * 1000
561 main.log.info( "Port up begin timestamp: " +
562 str( timestamp_begin_pt_up ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500563 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800564 main.log.info( "Tshark output file returned unexpected" +
565 " results." )
andrewonlab47eddf22014-11-06 17:10:54 -0500566 timestamp_begin_pt_up = 0
kelvin-onlab8a832582015-01-16 17:06:11 -0800567
andrewonlab47eddf22014-11-06 17:10:54 -0500568 f_port_up.close()
569
kelvin-onlab8a832582015-01-16 17:06:11 -0800570 main.step( "Obtain t1 by REST call" )
andrewonlab47eddf22014-11-06 17:10:54 -0500571 json_str_1 = main.ONOS1cli.topology_events_metrics()
572
kelvin-onlab8a832582015-01-16 17:06:11 -0800573 json_obj_1 = json.loads( json_str_1 )
andrewonlab47eddf22014-11-06 17:10:54 -0500574
kelvin-onlab8a832582015-01-16 17:06:11 -0800575 # Obtain graph timestamp. This timestsamp captures
576 # the epoch time at which the topology graph was updated.
andrewonlab47eddf22014-11-06 17:10:54 -0500577 graph_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800578 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500579
kelvin-onlab8a832582015-01-16 17:06:11 -0800580 # Obtain device timestamp. This timestamp captures
581 # the epoch time at which the device event happened
andrewonlab47eddf22014-11-06 17:10:54 -0500582 device_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800583 json_obj_1[ deviceTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500584
kelvin-onlab8a832582015-01-16 17:06:11 -0800585 # Get delta between graph event and OFP
586 pt_up_graph_to_ofp_1 = int( graph_timestamp_1 ) -\
587 int( timestamp_begin_pt_up )
andrewonlab47eddf22014-11-06 17:10:54 -0500588
kelvin-onlab8a832582015-01-16 17:06:11 -0800589 # Get delta between device event and OFP
590 pt_up_device_to_ofp_1 = int( device_timestamp_1 ) -\
591 int( timestamp_begin_pt_up )
andrewonlab47eddf22014-11-06 17:10:54 -0500592
kelvin-onlab8a832582015-01-16 17:06:11 -0800593 pt_up_graph_to_ofp_avg = float( pt_up_graph_to_ofp_1 )
594
595 pt_up_device_to_ofp_avg = float( pt_up_device_to_ofp_1 )
andrewonlab47eddf22014-11-06 17:10:54 -0500596
597 if pt_up_graph_to_ofp_avg > 0 and \
598 pt_up_graph_to_ofp_avg < 1000:
599 port_up_graph_to_ofp_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800600 pt_up_graph_to_ofp_avg )
601 main.log.info( "Port down: graph to ofp avg: " +
602 str( pt_up_graph_to_ofp_avg ) + " ms" )
andrewonlab47eddf22014-11-06 17:10:54 -0500603 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800604 main.log.info( "Average port up graph-to-ofp result" +
605 " exceeded the threshold: " +
606 str( pt_up_graph_to_ofp_avg ) )
607
andrewonlab47eddf22014-11-06 17:10:54 -0500608 if pt_up_device_to_ofp_avg > 0 and \
609 pt_up_device_to_ofp_avg < 1000:
610 port_up_device_to_ofp_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800611 pt_up_device_to_ofp_avg )
612 main.log.info( "Port up: device to ofp avg: " +
613 str( pt_up_device_to_ofp_avg ) + " ms" )
andrewonlab47eddf22014-11-06 17:10:54 -0500614 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800615 main.log.info( "Average port up device-to-ofp result" +
616 " exceeded the threshold: " +
617 str( pt_up_device_to_ofp_avg ) )
618
619 # END ITERATION FOR LOOP
620
621 # Check all list for latency existence and set assertion
622 if ( port_down_graph_to_ofp_list and port_down_device_to_ofp_list
623 and port_up_graph_to_ofp_list and port_up_device_to_ofp_list ):
andrewonlab47eddf22014-11-06 17:10:54 -0500624 assertion = main.TRUE
625
kelvin-onlab8a832582015-01-16 17:06:11 -0800626 # Calculate and report latency measurements
627 port_down_graph_to_ofp_min = min( port_down_graph_to_ofp_list )
628 port_down_graph_to_ofp_max = max( port_down_graph_to_ofp_list )
andrewonlab47eddf22014-11-06 17:10:54 -0500629 port_down_graph_to_ofp_avg = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800630 ( sum( port_down_graph_to_ofp_list ) /
631 len( port_down_graph_to_ofp_list ) )
632
633 main.log.report( "Port down graph-to-ofp Min: " +
634 str( port_down_graph_to_ofp_min ) + " ms Max: " +
635 str( port_down_graph_to_ofp_max ) + " ms Avg: " +
636 str( port_down_graph_to_ofp_avg ) )
637
638 port_down_device_to_ofp_min = min( port_down_device_to_ofp_list )
639 port_down_device_to_ofp_max = max( port_down_device_to_ofp_list )
andrewonlab47eddf22014-11-06 17:10:54 -0500640 port_down_device_to_ofp_avg = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800641 ( sum( port_down_device_to_ofp_list ) /
642 len( port_down_device_to_ofp_list ) )
643
644 main.log.report( "Port down device-to-ofp Min: " +
645 str( port_down_device_to_ofp_min ) + " ms Max: " +
646 str( port_down_device_to_ofp_max ) + " ms Avg: " +
647 str( port_down_device_to_ofp_avg ) )
648
649 port_up_graph_to_ofp_min = min( port_up_graph_to_ofp_list )
650 port_up_graph_to_ofp_max = max( port_up_graph_to_ofp_list )
andrewonlab47eddf22014-11-06 17:10:54 -0500651 port_up_graph_to_ofp_avg = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800652 ( sum( port_up_graph_to_ofp_list ) /
653 len( port_up_graph_to_ofp_list ) )
654
655 main.log.report( "Port up graph-to-ofp Min: " +
656 str( port_up_graph_to_ofp_min ) + " ms Max: " +
657 str( port_up_graph_to_ofp_max ) + " ms Avg: " +
658 str( port_up_graph_to_ofp_avg ) )
659
660 port_up_device_to_ofp_min = min( port_up_device_to_ofp_list )
661 port_up_device_to_ofp_max = max( port_up_device_to_ofp_list )
andrewonlab47eddf22014-11-06 17:10:54 -0500662 port_up_device_to_ofp_avg = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800663 ( sum( port_up_device_to_ofp_list ) /
664 len( port_up_device_to_ofp_list ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500665
kelvin-onlab8a832582015-01-16 17:06:11 -0800666 main.log.report( "Port up device-to-ofp Min: " +
667 str( port_up_device_to_ofp_min ) + " ms Max: " +
668 str( port_up_device_to_ofp_max ) + " ms Avg: " +
669 str( port_up_device_to_ofp_avg ) )
andrewonlab47eddf22014-11-06 17:10:54 -0500670
kelvin-onlab8a832582015-01-16 17:06:11 -0800671 utilities.assert_equals(
672 expect=main.TRUE,
673 actual=assertion,
674 onpass="Port discovery latency calculation successful",
675 onfail="Port discovery test failed" )
676
677 def CASE4( self, main ):
678 """
andrewonlab47eddf22014-11-06 17:10:54 -0500679 Link down event using loss rate 100%
kelvin-onlab8a832582015-01-16 17:06:11 -0800680
andrewonlab47eddf22014-11-06 17:10:54 -0500681 Important:
682 Use a simple 2 switch topology with 1 link between
kelvin-onlab8a832582015-01-16 17:06:11 -0800683 the two switches. Ensure that mac addresses of the
andrewonlab47eddf22014-11-06 17:10:54 -0500684 switches are 1 / 2 respectively
kelvin-onlab8a832582015-01-16 17:06:11 -0800685 """
andrewonlab47eddf22014-11-06 17:10:54 -0500686 import time
687 import subprocess
688 import os
689 import requests
690 import json
691
kelvin-onlab8a832582015-01-16 17:06:11 -0800692 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
693 ONOS_user = main.params[ 'CTRL' ][ 'user' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500694
kelvin-onlab8a832582015-01-16 17:06:11 -0800695 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
696
697 # Number of iterations of case
698 num_iter = main.params[ 'TEST' ][ 'numIter' ]
699
700 # Timestamp 'keys' for json metrics output.
701 # These are subject to change, hence moved into params
702 deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
703 linkTimestamp = main.params[ 'JSON' ][ 'linkTimestamp' ]
704 graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500705
706 assertion = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800707 # Link event timestamp to system time list
andrewonlab47eddf22014-11-06 17:10:54 -0500708 link_down_link_to_system_list = []
709 link_up_link_to_system_list = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800710 # Graph event timestamp to system time list
andrewonlab47eddf22014-11-06 17:10:54 -0500711 link_down_graph_to_system_list = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800712 link_up_graph_to_system_list = []
andrewonlab47eddf22014-11-06 17:10:54 -0500713
kelvin-onlab8a832582015-01-16 17:06:11 -0800714 main.log.report( "Add / remove link latency between " +
715 "two switches" )
andrewonlab47eddf22014-11-06 17:10:54 -0500716
kelvin-onlab8a832582015-01-16 17:06:11 -0800717 main.step( "Assign all switches" )
718 main.Mininet1.assign_sw_controller(
719 sw="1",
720 ip1=ONOS1_ip,
721 port1=default_sw_port )
722 main.Mininet1.assign_sw_controller(
723 sw="2",
724 ip1=ONOS1_ip,
725 port1=default_sw_port )
andrewonlab47eddf22014-11-06 17:10:54 -0500726
kelvin-onlab8a832582015-01-16 17:06:11 -0800727 main.step( "Verifying switch assignment" )
728 result_s1 = main.Mininet1.get_sw_controller( sw="s1" )
729 result_s2 = main.Mininet1.get_sw_controller( sw="s2" )
730
731 # Allow time for events to finish before taking measurements
732 time.sleep( 10 )
andrewonlab47eddf22014-11-06 17:10:54 -0500733
734 link_down = False
kelvin-onlab8a832582015-01-16 17:06:11 -0800735 # Start iteration of link event test
736 for i in range( 0, int( num_iter ) ):
737 main.step( "Getting initial system time as t0" )
andrewonlab47eddf22014-11-06 17:10:54 -0500738
kelvin-onlab8a832582015-01-16 17:06:11 -0800739 timestamp_link_down_t0 = time.time() * 1000
740 # Link down is simulated by 100% loss rate using traffic
741 # control command
742 main.Mininet1.handle.sendline(
743 "sh tc qdisc add dev s1-eth1 root netem loss 100%" )
744
745 # TODO: Iterate through 'links' command to verify that
746 # link s1 -> s2 went down ( loop timeout 30 seconds )
andrewonlab47eddf22014-11-06 17:10:54 -0500747 # on all 3 ONOS instances
kelvin-onlab8a832582015-01-16 17:06:11 -0800748 main.log.info( "Checking ONOS for link update" )
andrewonlab47eddf22014-11-06 17:10:54 -0500749 loop_count = 0
750 while( not link_down and loop_count < 30 ):
751 json_str = main.ONOS1cli.links()
kelvin-onlab8a832582015-01-16 17:06:11 -0800752
andrewonlab47eddf22014-11-06 17:10:54 -0500753 if not json_str:
kelvin-onlab8a832582015-01-16 17:06:11 -0800754 main.log.error( "CLI command returned error " )
andrewonlab47eddf22014-11-06 17:10:54 -0500755 break
756 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800757 json_obj = json.loads( json_str )
andrewonlab47eddf22014-11-06 17:10:54 -0500758 for obj in json_obj:
kelvin-onlab8a832582015-01-16 17:06:11 -0800759 if '01' not in obj[ 'src' ][ 'device' ]:
andrewonlab47eddf22014-11-06 17:10:54 -0500760 link_down = True
kelvin-onlab8a832582015-01-16 17:06:11 -0800761 main.log.report( "Link down from " +
762 "s1 -> s2 on ONOS1 detected" )
andrewonlab47eddf22014-11-06 17:10:54 -0500763 loop_count += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800764 # If CLI doesn't like the continuous requests
765 # and exits in this loop, increase the sleep here.
766 # Consequently, while loop timeout will increase
767 time.sleep( 1 )
768
769 # Give time for metrics measurement to catch up
770 # NOTE: May need to be configured more accurately
771 time.sleep( 10 )
772 # If we exited the while loop and link down 1,2,3 are still
773 # false, then ONOS has failed to discover link down event
andrewonlab47eddf22014-11-06 17:10:54 -0500774 if not link_down:
kelvin-onlab8a832582015-01-16 17:06:11 -0800775 main.log.info( "Link down discovery failed" )
776
andrewonlab47eddf22014-11-06 17:10:54 -0500777 link_down_lat_graph1 = 0
778 link_down_lat_device1 = 0
779 assertion = main.FALSE
780 else:
781 json_topo_metrics_1 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800782 main.ONOS1cli.topology_events_metrics()
783 json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
784
785 main.log.info( "Obtaining graph and device timestamp" )
andrewonlab47eddf22014-11-06 17:10:54 -0500786 graph_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800787 json_topo_metrics_1[ graphTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500788
789 link_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800790 json_topo_metrics_1[ linkTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500791
792 if graph_timestamp_1 and link_timestamp_1:
kelvin-onlab8a832582015-01-16 17:06:11 -0800793 link_down_lat_graph1 = int( graph_timestamp_1 ) -\
794 timestamp_link_down_t0
795
796 link_down_lat_link1 = int( link_timestamp_1 ) -\
797 timestamp_link_down_t0
andrewonlab47eddf22014-11-06 17:10:54 -0500798 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800799 main.log.error( "There was an error calculating" +
800 " the delta for link down event" )
andrewonlab47eddf22014-11-06 17:10:54 -0500801 link_down_lat_graph1 = 0
kelvin-onlab8a832582015-01-16 17:06:11 -0800802
andrewonlab47eddf22014-11-06 17:10:54 -0500803 link_down_lat_device1 = 0
kelvin-onlab8a832582015-01-16 17:06:11 -0800804
805 main.log.report( "Link down latency ONOS1 iteration " +
806 str( i ) + " (end-to-end): " +
807 str( link_down_lat_graph1 ) + " ms" )
808
809 main.log.report( "Link down latency ONOS1 iteration " +
810 str( i ) + " (link-event-to-system-timestamp): " +
811 str( link_down_lat_link1 ) + " ms" )
812
813 # Calculate avg of node calculations
andrewonlab47eddf22014-11-06 17:10:54 -0500814 link_down_lat_graph_avg = link_down_lat_graph1
815 link_down_lat_link_avg = link_down_lat_link1
816
kelvin-onlab8a832582015-01-16 17:06:11 -0800817 # Set threshold and append latency to list
andrewonlab47eddf22014-11-06 17:10:54 -0500818 if link_down_lat_graph_avg > 0.0 and\
819 link_down_lat_graph_avg < 30000:
820 link_down_graph_to_system_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800821 link_down_lat_graph_avg )
andrewonlab47eddf22014-11-06 17:10:54 -0500822 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800823 main.log.info( "Link down latency exceeded threshold" )
824 main.log.info( "Results for iteration " + str( i ) +
825 "have been omitted" )
andrewonlab47eddf22014-11-06 17:10:54 -0500826 if link_down_lat_link_avg > 0.0 and\
827 link_down_lat_link_avg < 30000:
828 link_down_link_to_system_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800829 link_down_lat_link_avg )
andrewonlab47eddf22014-11-06 17:10:54 -0500830 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800831 main.log.info( "Link down latency exceeded threshold" )
832 main.log.info( "Results for iteration " + str( i ) +
833 "have been omitted" )
andrewonlab47eddf22014-11-06 17:10:54 -0500834
kelvin-onlab8a832582015-01-16 17:06:11 -0800835 # NOTE: To remove loss rate and measure latency:
andrewonlab47eddf22014-11-06 17:10:54 -0500836 # 'sh tc qdisc del dev s1-eth1 root'
837 timestamp_link_up_t0 = time.time() * 1000
kelvin-onlab8a832582015-01-16 17:06:11 -0800838 main.Mininet1.handle.sendline( "sh tc qdisc del dev " +
839 "s1-eth1 root" )
840 main.Mininet1.handle.expect( "mininet>" )
841
842 main.log.info( "Checking ONOS for link update" )
843
andrewonlab47eddf22014-11-06 17:10:54 -0500844 link_down1 = True
845 loop_count = 0
846 while( link_down1 and loop_count < 30 ):
847 json_str1 = main.ONOS1cli.links()
848 if not json_str1:
kelvin-onlab8a832582015-01-16 17:06:11 -0800849 main.log.error( "CLI command returned error " )
andrewonlab47eddf22014-11-06 17:10:54 -0500850 break
851 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800852 json_obj1 = json.loads( json_str1 )
853
andrewonlab47eddf22014-11-06 17:10:54 -0500854 for obj1 in json_obj1:
kelvin-onlab8a832582015-01-16 17:06:11 -0800855 if '01' in obj1[ 'src' ][ 'device' ]:
856 link_down1 = False
857 main.log.report( "Link up from " +
858 "s1 -> s2 on ONOS1 detected" )
andrewonlab47eddf22014-11-06 17:10:54 -0500859 loop_count += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800860 time.sleep( 1 )
861
andrewonlab47eddf22014-11-06 17:10:54 -0500862 if link_down1:
kelvin-onlab8a832582015-01-16 17:06:11 -0800863 main.log.info( "Link up discovery failed" )
andrewonlab47eddf22014-11-06 17:10:54 -0500864 link_up_lat_graph1 = 0
865 link_up_lat_device1 = 0
866 assertion = main.FALSE
867 else:
868 json_topo_metrics_1 =\
kelvin-onlab8a832582015-01-16 17:06:11 -0800869 main.ONOS1cli.topology_events_metrics()
870 json_topo_metrics_1 = json.loads( json_topo_metrics_1 )
andrewonlab47eddf22014-11-06 17:10:54 -0500871
kelvin-onlab8a832582015-01-16 17:06:11 -0800872 main.log.info( "Obtaining graph and device timestamp" )
andrewonlab47eddf22014-11-06 17:10:54 -0500873 graph_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800874 json_topo_metrics_1[ graphTimestamp ][ 'value' ]
875
andrewonlab47eddf22014-11-06 17:10:54 -0500876 link_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -0800877 json_topo_metrics_1[ linkTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500878
879 if graph_timestamp_1 and link_timestamp_1:
kelvin-onlab8a832582015-01-16 17:06:11 -0800880 link_up_lat_graph1 = int( graph_timestamp_1 ) -\
881 timestamp_link_up_t0
882 link_up_lat_link1 = int( link_timestamp_1 ) -\
883 timestamp_link_up_t0
andrewonlab47eddf22014-11-06 17:10:54 -0500884 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800885 main.log.error( "There was an error calculating" +
886 " the delta for link down event" )
andrewonlab47eddf22014-11-06 17:10:54 -0500887 link_up_lat_graph1 = 0
888 link_up_lat_device1 = 0
kelvin-onlab8a832582015-01-16 17:06:11 -0800889
890 main.log.info( "Link up latency ONOS1 iteration " +
891 str( i ) + " (end-to-end): " +
892 str( link_up_lat_graph1 ) + " ms" )
893
894 main.log.info( "Link up latency ONOS1 iteration " +
895 str( i ) + " (link-event-to-system-timestamp): " +
896 str( link_up_lat_link1 ) + " ms" )
897
898 # Calculate avg of node calculations
andrewonlab47eddf22014-11-06 17:10:54 -0500899 link_up_lat_graph_avg = link_up_lat_graph1
900 link_up_lat_link_avg = link_up_lat_link1
901
kelvin-onlab8a832582015-01-16 17:06:11 -0800902 # Set threshold and append latency to list
andrewonlab47eddf22014-11-06 17:10:54 -0500903 if link_up_lat_graph_avg > 0.0 and\
904 link_up_lat_graph_avg < 30000:
905 link_up_graph_to_system_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800906 link_up_lat_graph_avg )
andrewonlab47eddf22014-11-06 17:10:54 -0500907 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800908 main.log.info( "Link up latency exceeded threshold" )
909 main.log.info( "Results for iteration " + str( i ) +
910 "have been omitted" )
andrewonlab47eddf22014-11-06 17:10:54 -0500911 if link_up_lat_link_avg > 0.0 and\
912 link_up_lat_link_avg < 30000:
913 link_up_link_to_system_list.append(
kelvin-onlab8a832582015-01-16 17:06:11 -0800914 link_up_lat_link_avg )
andrewonlab47eddf22014-11-06 17:10:54 -0500915 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800916 main.log.info( "Link up latency exceeded threshold" )
917 main.log.info( "Results for iteration " + str( i ) +
918 "have been omitted" )
andrewonlab47eddf22014-11-06 17:10:54 -0500919
kelvin-onlab8a832582015-01-16 17:06:11 -0800920 # Calculate min, max, avg of list and report
921 link_down_min = min( link_down_graph_to_system_list )
922 link_down_max = max( link_down_graph_to_system_list )
923 link_down_avg = sum( link_down_graph_to_system_list ) / \
924 len( link_down_graph_to_system_list )
925 link_up_min = min( link_up_graph_to_system_list )
926 link_up_max = max( link_up_graph_to_system_list )
927 link_up_avg = sum( link_up_graph_to_system_list ) / \
928 len( link_up_graph_to_system_list )
andrewonlab47eddf22014-11-06 17:10:54 -0500929
kelvin-onlab8a832582015-01-16 17:06:11 -0800930 main.log.report( "Link down latency - Min: " +
931 str( link_down_min ) + "ms Max: " +
932 str( link_down_max ) + "ms Avg: " +
933 str( link_down_avg ) + "ms" )
934 main.log.report( "Link up latency - Min: " +
935 str( link_up_min ) + "ms Max: " +
936 str( link_up_max ) + "ms Avg: " +
937 str( link_up_avg ) + "ms" )
andrewonlab47eddf22014-11-06 17:10:54 -0500938
kelvin-onlab8a832582015-01-16 17:06:11 -0800939 utilities.assert_equals(
940 expect=main.TRUE,
941 actual=assertion,
942 onpass="Link discovery latency calculation successful",
943 onfail="Link discovery latency case failed" )
andrewonlab47eddf22014-11-06 17:10:54 -0500944
kelvin-onlab8a832582015-01-16 17:06:11 -0800945 def CASE5( self, main ):
946 """
andrewonlab47eddf22014-11-06 17:10:54 -0500947 100 Switch discovery latency
948
949 Important:
kelvin-onlab8a832582015-01-16 17:06:11 -0800950 This test case can be potentially dangerous if
andrewonlab47eddf22014-11-06 17:10:54 -0500951 your machine has previously set iptables rules.
952 One of the steps of the test case will flush
953 all existing iptables rules.
954 Note:
kelvin-onlab8a832582015-01-16 17:06:11 -0800955 You can specify the number of switches in the
andrewonlab47eddf22014-11-06 17:10:54 -0500956 params file to adjust the switch discovery size
kelvin-onlab8a832582015-01-16 17:06:11 -0800957 ( and specify the corresponding topology in Mininet1
958 .topo file )
959 """
andrewonlab47eddf22014-11-06 17:10:54 -0500960 import time
961 import subprocess
962 import os
963 import requests
964 import json
965
kelvin-onlab8a832582015-01-16 17:06:11 -0800966 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
967 MN1_ip = main.params[ 'MN' ][ 'ip1' ]
968 ONOS_user = main.params[ 'CTRL' ][ 'user' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500969
kelvin-onlab8a832582015-01-16 17:06:11 -0800970 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab47eddf22014-11-06 17:10:54 -0500971
kelvin-onlab8a832582015-01-16 17:06:11 -0800972 # Number of iterations of case
973 num_iter = main.params[ 'TEST' ][ 'numIter' ]
974 num_sw = main.params[ 'TEST' ][ 'numSwitch' ]
975
976 # Timestamp 'keys' for json metrics output.
977 # These are subject to change, hence moved into params
978 deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
979 graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
980
981 tshark_ofp_output = "/tmp/tshark_ofp_" + num_sw + "sw.txt"
982 tshark_tcp_output = "/tmp/tshark_tcp_" + num_sw + "sw.txt"
andrewonlab47eddf22014-11-06 17:10:54 -0500983
984 tshark_ofp_result_list = []
985 tshark_tcp_result_list = []
986
kelvin-onlab8a832582015-01-16 17:06:11 -0800987 main.case( num_sw + " Switch discovery latency" )
988 main.step( "Assigning all switches to ONOS1" )
989 for i in range( 1, int( num_sw ) + 1 ):
andrewonlab47eddf22014-11-06 17:10:54 -0500990 main.Mininet1.assign_sw_controller(
kelvin-onlab8a832582015-01-16 17:06:11 -0800991 sw=str( i ),
992 ip1=ONOS1_ip,
993 port1=default_sw_port )
andrewonlab47eddf22014-11-06 17:10:54 -0500994
kelvin-onlab8a832582015-01-16 17:06:11 -0800995 # Ensure that nodes are configured with ptpd
996 # Just a warning message
997 main.log.info( "Please check ptpd configuration to ensure" +
998 " All nodes' system times are in sync" )
999 time.sleep( 5 )
1000
1001 for i in range( 0, int( num_iter ) ):
1002
1003 main.step( "Set iptables rule to block incoming sw connections" )
1004 # Set iptables rule to block incoming switch connections
1005 # The rule description is as follows:
andrewonlab47eddf22014-11-06 17:10:54 -05001006 # Append to INPUT rule,
1007 # behavior DROP that matches following:
1008 # * packet type: tcp
1009 # * source IP: MN1_ip
1010 # * destination PORT: 6633
1011 main.ONOS1.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -08001012 "sudo iptables -A INPUT -p tcp -s " + MN1_ip +
1013 " --dport " + default_sw_port + " -j DROP" )
1014 main.ONOS1.handle.expect( "\$" )
1015 # Append to OUTPUT rule,
andrewonlab47eddf22014-11-06 17:10:54 -05001016 # behavior DROP that matches following:
1017 # * packet type: tcp
1018 # * source IP: MN1_ip
1019 # * destination PORT: 6633
1020 main.ONOS1.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -08001021 "sudo iptables -A OUTPUT -p tcp -s " + MN1_ip +
1022 " --dport " + default_sw_port + " -j DROP" )
1023 main.ONOS1.handle.expect( "\$" )
1024 # Give time to allow rule to take effect
1025 # NOTE: Sleep period may need to be configured
andrewonlab47eddf22014-11-06 17:10:54 -05001026 # based on the number of switches in the topology
kelvin-onlab8a832582015-01-16 17:06:11 -08001027 main.log.info( "Please wait for switch connection to " +
1028 "time out" )
1029 time.sleep( 60 )
andrewonlab47eddf22014-11-06 17:10:54 -05001030
kelvin-onlab8a832582015-01-16 17:06:11 -08001031 # Gather vendor OFP with tshark
1032 main.ONOS1.tshark_grep( "OFP 86 Vendor",
1033 tshark_ofp_output )
1034 main.ONOS1.tshark_grep( "TCP 74 ",
1035 tshark_tcp_output )
1036
1037 # NOTE: Remove all iptables rule quickly ( flush )
1038 # Before removal, obtain TestON timestamp at which
andrewonlab47eddf22014-11-06 17:10:54 -05001039 # removal took place
kelvin-onlab8a832582015-01-16 17:06:11 -08001040 # ( ensuring nodes are configured via ptp )
andrewonlab47eddf22014-11-06 17:10:54 -05001041 # sudo iptables -F
kelvin-onlab8a832582015-01-16 17:06:11 -08001042
andrewonlab47eddf22014-11-06 17:10:54 -05001043 t0_system = time.time() * 1000
1044 main.ONOS1.handle.sendline(
kelvin-onlab8a832582015-01-16 17:06:11 -08001045 "sudo iptables -F" )
andrewonlab47eddf22014-11-06 17:10:54 -05001046
kelvin-onlab8a832582015-01-16 17:06:11 -08001047 # Counter to track loop count
andrewonlab47eddf22014-11-06 17:10:54 -05001048 counter_loop = 0
1049 counter_avail1 = 0
1050 onos1_dev = False
1051 while counter_loop < 60:
kelvin-onlab8a832582015-01-16 17:06:11 -08001052 # Continue to check devices for all device
1053 # availability. When all devices in all 3
1054 # ONOS instances indicate that devices are available
1055 # obtain graph event timestamp for t1.
andrewonlab47eddf22014-11-06 17:10:54 -05001056 device_str_obj1 = main.ONOS1cli.devices()
kelvin-onlab8a832582015-01-16 17:06:11 -08001057 device_json1 = json.loads( device_str_obj1 )
1058
andrewonlab47eddf22014-11-06 17:10:54 -05001059 for device1 in device_json1:
kelvin-onlab8a832582015-01-16 17:06:11 -08001060 if device1[ 'available' ]:
andrewonlab47eddf22014-11-06 17:10:54 -05001061 counter_avail1 += 1
kelvin-onlab8a832582015-01-16 17:06:11 -08001062 if counter_avail1 == int( num_sw ):
andrewonlab47eddf22014-11-06 17:10:54 -05001063 onos1_dev = True
kelvin-onlab8a832582015-01-16 17:06:11 -08001064 main.log.info( "All devices have been " +
1065 "discovered on ONOS1" )
andrewonlab47eddf22014-11-06 17:10:54 -05001066 else:
1067 counter_avail1 = 0
1068
kelvin-onlab8a832582015-01-16 17:06:11 -08001069 if onos1_dev:
1070 main.log.info( "All devices have been discovered " +
1071 "on all ONOS instances" )
andrewonlab47eddf22014-11-06 17:10:54 -05001072 json_str_topology_metrics_1 =\
1073 main.ONOS1cli.topology_events_metrics()
kelvin-onlab8a832582015-01-16 17:06:11 -08001074 # Exit while loop if all devices discovered
1075 break
1076
andrewonlab47eddf22014-11-06 17:10:54 -05001077 counter_loop += 1
kelvin-onlab8a832582015-01-16 17:06:11 -08001078 # Give some time in between CLI calls
1079 #( will not affect measurement )
1080 time.sleep( 3 )
andrewonlab47eddf22014-11-06 17:10:54 -05001081
1082 main.ONOS1.tshark_stop()
andrewonlab47eddf22014-11-06 17:10:54 -05001083
kelvin-onlab8a832582015-01-16 17:06:11 -08001084 os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
1085 tshark_ofp_output + " /tmp/" )
1086 os.system( "scp " + ONOS_user + "@" + ONOS1_ip + ":" +
1087 tshark_tcp_output + " /tmp/" )
1088 ofp_file = open( tshark_ofp_output, 'r' )
1089
1090 # The following is for information purpose only.
1091 # TODO: Automate OFP output analysis
1092 main.log.info( "Tshark OFP Vendor output: " )
andrewonlab47eddf22014-11-06 17:10:54 -05001093 for line in ofp_file:
kelvin-onlab8a832582015-01-16 17:06:11 -08001094 tshark_ofp_result_list.append( line )
1095 main.log.info( line )
andrewonlab47eddf22014-11-06 17:10:54 -05001096
1097 ofp_file.close()
1098
kelvin-onlab8a832582015-01-16 17:06:11 -08001099 tcp_file = open( tshark_tcp_output, 'r' )
1100 main.log.info( "Tshark TCP 74 output: " )
andrewonlab47eddf22014-11-06 17:10:54 -05001101 for line in tcp_file:
kelvin-onlab8a832582015-01-16 17:06:11 -08001102 tshark_tcp_result_list.append( line )
1103 main.log.info( line )
andrewonlab47eddf22014-11-06 17:10:54 -05001104
1105 tcp_file.close()
1106
kelvin-onlab8a832582015-01-16 17:06:11 -08001107 json_obj_1 = json.loads( json_str_topology_metrics_1 )
andrewonlab47eddf22014-11-06 17:10:54 -05001108
1109 graph_timestamp_1 = \
kelvin-onlab8a832582015-01-16 17:06:11 -08001110 json_obj_1[ graphTimestamp ][ 'value' ]
andrewonlab47eddf22014-11-06 17:10:54 -05001111
1112 main.log.info(
kelvin-onlab8a832582015-01-16 17:06:11 -08001113 int( graph_timestamp_1 ) - int( t0_system ) )