blob: f71d2e57df155b3fd44d8795e9d22bc595de8c89 [file] [log] [blame]
YPZhangcbc2a062016-07-11 10:55:44 -07001'''
2SCPFintentEventTp
3 - Use intentperf app to generate a lot of intent install and withdraw events
4 - Test will run with 1,3,5,7 nodes, and with all neighbors
5 - Test will run 400 seconds and grep the overall rate from intent-perf summary
andrew@onlab.us2ae3a112015-02-02 11:24:32 -08006
YPZhangcbc2a062016-07-11 10:55:44 -07007 yunpeng@onlab.us
8'''
9
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070010import time
andrew@onlab.us10332202015-03-11 15:04:43 -070011
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080012
suibin7f2c9cd2015-07-08 17:34:59 -070013class SCPFintentEventTp:
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080014 def __init__( self ):
15 self.default = ''
16
YPZhangcbc2a062016-07-11 10:55:44 -070017 def CASE0( self, main ):
18 '''
19 - GIT
20 - BUILDING ONOS
21 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
22 This step is usually skipped. Because in a Jenkins driven automated
23 test env. We want Jenkins jobs to pull&build for flexibility to handle
24 different versions of ONOS.
25 - Construct tests variables
26 '''
27 gitPull = main.params['GIT']['gitPull']
28 gitBranch = main.params['GIT']['gitBranch']
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070029
YPZhangcbc2a062016-07-11 10:55:44 -070030 main.case( "Pull onos branch and build onos on Teststation." )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070031
YPZhangcbc2a062016-07-11 10:55:44 -070032 if gitPull == 'True':
33 main.step( "Git Checkout ONOS branch: " + gitBranch )
34 stepResult = main.ONOSbench.gitCheckout( branch=gitBranch )
35 utilities.assert_equals(expect=main.TRUE,
36 actual=stepResult,
37 onpass="Successfully checkout onos branch.",
38 onfail="Failed to checkout onos branch. Exiting test...")
39 if not stepResult: main.exit()
YPZhange6ef82a2016-07-05 16:48:15 -070040
YPZhangcbc2a062016-07-11 10:55:44 -070041 main.step( "Git Pull on ONOS branch:" + gitBranch )
42 stepResult = main.ONOSbench.gitPull()
43 utilities.assert_equals(expect=main.TRUE,
44 actual=stepResult,
45 onpass="Successfully pull onos. ",
46 onfail="Failed to pull onos. Exiting test ...")
47 if not stepResult: main.exit()
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080048
YPZhangcbc2a062016-07-11 10:55:44 -070049 else:
Devin Lim8d7c7782017-06-07 16:21:20 -070050 main.log.warn( "Skipped pulling onos" )
YPZhangcbc2a062016-07-11 10:55:44 -070051
52 main.cellName = main.params['ENV']['cellName']
53 main.Apps = main.params['ENV']['cellApps']
54 main.BENCHIp = main.params['BENCH']['ip1']
55 main.BENCHUser = main.params['BENCH']['user']
56 main.MN1Ip = main.params['MN']['ip1']
57 main.maxNodes = int(main.params['max'])
58 main.numSwitches = (main.params['TEST']['numSwitches']).split(",")
YPZhangcbc2a062016-07-11 10:55:44 -070059 main.skipRelRsrc = main.params['TEST']['skipReleaseResourcesOnWithdrawal']
YPZhange6ef82a2016-07-05 16:48:15 -070060 main.flowObj = main.params['TEST']['flowObj']
YPZhangcbc2a062016-07-11 10:55:44 -070061 main.startUpSleep = int(main.params['SLEEP']['startup'])
62 main.installSleep = int(main.params['SLEEP']['install'])
63 main.verifySleep = int(main.params['SLEEP']['verify'])
64 main.scale = (main.params['SCALE']).split(",")
65 main.testDuration = main.params[ 'TEST' ][ 'duration' ]
66 main.logInterval = main.params[ 'TEST' ][ 'log_interval' ]
67 main.debug = main.params[ 'debugMode' ]
YPZhangcbc2a062016-07-11 10:55:44 -070068 main.timeout = int(main.params['SLEEP']['timeout'])
69 main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
YPZhange6ef82a2016-07-05 16:48:15 -070070 if main.flowObj == "True":
71 main.flowObj = True
72 main.dbFileName = main.params['DATABASE']['dbFlowObj']
You Wange1427332017-02-06 17:16:20 -080073 main.numKeys = main.params[ 'TEST' ][ 'numKeysFlowObj' ]
YPZhange6ef82a2016-07-05 16:48:15 -070074 else:
75 main.flowObj = False
76 main.dbFileName = main.params['DATABASE']['dbName']
You Wange1427332017-02-06 17:16:20 -080077 main.numKeys = main.params[ 'TEST' ][ 'numKeys' ]
YPZhangcbc2a062016-07-11 10:55:44 -070078 # Create DataBase file
79 main.log.info( "Create Database file " + main.dbFileName )
80 resultsDB = open( main.dbFileName, "w+" )
81 resultsDB.close()
YPZhange6ef82a2016-07-05 16:48:15 -070082
YPZhangcbc2a062016-07-11 10:55:44 -070083 # set neighbors
84 main.neighbors = "1"
cameron@onlab.us412e9562015-05-13 16:04:34 -070085
YPZhangcbc2a062016-07-11 10:55:44 -070086 def CASE1( self, main ):
87 # Clean up test environment and set up
88 import time
89 main.log.info( "Get ONOS cluster IP" )
90 print( main.scale )
91 main.numCtrls = int( main.scale.pop(0) )
92 main.ONOSip = []
93 main.maxNumBatch = 0
94 main.AllONOSip = main.ONOSbench.getOnosIps()
95 for i in range( main.numCtrls ):
96 main.ONOSip.append( main.AllONOSip[i] )
97 main.log.info( main.ONOSip )
98 main.CLIs = []
99 main.log.info( "Creating list of ONOS cli handles" )
100 for i in range( main.numCtrls ):
Devin Lim28706842017-06-08 10:23:48 -0700101 main.CLIs.append( getattr( main, 'ONOScli%s' % (i + 1) ) )
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700102
YPZhangcbc2a062016-07-11 10:55:44 -0700103 if not main.CLIs:
104 main.log.error( "Failed to create the list of ONOS cli handles" )
105 main.cleanup()
106 main.exit()
cameron@onlab.usc5bf8192015-07-13 13:36:05 -0700107
YPZhangcbc2a062016-07-11 10:55:44 -0700108 main.commit = main.ONOSbench.getVersion( report=True )
109 main.commit = main.commit.split(" ")[1]
110 main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls )
111 main.log.info("Safety check, killing all ONOS processes" +
112 " before initiating environment setup")
cameron@onlab.us059c2562015-04-02 14:12:51 -0700113
YPZhangcbc2a062016-07-11 10:55:44 -0700114 for i in range( main.numCtrls ):
You Wangb98a9fa2017-02-15 17:27:42 -0800115 main.ONOSbench.onosStop( main.ONOSip[i] )
116 main.ONOSbench.onosKill( main.ONOSip[i] )
jenkins15b2b132015-06-23 14:04:09 -0700117
YPZhangcbc2a062016-07-11 10:55:44 -0700118 main.log.info( "NODE COUNT = %s" % main.numCtrls )
119 main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
120 main.cellName,
121 main.MN1Ip,
122 main.Apps,
Devin Lim461f0872017-06-05 16:49:33 -0700123 main.ONOSip,
Devin Limdc78e202017-06-09 18:30:07 -0700124 main.ONOScli1.karafUser )
YPZhangcbc2a062016-07-11 10:55:44 -0700125 main.step( "Apply cell to environment" )
126 cellResult = main.ONOSbench.setCell( main.cellName )
127 verifyResult = main.ONOSbench.verifyCell()
128 stepResult = cellResult and verifyResult
129 utilities.assert_equals(expect=main.TRUE,
130 actual=stepResult,
131 onpass="Successfully applied cell to " + \
132 "environment",
133 onfail="Failed to apply cell to environment ")
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800134
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800135 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700136 packageResult = main.ONOSbench.buckBuild()
YPZhangcbc2a062016-07-11 10:55:44 -0700137 stepResult = packageResult
138 utilities.assert_equals(expect=main.TRUE,
139 actual=stepResult,
140 onpass="Successfully created ONOS package",
141 onfail="Failed to create ONOS package")
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800142
YPZhangcbc2a062016-07-11 10:55:44 -0700143 main.step( "Uninstall ONOS package on all Nodes" )
144 uninstallResult = main.TRUE
145 for i in range( int( main.numCtrls ) ):
146 main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] )
147 u_result = main.ONOSbench.onosUninstall( main.ONOSip[i] )
148 utilities.assert_equals(expect=main.TRUE, actual=u_result,
149 onpass="Test step PASS",
150 onfail="Test step FAIL")
151 uninstallResult = ( uninstallResult and u_result )
Jon Hall4ba53f02015-07-29 13:07:41 -0700152
YPZhangcbc2a062016-07-11 10:55:44 -0700153 main.step( "Install ONOS package on all Nodes" )
154 installResult = main.TRUE
155 for i in range( int( main.numCtrls ) ):
156 main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] )
157 i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
158 utilities.assert_equals(expect=main.TRUE, actual=i_result,
159 onpass="Test step PASS",
160 onfail="Test step FAIL")
161 installResult = installResult and i_result
cameron@onlab.us059c2562015-04-02 14:12:51 -0700162
Chiyu Chengef109502016-11-21 15:51:38 -0800163 main.step( "Set up ONOS secure SSH" )
164 secureSshResult = main.TRUE
165 for i in range( int( main.numCtrls ) ):
166 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
167 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
168 onpass="Test step PASS",
169 onfail="Test step FAIL" )
170
You Wang0357c432017-01-09 16:13:33 -0800171 time.sleep( main.startUpSleep )
172 main.step( "Starting ONOS service" )
173 stopResult = main.TRUE
174 startResult = main.TRUE
175 onosIsUp = main.TRUE
176 for i in range( main.numCtrls ):
177 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
178 if onosIsUp == main.TRUE:
179 main.log.report( "ONOS instance is up and ready" )
180 else:
181 main.log.report( "ONOS instance may not be up, stop and " +
182 "start ONOS again " )
183 for i in range( main.numCtrls ):
184 stopResult = stopResult and \
185 main.ONOSbench.onosStop( main.ONOSip[ i ] )
186 for i in range( main.numCtrls ):
187 startResult = startResult and \
188 main.ONOSbench.onosStart( main.ONOSip[ i ] )
189 stepResult = onosIsUp and stopResult and startResult
190 utilities.assert_equals( expect=main.TRUE,
191 actual=stepResult,
192 onpass="ONOS service is ready",
193 onfail="ONOS service did not start properly" )
194
YPZhangcbc2a062016-07-11 10:55:44 -0700195 main.step( "Start ONOS cli using thread" )
196 startCliResult = main.TRUE
197 pool = []
198 main.threadID = 0
199 for i in range(int(main.numCtrls)):
200 t = main.Thread(target=main.CLIs[i].startOnosCli,
201 threadID=main.threadID,
202 name="startOnosCli",
203 args=[main.ONOSip[i]],
204 kwargs={"onosStartTimeout": main.timeout})
205 pool.append(t)
206 t.start()
207 main.threadID = main.threadID + 1
208 for t in pool:
209 t.join()
210 startCliResult = startCliResult and t.result
211 time.sleep( main.startUpSleep )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700212
YPZhangcbc2a062016-07-11 10:55:44 -0700213 # config apps
YPZhangcbc2a062016-07-11 10:55:44 -0700214 main.CLIs[0].setCfg( "org.onosproject.net.intent.impl.IntentManager",
215 "skipReleaseResourcesOnWithdrawal " + main.skipRelRsrc )
216 main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(int(main.numCtrls*10)) )
217 main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "topoShape linear" )
218 main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled true" )
YPZhange6ef82a2016-07-05 16:48:15 -0700219 if main.flowObj:
YPZhangcbc2a062016-07-11 10:55:44 -0700220 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
221 "useFlowObjectives", value="true")
You Wang106d0fa2017-05-15 17:22:15 -0700222 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
223 "defaultFlowObjectiveCompiler",
224 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler')
YPZhangcbc2a062016-07-11 10:55:44 -0700225 time.sleep( main.startUpSleep )
cameron@onlab.useae03dc2015-07-29 11:51:28 -0700226
YPZhangcbc2a062016-07-11 10:55:44 -0700227 # balanceMasters
228 main.CLIs[0].balanceMasters()
229 time.sleep( main.startUpSleep )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700230
YPZhangcbc2a062016-07-11 10:55:44 -0700231 def CASE2(self, main):
jenkins3af0cd82015-03-24 10:27:16 -0700232 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700233
YPZhangcbc2a062016-07-11 10:55:44 -0700234 main.log.info( "Cluster Count = " + str( main.numCtrls ) )
235 # adjust neighbors
236 if main.numCtrls == 1:
237 main.neighbors = "0"
238 main.log.info( "Neighbors: 0" )
239 elif main.neighbors != "0":
240 main.neighbors = "0"
241 main.log.info( "Neighbors: 0" )
242 elif main.neighbors == "0":
243 main.neighbors = str( main.numCtrls - 1 )
244 main.log.info( "Neighbors: " + main.neighbors )
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700245
YPZhangcbc2a062016-07-11 10:55:44 -0700246 main.log.info( "Config intent-perf app" )
247 main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numKeys " + main.numKeys )
248 main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numNeighbors " + str( main.neighbors ) )
249 main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "cyclePeriod " + main.cyclePeriod )
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700250
YPZhangcbc2a062016-07-11 10:55:44 -0700251 main.log.info( "Starting intent-perf test for " + str(main.testDuration) + " seconds..." )
252 main.CLIs[0].sendline( "intent-perf-start" )
253 stop = time.time() + float( main.testDuration )
andrew@onlab.us10332202015-03-11 15:04:43 -0700254
YPZhangcbc2a062016-07-11 10:55:44 -0700255 while time.time() < stop:
256 time.sleep(15)
257 result = main.CLIs[0].getIntentPerfSummary()
258 if result:
259 for ip in main.ONOSip:
260 main.log.info( "Node {} Overall Rate: {}".format( ip, result[ip] ) )
261 main.log.info( "Stop intent-perf" )
262 for node in main.CLIs:
263 node.sendline( "intent-perf-stop" )
264 if result:
265 for ip in main.ONOSip:
266 main.log.info( "Node {} final Overall Rate: {}".format( ip, result[ip] ) )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800267
YPZhangcbc2a062016-07-11 10:55:44 -0700268 with open( main.dbFileName, "a" ) as resultDB:
269 for nodes in range( 0, len( main.ONOSip ) ):
270 resultString = "'" + main.commit + "',"
271 resultString += "'1gig',"
272 resultString += str(main.numCtrls) + ","
273 resultString += "'baremetal" + str( nodes+1 ) + "',"
274 resultString += main.neighbors + ","
275 resultString += result[ main.ONOSip[ nodes ] ]+","
276 resultString += str(0) + "\n" # no stddev
277 resultDB.write( resultString )
278 resultDB.close()