blob: 4c26b59ee9298c310bdfb4126250d6a549977263 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070021"""
YPZhang38fb1192016-08-11 11:03:38 -070022 Wrapper function for SCPFswitchLat test
23 Assign switch and capture openflow package
24 remove switch and caputer openflow package
25 calculate latency
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070026"""
YPZhang38fb1192016-08-11 11:03:38 -070027import time
28import json
chengchiyu08303a02016-09-08 17:40:26 -070029
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070030
chengchiyu08303a02016-09-08 17:40:26 -070031def getTimestampFromLog( index, searchTerm ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070032 """
chengchiyu08303a02016-09-08 17:40:26 -070033 Get timestamp value of the search term from log.
34 Args:
35 index: the index of cli
36 searchTerm: the key term of timestamp
37
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070038 """
Devin Lim142b5342017-07-20 15:22:39 -070039 lines = main.Cluster.active( index ).CLI.logSearch( mode='last', searchTerm=searchTerm )
chengchiyu08303a02016-09-08 17:40:26 -070040 try:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070041 assert lines is not None
42 logString = lines[ len( lines ) - 1 ]
43 # get the target value
chengchiyu08303a02016-09-08 17:40:26 -070044 line = logString.split( "time = " )
45 key = line[ 1 ].split( " " )
46 return int( key[ 0 ] )
47 except IndexError:
48 main.log.warn( "Index Error!" )
49 return 0
50 except AssertionError:
51 main.log.warn( "Search Term Not Found" )
52 return 0
53
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070054
YPZhang38fb1192016-08-11 11:03:38 -070055def processPackage( package ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070056 """
YPZhang38fb1192016-08-11 11:03:38 -070057 split package information to dictionary
58 Args:
59 package: Package String
60
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070061 """
You Wang1ecfd0a2019-06-21 15:00:45 -070062 pacakge = package.strip().split( " " )
YPZhang38fb1192016-08-11 11:03:38 -070063 dic = {}
64 for s in pacakge:
65 try:
chengchiyu08303a02016-09-08 17:40:26 -070066 [ key, value ] = s.split( "=" )
67 dic[ key ] = value
YPZhang38fb1192016-08-11 11:03:38 -070068 except:
69 continue
70 return dic
71
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070072
chengchiyu08303a02016-09-08 17:40:26 -070073def findSeqBySeqAck( seq, packageList ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070074 """
YPZhang38fb1192016-08-11 11:03:38 -070075 Find specific Seq of package in packageList
76 Args:
77 seq: seq from last TCP package
78 packageList: find package in packageList
79
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070080 """
YPZhang38fb1192016-08-11 11:03:38 -070081 for l in packageList:
chengchiyu08303a02016-09-08 17:40:26 -070082 temp = processPackage( l )
83 tA = temp[ 'Ack' ]
84 if int( seq ) + 1 == int( tA ):
85 return temp[ 'Seq' ]
86
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070087
chengchiyu08303a02016-09-08 17:40:26 -070088def arrangeTsharkFile( switchStatus, keyTerm ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070089 """
chengchiyu08303a02016-09-08 17:40:26 -070090 Arrange different tshark messeage from overall file to different specific files
91 Args:
92 switchStatus: switch up or down
93 keyTerm: A dictionary that store the path name as value and the searchTerm as key
94
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070095 """
chengchiyu08303a02016-09-08 17:40:26 -070096 with open( main.tsharkResultPath[ switchStatus ][ 'ALL' ], 'r' ) as resultFile:
97 resultText = resultFile.readlines()
98 resultFile.close()
99
100 for line in resultText:
101 for term in keyTerm:
102 if term in line:
You Wang112d84c2018-04-27 15:58:28 -0700103 # Exclude non-openflow FIN packets
You Wang1ecfd0a2019-06-21 15:00:45 -0700104 if term == "[FIN, ACK]" and "6653" not in line:
You Wang112d84c2018-04-27 15:58:28 -0700105 continue
chengchiyu08303a02016-09-08 17:40:26 -0700106 path = '/tmp/Tshark_' + str( keyTerm[ term ] )
107 with open( path, 'a' ) as outputfile:
108 outputfile.write( line )
109 outputfile.close()
110
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700111
chengchiyu08303a02016-09-08 17:40:26 -0700112def checkResult( result1, result2, result3 ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700113 """
chengchiyu08303a02016-09-08 17:40:26 -0700114 Check if the inputs meet the requirement
115 Returns:
116 1 means the results are right, 0 means the results are wrong
117
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700118 """
chengchiyu08303a02016-09-08 17:40:26 -0700119 result = check( result1 ) + check( result2 ) + check( result3 )
120 if result < 3:
121 # if any result is wrong, increase the main wrong number
122 main.wrong[ 'checkResultIncorrect' ] += 1
123 main.wrong[ 'totalWrong' ] += 1
124 checkTotalWrongNum()
125 return 0
126 return 1
127
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700128
chengchiyu08303a02016-09-08 17:40:26 -0700129def check( result ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700130 """
chengchiyu08303a02016-09-08 17:40:26 -0700131 Check the single input.
132 Returns:
133 1 means the input is good, 0 means the input is wrong
134
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700135 """
chengchiyu08303a02016-09-08 17:40:26 -0700136 if result < int( main.resultRange[ 'Min' ] ) or result > int( main.resultRange[ 'Max' ] ):
Devin Limaa256a72017-10-13 13:40:30 -0700137 main.log.warn( str( result ) + " is not meet the requirement" )
chengchiyu08303a02016-09-08 17:40:26 -0700138 return 0
139 return 1
140
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700141
chengchiyu08303a02016-09-08 17:40:26 -0700142def checkTotalWrongNum():
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700143 """
chengchiyu08303a02016-09-08 17:40:26 -0700144 Check if the total wrong number is bigger than the max wrong number. If it is, then exit the
145 test.
146
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700147 """
chengchiyu08303a02016-09-08 17:40:26 -0700148 # if there are too many wrongs in this test, then exit
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700149 if main.wrong[ 'totalWrong' ] > main.maxWrong:
chengchiyu08303a02016-09-08 17:40:26 -0700150 main.log.error( "The total wrong number exceeds %d, test terminated" % main.maxWrong )
Devin Lim44075962017-08-11 10:56:37 -0700151 main.cleanAndExit()
chengchiyu08303a02016-09-08 17:40:26 -0700152
YPZhang38fb1192016-08-11 11:03:38 -0700153
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700154def captureOfPack( main, deviceName, ofPack, switchStatus, resultDict, warmup ):
155 """
YPZhang38fb1192016-08-11 11:03:38 -0700156 Args:
157 main: TestON class
158 deviceName: device name
159 ofPack: openflow package key word
160 switchStatus: Up -- assign, down -- remove
161 resultDict: dictionary to contain result
162 warmup: warm up boolean
163
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700164 """
chengchiyu08303a02016-09-08 17:40:26 -0700165 main.log.debug( "TOTAL WRONG: " + str( main.wrong ) )
166 for d in ofPack[ switchStatus ]:
167 main.log.info( "Clean up Tshark" )
168 with open( main.tsharkResultPath[ switchStatus ][ d ], "w" ) as tshark:
169 tshark.write( "" )
170 # use one tshark to grep everything
171 # Get the grep string
172 grepString = ''
173 keyTerm = {}
174 for d in ofPack[ switchStatus ]:
175 grepString = grepString + ofPack[ switchStatus ][ d ] + '|'
176 # get rid of regular experssion format
177 cleanTerm = ofPack[ switchStatus ][ d ].replace( '\\', '' )
178 keyTerm[ cleanTerm ] = d
179 # Delete the last '|'
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700180 grepString = grepString[ :-1 ]
chengchiyu08303a02016-09-08 17:40:26 -0700181 # open tshark
182 main.log.info( "starting tshark capture" )
183 main.ONOSbench.tsharkGrep( grepString, main.tsharkResultPath[ switchStatus ][ 'ALL' ], grepOptions='-E' )
YPZhang38fb1192016-08-11 11:03:38 -0700184 if switchStatus == 'up':
185 # if up, assign switch to controller
chengchiyu08303a02016-09-08 17:40:26 -0700186 time.sleep( main.measurementSleep )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700187 main.log.info( 'Assigning {} to controller'.format( deviceName ) )
Devin Lim142b5342017-07-20 15:22:39 -0700188 main.Mininet1.assignSwController( sw=deviceName, ip=main.Cluster.active( 0 ).ipAddress )
chengchiyu08303a02016-09-08 17:40:26 -0700189 time.sleep( main.measurementSleep )
YPZhang38fb1192016-08-11 11:03:38 -0700190 if switchStatus == 'down':
191 # if down, remove switch from topology
chengchiyu08303a02016-09-08 17:40:26 -0700192 time.sleep( main.measurementSleep )
193 main.step( 'Remove switch from controler' )
194 main.Mininet1.deleteSwController( deviceName )
195 time.sleep( main.deleteSwSleep )
YPZhang38fb1192016-08-11 11:03:38 -0700196 main.log.info( "Stopping all Tshark processes" )
197 main.ONOSbench.tsharkStop()
YPZhang38fb1192016-08-11 11:03:38 -0700198 tempResultDict = {}
chengchiyu08303a02016-09-08 17:40:26 -0700199 arrangeTsharkFile( switchStatus, keyTerm )
200
YPZhang38fb1192016-08-11 11:03:38 -0700201 if switchStatus == 'up':
chengchiyu08303a02016-09-08 17:40:26 -0700202 for d in main.tsharkResultPath[ 'up' ]:
203 with open( main.tsharkResultPath[ switchStatus ][ d ], "r" ) as resultFile:
YPZhang38fb1192016-08-11 11:03:38 -0700204 # grep tshark result timestamp
205 resultText = resultFile.readlines()
You Wang5b811272017-08-04 17:22:18 -0700206 if not resultText:
207 main.log.warn( "Empty tshark result!" )
208 main.wrong[ 'TsharkValueIncorrect' ] += 1
209 main.wrong[ 'totalWrong' ] += 1
210 checkTotalWrongNum()
211 return
YPZhang21adb602016-08-18 16:00:11 -0700212 if d == "TCP":
213 # if TCP package, we should use the latest one package
chengchiyu08303a02016-09-08 17:40:26 -0700214 resultText = resultText[ len( resultText ) - 1 ]
YPZhang21adb602016-08-18 16:00:11 -0700215 else:
chengchiyu08303a02016-09-08 17:40:26 -0700216 resultText = resultText[ 0 ]
217 main.log.info( "Capture result:" + resultText )
YPZhang38fb1192016-08-11 11:03:38 -0700218 resultText = resultText.strip()
219 resultText = resultText.split( " " )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700220 if len( resultText ) > 1:
221 tempResultDict[ d ] = int( ( float( resultText[ 1 ] ) * 1000 ) )
YPZhang38fb1192016-08-11 11:03:38 -0700222 resultFile.close()
223 elif switchStatus == 'down':
224 # if state is down, we should capture Fin/Ack and ACK package
225 # Use seq number in FIN/ACK package to located ACK package
chengchiyu08303a02016-09-08 17:40:26 -0700226 with open( main.tsharkResultPath[ 'down' ][ 'FA' ], 'r' ) as resultFile:
YPZhang38fb1192016-08-11 11:03:38 -0700227 resultText = resultFile.readlines()
chengchiyu08303a02016-09-08 17:40:26 -0700228 FinAckText = resultText.pop( 0 )
YPZhang38fb1192016-08-11 11:03:38 -0700229 resultFile.close()
chengchiyu08303a02016-09-08 17:40:26 -0700230 FinAckSeq = processPackage( FinAckText )[ 'Seq' ]
231 FinAckOFseq = findSeqBySeqAck( FinAckSeq, resultText )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700232 if FinAckOFseq is None:
You Wang18477602017-02-24 15:48:01 -0800233 main.log.warn( "Tshark Result was incorrect!" )
234 main.log.warn( resultText )
235 main.wrong[ 'TsharkValueIncorrect' ] += 1
236 main.wrong[ 'totalWrong' ] += 1
237 checkTotalWrongNum()
238 return
chengchiyu08303a02016-09-08 17:40:26 -0700239 with open( main.tsharkResultPath[ 'down' ][ 'ACK' ], "r" ) as resultFile:
YPZhang38fb1192016-08-11 11:03:38 -0700240 ACKlines = resultFile.readlines()
241 resultFile.close()
YPZhang3943fbe2016-08-18 14:33:29 -0700242 AckPackage = ""
YPZhang38fb1192016-08-11 11:03:38 -0700243 for l in ACKlines:
chengchiyu08303a02016-09-08 17:40:26 -0700244 temp = processPackage( l )
245 finSeq = findSeqBySeqAck( FinAckOFseq, ACKlines )
246 if temp[ 'Seq' ] == finSeq:
YPZhang38fb1192016-08-11 11:03:38 -0700247 AckPackage = l
chengchiyu08303a02016-09-08 17:40:26 -0700248 if len( AckPackage ) > 0:
YPZhang3943fbe2016-08-18 14:33:29 -0700249 FinAckText = FinAckText.strip()
chengchiyu08303a02016-09-08 17:40:26 -0700250 FinAckText = FinAckText.split( " " )
YPZhang3943fbe2016-08-18 14:33:29 -0700251 AckPackage = AckPackage.strip()
chengchiyu08303a02016-09-08 17:40:26 -0700252 AckPackage = AckPackage.split( " " )
253 tempResultDict[ 'ACK' ] = int( float( AckPackage[ 1 ] ) * 1000 )
254 tempResultDict[ 'FA' ] = int( float( FinAckText[ 1 ] ) * 1000 )
YPZhang3943fbe2016-08-18 14:33:29 -0700255 else:
chengchiyu08303a02016-09-08 17:40:26 -0700256 main.wrong[ 'skipDown' ] += 1
257 main.wrong[ 'totalWrong' ] += 1
258 checkTotalWrongNum()
YPZhang3943fbe2016-08-18 14:33:29 -0700259 return
chengchiyu08303a02016-09-08 17:40:26 -0700260
YPZhang38fb1192016-08-11 11:03:38 -0700261 # calculate latency
262 if switchStatus == "up":
263 # up Latency
chengchiyu08303a02016-09-08 17:40:26 -0700264 for d in resultDict[ switchStatus ]:
YPZhang38fb1192016-08-11 11:03:38 -0700265 T_Ftemp = 0
YPZhang38fb1192016-08-11 11:03:38 -0700266 try:
chengchiyu08303a02016-09-08 17:40:26 -0700267 T_Ftemp = tempResultDict[ 'Feature' ] - tempResultDict[ 'TCP' ]
YPZhang38fb1192016-08-11 11:03:38 -0700268 except KeyError:
chengchiyu08303a02016-09-08 17:40:26 -0700269 main.log.warn( "Tshark Result was incorrect!" )
270 main.log.warn( tempResultDict )
271 main.wrong[ 'TsharkValueIncorrect' ] += 1
272 main.wrong[ 'totalWrong' ] += 1
273 checkTotalWrongNum()
YPZhang38fb1192016-08-11 11:03:38 -0700274 return
275 if not warmup:
chengchiyu08303a02016-09-08 17:40:26 -0700276 resultDict[ switchStatus ][ d ][ 'T_F' ].append( T_Ftemp )
YPZhang38fb1192016-08-11 11:03:38 -0700277
chengchiyu08303a02016-09-08 17:40:26 -0700278 main.log.info( "{} TCP to Feature: {}".format( d, str( T_Ftemp ) ) )
YPZhang38fb1192016-08-11 11:03:38 -0700279
Devin Lim142b5342017-07-20 15:22:39 -0700280 for i in range( 1, main.Cluster.numCtrls + 1 ):
Devin Limf70bb3a2018-04-13 19:15:51 -0700281 F_Dtemp = 0
YPZhang38fb1192016-08-11 11:03:38 -0700282 D_Gtemp = 0
283 E_Etemp = 0
chengchiyu08303a02016-09-08 17:40:26 -0700284 main.log.info( "================================================" )
YPZhang38fb1192016-08-11 11:03:38 -0700285 # get onos metrics timestamps
286 try:
Devin Lim142b5342017-07-20 15:22:39 -0700287 response = json.loads( main.Cluster.active( i - 1 ).CLI.topologyEventsMetrics() )
Devin Limaa256a72017-10-13 13:40:30 -0700288
289 # Just to show the other event times.
290 main.log.info( "ONOS{} device Event timestamp: {}".format(
291 i, int( response.get( "topologyDeviceEventTimestamp" ).get( "value" ) ) ) )
292 main.log.info( "ONOS{} graph reason Event timestamp: {}".format(
293 i, int( response.get( "topologyGraphReasonsEventTimestamp" ).get( "value" ) ) ) )
294
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700295 DeviceTime = getTimestampFromLog( i - 1, searchTerm=main.searchTerm[ switchStatus ] )
Devin Limaa256a72017-10-13 13:40:30 -0700296 main.log.info( "ONOS{} device from karaf log: {}".format( i, DeviceTime ) )
chengchiyu08303a02016-09-08 17:40:26 -0700297 GraphTime = int( response.get( "topologyGraphEventTimestamp" ).get( "value" ) )
298 main.log.info( "ONOS{} Graph Event timestamp: {}".format( i, GraphTime ) )
YPZhang38fb1192016-08-11 11:03:38 -0700299 except TypeError:
chengchiyu08303a02016-09-08 17:40:26 -0700300 main.log.warn( "TypeError" )
301 main.wrong[ 'TypeError' ] += 1
302 main.wrong[ 'totalWrong' ] += 1
303 checkTotalWrongNum()
YPZhang38fb1192016-08-11 11:03:38 -0700304 break
305 except ValueError:
chengchiyu08303a02016-09-08 17:40:26 -0700306 main.log.warn( "Error to decode Json object!" )
307 main.wrong[ 'decodeJasonError' ] += 1
308 main.wrong[ 'totalWrong' ] += 1
309 checkTotalWrongNum()
YPZhang38fb1192016-08-11 11:03:38 -0700310 break
chengchiyu08303a02016-09-08 17:40:26 -0700311 if DeviceTime != 0:
312 try:
Devin Limf70bb3a2018-04-13 19:15:51 -0700313 F_Dtemp = DeviceTime - tempResultDict[ 'Feature' ]
chengchiyu08303a02016-09-08 17:40:26 -0700314 D_Gtemp = GraphTime - DeviceTime
315 E_Etemp = GraphTime - tempResultDict[ 'TCP' ]
Devin Limf70bb3a2018-04-13 19:15:51 -0700316 check = checkResult( F_Dtemp, D_Gtemp, E_Etemp )
chengchiyu08303a02016-09-08 17:40:26 -0700317 if check == 1:
Devin Limf70bb3a2018-04-13 19:15:51 -0700318 main.log.info( "Feature to Device:{}".format( F_Dtemp ) )
chengchiyu08303a02016-09-08 17:40:26 -0700319 main.log.info( "Device to Graph:{}".format( D_Gtemp ) )
320 main.log.info( "End to End:{}".format( E_Etemp ) )
321 main.log.info( "================================================" )
322 except KeyError:
323 main.log.warn( "Tshark Result was incorrect!" )
324 main.log.warn( tempResultDict )
325 main.wrong[ 'TsharkValueIncorrect' ] += 1
326 main.wrong[ 'totalWrong' ] += 1
327 checkTotalWrongNum()
328 return
329 except TypeError:
330 main.log.warn( "TypeError" )
331 main.wrong[ 'TypeError' ] += 1
332 main.wrong[ 'totalWrong' ] += 1
333 checkTotalWrongNum()
334 break
335 except ValueError:
336 main.log.warn( "Error to decode Json object!" )
337 main.wrong[ 'decodeJasonError' ] += 1
338 main.wrong[ 'totalWrong' ] += 1
339 checkTotalWrongNum()
340 break
341 if not warmup and check == 1:
Devin Limf70bb3a2018-04-13 19:15:51 -0700342 resultDict[ switchStatus ][ 'node' + str( i ) ][ 'F_D' ].append( F_Dtemp )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700343 resultDict[ switchStatus ][ 'node' + str( i ) ][ 'D_G' ].append( D_Gtemp )
344 resultDict[ switchStatus ][ 'node' + str( i ) ][ 'E_E' ].append( E_Etemp )
chengchiyu08303a02016-09-08 17:40:26 -0700345 else:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700346 main.wrong[ 'checkResultIncorrect' ] += 1
chengchiyu08303a02016-09-08 17:40:26 -0700347 main.wrong[ 'totalWrong' ] += 1
348 checkTotalWrongNum()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700349 main.log.debug( "Skip this iteration due to the None Devicetime" )
YPZhang38fb1192016-08-11 11:03:38 -0700350
351 if switchStatus == "down":
352 # down Latency
chengchiyu08303a02016-09-08 17:40:26 -0700353 for d in resultDict[ switchStatus ]:
YPZhang38fb1192016-08-11 11:03:38 -0700354 FA_Atemp = 0
355 try:
chengchiyu08303a02016-09-08 17:40:26 -0700356 FA_Atemp = tempResultDict[ 'ACK' ] - tempResultDict[ 'FA' ]
YPZhang38fb1192016-08-11 11:03:38 -0700357 except KeyError:
chengchiyu08303a02016-09-08 17:40:26 -0700358 main.log.warn( "Tshark Result was incorrect!" )
359 main.log.warn( tempResultDict )
360 main.wrong[ 'TsharkValueIncorrect' ] += 1
361 main.wrong[ 'totalWrong' ] += 1
362 checkTotalWrongNum()
YPZhang38fb1192016-08-11 11:03:38 -0700363 return
364 if not warmup:
chengchiyu08303a02016-09-08 17:40:26 -0700365 resultDict[ switchStatus ][ d ][ 'FA_A' ].append( FA_Atemp )
366 main.log.info( "{} FIN/ACK TO ACK {}:".format( d, FA_Atemp ) )
Devin Lim142b5342017-07-20 15:22:39 -0700367 for i in range( 1, main.Cluster.numCtrls + 1 ):
YPZhang38fb1192016-08-11 11:03:38 -0700368 A_Dtemp = 0
369 D_Gtemp = 0
370 E_Etemp = 0
chengchiyu08303a02016-09-08 17:40:26 -0700371 main.log.info( "================================================" )
YPZhang38fb1192016-08-11 11:03:38 -0700372 # get onos metrics timestamps
373 try:
Devin Lim142b5342017-07-20 15:22:39 -0700374 response = json.loads( main.Cluster.active( i - 1 ).CLI.topologyEventsMetrics() )
Devin Limaa256a72017-10-13 13:40:30 -0700375 # Just to show the other event times.
376 main.log.info( "ONOS{} device Event timestamp: {}".format(
377 i, int( response.get( "topologyDeviceEventTimestamp" ).get( "value" ) ) ) )
378 main.log.info( "ONOS{} graph reason Event timestamp: {}".format(
379 i, int( response.get( "topologyGraphReasonsEventTimestamp" ).get( "value" ) ) ) )
380
Devin Lim142b5342017-07-20 15:22:39 -0700381 DeviceTime = getTimestampFromLog( i - 1, searchTerm=main.searchTerm[ switchStatus ] )
Devin Limaa256a72017-10-13 13:40:30 -0700382 main.log.info( "ONOS{} device from karaf log: {}".format( i, DeviceTime ) )
chengchiyu08303a02016-09-08 17:40:26 -0700383 GraphTime = int( response.get( "topologyGraphEventTimestamp" ).get( "value" ) )
384 main.log.info( "ONOS{} Graph Event timestamp: {}".format( i, GraphTime ) )
YPZhang38fb1192016-08-11 11:03:38 -0700385 except TypeError:
chengchiyu08303a02016-09-08 17:40:26 -0700386 main.log.warn( "TypeError" )
387 main.wrong[ 'TypeError' ] += 1
388 main.wrong[ 'totalWrong' ] += 1
389 checkTotalWrongNum()
YPZhang38fb1192016-08-11 11:03:38 -0700390 break
391 except ValueError:
chengchiyu08303a02016-09-08 17:40:26 -0700392 main.log.warn( "Error to decode Json object!" )
393 main.wrong[ 'decodeJasonError' ] += 1
394 main.wrong[ 'totalWrong' ] += 1
395 checkTotalWrongNum()
YPZhang38fb1192016-08-11 11:03:38 -0700396 break
chengchiyu08303a02016-09-08 17:40:26 -0700397 if DeviceTime != 0:
398 main.log.info( "================================================" )
399 try:
400 A_Dtemp = DeviceTime - tempResultDict[ 'ACK' ]
401 D_Gtemp = GraphTime - DeviceTime
402 E_Etemp = GraphTime - tempResultDict[ 'FA' ]
403 check = checkResult( A_Dtemp, D_Gtemp, E_Etemp )
404 if check == 1:
405 main.log.info( "ACK to device: {}".format( A_Dtemp ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700406 main.log.info( "Device to Graph: {}".format( D_Gtemp ) )
chengchiyu08303a02016-09-08 17:40:26 -0700407 main.log.info( "End to End: {}".format( E_Etemp ) )
408 main.log.info( "================================================" )
409 except KeyError:
410 main.log.warn( "Tshark Result was incorrect!" )
411 main.log.warn( tempResultDict )
412 main.wrong[ 'TsharkValueIncorrect' ] += 1
413 main.wrong[ 'totalWrong' ] += 1
414 checkTotalWrongNum()
415 return
416 except TypeError:
417 main.log.warn( "TypeError" )
418 main.wrong[ 'TypeError' ] += 1
419 main.wrong[ 'totalWrong' ] += 1
420 checkTotalWrongNum()
421 break
422 except ValueError:
423 main.log.warn( "Error to decode Json object!" )
424 main.wrong[ 'decodeJasonError' ] += 1
425 main.wrong[ 'totalWrong' ] += 1
426 checkTotalWrongNum()
427 break
428 if not warmup and check == 1:
429 resultDict[ switchStatus ][ 'node' + str( i ) ][ 'A_D' ].append( A_Dtemp )
430 resultDict[ switchStatus ][ 'node' + str( i ) ][ 'D_G' ].append( D_Gtemp )
431 resultDict[ switchStatus ][ 'node' + str( i ) ][ 'E_E' ].append( E_Etemp )
432
433 else:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700434 main.wrong[ 'checkResultIncorrect' ] += 1
435 main.wrong[ 'totalWrong' ] += 1
chengchiyu08303a02016-09-08 17:40:26 -0700436 checkTotalWrongNum()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700437 main.log.debug( "Skip this iteration due to the None Devicetime" )