blob: deaaead75684a39cdd9b6085c9c3323ff6d3e127 [file] [log] [blame]
YPZhang38fb1192016-08-11 11:03:38 -07001'''
2 SCPFswitchLat
3 Test Switch add/remove latency
4 calculate package latency between switch and ONOS
5 Switch UP:
6 TCP -- Feature Reply -- Role Request -- Role Reply -- Device -- Graph
7 Siwtch Down:
8 Openflow FIN/ACK -- ACK -- Device -- Graph
9'''
cameron@onlab.us21106ea2015-07-23 15:32:51 -070010
11class SCPFswitchLat:
12
YPZhang38fb1192016-08-11 11:03:38 -070013 def __init__(self):
cameron@onlab.us21106ea2015-07-23 15:32:51 -070014 self.default = ''
15
YPZhang38fb1192016-08-11 11:03:38 -070016 def CASE0( self, main ):
cameron@onlab.us21106ea2015-07-23 15:32:51 -070017 import os
YPZhang38fb1192016-08-11 11:03:38 -070018 import imp
19 '''
20 - GIT
21 - BUILDING ONOS
22 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
23 This step is usually skipped. Because in a Jenkins driven automated
24 test env. We want Jenkins jobs to pull&build for flexibility to handle
25 different versions of ONOS.
26 - Construct tests variables
27 '''
Devin Lim58046fa2017-07-05 16:55:00 -070028 try:
29 from tests.dependencies.ONOSSetup import ONOSSetup
30 main.testSetUp = ONOSSetup()
31 except ImportError:
32 main.log.error( "ONOSSetup not found. exiting the test" )
33 main.exit()
34 main.testSetUp.envSetupDescription()
35 stepResult = main.FALSE
36 try:
37 # The dictionary to record different type of wrongs
38 main.wrong = { 'totalWrong': 0, 'skipDown' : 0, 'TsharkValueIncorrect': 0,
39 'TypeError' : 0, 'decodeJasonError': 0,
40 'checkResultIncorrect': 0}
41 main.maxWrong = int( main.params['TEST'] ['MaxWrong'] )
42 main.resultRange = main.params['TEST']['ResultRange']
43 main.searchTerm = main.params['TEST']['SearchTerm']
44 main.MN1Ip = main.params['MN']['ip1']
45 main.dependencyPath = main.testOnDirectory + \
46 main.params['DEPENDENCY']['path']
47 main.topoName = main.params['DEPENDENCY']['topology']
48 main.dependencyFunc = main.params['DEPENDENCY']['function']
49 main.cellName = main.params['ENV']['cellName']
50 main.apps = main.params['ENV']['cellApps']
51 main.scale = (main.params['SCALE']).split(",")
YPZhang38fb1192016-08-11 11:03:38 -070052
Devin Lim58046fa2017-07-05 16:55:00 -070053 main.ofPackage = main.params['TSHARK']
YPZhang38fb1192016-08-11 11:03:38 -070054
Devin Lim58046fa2017-07-05 16:55:00 -070055 main.tsharkResultPath = main.params['TEST']['tsharkResultPath']
56 main.sampleSize = int(main.params['TEST']['sampleSize'])
57 main.warmUp = int(main.params['TEST']['warmUp'])
58 main.dbFileName = main.params['DATABASE']['dbName']
59 main.startUpSleep = int(main.params['SLEEP']['startup'])
60 main.measurementSleep = int( main.params['SLEEP']['measure'] )
61 main.deleteSwSleep = int( main.params['SLEEP']['deleteSW'] )
62 main.maxScale = int( main.params['max'] )
63 main.timeout = int( main.params['TIMEOUT']['timeout'] )
64 main.MNSleep = int( main.params['SLEEP']['mininet'])
65 main.device = main.params['TEST']['device']
66 stepResult = main.testSetUp.gitPulling()
67 main.log.info("Create Database file " + main.dbFileName)
68 resultsDB = open(main.dbFileName, "w+")
69 resultsDB.close()
YPZhang38fb1192016-08-11 11:03:38 -070070
Devin Lim58046fa2017-07-05 16:55:00 -070071 main.switchFunc = imp.load_source(main.dependencyFunc,
72 main.dependencyPath +
73 main.dependencyFunc +
74 ".py")
75 except Exception as e:
76 main.testSetUp.envSetupException( e )
77 main.testSetUp.evnSetupConclusion( stepResult )
78 main.commit = main.commit.split( " " )[ 1 ]
YPZhang38fb1192016-08-11 11:03:38 -070079 def CASE1(self, main):
80 # Clean up test environment and set up
cameron@onlab.us21106ea2015-07-23 15:32:51 -070081 import time
Devin Lim58046fa2017-07-05 16:55:00 -070082 try:
83 from tests.dependencies.utils import Utils
84 except ImportError:
85 main.log.error( "Utils not found exiting the test" )
YPZhang38fb1192016-08-11 11:03:38 -070086 main.exit()
Devin Lim58046fa2017-07-05 16:55:00 -070087 try:
88 main.Utils
89 except ( NameError, AttributeError ):
90 main.Utils = Utils()
91 main.maxNumBatch = 0
92 main.testSetUp.getNumCtrls( True )
93 main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
94 main.testSetUp.ONOSSetUp( main.Mininet1, True,
95 cellName=main.cellName, killRemoveMax=False,
96 CtrlsSet=False )
YPZhang38fb1192016-08-11 11:03:38 -070097
98 main.log.info("Configure apps")
99 main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider",
100 "maxEvents 1")
101 main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider",
102 "maxBatchMs 0")
103 main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider",
104 "maxIdleMs 0")
chengchiyu08303a02016-09-08 17:40:26 -0700105 for i in range(main.numCtrls):
106 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology")
YPZhang38fb1192016-08-11 11:03:38 -0700107 time.sleep(1)
108
109 main.log.info("Copy topology file to Mininet")
110 main.ONOSbench.copyMininetFile(main.topoName,
111 main.dependencyPath,
112 main.Mininet1.user_name,
113 main.Mininet1.ip_address)
Devin Lim58046fa2017-07-05 16:55:00 -0700114 main.Utils.mininetCleanup( main.Mininet1 )
YPZhang38fb1192016-08-11 11:03:38 -0700115 time.sleep(main.MNSleep)
116 main.log.info("Start new mininet topology")
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700117 main.Mininet1.startNet()
YPZhang38fb1192016-08-11 11:03:38 -0700118 main.log.info("Assign switch to controller to ONOS node 1")
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700119
YPZhang38fb1192016-08-11 11:03:38 -0700120 time.sleep(2)
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700121
YPZhang38fb1192016-08-11 11:03:38 -0700122 def CASE2(self,main):
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700123 import time
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700124 import json
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700125 import numpy
126
YPZhang38fb1192016-08-11 11:03:38 -0700127 resultDict = {'up' : {}, 'down' : {}}
128 for i in range(1, main.numCtrls + 1):
129 resultDict['up'][ 'node' + str(i) ] = {}
130 resultDict['up'][ 'node' + str(i) ][ 'Ave' ] = {}
131 resultDict['up'][ 'node' + str(i) ][ 'Std' ] = {}
132 resultDict['up'][ 'node' + str(i) ][ 'T_F' ] = []#TCP to Feature
133 resultDict['up'][ 'node' + str(i) ][ 'F_R' ] = []#Feature to Role
134 resultDict['up'][ 'node' + str(i) ][ 'RQ_RR' ] = []#role request to role reply
135 resultDict['up'][ 'node' + str(i) ][ 'RR_D' ] = []#role reply to Device
136 resultDict['up'][ 'node' + str(i) ][ 'D_G' ] = []#Device to Graph
137 resultDict['up'][ 'node' + str(i) ][ 'E_E' ] = []#TCP to Graph
Jon Hall4ba53f02015-07-29 13:07:41 -0700138
YPZhang38fb1192016-08-11 11:03:38 -0700139 for i in range(1,main.numCtrls + 1):
140 resultDict['down'][ 'node' + str(i) ] = {}
141 resultDict['down'][ 'node' + str(i) ][ 'Ave' ] = {}
142 resultDict['down'][ 'node' + str(i) ][ 'Std' ] = {}
143 resultDict['down'][ 'node' + str(i) ][ 'FA_A' ] = []#Fin_ack to ACK
144 resultDict['down'][ 'node' + str(i) ][ 'A_D' ] = []#Ack to Device
145 resultDict['down'][ 'node' + str(i) ][ 'D_G' ] = []#Device to Graph
146 resultDict['down'][ 'node' + str(i) ][ 'E_E' ] = []#fin_ack to Graph
147 for i in range(1 , main.sampleSize + main.warmUp):
148 main.log.info("************************************************************")
149 main.log.info("************************ Iteration: {} **********************" .format(str( i )) )
150 if i < main.warmUp:
151 main.switchFunc.captureOfPack( main, main.device, main.ofPackage,
152 "up", resultDict, True )
153 main.switchFunc.captureOfPack( main, main.device, main.ofPackage,
154 "down", resultDict, True )
chengchiyu08303a02016-09-08 17:40:26 -0700155 main.CLIs[0].removeDevice( "of:0000000000000001" )
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700156 else:
YPZhang38fb1192016-08-11 11:03:38 -0700157 main.switchFunc.captureOfPack( main, main.device, main.ofPackage,
158 "up", resultDict, False )
159 main.switchFunc.captureOfPack (main, main.device, main.ofPackage,
160 "down", resultDict, False )
chengchiyu08303a02016-09-08 17:40:26 -0700161 main.CLIs[0].removeDevice( "of:0000000000000001" )
162
YPZhang38fb1192016-08-11 11:03:38 -0700163 # Dictionary for result
164 maxDict = {}
165 maxDict['down'] = {}
166 maxDict['up'] = {}
167 maxDict['down']['max'] = 0
168 maxDict['up']['max'] = 0
169 maxDict['down']['node'] = 0
170 maxDict['up']['node'] = 0
Jon Hall4ba53f02015-07-29 13:07:41 -0700171
YPZhang38fb1192016-08-11 11:03:38 -0700172 for i in range(1, main.numCtrls + 1):
173 # calculate average and std for result, and grep the max End to End data
174 EtoEtemp = numpy.average( resultDict['up'][ 'node' + str(i) ]['E_E'] )
175 resultDict['up'][ 'node' + str(i) ][ 'Ave' ][ 'E_E' ] = EtoEtemp
176 if maxDict['up']['max'] < EtoEtemp:
177 # get max End to End latency
178 maxDict['up']['max'] = EtoEtemp
179 maxDict['up']['node'] = i
180 resultDict['up']['node' + str(i)]['Ave']['T_F'] = numpy.average(resultDict['up']['node' + str(i)]['T_F'])
181 resultDict['up']['node' + str(i)]['Ave']['F_R'] = numpy.average(resultDict['up']['node' + str(i)]['F_R'])
182 resultDict['up']['node' + str(i)]['Ave']['RQ_RR'] = numpy.average(resultDict['up']['node' + str(i)]['RQ_RR'])
183 resultDict['up']['node' + str(i)]['Ave']['RR_D'] = numpy.average(resultDict['up']['node' + str(i)]['RR_D'])
184 resultDict['up']['node' + str(i)]['Ave']['D_G'] = numpy.average(resultDict['up']['node' + str(i)]['D_G'])
Jon Hall4ba53f02015-07-29 13:07:41 -0700185
YPZhang38fb1192016-08-11 11:03:38 -0700186 resultDict['up'][ 'node' + str(i) ][ 'Std' ][ 'E_E' ] = numpy.std( resultDict['up'][ 'node' + str(i) ]['E_E'] )
187 resultDict['up']['node' + str(i)]['Std']['T_F'] = numpy.std(resultDict['up']['node' + str(i)]['T_F'])
188 resultDict['up']['node' + str(i)]['Std']['F_R'] = numpy.std(resultDict['up']['node' + str(i)]['F_R'])
189 resultDict['up']['node' + str(i)]['Std']['RQ_RR'] = numpy.std(resultDict['up']['node' + str(i)]['RQ_RR'])
190 resultDict['up']['node' + str(i)]['Std']['RR_D'] = numpy.std(resultDict['up']['node' + str(i)]['RR_D'])
191 resultDict['up']['node' + str(i)]['Std']['D_G'] = numpy.std(resultDict['up']['node' + str(i)]['D_G'])
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700192
YPZhang38fb1192016-08-11 11:03:38 -0700193 # calculate average and std for result, and grep the max End to End data
194 EtoEtemp = numpy.average( resultDict['down'][ 'node' + str(i) ]['E_E'] )
195 resultDict['down'][ 'node' + str(i) ][ 'Ave' ][ 'E_E' ] = EtoEtemp
196 if maxDict['down']['max'] < EtoEtemp:
197 # get max End to End latency
198 maxDict['down']['max'] = EtoEtemp
199 maxDict['down']['node'] = i
200 resultDict['down']['node' + str(i)]['Ave']['FA_A'] = numpy.average(resultDict['down']['node' + str(i)]['FA_A'])
201 resultDict['down']['node' + str(i)]['Ave']['A_D'] = numpy.average(resultDict['down']['node' + str(i)]['A_D'])
202 resultDict['down']['node' + str(i)]['Ave']['D_G'] = numpy.average(resultDict['down']['node' + str(i)]['D_G'])
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700203
YPZhang38fb1192016-08-11 11:03:38 -0700204 resultDict['down'][ 'node' + str(i) ][ 'Std' ][ 'E_E' ] = numpy.std( resultDict['down'][ 'node' + str(i) ]['E_E'] )
205 resultDict['down']['node' + str(i)]['Std']['FA_A'] = numpy.std(resultDict['down']['node' + str(i)]['FA_A'])
206 resultDict['down']['node' + str(i)]['Std']['A_D'] = numpy.std(resultDict['down']['node' + str(i)]['A_D'])
207 resultDict['down']['node' + str(i)]['Std']['D_G'] = numpy.std(resultDict['down']['node' + str(i)]['D_G'])
Jon Hall4ba53f02015-07-29 13:07:41 -0700208
YPZhang38fb1192016-08-11 11:03:38 -0700209 main.log.report( "=====node{} Summary:=====".format( str(i) ) )
210 main.log.report( "=============Switch up=======" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700211
YPZhang38fb1192016-08-11 11:03:38 -0700212 main.log.report(
213 "End to End average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'E_E' ]) ) )
214 main.log.report(
215 "End to End Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'E_E' ]) ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700216
YPZhang38fb1192016-08-11 11:03:38 -0700217 main.log.report(
218 "TCP to Feature average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'T_F' ]) ) )
219 main.log.report(
220 "TCP to Feature Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'T_F' ]) ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700221
YPZhang38fb1192016-08-11 11:03:38 -0700222 main.log.report(
223 "Feature to Role average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'F_R' ]) ) )
224 main.log.report(
225 "Feature to Role Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'F_R' ]) ) )
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700226
YPZhang38fb1192016-08-11 11:03:38 -0700227 main.log.report(
228 "Role request to Role reply average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'RQ_RR' ]) ) )
229 main.log.report(
230 "Role request to Role reply Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'RQ_RR' ]) ) )
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700231
YPZhang38fb1192016-08-11 11:03:38 -0700232 main.log.report(
233 "Role reply to Device average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'RR_D' ]) ) )
234 main.log.report(
235 "Role reply to Device Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'RR_D' ]) ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700236
YPZhang38fb1192016-08-11 11:03:38 -0700237 main.log.report(
238 "Device to Graph average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'D_G' ]) ) )
239 main.log.report(
240 "Device to Graph Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'D_G' ]) ) )
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700241
YPZhang38fb1192016-08-11 11:03:38 -0700242 main.log.report( "=============Switch down=======" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700243
YPZhang38fb1192016-08-11 11:03:38 -0700244 main.log.report(
245 "End to End average: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Ave' ][ 'E_E' ]) ) )
246 main.log.report(
247 "End to End Std: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Std' ][ 'E_E' ]) ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700248
YPZhang38fb1192016-08-11 11:03:38 -0700249 main.log.report(
250 "Fin_ACK to ACK average: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Ave' ][ 'FA_A' ]) ) )
251 main.log.report(
252 "Fin_ACK to ACK Std: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Std' ][ 'FA_A' ]) ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700253
YPZhang38fb1192016-08-11 11:03:38 -0700254 main.log.report(
255 "ACK to Device average: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Ave' ][ 'A_D' ]) ) )
256 main.log.report(
257 "ACK to Device Std: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Std' ][ 'A_D' ]) ) )
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700258
YPZhang38fb1192016-08-11 11:03:38 -0700259 main.log.report(
260 "Device to Graph average: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Ave' ][ 'D_G' ]) ) )
261 main.log.report(
262 "Device to Graph Std: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Std' ][ 'D_G' ]) ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700263
YPZhang38fb1192016-08-11 11:03:38 -0700264 with open(main.dbFileName, "a") as dbFile:
265 # TODO: Save STD to Database
266 # Scale number
267 temp = str(main.numCtrls)
268 temp += ",'baremetal1'"
269 # put result
270 temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'E_E' ] )
271 temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'T_F' ] )
272 temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'F_R' ] )
273 temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'RQ_RR' ] )
274 temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'RR_D' ] )
275 temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'D_G' ] )
cameron@onlab.us21106ea2015-07-23 15:32:51 -0700276
YPZhang38fb1192016-08-11 11:03:38 -0700277 temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'E_E' ] )
278 temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'FA_A' ] )
279 temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'A_D' ] )
280 temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'D_G' ] )
chengchiyuc6f4cc02016-08-24 14:04:20 -0700281
282 temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Std' ][ 'E_E' ] )
283 temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Std' ][ 'E_E' ] )
284
YPZhang38fb1192016-08-11 11:03:38 -0700285 temp += "\n"
286 dbFile.write( temp )
287 dbFile.close()