blob: d7acaa1f9f72e909a242b0bb1833ef275e31aa78 [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
You Wang227baa92017-07-24 11:21:28 -0700128 main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount )
129 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" )
131 main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.IntentManager", "skipReleaseResourcesOnWithdrawal", value="true" )
YPZhange6ef82a2016-07-05 16:48:15 -0700132 if main.flowObj:
You Wang227baa92017-07-24 11:21:28 -0700133 main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
134 "useFlowObjectives", value="true" )
135 main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
You Wang106d0fa2017-05-15 17:22:15 -0700136 "defaultFlowObjectiveCompiler",
You Wang227baa92017-07-24 11:21:28 -0700137 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800138 time.sleep( main.startUpSleep )
139 for i in range( int( main.numCtrls ) ):
140 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology" )
141 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.intent" )
YPZhangfebf7302016-05-24 16:45:56 -0700142 # Balance Master
143 main.CLIs[0].balanceMasters()
You Wang0b9039d2017-01-12 16:51:29 -0800144 time.sleep( main.setMasterSleep )
Devin Lim58046fa2017-07-05 16:55:00 -0700145 if main.numCtrls:
146 main.CLIs[0].deviceRole( main.end1[ 'name' ], main.ONOSip[0] )
147 main.CLIs[0].deviceRole( main.end2[ 'name' ], main.ONOSip[0] )
YPZhang2b9b26d2016-06-20 16:18:29 -0700148 time.sleep( main.setMasterSleep )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700149
150 def CASE2( self, main ):
cameron@onlab.us78b89652015-07-08 15:21:03 -0700151 import time
152 import numpy
153 import datetime
YPZhangfebf7302016-05-24 16:45:56 -0700154 import json
155 # from scipy import stats
cameron@onlab.us78b89652015-07-08 15:21:03 -0700156
Devin Lim58046fa2017-07-05 16:55:00 -0700157 print( main.intentsList)
YPZhangfebf7302016-05-24 16:45:56 -0700158 for batchSize in main.intentsList:
You Wang0b9039d2017-01-12 16:51:29 -0800159 main.batchSize = batchSize
YPZhangfebf7302016-05-24 16:45:56 -0700160 main.log.report("Intent Batch size: " + str(batchSize) + "\n ")
You Wang6d301d42017-04-21 10:49:33 -0700161 firstLocalLatencies = []
162 lastLocalLatencies = []
163 firstGlobalLatencies = []
164 lastGlobalLatencies = []
165 main.startLine = {}
Chiyu Chengec63bde2016-11-17 18:11:36 -0800166 main.validRun = 0
167 main.invalidRun = 0
You Wang0b9039d2017-01-12 16:51:29 -0800168 while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= main.maxInvalidRun:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800169 if main.validRun >= main.warmUp:
YPZhangfebf7302016-05-24 16:45:56 -0700170 main.log.info("================================================")
Devin Lim58046fa2017-07-05 16:55:00 -0700171 main.log.info("Valid iteration: {} ".format( main.validRun - main.warmUp) )
172 main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun) )
YPZhangfebf7302016-05-24 16:45:56 -0700173 main.log.info("================================================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700174 else:
YPZhangfebf7302016-05-24 16:45:56 -0700175 main.log.info("====================Warm Up=====================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700176
YPZhangfebf7302016-05-24 16:45:56 -0700177 # push intents
Devin Lim58046fa2017-07-05 16:55:00 -0700178 main.CLIs[0].pushTestIntents( main.ingress, main.egress, main.batchSize,
YPZhangfebf7302016-05-24 16:45:56 -0700179 offset=1, options="-i", timeout=main.timeout)
cameron@onlab.us78b89652015-07-08 15:21:03 -0700180
You Wang6d301d42017-04-21 10:49:33 -0700181 # check links, flows and intents
Devin Lim58046fa2017-07-05 16:55:00 -0700182 main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, batchSize * ( main.deviceCount - 1 ), main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800183 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700184 main.log.warn( "Sanity check failed, skipping this iteration..." )
185 continue
186
187 # Insert one line in karaf.log before link down
188 for i in range( main.numCtrls ):
189 main.CLIs[ i ].log( "\'Scale: {}, Batch:{}, Iteration: {}\'".format( main.numCtrls, batchSize, main.validRun + main.invalidRun ) )
190
191 # bring link down
Chiyu Cheng1976db52016-10-21 15:57:30 -0700192 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down",
YPZhangfebf7302016-05-24 16:45:56 -0700193 timeout=main.timeout, showResponse=False)
You Wang6d301d42017-04-21 10:49:33 -0700194
195 # check links, flows and intents
Devin Lim58046fa2017-07-05 16:55:00 -0700196 main.intentRerouteLatFuncs.sanityCheck( main, ( main.deviceCount - 1) * 2, batchSize * main.deviceCount, main.batchSize )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800197 if not main.verify:
You Wang6d301d42017-04-21 10:49:33 -0700198 main.log.warn( "Sanity check failed, skipping this iteration..." )
199 continue
200
201 # Get timestamp of last LINK_REMOVED event as separator between iterations
202 skip = False
Chiyu Chengec63bde2016-11-17 18:11:36 -0800203 for i in range( main.numCtrls ):
You Wang6d301d42017-04-21 10:49:33 -0700204 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
205 timestamp = str( main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ) )
206 if timestamp == main.ERROR:
207 # Try again in case that the log number just increased
208 logNum = main.intentRerouteLatFuncs.getLogNum( main, i )
209 timestamp = str( main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ) )
210 if timestamp == main.ERROR:
211 main.log.warn( "Cannot find the event we want in the log, skipping this iteration..." )
212 main.intentRerouteLatFuncs.bringBackTopology( main )
213 if main.validRun >= main.warmUp:
214 main.invalidRun += 1
215 else:
216 main.validRun += 1
217 skip = True
218 break
219 else:
220 main.startLine[ i ] = timestamp
221 main.log.info( "Timestamp of last LINK_REMOVED event on node {} is {}".format( i+1, main.startLine[ i ] ) )
222 if skip: continue
223
224 # calculate values
225 topologyTimestamps = main.intentRerouteLatFuncs.getTopologyTimestamps( main )
226 intentTimestamps = main.intentRerouteLatFuncs.getIntentTimestamps( main )
227 if intentTimestamps == main.ERROR or topologyTimestamps == main.ERROR:
228 main.log.info( "Got invalid timestamp, skipping this iteration..." )
229 main.intentRerouteLatFuncs.bringBackTopology( main )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800230 if main.validRun >= main.warmUp:
231 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700232 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800233 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700234 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800235 else:
You Wang6d301d42017-04-21 10:49:33 -0700236 main.log.info( "Got valid timestamps" )
237
238 firstLocalLatnecy, lastLocalLatnecy, firstGlobalLatency, lastGlobalLatnecy = main.intentRerouteLatFuncs.calculateLatency( main, topologyTimestamps, intentTimestamps )
239 if firstLocalLatnecy < 0:
240 main.log.info( "Got negative latency, skipping this iteration..." )
241 main.intentRerouteLatFuncs.bringBackTopology( main )
242 if main.validRun >= main.warmUp:
243 main.invalidRun += 1
244 else:
245 main.validRun += 1
246 continue
247 else:
248 main.log.info( "Got valid latencies" )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800249 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700250
You Wang6d301d42017-04-21 10:49:33 -0700251 firstLocalLatencies.append( firstLocalLatnecy )
252 lastLocalLatencies.append( lastLocalLatnecy )
253 firstGlobalLatencies.append( firstGlobalLatency )
254 lastGlobalLatencies.append( lastGlobalLatnecy )
255
256 # bring up link and withdraw intents
Chiyu Cheng1976db52016-10-21 15:57:30 -0700257 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up",
YPZhangfebf7302016-05-24 16:45:56 -0700258 timeout=main.timeout)
Devin Lim58046fa2017-07-05 16:55:00 -0700259 main.CLIs[0].pushTestIntents( main.ingress, main.egress, batchSize,
You Wang6d301d42017-04-21 10:49:33 -0700260 offset=1, options="-w", timeout=main.timeout)
261 main.CLIs[0].purgeWithdrawnIntents()
262
263 # check links, flows and intents
264 main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, 0, 0 )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800265 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700266 continue
267
You Wang6d301d42017-04-21 10:49:33 -0700268 aveLocalLatency = numpy.average( lastLocalLatencies )
269 aveGlobalLatency = numpy.average( lastGlobalLatencies )
270 stdLocalLatency = numpy.std( lastLocalLatencies )
271 stdGlobalLatency = numpy.std( lastGlobalLatencies )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800272
273 main.log.report( "Scale: " + str( main.numCtrls ) + " \tIntent batch: " + str( batchSize ) )
You Wang6d301d42017-04-21 10:49:33 -0700274 main.log.report( "Local latency average:................" + str( aveLocalLatency ) )
275 main.log.report( "Global latency average:................" + str( aveGlobalLatency ) )
276 main.log.report( "Local latency std:................" + str( stdLocalLatency ) )
277 main.log.report( "Global latency std:................" + str( stdGlobalLatency ) )
Chiyu Chengec63bde2016-11-17 18:11:36 -0800278 main.log.report( "________________________________________________________" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700279
You Wang6d301d42017-04-21 10:49:33 -0700280 if not ( numpy.isnan( aveLocalLatency ) or numpy.isnan( aveGlobalLatency ) ):
YPZhang8742d2e2016-06-16 15:31:58 -0700281 # check if got NaN for result
You Wang6d301d42017-04-21 10:49:33 -0700282 resultsDB = open( main.dbFileName, "a" )
283 resultsDB.write( "'" + main.commit + "'," )
284 resultsDB.write( str( main.numCtrls ) + "," )
285 resultsDB.write( str( batchSize ) + "," )
286 resultsDB.write( str( aveLocalLatency ) + "," )
287 resultsDB.write( str( stdLocalLatency ) + "\n" )
YPZhang8742d2e2016-06-16 15:31:58 -0700288 resultsDB.close()