blob: 41a3408c1270e954b882bc2be71eeca92c66dc30 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 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"""
YPZhangfebf7302016-05-24 16:45:56 -070021# SCPFintentRerouteLat
22"""
23SCPFintentRerouteLat
24 - Test Intent Reroute Latency
25 - Test Algorithm:
26 1. Start Null Provider reroute Topology
27 2. Using Push-test-intents to push batch size intents from switch 1 to switch 7
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070028 3. Cut the link between switch 3 and switch 4 ( the path will reroute to switch 8 )
YPZhangfebf7302016-05-24 16:45:56 -070029 4. Get the topology time stamp
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070030 5. Get Intent reroute( Installed ) time stamp from each nodes
YPZhangfebf7302016-05-24 16:45:56 -070031 6. Use the latest intent time stamp subtract topology time stamp
32 - This test will run 5 warm up by default, warm up iteration can be setup in Param file
33 - The intent batch size will default set to 1, 100, and 1000, also can be set in Param file
34 - The unit of the latency result is milliseconds
35"""
cameron@onlab.us78b89652015-07-08 15:21:03 -070036class SCPFintentRerouteLat:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070037
Devin Lim142b5342017-07-20 15:22:39 -070038 def __init__( self ):
cameron@onlab.us78b89652015-07-08 15:21:03 -070039 self.default = ''
40
YPZhangfebf7302016-05-24 16:45:56 -070041 def CASE0( self, main ):
Chiyu Chengec63bde2016-11-17 18:11:36 -080042 import imp
43 import os
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070044 """
YPZhangfebf7302016-05-24 16:45:56 -070045 - GIT
46 - BUILDING ONOS
47 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
48 This step is usually skipped. Because in a Jenkins driven automated
49 test env. We want Jenkins jobs to pull&build for flexibility to handle
50 different versions of ONOS.
51 - Construct tests variables
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070052 """
Devin Lim58046fa2017-07-05 16:55:00 -070053 try:
54 from tests.dependencies.ONOSSetup import ONOSSetup
55 main.testSetUp = ONOSSetup()
56 except ImportError:
57 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070058 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070059 main.testSetUp.envSetupDescription()
60 stepResult = main.FALSE
61 try:
Devin Lim58046fa2017-07-05 16:55:00 -070062 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
63 main.BENCHUser = main.params[ 'BENCH' ][ 'user' ]
64 main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
65 main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
Devin Lim58046fa2017-07-05 16:55:00 -070066 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
Devin Lim142b5342017-07-20 15:22:39 -070067 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
Devin Lim58046fa2017-07-05 16:55:00 -070068 main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
69 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
70 main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
71 main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
72 main.setMasterSleep = int( main.params[ 'SLEEP' ][ 'setmaster' ] )
73 main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] )
74 main.maxInvalidRun = int( main.params[ 'ATTEMPTS' ][ 'maxInvalidRun' ] )
75 main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
Devin Lim142b5342017-07-20 15:22:39 -070076 main.intentManagerCfg = main.params[ 'CFG' ][ 'intentManager' ]
77 main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ]
78 main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ]
79 main.linkCollectionIntentCfg = main.params[ 'CFG' ][ 'linkCollectionIntent' ]
Devin Lim58046fa2017-07-05 16:55:00 -070080 main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
81 main.ingress = main.params[ 'TEST' ][ 'ingress' ]
82 main.egress = main.params[ 'TEST' ][ 'egress' ]
83 main.debug = main.params[ 'TEST' ][ 'debug' ]
84 main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
85 main.deviceCount = int( main.params[ 'TEST' ][ 'deviceCount' ] )
86 main.end1 = main.params[ 'TEST' ][ 'end1' ]
87 main.end2 = main.params[ 'TEST' ][ 'end2' ]
88 main.searchTerm = main.params[ 'SEARCHTERM' ]
89 if main.flowObj == "True":
90 main.flowObj = True
91 main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
92 main.intentsList = ( main.params[ 'TEST' ][ 'FObjintents' ] ).split( "," )
93 else:
94 main.flowObj = False
95 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
96 main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," )
cameron@onlab.us78b89652015-07-08 15:21:03 -070097
Devin Lim142b5342017-07-20 15:22:39 -070098 stepResult = main.testSetUp.envSetup()
YPZhangfebf7302016-05-24 16:45:56 -070099
Devin Lim142b5342017-07-20 15:22:39 -0700100 for i in range( 0, len( main.intentsList ) ):
Devin Lim58046fa2017-07-05 16:55:00 -0700101 main.intentsList[ i ] = int( main.intentsList[ i ] )
102 # Create DataBase file
103 main.log.info( "Create Database file " + main.dbFileName )
104 resultsDB = open( main.dbFileName, "w+" )
105 resultsDB.close()
106 file1 = main.params[ "DEPENDENCY" ][ "FILE1" ]
107 main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ]
108 main.intentRerouteLatFuncs = imp.load_source( file1, main.dependencyPath + file1 + ".py" )
YPZhangfebf7302016-05-24 16:45:56 -0700109
Devin Lim58046fa2017-07-05 16:55:00 -0700110 main.record = 0
111 except Exception as e:
112 main.testSetUp.envSetupException( e )
113 main.testSetUp.evnSetupConclusion( stepResult )
You Wang47b91832017-08-02 11:36:13 -0700114 main.commit = main.commit.split( " " )[ 1 ]
YPZhangfebf7302016-05-24 16:45:56 -0700115
116 def CASE1( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700117 """
YPZhangfebf7302016-05-24 16:45:56 -0700118 clean up test environment and set up
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700119 """
cameron@onlab.us78b89652015-07-08 15:21:03 -0700120 import time
121
YPZhangfebf7302016-05-24 16:45:56 -0700122 main.maxNumBatch = 0
Devin Lim142b5342017-07-20 15:22:39 -0700123 main.testSetUp.ONOSSetUp( main.MN1Ip, main.Cluster, True,
124 cellName=main.cellName, killRemoveMax=False )
YPZhangfebf7302016-05-24 16:45:56 -0700125 # configure apps
Devin Lim142b5342017-07-20 15:22:39 -0700126 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "deviceCount", value=main.deviceCount )
127 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "topoShape", value="reroute" )
128 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "enabled", value="true" )
129 main.Cluster.active( 0 ).CLI.setCfg( main.intentManagerCfg, "skipReleaseResourcesOnWithdrawal",
130 value="true" )
YPZhange6ef82a2016-07-05 16:48:15 -0700131 if main.flowObj:
Devin Lim142b5342017-07-20 15:22:39 -0700132 main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg,
133 "useFlowObjectives", value="true" )
134 main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg,
135 "defaultFlowObjectiveCompiler",
136 value=main.linkCollectionIntentCfg )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800137 time.sleep( main.startUpSleep )
Devin Lim142b5342017-07-20 15:22:39 -0700138 for ctrl in main.Cluster.active():
139 ctrl.CLI.logSet( "DEBUG", "org.onosproject.metrics.topology" )
140 ctrl.CLI.logSet( "DEBUG", "org.onosproject.metrics.intent" )
YPZhangfebf7302016-05-24 16:45:56 -0700141 # Balance Master
Devin Lim142b5342017-07-20 15:22:39 -0700142 main.Cluster.active( 0 ).CLI.balanceMasters()
You Wang0b9039d2017-01-12 16:51:29 -0800143 time.sleep( main.setMasterSleep )
Devin Lim142b5342017-07-20 15:22:39 -0700144 if main.Cluster.numCtrls:
145 main.Cluster.active( 0 ).CLI.deviceRole( main.end1[ 'name' ], main.Cluster.active( 0 ).ipAddress )
146 main.Cluster.active( 0 ).CLI.deviceRole( main.end2[ 'name' ], main.Cluster.active( 0 ).ipAddress )
YPZhang2b9b26d2016-06-20 16:18:29 -0700147 time.sleep( main.setMasterSleep )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700148
149 def CASE2( self, main ):
cameron@onlab.us78b89652015-07-08 15:21:03 -0700150 import time
151 import numpy
152 import datetime
YPZhangfebf7302016-05-24 16:45:56 -0700153 import json
154 # from scipy import stats
cameron@onlab.us78b89652015-07-08 15:21:03 -0700155
Devin Lim142b5342017-07-20 15:22:39 -0700156 print( main.intentsList )
YPZhangfebf7302016-05-24 16:45:56 -0700157 for batchSize in main.intentsList:
You Wang0b9039d2017-01-12 16:51:29 -0800158 main.batchSize = batchSize
Devin Lim142b5342017-07-20 15:22:39 -0700159 main.log.report( "Intent Batch size: " + str( batchSize ) + "\n " )
You Wang6d301d42017-04-21 10:49:33 -0700160 firstLocalLatencies = []
161 lastLocalLatencies = []
162 firstGlobalLatencies = []
163 lastGlobalLatencies = []
164 main.startLine = {}
Chiyu Chengec63bde2016-11-17 18:11:36 -0800165 main.validRun = 0
166 main.invalidRun = 0
You Wang0b9039d2017-01-12 16:51:29 -0800167 while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= main.maxInvalidRun:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800168 if main.validRun >= main.warmUp:
Devin Lim142b5342017-07-20 15:22:39 -0700169 main.log.info( "================================================" )
170 main.log.info( "Valid iteration: {} ".format( main.validRun - main.warmUp ) )
171 main.log.info( "Total iteration: {}".format( main.validRun + main.invalidRun ) )
172 main.log.info( "================================================" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700173 else:
Devin Lim142b5342017-07-20 15:22:39 -0700174 main.log.info( "====================Warm Up=====================" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700175
YPZhangfebf7302016-05-24 16:45:56 -0700176 # push intents
Devin Lim142b5342017-07-20 15:22:39 -0700177 main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress,
178 main.egress,
179 main.batchSize,
180 offset=1,
181 options="-i",
182 timeout=main.timeout )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700183
You Wang6d301d42017-04-21 10:49:33 -0700184 # check links, flows and intents
Devin Lim142b5342017-07-20 15:22:39 -0700185 main.intentRerouteLatFuncs.sanityCheck( main,
186 main.deviceCount * 2,
187 batchSize * ( main.deviceCount - 1 ),
188 main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800189 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700190 main.log.warn( "Sanity check failed, skipping this iteration..." )
191 continue
192
193 # Insert one line in karaf.log before link down
Devin Lim142b5342017-07-20 15:22:39 -0700194 main.Cluster.command( "log",
195 args=[ "\'Scale: {}, Batch:{}, Iteration: {}\'".format(
196 main.Cluster.numCtrls, batchSize, main.validRun + main.invalidRun ) ],
197 returnBool=True, specificDriver=2 )
You Wang6d301d42017-04-21 10:49:33 -0700198 # bring link down
Devin Lim142b5342017-07-20 15:22:39 -0700199 main.Cluster.active( 0 ).CLI.link( main.end1[ 'port' ], main.end2[ 'port' ], "down",
200 timeout=main.timeout, showResponse=False )
You Wang6d301d42017-04-21 10:49:33 -0700201
202 # check links, flows and intents
Devin Lim142b5342017-07-20 15:22:39 -0700203 main.intentRerouteLatFuncs.sanityCheck( main,
204 ( main.deviceCount - 1 ) * 2,
205 batchSize * main.deviceCount,
206 main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800207 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700208 main.log.warn( "Sanity check failed, skipping this iteration..." )
209 continue
210
211 # Get timestamp of last LINK_REMOVED event as separator between iterations
212 skip = False
Devin Lim142b5342017-07-20 15:22:39 -0700213 for i in range( main.Cluster.numCtrls ):
You Wang6d301d42017-04-21 10:49:33 -0700214 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
Devin Lim142b5342017-07-20 15:22:39 -0700215 timestamp = str( main.Cluster.active( i ).CLI.getTimeStampFromLog( "last",
216 "LINK_REMOVED",
217 "time = ", " ",
218 logNum=logNum ) )
You Wang6d301d42017-04-21 10:49:33 -0700219 if timestamp == main.ERROR:
220 # Try again in case that the log number just increased
221 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
Devin Lim142b5342017-07-20 15:22:39 -0700222 timestamp = str( main.Cluster.active( i ).CLI.getTimeStampFromLog( "last",
223 "LINK_REMOVED",
224 "time = ", " ",
225 logNum=logNum ) )
You Wang6d301d42017-04-21 10:49:33 -0700226 if timestamp == main.ERROR:
227 main.log.warn( "Cannot find the event we want in the log, skipping this iteration..." )
228 main.intentRerouteLatFuncs.bringBackTopology( main )
229 if main.validRun >= main.warmUp:
230 main.invalidRun += 1
231 else:
232 main.validRun += 1
233 skip = True
234 break
235 else:
236 main.startLine[ i ] = timestamp
Devin Lim142b5342017-07-20 15:22:39 -0700237 main.log.info( "Timestamp of last LINK_REMOVED event on node {} is {}".format( i + 1,
238 main.startLine[ i ] ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700239 if skip:
240 continue
You Wang6d301d42017-04-21 10:49:33 -0700241
242 # calculate values
243 topologyTimestamps = main.intentRerouteLatFuncs.getTopologyTimestamps( main )
244 intentTimestamps = main.intentRerouteLatFuncs.getIntentTimestamps( main )
245 if intentTimestamps == main.ERROR or topologyTimestamps == main.ERROR:
246 main.log.info( "Got invalid timestamp, skipping this iteration..." )
247 main.intentRerouteLatFuncs.bringBackTopology( main )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800248 if main.validRun >= main.warmUp:
249 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700250 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800251 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700252 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800253 else:
You Wang6d301d42017-04-21 10:49:33 -0700254 main.log.info( "Got valid timestamps" )
255
Devin Lim142b5342017-07-20 15:22:39 -0700256 firstLocalLatnecy, lastLocalLatnecy, firstGlobalLatency, lastGlobalLatnecy \
257 = main.intentRerouteLatFuncs.calculateLatency( main, topologyTimestamps, intentTimestamps )
You Wang6d301d42017-04-21 10:49:33 -0700258 if firstLocalLatnecy < 0:
259 main.log.info( "Got negative latency, skipping this iteration..." )
260 main.intentRerouteLatFuncs.bringBackTopology( main )
261 if main.validRun >= main.warmUp:
262 main.invalidRun += 1
263 else:
264 main.validRun += 1
265 continue
266 else:
267 main.log.info( "Got valid latencies" )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800268 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700269
You Wang6d301d42017-04-21 10:49:33 -0700270 firstLocalLatencies.append( firstLocalLatnecy )
271 lastLocalLatencies.append( lastLocalLatnecy )
272 firstGlobalLatencies.append( firstGlobalLatency )
273 lastGlobalLatencies.append( lastGlobalLatnecy )
274
275 # bring up link and withdraw intents
Devin Lim142b5342017-07-20 15:22:39 -0700276 main.Cluster.active( 0 ).CLI.link( main.end1[ 'port' ],
277 main.end2[ 'port' ],
278 "up",
279 timeout=main.timeout )
280 main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress,
281 main.egress,
282 batchSize,
283 offset=1,
284 options="-w",
285 timeout=main.timeout )
286 main.Cluster.active( 0 ).CLI.purgeWithdrawnIntents()
You Wang6d301d42017-04-21 10:49:33 -0700287
288 # check links, flows and intents
289 main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, 0, 0 )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800290 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700291 continue
292
You Wang6d301d42017-04-21 10:49:33 -0700293 aveLocalLatency = numpy.average( lastLocalLatencies )
294 aveGlobalLatency = numpy.average( lastGlobalLatencies )
295 stdLocalLatency = numpy.std( lastLocalLatencies )
296 stdGlobalLatency = numpy.std( lastGlobalLatencies )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800297
Devin Lim142b5342017-07-20 15:22:39 -0700298 main.log.report( "Scale: " + str( main.Cluster.numCtrls ) + " \tIntent batch: " + str( batchSize ) )
You Wang6d301d42017-04-21 10:49:33 -0700299 main.log.report( "Local latency average:................" + str( aveLocalLatency ) )
300 main.log.report( "Global latency average:................" + str( aveGlobalLatency ) )
301 main.log.report( "Local latency std:................" + str( stdLocalLatency ) )
302 main.log.report( "Global latency std:................" + str( stdGlobalLatency ) )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800303 main.log.report( "________________________________________________________" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700304
You Wang6d301d42017-04-21 10:49:33 -0700305 if not ( numpy.isnan( aveLocalLatency ) or numpy.isnan( aveGlobalLatency ) ):
YPZhang8742d2e2016-06-16 15:31:58 -0700306 # check if got NaN for result
You Wang6d301d42017-04-21 10:49:33 -0700307 resultsDB = open( main.dbFileName, "a" )
308 resultsDB.write( "'" + main.commit + "'," )
Devin Lim142b5342017-07-20 15:22:39 -0700309 resultsDB.write( str( main.Cluster.numCtrls ) + "," )
You Wang6d301d42017-04-21 10:49:33 -0700310 resultsDB.write( str( batchSize ) + "," )
311 resultsDB.write( str( aveLocalLatency ) + "," )
312 resultsDB.write( str( stdLocalLatency ) + "\n" )
YPZhang8742d2e2016-06-16 15:31:58 -0700313 resultsDB.close()