blob: 19a82a498de67e95bcf87cd67d38d98a3b493f62 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2015 Open Networking Foundation (ONF)
3
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
11 (at your option) any later version.
12
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"""
21
YPZhangfebf7302016-05-24 16:45:56 -070022# SCPFintentRerouteLat
23"""
24SCPFintentRerouteLat
25 - Test Intent Reroute Latency
26 - Test Algorithm:
27 1. Start Null Provider reroute Topology
28 2. Using Push-test-intents to push batch size intents from switch 1 to switch 7
29 3. Cut the link between switch 3 and switch 4 (the path will reroute to switch 8)
30 4. Get the topology time stamp
31 5. Get Intent reroute(Installed) time stamp from each nodes
32 6. Use the latest intent time stamp subtract topology time stamp
33 - This test will run 5 warm up by default, warm up iteration can be setup in Param file
34 - The intent batch size will default set to 1, 100, and 1000, also can be set in Param file
35 - The unit of the latency result is milliseconds
36"""
cameron@onlab.us78b89652015-07-08 15:21:03 -070037
Chiyu Chengec63bde2016-11-17 18:11:36 -080038
cameron@onlab.us78b89652015-07-08 15:21:03 -070039class SCPFintentRerouteLat:
Devin Lim142b5342017-07-20 15:22:39 -070040 def __init__( self ):
cameron@onlab.us78b89652015-07-08 15:21:03 -070041 self.default = ''
42
YPZhangfebf7302016-05-24 16:45:56 -070043 def CASE0( self, main ):
Chiyu Chengec63bde2016-11-17 18:11:36 -080044 import imp
45 import os
YPZhangfebf7302016-05-24 16:45:56 -070046 '''
47 - GIT
48 - BUILDING ONOS
49 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
50 This step is usually skipped. Because in a Jenkins driven automated
51 test env. We want Jenkins jobs to pull&build for flexibility to handle
52 different versions of ONOS.
53 - Construct tests variables
54 '''
Devin Lim58046fa2017-07-05 16:55:00 -070055 try:
56 from tests.dependencies.ONOSSetup import ONOSSetup
57 main.testSetUp = ONOSSetup()
58 except ImportError:
59 main.log.error( "ONOSSetup not found. exiting the test" )
60 main.exit()
61 main.testSetUp.envSetupDescription()
62 stepResult = main.FALSE
63 try:
Devin Lim58046fa2017-07-05 16:55:00 -070064 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
65 main.BENCHUser = main.params[ 'BENCH' ][ 'user' ]
66 main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
67 main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
Devin Lim58046fa2017-07-05 16:55:00 -070068 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
Devin Lim142b5342017-07-20 15:22:39 -070069 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
Devin Lim58046fa2017-07-05 16:55:00 -070070 main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
71 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
72 main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
73 main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
74 main.setMasterSleep = int( main.params[ 'SLEEP' ][ 'setmaster' ] )
75 main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] )
76 main.maxInvalidRun = int( main.params[ 'ATTEMPTS' ][ 'maxInvalidRun' ] )
77 main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
Devin Lim142b5342017-07-20 15:22:39 -070078 main.intentManagerCfg = main.params[ 'CFG' ][ 'intentManager' ]
79 main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ]
80 main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ]
81 main.linkCollectionIntentCfg = main.params[ 'CFG' ][ 'linkCollectionIntent' ]
Devin Lim58046fa2017-07-05 16:55:00 -070082 main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
83 main.ingress = main.params[ 'TEST' ][ 'ingress' ]
84 main.egress = main.params[ 'TEST' ][ 'egress' ]
85 main.debug = main.params[ 'TEST' ][ 'debug' ]
86 main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
87 main.deviceCount = int( main.params[ 'TEST' ][ 'deviceCount' ] )
88 main.end1 = main.params[ 'TEST' ][ 'end1' ]
89 main.end2 = main.params[ 'TEST' ][ 'end2' ]
90 main.searchTerm = main.params[ 'SEARCHTERM' ]
91 if main.flowObj == "True":
92 main.flowObj = True
93 main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
94 main.intentsList = ( main.params[ 'TEST' ][ 'FObjintents' ] ).split( "," )
95 else:
96 main.flowObj = False
97 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
98 main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," )
cameron@onlab.us78b89652015-07-08 15:21:03 -070099
Devin Lim142b5342017-07-20 15:22:39 -0700100 stepResult = main.testSetUp.envSetup()
YPZhangfebf7302016-05-24 16:45:56 -0700101
Devin Lim142b5342017-07-20 15:22:39 -0700102 for i in range( 0, len( main.intentsList ) ):
Devin Lim58046fa2017-07-05 16:55:00 -0700103 main.intentsList[ i ] = int( main.intentsList[ i ] )
104 # Create DataBase file
105 main.log.info( "Create Database file " + main.dbFileName )
106 resultsDB = open( main.dbFileName, "w+" )
107 resultsDB.close()
108 file1 = main.params[ "DEPENDENCY" ][ "FILE1" ]
109 main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ]
110 main.intentRerouteLatFuncs = imp.load_source( file1, main.dependencyPath + file1 + ".py" )
YPZhangfebf7302016-05-24 16:45:56 -0700111
Devin Lim58046fa2017-07-05 16:55:00 -0700112 main.record = 0
113 except Exception as e:
114 main.testSetUp.envSetupException( e )
115 main.testSetUp.evnSetupConclusion( stepResult )
YPZhangfebf7302016-05-24 16:45:56 -0700116
Devin Lim142b5342017-07-20 15:22:39 -0700117
YPZhangfebf7302016-05-24 16:45:56 -0700118 def CASE1( self, main ):
119 '''
120 clean up test environment and set up
121 '''
cameron@onlab.us78b89652015-07-08 15:21:03 -0700122 import time
123
YPZhangfebf7302016-05-24 16:45:56 -0700124 main.maxNumBatch = 0
Devin Lim142b5342017-07-20 15:22:39 -0700125 main.testSetUp.ONOSSetUp( main.MN1Ip, main.Cluster, True,
126 cellName=main.cellName, killRemoveMax=False )
YPZhangfebf7302016-05-24 16:45:56 -0700127 # configure apps
Devin Lim142b5342017-07-20 15:22:39 -0700128 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "deviceCount", value=main.deviceCount )
129 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "topoShape", value="reroute" )
130 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "enabled", value="true" )
131 main.Cluster.active( 0 ).CLI.setCfg( main.intentManagerCfg, "skipReleaseResourcesOnWithdrawal",
132 value="true" )
YPZhange6ef82a2016-07-05 16:48:15 -0700133 if main.flowObj:
Devin Lim142b5342017-07-20 15:22:39 -0700134 main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg,
135 "useFlowObjectives", value="true" )
136 main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg,
137 "defaultFlowObjectiveCompiler",
138 value=main.linkCollectionIntentCfg )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800139 time.sleep( main.startUpSleep )
Devin Lim142b5342017-07-20 15:22:39 -0700140 for ctrl in main.Cluster.active():
141 ctrl.CLI.logSet( "DEBUG", "org.onosproject.metrics.topology" )
142 ctrl.CLI.logSet( "DEBUG", "org.onosproject.metrics.intent" )
YPZhangfebf7302016-05-24 16:45:56 -0700143 # Balance Master
Devin Lim142b5342017-07-20 15:22:39 -0700144 main.Cluster.active( 0 ).CLI.balanceMasters()
You Wang0b9039d2017-01-12 16:51:29 -0800145 time.sleep( main.setMasterSleep )
Devin Lim142b5342017-07-20 15:22:39 -0700146 if main.Cluster.numCtrls:
147 main.Cluster.active( 0 ).CLI.deviceRole( main.end1[ 'name' ], main.Cluster.active( 0 ).ipAddress )
148 main.Cluster.active( 0 ).CLI.deviceRole( main.end2[ 'name' ], main.Cluster.active( 0 ).ipAddress )
YPZhang2b9b26d2016-06-20 16:18:29 -0700149 time.sleep( main.setMasterSleep )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700150
151 def CASE2( self, main ):
cameron@onlab.us78b89652015-07-08 15:21:03 -0700152 import time
153 import numpy
154 import datetime
YPZhangfebf7302016-05-24 16:45:56 -0700155 import json
156 # from scipy import stats
cameron@onlab.us78b89652015-07-08 15:21:03 -0700157
Devin Lim142b5342017-07-20 15:22:39 -0700158 print( main.intentsList )
YPZhangfebf7302016-05-24 16:45:56 -0700159 for batchSize in main.intentsList:
You Wang0b9039d2017-01-12 16:51:29 -0800160 main.batchSize = batchSize
Devin Lim142b5342017-07-20 15:22:39 -0700161 main.log.report( "Intent Batch size: " + str( batchSize ) + "\n " )
You Wang6d301d42017-04-21 10:49:33 -0700162 firstLocalLatencies = []
163 lastLocalLatencies = []
164 firstGlobalLatencies = []
165 lastGlobalLatencies = []
166 main.startLine = {}
Chiyu Chengec63bde2016-11-17 18:11:36 -0800167 main.validRun = 0
168 main.invalidRun = 0
You Wang0b9039d2017-01-12 16:51:29 -0800169 while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= main.maxInvalidRun:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800170 if main.validRun >= main.warmUp:
Devin Lim142b5342017-07-20 15:22:39 -0700171 main.log.info( "================================================" )
172 main.log.info( "Valid iteration: {} ".format( main.validRun - main.warmUp ) )
173 main.log.info( "Total iteration: {}".format( main.validRun + main.invalidRun ) )
174 main.log.info( "================================================" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700175 else:
Devin Lim142b5342017-07-20 15:22:39 -0700176 main.log.info( "====================Warm Up=====================" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700177
YPZhangfebf7302016-05-24 16:45:56 -0700178 # push intents
Devin Lim142b5342017-07-20 15:22:39 -0700179 main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress,
180 main.egress,
181 main.batchSize,
182 offset=1,
183 options="-i",
184 timeout=main.timeout )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700185
You Wang6d301d42017-04-21 10:49:33 -0700186 # check links, flows and intents
Devin Lim142b5342017-07-20 15:22:39 -0700187 main.intentRerouteLatFuncs.sanityCheck( main,
188 main.deviceCount * 2,
189 batchSize * ( main.deviceCount - 1 ),
190 main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800191 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700192 main.log.warn( "Sanity check failed, skipping this iteration..." )
193 continue
194
195 # Insert one line in karaf.log before link down
Devin Lim142b5342017-07-20 15:22:39 -0700196 main.Cluster.command( "log",
197 args=[ "\'Scale: {}, Batch:{}, Iteration: {}\'".format(
198 main.Cluster.numCtrls, batchSize, main.validRun + main.invalidRun ) ],
199 returnBool=True, specificDriver=2 )
You Wang6d301d42017-04-21 10:49:33 -0700200 # bring link down
Devin Lim142b5342017-07-20 15:22:39 -0700201 main.Cluster.active( 0 ).CLI.link( main.end1[ 'port' ], main.end2[ 'port' ], "down",
202 timeout=main.timeout, showResponse=False )
You Wang6d301d42017-04-21 10:49:33 -0700203
204 # check links, flows and intents
Devin Lim142b5342017-07-20 15:22:39 -0700205 main.intentRerouteLatFuncs.sanityCheck( main,
206 ( main.deviceCount - 1 ) * 2,
207 batchSize * main.deviceCount,
208 main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800209 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700210 main.log.warn( "Sanity check failed, skipping this iteration..." )
211 continue
212
213 # Get timestamp of last LINK_REMOVED event as separator between iterations
214 skip = False
Devin Lim142b5342017-07-20 15:22:39 -0700215 for i in range( main.Cluster.numCtrls ):
You Wang6d301d42017-04-21 10:49:33 -0700216 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
Devin Lim142b5342017-07-20 15:22:39 -0700217 timestamp = str( main.Cluster.active( i ).CLI.getTimeStampFromLog( "last",
218 "LINK_REMOVED",
219 "time = ", " ",
220 logNum=logNum ) )
You Wang6d301d42017-04-21 10:49:33 -0700221 if timestamp == main.ERROR:
222 # Try again in case that the log number just increased
223 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
Devin Lim142b5342017-07-20 15:22:39 -0700224 timestamp = str( main.Cluster.active( i ).CLI.getTimeStampFromLog( "last",
225 "LINK_REMOVED",
226 "time = ", " ",
227 logNum=logNum ) )
You Wang6d301d42017-04-21 10:49:33 -0700228 if timestamp == main.ERROR:
229 main.log.warn( "Cannot find the event we want in the log, skipping this iteration..." )
230 main.intentRerouteLatFuncs.bringBackTopology( main )
231 if main.validRun >= main.warmUp:
232 main.invalidRun += 1
233 else:
234 main.validRun += 1
235 skip = True
236 break
237 else:
238 main.startLine[ i ] = timestamp
Devin Lim142b5342017-07-20 15:22:39 -0700239 main.log.info( "Timestamp of last LINK_REMOVED event on node {} is {}".format( i + 1,
240 main.startLine[ i ] ) )
You Wang6d301d42017-04-21 10:49:33 -0700241 if skip: continue
242
243 # calculate values
244 topologyTimestamps = main.intentRerouteLatFuncs.getTopologyTimestamps( main )
245 intentTimestamps = main.intentRerouteLatFuncs.getIntentTimestamps( main )
246 if intentTimestamps == main.ERROR or topologyTimestamps == main.ERROR:
247 main.log.info( "Got invalid timestamp, skipping this iteration..." )
248 main.intentRerouteLatFuncs.bringBackTopology( main )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800249 if main.validRun >= main.warmUp:
250 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700251 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800252 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700253 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800254 else:
You Wang6d301d42017-04-21 10:49:33 -0700255 main.log.info( "Got valid timestamps" )
256
Devin Lim142b5342017-07-20 15:22:39 -0700257 firstLocalLatnecy, lastLocalLatnecy, firstGlobalLatency, lastGlobalLatnecy \
258 = main.intentRerouteLatFuncs.calculateLatency( main, topologyTimestamps, intentTimestamps )
You Wang6d301d42017-04-21 10:49:33 -0700259 if firstLocalLatnecy < 0:
260 main.log.info( "Got negative latency, skipping this iteration..." )
261 main.intentRerouteLatFuncs.bringBackTopology( main )
262 if main.validRun >= main.warmUp:
263 main.invalidRun += 1
264 else:
265 main.validRun += 1
266 continue
267 else:
268 main.log.info( "Got valid latencies" )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800269 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700270
You Wang6d301d42017-04-21 10:49:33 -0700271 firstLocalLatencies.append( firstLocalLatnecy )
272 lastLocalLatencies.append( lastLocalLatnecy )
273 firstGlobalLatencies.append( firstGlobalLatency )
274 lastGlobalLatencies.append( lastGlobalLatnecy )
275
276 # bring up link and withdraw intents
Devin Lim142b5342017-07-20 15:22:39 -0700277 main.Cluster.active( 0 ).CLI.link( main.end1[ 'port' ],
278 main.end2[ 'port' ],
279 "up",
280 timeout=main.timeout )
281 main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress,
282 main.egress,
283 batchSize,
284 offset=1,
285 options="-w",
286 timeout=main.timeout )
287 main.Cluster.active( 0 ).CLI.purgeWithdrawnIntents()
You Wang6d301d42017-04-21 10:49:33 -0700288
289 # check links, flows and intents
290 main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, 0, 0 )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800291 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700292 continue
293
You Wang6d301d42017-04-21 10:49:33 -0700294 aveLocalLatency = numpy.average( lastLocalLatencies )
295 aveGlobalLatency = numpy.average( lastGlobalLatencies )
296 stdLocalLatency = numpy.std( lastLocalLatencies )
297 stdGlobalLatency = numpy.std( lastGlobalLatencies )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800298
Devin Lim142b5342017-07-20 15:22:39 -0700299 main.log.report( "Scale: " + str( main.Cluster.numCtrls ) + " \tIntent batch: " + str( batchSize ) )
You Wang6d301d42017-04-21 10:49:33 -0700300 main.log.report( "Local latency average:................" + str( aveLocalLatency ) )
301 main.log.report( "Global latency average:................" + str( aveGlobalLatency ) )
302 main.log.report( "Local latency std:................" + str( stdLocalLatency ) )
303 main.log.report( "Global latency std:................" + str( stdGlobalLatency ) )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800304 main.log.report( "________________________________________________________" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700305
You Wang6d301d42017-04-21 10:49:33 -0700306 if not ( numpy.isnan( aveLocalLatency ) or numpy.isnan( aveGlobalLatency ) ):
YPZhang8742d2e2016-06-16 15:31:58 -0700307 # check if got NaN for result
You Wang6d301d42017-04-21 10:49:33 -0700308 resultsDB = open( main.dbFileName, "a" )
309 resultsDB.write( "'" + main.commit + "'," )
Devin Lim142b5342017-07-20 15:22:39 -0700310 resultsDB.write( str( main.Cluster.numCtrls ) + "," )
You Wang6d301d42017-04-21 10:49:33 -0700311 resultsDB.write( str( batchSize ) + "," )
312 resultsDB.write( str( aveLocalLatency ) + "," )
313 resultsDB.write( str( stdLocalLatency ) + "\n" )
YPZhang8742d2e2016-06-16 15:31:58 -0700314 resultsDB.close()