blob: baff10b73d26287883186b7ade1f0c3ba30b6984 [file] [log] [blame]
YPZhangfebf7302016-05-24 16:45:56 -07001# SCPFintentRerouteLat
2"""
3SCPFintentRerouteLat
4 - Test Intent Reroute Latency
5 - Test Algorithm:
6 1. Start Null Provider reroute Topology
7 2. Using Push-test-intents to push batch size intents from switch 1 to switch 7
8 3. Cut the link between switch 3 and switch 4 (the path will reroute to switch 8)
9 4. Get the topology time stamp
10 5. Get Intent reroute(Installed) time stamp from each nodes
11 6. Use the latest intent time stamp subtract topology time stamp
12 - This test will run 5 warm up by default, warm up iteration can be setup in Param file
13 - The intent batch size will default set to 1, 100, and 1000, also can be set in Param file
14 - The unit of the latency result is milliseconds
15"""
cameron@onlab.us78b89652015-07-08 15:21:03 -070016
Chiyu Chengec63bde2016-11-17 18:11:36 -080017
cameron@onlab.us78b89652015-07-08 15:21:03 -070018class SCPFintentRerouteLat:
YPZhangfebf7302016-05-24 16:45:56 -070019 def __init__(self):
cameron@onlab.us78b89652015-07-08 15:21:03 -070020 self.default = ''
21
YPZhangfebf7302016-05-24 16:45:56 -070022 def CASE0( self, main ):
Chiyu Chengec63bde2016-11-17 18:11:36 -080023 import imp
24 import os
YPZhangfebf7302016-05-24 16:45:56 -070025 '''
26 - GIT
27 - BUILDING ONOS
28 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
29 This step is usually skipped. Because in a Jenkins driven automated
30 test env. We want Jenkins jobs to pull&build for flexibility to handle
31 different versions of ONOS.
32 - Construct tests variables
33 '''
Devin Lim58046fa2017-07-05 16:55:00 -070034 try:
35 from tests.dependencies.ONOSSetup import ONOSSetup
36 main.testSetUp = ONOSSetup()
37 except ImportError:
38 main.log.error( "ONOSSetup not found. exiting the test" )
39 main.exit()
40 main.testSetUp.envSetupDescription()
41 stepResult = main.FALSE
42 try:
43 main.onosIp = main.ONOSbench.getOnosIps()
44 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
45 main.BENCHUser = main.params[ 'BENCH' ][ 'user' ]
46 main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
47 main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
48 main.maxNodes = int( main.params[ 'max' ] )
49 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
50 main.scale = ( main.params[ 'SCALE' ] ).split(",")
51 main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
52 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
53 main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
54 main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
55 main.setMasterSleep = int( main.params[ 'SLEEP' ][ 'setmaster' ] )
56 main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] )
57 main.maxInvalidRun = int( main.params[ 'ATTEMPTS' ][ 'maxInvalidRun' ] )
58 main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
59 main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
60 main.ingress = main.params[ 'TEST' ][ 'ingress' ]
61 main.egress = main.params[ 'TEST' ][ 'egress' ]
62 main.debug = main.params[ 'TEST' ][ 'debug' ]
63 main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
64 main.deviceCount = int( main.params[ 'TEST' ][ 'deviceCount' ] )
65 main.end1 = main.params[ 'TEST' ][ 'end1' ]
66 main.end2 = main.params[ 'TEST' ][ 'end2' ]
67 main.searchTerm = main.params[ 'SEARCHTERM' ]
68 if main.flowObj == "True":
69 main.flowObj = True
70 main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
71 main.intentsList = ( main.params[ 'TEST' ][ 'FObjintents' ] ).split( "," )
72 else:
73 main.flowObj = False
74 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
75 main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," )
cameron@onlab.us78b89652015-07-08 15:21:03 -070076
Devin Lim58046fa2017-07-05 16:55:00 -070077 stepResult = main.testSetUp.gitPulling()
YPZhangfebf7302016-05-24 16:45:56 -070078
Devin Lim58046fa2017-07-05 16:55:00 -070079 for i in range( 0, len( main.intentsList) ):
80 main.intentsList[ i ] = int( main.intentsList[ i ] )
81 # Create DataBase file
82 main.log.info( "Create Database file " + main.dbFileName )
83 resultsDB = open( main.dbFileName, "w+" )
84 resultsDB.close()
85 file1 = main.params[ "DEPENDENCY" ][ "FILE1" ]
86 main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ]
87 main.intentRerouteLatFuncs = imp.load_source( file1, main.dependencyPath + file1 + ".py" )
YPZhangfebf7302016-05-24 16:45:56 -070088
Devin Lim58046fa2017-07-05 16:55:00 -070089 main.record = 0
90 except Exception as e:
91 main.testSetUp.envSetupException( e )
92 main.testSetUp.evnSetupConclusion( stepResult )
YPZhangfebf7302016-05-24 16:45:56 -070093
94 def CASE1( self, main ):
95 '''
96 clean up test environment and set up
97 '''
cameron@onlab.us78b89652015-07-08 15:21:03 -070098 import time
99
YPZhangfebf7302016-05-24 16:45:56 -0700100 main.maxNumBatch = 0
Devin Lim58046fa2017-07-05 16:55:00 -0700101 main.testSetUp.getNumCtrls( True )
102 main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
103 main.testSetUp.ONOSSetUp( main.MN1Ip, True,
104 cellName=main.cellName, killRemoveMax=False,
105 CtrlsSet=False )
YPZhangfebf7302016-05-24 16:45:56 -0700106 # configure apps
Chiyu Cheng1976db52016-10-21 15:57:30 -0700107 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
YPZhangfebf7302016-05-24 16:45:56 -0700108 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute")
109 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
YPZhange6ef82a2016-07-05 16:48:15 -0700110 if main.flowObj:
111 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
112 "useFlowObjectives", value="true")
You Wang106d0fa2017-05-15 17:22:15 -0700113 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
114 "defaultFlowObjectiveCompiler",
115 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler')
Chiyu Chengec63bde2016-11-17 18:11:36 -0800116 time.sleep( main.startUpSleep )
117 for i in range( int( main.numCtrls ) ):
118 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology" )
119 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.intent" )
YPZhangfebf7302016-05-24 16:45:56 -0700120 # Balance Master
121 main.CLIs[0].balanceMasters()
You Wang0b9039d2017-01-12 16:51:29 -0800122 time.sleep( main.setMasterSleep )
Devin Lim58046fa2017-07-05 16:55:00 -0700123 if main.numCtrls:
124 main.CLIs[0].deviceRole( main.end1[ 'name' ], main.ONOSip[0] )
125 main.CLIs[0].deviceRole( main.end2[ 'name' ], main.ONOSip[0] )
YPZhang2b9b26d2016-06-20 16:18:29 -0700126 time.sleep( main.setMasterSleep )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700127
128 def CASE2( self, main ):
cameron@onlab.us78b89652015-07-08 15:21:03 -0700129 import time
130 import numpy
131 import datetime
YPZhangfebf7302016-05-24 16:45:56 -0700132 import json
133 # from scipy import stats
cameron@onlab.us78b89652015-07-08 15:21:03 -0700134
Devin Lim58046fa2017-07-05 16:55:00 -0700135 print( main.intentsList)
YPZhangfebf7302016-05-24 16:45:56 -0700136 for batchSize in main.intentsList:
You Wang0b9039d2017-01-12 16:51:29 -0800137 main.batchSize = batchSize
YPZhangfebf7302016-05-24 16:45:56 -0700138 main.log.report("Intent Batch size: " + str(batchSize) + "\n ")
You Wang6d301d42017-04-21 10:49:33 -0700139 firstLocalLatencies = []
140 lastLocalLatencies = []
141 firstGlobalLatencies = []
142 lastGlobalLatencies = []
143 main.startLine = {}
Chiyu Chengec63bde2016-11-17 18:11:36 -0800144 main.validRun = 0
145 main.invalidRun = 0
You Wang0b9039d2017-01-12 16:51:29 -0800146 while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= main.maxInvalidRun:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800147 if main.validRun >= main.warmUp:
YPZhangfebf7302016-05-24 16:45:56 -0700148 main.log.info("================================================")
Devin Lim58046fa2017-07-05 16:55:00 -0700149 main.log.info("Valid iteration: {} ".format( main.validRun - main.warmUp) )
150 main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun) )
YPZhangfebf7302016-05-24 16:45:56 -0700151 main.log.info("================================================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700152 else:
YPZhangfebf7302016-05-24 16:45:56 -0700153 main.log.info("====================Warm Up=====================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700154
YPZhangfebf7302016-05-24 16:45:56 -0700155 # push intents
Devin Lim58046fa2017-07-05 16:55:00 -0700156 main.CLIs[0].pushTestIntents( main.ingress, main.egress, main.batchSize,
YPZhangfebf7302016-05-24 16:45:56 -0700157 offset=1, options="-i", timeout=main.timeout)
cameron@onlab.us78b89652015-07-08 15:21:03 -0700158
You Wang6d301d42017-04-21 10:49:33 -0700159 # check links, flows and intents
Devin Lim58046fa2017-07-05 16:55:00 -0700160 main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, batchSize * ( main.deviceCount - 1 ), main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800161 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700162 main.log.warn( "Sanity check failed, skipping this iteration..." )
163 continue
164
165 # Insert one line in karaf.log before link down
166 for i in range( main.numCtrls ):
167 main.CLIs[ i ].log( "\'Scale: {}, Batch:{}, Iteration: {}\'".format( main.numCtrls, batchSize, main.validRun + main.invalidRun ) )
168
169 # bring link down
Chiyu Cheng1976db52016-10-21 15:57:30 -0700170 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down",
YPZhangfebf7302016-05-24 16:45:56 -0700171 timeout=main.timeout, showResponse=False)
You Wang6d301d42017-04-21 10:49:33 -0700172
173 # check links, flows and intents
Devin Lim58046fa2017-07-05 16:55:00 -0700174 main.intentRerouteLatFuncs.sanityCheck( main, ( main.deviceCount - 1) * 2, batchSize * main.deviceCount, main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800175 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700176 main.log.warn( "Sanity check failed, skipping this iteration..." )
177 continue
178
179 # Get timestamp of last LINK_REMOVED event as separator between iterations
180 skip = False
Chiyu Chengec63bde2016-11-17 18:11:36 -0800181 for i in range( main.numCtrls ):
You Wang6d301d42017-04-21 10:49:33 -0700182 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
183 timestamp = str( main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ) )
184 if timestamp == main.ERROR:
185 # Try again in case that the log number just increased
186 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
187 timestamp = str( main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ) )
188 if timestamp == main.ERROR:
189 main.log.warn( "Cannot find the event we want in the log, skipping this iteration..." )
190 main.intentRerouteLatFuncs.bringBackTopology( main )
191 if main.validRun >= main.warmUp:
192 main.invalidRun += 1
193 else:
194 main.validRun += 1
195 skip = True
196 break
197 else:
198 main.startLine[ i ] = timestamp
199 main.log.info( "Timestamp of last LINK_REMOVED event on node {} is {}".format( i+1, main.startLine[ i ] ) )
200 if skip: continue
201
202 # calculate values
203 topologyTimestamps = main.intentRerouteLatFuncs.getTopologyTimestamps( main )
204 intentTimestamps = main.intentRerouteLatFuncs.getIntentTimestamps( main )
205 if intentTimestamps == main.ERROR or topologyTimestamps == main.ERROR:
206 main.log.info( "Got invalid timestamp, skipping this iteration..." )
207 main.intentRerouteLatFuncs.bringBackTopology( main )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800208 if main.validRun >= main.warmUp:
209 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700210 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800211 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700212 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800213 else:
You Wang6d301d42017-04-21 10:49:33 -0700214 main.log.info( "Got valid timestamps" )
215
216 firstLocalLatnecy, lastLocalLatnecy, firstGlobalLatency, lastGlobalLatnecy = main.intentRerouteLatFuncs.calculateLatency( main, topologyTimestamps, intentTimestamps )
217 if firstLocalLatnecy < 0:
218 main.log.info( "Got negative latency, skipping this iteration..." )
219 main.intentRerouteLatFuncs.bringBackTopology( main )
220 if main.validRun >= main.warmUp:
221 main.invalidRun += 1
222 else:
223 main.validRun += 1
224 continue
225 else:
226 main.log.info( "Got valid latencies" )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800227 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700228
You Wang6d301d42017-04-21 10:49:33 -0700229 firstLocalLatencies.append( firstLocalLatnecy )
230 lastLocalLatencies.append( lastLocalLatnecy )
231 firstGlobalLatencies.append( firstGlobalLatency )
232 lastGlobalLatencies.append( lastGlobalLatnecy )
233
234 # bring up link and withdraw intents
Chiyu Cheng1976db52016-10-21 15:57:30 -0700235 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up",
YPZhangfebf7302016-05-24 16:45:56 -0700236 timeout=main.timeout)
Devin Lim58046fa2017-07-05 16:55:00 -0700237 main.CLIs[0].pushTestIntents( main.ingress, main.egress, batchSize,
You Wang6d301d42017-04-21 10:49:33 -0700238 offset=1, options="-w", timeout=main.timeout)
239 main.CLIs[0].purgeWithdrawnIntents()
240
241 # check links, flows and intents
242 main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, 0, 0 )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800243 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700244 continue
245
You Wang6d301d42017-04-21 10:49:33 -0700246 aveLocalLatency = numpy.average( lastLocalLatencies )
247 aveGlobalLatency = numpy.average( lastGlobalLatencies )
248 stdLocalLatency = numpy.std( lastLocalLatencies )
249 stdGlobalLatency = numpy.std( lastGlobalLatencies )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800250
251 main.log.report( "Scale: " + str( main.numCtrls ) + " \tIntent batch: " + str( batchSize ) )
You Wang6d301d42017-04-21 10:49:33 -0700252 main.log.report( "Local latency average:................" + str( aveLocalLatency ) )
253 main.log.report( "Global latency average:................" + str( aveGlobalLatency ) )
254 main.log.report( "Local latency std:................" + str( stdLocalLatency ) )
255 main.log.report( "Global latency std:................" + str( stdGlobalLatency ) )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800256 main.log.report( "________________________________________________________" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700257
You Wang6d301d42017-04-21 10:49:33 -0700258 if not ( numpy.isnan( aveLocalLatency ) or numpy.isnan( aveGlobalLatency ) ):
YPZhang8742d2e2016-06-16 15:31:58 -0700259 # check if got NaN for result
You Wang6d301d42017-04-21 10:49:33 -0700260 resultsDB = open( main.dbFileName, "a" )
261 resultsDB.write( "'" + main.commit + "'," )
262 resultsDB.write( str( main.numCtrls ) + "," )
263 resultsDB.write( str( batchSize ) + "," )
264 resultsDB.write( str( aveLocalLatency ) + "," )
265 resultsDB.write( str( stdLocalLatency ) + "\n" )
YPZhang8742d2e2016-06-16 15:31:58 -0700266 resultsDB.close()