blob: 093b5ca9ddb7e84db85dcde3bda151f45f1062b2 [file] [log] [blame]
YPZhangb34b7e12016-06-14 14:28:19 -07001"""
2SCPFintentInstallWithdrawLat:
3 - Test the latency of intent installed and withdrawn
4 - Use Push-test-intents command to push intents
5 - Use Null provider with 7 devices and linear topology
6 - Always push intents between 1/6 and 7/5
Devin Lim58046fa2017-07-05 16:55:00 -07007 - The batch size is defined in parm file. ( default 1,100,1000)
cameron@onlab.us41c16f52015-07-08 15:40:28 -07008
YPZhangb34b7e12016-06-14 14:28:19 -07009 yunpeng@onlab.us
10"""
cameron@onlab.us41c16f52015-07-08 15:40:28 -070011class SCPFintentInstallWithdrawLat:
cameron@onlab.us41c16f52015-07-08 15:40:28 -070012 def __init__( self ):
13 self.default = ''
14
YPZhangb34b7e12016-06-14 14:28:19 -070015 def CASE0( self, main ):
16 '''
17 - GIT
18 - BUILDING ONOS
19 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
20 This step is usually skipped. Because in a Jenkins driven automated
21 test env. We want Jenkins jobs to pull&build for flexibility to handle
22 different versions of ONOS.
23 - Construct tests variables
24 '''
YPZhangb34b7e12016-06-14 14:28:19 -070025
Devin Lim58046fa2017-07-05 16:55:00 -070026 try:
27 from tests.dependencies.ONOSSetup import ONOSSetup
28 main.testSetUp = ONOSSetup()
29 except ImportError:
30 main.log.error( "ONOSSetup not found. exiting the test" )
31 main.exit()
32 main.testSetUp.envSetupDescription()
33 stepResult = main.FALSE
34 try:
YPZhangb34b7e12016-06-14 14:28:19 -070035
Devin Lim58046fa2017-07-05 16:55:00 -070036 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
37 main.BENCHUser = main.params[ 'BENCH' ][ 'user' ]
38 main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
39 main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
40 main.maxNodes = int( main.params[ 'max' ] )
41 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
42 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
43 main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
44 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
45 main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
46 main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
47 main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] )
48 main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
49 main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
50 main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," )
51 main.ingress = main.params[ 'TEST' ][ 'ingress' ]
52 main.egress = main.params[ 'TEST' ][ 'egress' ]
53 main.debug = main.params[ 'TEST' ][ 'debug' ]
54 main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
YPZhangb34b7e12016-06-14 14:28:19 -070055
Devin Lim58046fa2017-07-05 16:55:00 -070056 if main.flowObj == "True":
57 main.flowObj = True
58 main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
59 else:
60 main.flowObj = False
61 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
YPZhangb34b7e12016-06-14 14:28:19 -070062
Devin Lim58046fa2017-07-05 16:55:00 -070063 for i in range( 0, len( main.intentsList ) ):
64 main.intentsList[ i ] = int( main.intentsList[ i ] )
YPZhangb34b7e12016-06-14 14:28:19 -070065
Devin Lim58046fa2017-07-05 16:55:00 -070066 stepResult = main.testSetUp.gitPulling()
67 # Create DataBase file
68 main.log.info( "Create Database file " + main.dbFileName )
69 resultsDB = open( main.dbFileName, "w+" )
70 resultsDB.close()
71 except Exception as e:
72 main.testSetUp.envSetupException( e )
73 main.testSetUp.evnSetupConclusion( stepResult )
74 main.commit = main.commit.split( " " )[ 1 ]
Jon Hall4ba53f02015-07-29 13:07:41 -070075 def CASE1( self, main ):
YPZhangb34b7e12016-06-14 14:28:19 -070076 # Clean up test environment and set up
Jon Hall4ba53f02015-07-29 13:07:41 -070077 import time
Devin Lim58046fa2017-07-05 16:55:00 -070078
YPZhangb34b7e12016-06-14 14:28:19 -070079 main.maxNumBatch = 0
Devin Lim58046fa2017-07-05 16:55:00 -070080 main.testSetUp.getNumCtrls( True )
81 main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
82 main.testSetUp.ONOSSetUp( main.MN1Ip, True,
83 cellName=main.cellName, killRemoveMax=False,
84 CtrlsSet=False )
cameron@onlab.us41c16f52015-07-08 15:40:28 -070085
YPZhangb34b7e12016-06-14 14:28:19 -070086 # configure apps
Devin Lim58046fa2017-07-05 16:55:00 -070087 main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount", value=7 )
88 main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "topoShape", value="linear" )
89 main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled", value="true" )
90 main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.IntentManager", "skipReleaseResourcesOnWithdrawal", value="true" )
YPZhange6ef82a2016-07-05 16:48:15 -070091 if main.flowObj:
Devin Lim58046fa2017-07-05 16:55:00 -070092 main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
93 "useFlowObjectives", value="true" )
94 main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
You Wang106d0fa2017-05-15 17:22:15 -070095 "defaultFlowObjectiveCompiler",
Devin Lim58046fa2017-07-05 16:55:00 -070096 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
97 time.sleep( main.startUpSleep )
Jon Hall4ba53f02015-07-29 13:07:41 -070098
YPZhangb34b7e12016-06-14 14:28:19 -070099 # balanceMasters
Devin Lim58046fa2017-07-05 16:55:00 -0700100 main.CLIs[ 0 ].balanceMasters()
101 time.sleep( main.startUpSleep )
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700102
103 def CASE2( self, main ):
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700104 import time
105 import numpy
YPZhangb34b7e12016-06-14 14:28:19 -0700106 import json
Devin Lim58046fa2017-07-05 16:55:00 -0700107 print( main.intentsList )
YPZhangb34b7e12016-06-14 14:28:19 -0700108 for batchSize in main.intentsList:
Devin Lim58046fa2017-07-05 16:55:00 -0700109 main.log.report( "Intent Batch size: {}".format( batchSize ) )
YPZhangb34b7e12016-06-14 14:28:19 -0700110 main.installLatList = []
111 main.withdrawLatList = []
112 validrun = 0
113 invalidrun = 0
114 # we use two variables to control the iteration
115 while validrun <= main.warmUp + main.sampleSize and invalidrun < 20:
116 if validrun >= main.warmUp:
Devin Lim58046fa2017-07-05 16:55:00 -0700117 main.log.info( "================================================" )
118 main.log.info( "Starting test iteration " + str( validrun - main.warmUp ) )
119 main.log.info( "Total test iteration: " + str( invalidrun + validrun ) )
120 main.log.info( "================================================" )
YPZhangb34b7e12016-06-14 14:28:19 -0700121 else:
Devin Lim58046fa2017-07-05 16:55:00 -0700122 main.log.info( "====================Warm Up=====================" )
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700123
YPZhangb34b7e12016-06-14 14:28:19 -0700124 # push intents
Devin Lim58046fa2017-07-05 16:55:00 -0700125 installResult = main.CLIs[ 0 ].pushTestIntents( main.ingress, main.egress, batchSize,
YPZhangb34b7e12016-06-14 14:28:19 -0700126 offset=1, options="-i", timeout=main.timeout,
Devin Lim58046fa2017-07-05 16:55:00 -0700127 getResponse=True )
128 if type( installResult ) is str:
YPZhangb34b7e12016-06-14 14:28:19 -0700129 if "Failure" in installResult:
Devin Lim58046fa2017-07-05 16:55:00 -0700130 main.log.error( "Install Intents failure, ignore this iteration." )
YPZhangb34b7e12016-06-14 14:28:19 -0700131 if validrun < main.warmUp:
132 validrun += 1
133 continue
134 else:
135 invalidrun += 1
136 continue
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700137
YPZhangb34b7e12016-06-14 14:28:19 -0700138 try:
Devin Lim58046fa2017-07-05 16:55:00 -0700139 latency = int( installResult.split()[ 5 ] )
140 main.log.info( installResult )
YPZhangb34b7e12016-06-14 14:28:19 -0700141 except:
Devin Lim58046fa2017-07-05 16:55:00 -0700142 main.log.error( "Failed to get latency, ignore this iteration." )
143 main.log.error( "Response from ONOS:" )
144 print( installResult )
YPZhangb34b7e12016-06-14 14:28:19 -0700145 if validrun < main.warmUp:
146 validrun += 1
147 continue
148 else:
149 invalidrun += 1
150 continue
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700151
YPZhangb34b7e12016-06-14 14:28:19 -0700152 if validrun >= main.warmUp:
Devin Lim58046fa2017-07-05 16:55:00 -0700153 main.installLatList.append( latency )
YPZhangb34b7e12016-06-14 14:28:19 -0700154 else:
155 invalidrun += 1
156 continue
Devin Lim58046fa2017-07-05 16:55:00 -0700157 time.sleep( 2 )
YPZhangb34b7e12016-06-14 14:28:19 -0700158 # Withdraw Intents
Devin Lim58046fa2017-07-05 16:55:00 -0700159 withdrawResult = main.CLIs[ 0 ].pushTestIntents( main.ingress, main.egress, batchSize,
YPZhangb34b7e12016-06-14 14:28:19 -0700160 offset=1, options="-w", timeout=main.timeout,
Devin Lim58046fa2017-07-05 16:55:00 -0700161 getResponse=True )
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700162
Devin Lim58046fa2017-07-05 16:55:00 -0700163 if type( withdrawResult ) is str:
YPZhangb34b7e12016-06-14 14:28:19 -0700164 if "Failure" in withdrawResult:
Devin Lim58046fa2017-07-05 16:55:00 -0700165 main.log.error( "withdraw Intents failure, ignore this iteration." )
YPZhangb34b7e12016-06-14 14:28:19 -0700166 if validrun < main.warmUp:
167 validrun += 1
168 continue
169 else:
170 invalidrun += 1
171 continue
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700172
YPZhangb34b7e12016-06-14 14:28:19 -0700173 try:
Devin Lim58046fa2017-07-05 16:55:00 -0700174 latency = int( withdrawResult.split()[ 5 ] )
175 main.log.info( withdrawResult )
YPZhangb34b7e12016-06-14 14:28:19 -0700176 except:
Devin Lim58046fa2017-07-05 16:55:00 -0700177 main.log.error( "Failed to get latency, ignore this iteration." )
178 main.log.error( "Response from ONOS:" )
179 print( withdrawResult )
YPZhangb34b7e12016-06-14 14:28:19 -0700180 if validrun < main.warmUp:
181 validrun += 1
182 continue
183 else:
184 invalidrun += 1
185 continue
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700186
YPZhangb34b7e12016-06-14 14:28:19 -0700187 if validrun >= main.warmUp:
Devin Lim58046fa2017-07-05 16:55:00 -0700188 main.withdrawLatList.append( latency )
YPZhangb34b7e12016-06-14 14:28:19 -0700189 else:
190 invalidrun += 1
191 continue
Devin Lim58046fa2017-07-05 16:55:00 -0700192 time.sleep( 2 )
193 main.CLIs[ 0 ].purgeWithdrawnIntents()
YPZhangb34b7e12016-06-14 14:28:19 -0700194 validrun += 1
Devin Lim58046fa2017-07-05 16:55:00 -0700195 installave = numpy.average( main.installLatList )
196 installstd = numpy.std( main.installLatList )
197 withdrawave = numpy.average( main.withdrawLatList )
198 withdrawstd = numpy.std( main.withdrawLatList )
YPZhangb34b7e12016-06-14 14:28:19 -0700199 # log report
Devin Lim58046fa2017-07-05 16:55:00 -0700200 main.log.report( "----------------------------------------------------" )
201 main.log.report( "Scale: " + str( main.numCtrls ) )
202 main.log.report( "Intent batch: " + str( batchSize ) )
203 main.log.report( "Install average: {} std: {}".format( installave, installstd ) )
204 main.log.report( "Withdraw average: {} std: {}".format( withdrawave, withdrawstd ) )
YPZhangb34b7e12016-06-14 14:28:19 -0700205 # write result to database file
Devin Lim58046fa2017-07-05 16:55:00 -0700206 if not ( numpy.isnan( installave ) or numpy.isnan( installstd ) or\
207 numpy.isnan( withdrawstd ) or numpy.isnan( withdrawave ) ):
YPZhangb34b7e12016-06-14 14:28:19 -0700208 databaseString = "'" + main.commit + "',"
Devin Lim58046fa2017-07-05 16:55:00 -0700209 databaseString += str( main.numCtrls ) + ","
210 databaseString += str( batchSize ) + ","
211 databaseString += str( installave ) + ","
212 databaseString += str( installstd ) + ","
213 databaseString += str( withdrawave ) + ","
214 databaseString += str( withdrawstd ) + "\n"
215 resultsDB = open( main.dbFileName, "a" )
216 resultsDB.write( databaseString )
YPZhangb34b7e12016-06-14 14:28:19 -0700217 resultsDB.close()