blob: 29575d74460b85c5f12954b967d972cad297e887 [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:
YPZhangfebf7302016-05-24 16:45:56 -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:
64 main.onosIp = main.ONOSbench.getOnosIps()
65 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
66 main.BENCHUser = main.params[ 'BENCH' ][ 'user' ]
67 main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
68 main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
69 main.maxNodes = int( main.params[ 'max' ] )
70 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
71 main.scale = ( main.params[ 'SCALE' ] ).split(",")
72 main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
73 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
74 main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
75 main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
76 main.setMasterSleep = int( main.params[ 'SLEEP' ][ 'setmaster' ] )
77 main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] )
78 main.maxInvalidRun = int( main.params[ 'ATTEMPTS' ][ 'maxInvalidRun' ] )
79 main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
80 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 Lim58046fa2017-07-05 16:55:00 -070098 stepResult = main.testSetUp.gitPulling()
YPZhangfebf7302016-05-24 16:45:56 -070099
Devin Lim58046fa2017-07-05 16:55:00 -0700100 for i in range( 0, len( main.intentsList) ):
101 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 )
YPZhangfebf7302016-05-24 16:45:56 -0700114
115 def CASE1( self, main ):
116 '''
117 clean up test environment and set up
118 '''
cameron@onlab.us78b89652015-07-08 15:21:03 -0700119 import time
120
YPZhangfebf7302016-05-24 16:45:56 -0700121 main.maxNumBatch = 0
Devin Lim58046fa2017-07-05 16:55:00 -0700122 main.testSetUp.getNumCtrls( True )
123 main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
124 main.testSetUp.ONOSSetUp( main.MN1Ip, True,
125 cellName=main.cellName, killRemoveMax=False,
126 CtrlsSet=False )
YPZhangfebf7302016-05-24 16:45:56 -0700127 # configure apps
Chiyu Cheng1976db52016-10-21 15:57:30 -0700128 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
YPZhangfebf7302016-05-24 16:45:56 -0700129 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute")
130 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
YPZhange6ef82a2016-07-05 16:48:15 -0700131 if main.flowObj:
132 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
133 "useFlowObjectives", value="true")
You Wang106d0fa2017-05-15 17:22:15 -0700134 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
135 "defaultFlowObjectiveCompiler",
136 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler')
Chiyu Chengec63bde2016-11-17 18:11:36 -0800137 time.sleep( main.startUpSleep )
138 for i in range( int( main.numCtrls ) ):
139 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology" )
140 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.intent" )
YPZhangfebf7302016-05-24 16:45:56 -0700141 # Balance Master
142 main.CLIs[0].balanceMasters()
You Wang0b9039d2017-01-12 16:51:29 -0800143 time.sleep( main.setMasterSleep )
Devin Lim58046fa2017-07-05 16:55:00 -0700144 if main.numCtrls:
145 main.CLIs[0].deviceRole( main.end1[ 'name' ], main.ONOSip[0] )
146 main.CLIs[0].deviceRole( main.end2[ 'name' ], main.ONOSip[0] )
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 Lim58046fa2017-07-05 16:55:00 -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
YPZhangfebf7302016-05-24 16:45:56 -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:
YPZhangfebf7302016-05-24 16:45:56 -0700169 main.log.info("================================================")
Devin Lim58046fa2017-07-05 16:55:00 -0700170 main.log.info("Valid iteration: {} ".format( main.validRun - main.warmUp) )
171 main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun) )
YPZhangfebf7302016-05-24 16:45:56 -0700172 main.log.info("================================================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700173 else:
YPZhangfebf7302016-05-24 16:45:56 -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 Lim58046fa2017-07-05 16:55:00 -0700177 main.CLIs[0].pushTestIntents( main.ingress, main.egress, main.batchSize,
YPZhangfebf7302016-05-24 16:45:56 -0700178 offset=1, options="-i", timeout=main.timeout)
cameron@onlab.us78b89652015-07-08 15:21:03 -0700179
You Wang6d301d42017-04-21 10:49:33 -0700180 # check links, flows and intents
Devin Lim58046fa2017-07-05 16:55:00 -0700181 main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, batchSize * ( main.deviceCount - 1 ), main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800182 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700183 main.log.warn( "Sanity check failed, skipping this iteration..." )
184 continue
185
186 # Insert one line in karaf.log before link down
187 for i in range( main.numCtrls ):
188 main.CLIs[ i ].log( "\'Scale: {}, Batch:{}, Iteration: {}\'".format( main.numCtrls, batchSize, main.validRun + main.invalidRun ) )
189
190 # bring link down
Chiyu Cheng1976db52016-10-21 15:57:30 -0700191 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down",
YPZhangfebf7302016-05-24 16:45:56 -0700192 timeout=main.timeout, showResponse=False)
You Wang6d301d42017-04-21 10:49:33 -0700193
194 # check links, flows and intents
Devin Lim58046fa2017-07-05 16:55:00 -0700195 main.intentRerouteLatFuncs.sanityCheck( main, ( main.deviceCount - 1) * 2, batchSize * main.deviceCount, main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800196 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700197 main.log.warn( "Sanity check failed, skipping this iteration..." )
198 continue
199
200 # Get timestamp of last LINK_REMOVED event as separator between iterations
201 skip = False
Chiyu Chengec63bde2016-11-17 18:11:36 -0800202 for i in range( main.numCtrls ):
You Wang6d301d42017-04-21 10:49:33 -0700203 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
204 timestamp = str( main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ) )
205 if timestamp == main.ERROR:
206 # Try again in case that the log number just increased
207 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
208 timestamp = str( main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ) )
209 if timestamp == main.ERROR:
210 main.log.warn( "Cannot find the event we want in the log, skipping this iteration..." )
211 main.intentRerouteLatFuncs.bringBackTopology( main )
212 if main.validRun >= main.warmUp:
213 main.invalidRun += 1
214 else:
215 main.validRun += 1
216 skip = True
217 break
218 else:
219 main.startLine[ i ] = timestamp
220 main.log.info( "Timestamp of last LINK_REMOVED event on node {} is {}".format( i+1, main.startLine[ i ] ) )
221 if skip: continue
222
223 # calculate values
224 topologyTimestamps = main.intentRerouteLatFuncs.getTopologyTimestamps( main )
225 intentTimestamps = main.intentRerouteLatFuncs.getIntentTimestamps( main )
226 if intentTimestamps == main.ERROR or topologyTimestamps == main.ERROR:
227 main.log.info( "Got invalid timestamp, skipping this iteration..." )
228 main.intentRerouteLatFuncs.bringBackTopology( main )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800229 if main.validRun >= main.warmUp:
230 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700231 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800232 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700233 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800234 else:
You Wang6d301d42017-04-21 10:49:33 -0700235 main.log.info( "Got valid timestamps" )
236
237 firstLocalLatnecy, lastLocalLatnecy, firstGlobalLatency, lastGlobalLatnecy = main.intentRerouteLatFuncs.calculateLatency( main, topologyTimestamps, intentTimestamps )
238 if firstLocalLatnecy < 0:
239 main.log.info( "Got negative latency, skipping this iteration..." )
240 main.intentRerouteLatFuncs.bringBackTopology( main )
241 if main.validRun >= main.warmUp:
242 main.invalidRun += 1
243 else:
244 main.validRun += 1
245 continue
246 else:
247 main.log.info( "Got valid latencies" )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800248 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700249
You Wang6d301d42017-04-21 10:49:33 -0700250 firstLocalLatencies.append( firstLocalLatnecy )
251 lastLocalLatencies.append( lastLocalLatnecy )
252 firstGlobalLatencies.append( firstGlobalLatency )
253 lastGlobalLatencies.append( lastGlobalLatnecy )
254
255 # bring up link and withdraw intents
Chiyu Cheng1976db52016-10-21 15:57:30 -0700256 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up",
YPZhangfebf7302016-05-24 16:45:56 -0700257 timeout=main.timeout)
Devin Lim58046fa2017-07-05 16:55:00 -0700258 main.CLIs[0].pushTestIntents( main.ingress, main.egress, batchSize,
You Wang6d301d42017-04-21 10:49:33 -0700259 offset=1, options="-w", timeout=main.timeout)
260 main.CLIs[0].purgeWithdrawnIntents()
261
262 # check links, flows and intents
263 main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, 0, 0 )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800264 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700265 continue
266
You Wang6d301d42017-04-21 10:49:33 -0700267 aveLocalLatency = numpy.average( lastLocalLatencies )
268 aveGlobalLatency = numpy.average( lastGlobalLatencies )
269 stdLocalLatency = numpy.std( lastLocalLatencies )
270 stdGlobalLatency = numpy.std( lastGlobalLatencies )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800271
272 main.log.report( "Scale: " + str( main.numCtrls ) + " \tIntent batch: " + str( batchSize ) )
You Wang6d301d42017-04-21 10:49:33 -0700273 main.log.report( "Local latency average:................" + str( aveLocalLatency ) )
274 main.log.report( "Global latency average:................" + str( aveGlobalLatency ) )
275 main.log.report( "Local latency std:................" + str( stdLocalLatency ) )
276 main.log.report( "Global latency std:................" + str( stdGlobalLatency ) )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800277 main.log.report( "________________________________________________________" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700278
You Wang6d301d42017-04-21 10:49:33 -0700279 if not ( numpy.isnan( aveLocalLatency ) or numpy.isnan( aveGlobalLatency ) ):
YPZhang8742d2e2016-06-16 15:31:58 -0700280 # check if got NaN for result
You Wang6d301d42017-04-21 10:49:33 -0700281 resultsDB = open( main.dbFileName, "a" )
282 resultsDB.write( "'" + main.commit + "'," )
283 resultsDB.write( str( main.numCtrls ) + "," )
284 resultsDB.write( str( batchSize ) + "," )
285 resultsDB.write( str( aveLocalLatency ) + "," )
286 resultsDB.write( str( stdLocalLatency ) + "\n" )
YPZhang8742d2e2016-06-16 15:31:58 -0700287 resultsDB.close()