blob: f77342addf231371ae2ef32a5a4ae87edb4e4bc6 [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 main.step( "Building ONOS branch: " + gitBranch )
50 stepResult = main.ONOSbench.cleanInstall( skipTest=True )
51 utilities.assert_equals(expect=main.TRUE,
52 actual=stepResult,
53 onpass="Successfully build onos.",
54 onfail="Failed to build onos. Exiting test...")
55 if not stepResult: main.exit()
56
57 else:
58 main.log.warn( "Skipped pulling onos and Skipped building ONOS" )
59
60 main.cellName = main.params['ENV']['cellName']
61 main.Apps = main.params['ENV']['cellApps']
62 main.BENCHIp = main.params['BENCH']['ip1']
63 main.BENCHUser = main.params['BENCH']['user']
64 main.MN1Ip = main.params['MN']['ip1']
65 main.maxNodes = int(main.params['max'])
66 main.numSwitches = (main.params['TEST']['numSwitches']).split(",")
YPZhangcbc2a062016-07-11 10:55:44 -070067 main.skipRelRsrc = main.params['TEST']['skipReleaseResourcesOnWithdrawal']
YPZhange6ef82a2016-07-05 16:48:15 -070068 main.flowObj = main.params['TEST']['flowObj']
YPZhangcbc2a062016-07-11 10:55:44 -070069 main.startUpSleep = int(main.params['SLEEP']['startup'])
70 main.installSleep = int(main.params['SLEEP']['install'])
71 main.verifySleep = int(main.params['SLEEP']['verify'])
72 main.scale = (main.params['SCALE']).split(",")
73 main.testDuration = main.params[ 'TEST' ][ 'duration' ]
74 main.logInterval = main.params[ 'TEST' ][ 'log_interval' ]
75 main.debug = main.params[ 'debugMode' ]
YPZhangcbc2a062016-07-11 10:55:44 -070076 main.timeout = int(main.params['SLEEP']['timeout'])
77 main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
YPZhange6ef82a2016-07-05 16:48:15 -070078 if main.flowObj == "True":
79 main.flowObj = True
80 main.dbFileName = main.params['DATABASE']['dbFlowObj']
You Wange1427332017-02-06 17:16:20 -080081 main.numKeys = main.params[ 'TEST' ][ 'numKeysFlowObj' ]
YPZhange6ef82a2016-07-05 16:48:15 -070082 else:
83 main.flowObj = False
84 main.dbFileName = main.params['DATABASE']['dbName']
You Wange1427332017-02-06 17:16:20 -080085 main.numKeys = main.params[ 'TEST' ][ 'numKeys' ]
YPZhangcbc2a062016-07-11 10:55:44 -070086 # Create DataBase file
87 main.log.info( "Create Database file " + main.dbFileName )
88 resultsDB = open( main.dbFileName, "w+" )
89 resultsDB.close()
YPZhange6ef82a2016-07-05 16:48:15 -070090
YPZhangcbc2a062016-07-11 10:55:44 -070091 # set neighbors
92 main.neighbors = "1"
cameron@onlab.us412e9562015-05-13 16:04:34 -070093
YPZhangcbc2a062016-07-11 10:55:44 -070094 def CASE1( self, main ):
95 # Clean up test environment and set up
96 import time
97 main.log.info( "Get ONOS cluster IP" )
98 print( main.scale )
99 main.numCtrls = int( main.scale.pop(0) )
100 main.ONOSip = []
101 main.maxNumBatch = 0
102 main.AllONOSip = main.ONOSbench.getOnosIps()
103 for i in range( main.numCtrls ):
104 main.ONOSip.append( main.AllONOSip[i] )
105 main.log.info( main.ONOSip )
106 main.CLIs = []
107 main.log.info( "Creating list of ONOS cli handles" )
108 for i in range( main.numCtrls ):
109 main.CLIs.append( getattr( main, 'ONOS%scli' % (i + 1) ) )
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700110
YPZhangcbc2a062016-07-11 10:55:44 -0700111 if not main.CLIs:
112 main.log.error( "Failed to create the list of ONOS cli handles" )
113 main.cleanup()
114 main.exit()
cameron@onlab.usc5bf8192015-07-13 13:36:05 -0700115
YPZhangcbc2a062016-07-11 10:55:44 -0700116 main.commit = main.ONOSbench.getVersion( report=True )
117 main.commit = main.commit.split(" ")[1]
118 main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls )
119 main.log.info("Safety check, killing all ONOS processes" +
120 " before initiating environment setup")
cameron@onlab.us059c2562015-04-02 14:12:51 -0700121
YPZhangcbc2a062016-07-11 10:55:44 -0700122 for i in range( main.numCtrls ):
You Wangb98a9fa2017-02-15 17:27:42 -0800123 main.ONOSbench.onosStop( main.ONOSip[i] )
124 main.ONOSbench.onosKill( main.ONOSip[i] )
jenkins15b2b132015-06-23 14:04:09 -0700125
YPZhangcbc2a062016-07-11 10:55:44 -0700126 main.log.info( "NODE COUNT = %s" % main.numCtrls )
127 main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
128 main.cellName,
129 main.MN1Ip,
130 main.Apps,
131 main.ONOSip)
132 main.step( "Apply cell to environment" )
133 cellResult = main.ONOSbench.setCell( main.cellName )
134 verifyResult = main.ONOSbench.verifyCell()
135 stepResult = cellResult and verifyResult
136 utilities.assert_equals(expect=main.TRUE,
137 actual=stepResult,
138 onpass="Successfully applied cell to " + \
139 "environment",
140 onfail="Failed to apply cell to environment ")
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800141
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800142 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700143 packageResult = main.ONOSbench.buckBuild()
YPZhangcbc2a062016-07-11 10:55:44 -0700144 stepResult = packageResult
145 utilities.assert_equals(expect=main.TRUE,
146 actual=stepResult,
147 onpass="Successfully created ONOS package",
148 onfail="Failed to create ONOS package")
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800149
YPZhangcbc2a062016-07-11 10:55:44 -0700150 main.step( "Uninstall ONOS package on all Nodes" )
151 uninstallResult = main.TRUE
152 for i in range( int( main.numCtrls ) ):
153 main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] )
154 u_result = main.ONOSbench.onosUninstall( main.ONOSip[i] )
155 utilities.assert_equals(expect=main.TRUE, actual=u_result,
156 onpass="Test step PASS",
157 onfail="Test step FAIL")
158 uninstallResult = ( uninstallResult and u_result )
Jon Hall4ba53f02015-07-29 13:07:41 -0700159
YPZhangcbc2a062016-07-11 10:55:44 -0700160 main.step( "Install ONOS package on all Nodes" )
161 installResult = main.TRUE
162 for i in range( int( main.numCtrls ) ):
163 main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] )
164 i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
165 utilities.assert_equals(expect=main.TRUE, actual=i_result,
166 onpass="Test step PASS",
167 onfail="Test step FAIL")
168 installResult = installResult and i_result
cameron@onlab.us059c2562015-04-02 14:12:51 -0700169
Chiyu Chengef109502016-11-21 15:51:38 -0800170 main.step( "Set up ONOS secure SSH" )
171 secureSshResult = main.TRUE
172 for i in range( int( main.numCtrls ) ):
173 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
174 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
175 onpass="Test step PASS",
176 onfail="Test step FAIL" )
177
You Wang0357c432017-01-09 16:13:33 -0800178 time.sleep( main.startUpSleep )
179 main.step( "Starting ONOS service" )
180 stopResult = main.TRUE
181 startResult = main.TRUE
182 onosIsUp = main.TRUE
183 for i in range( main.numCtrls ):
184 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
185 if onosIsUp == main.TRUE:
186 main.log.report( "ONOS instance is up and ready" )
187 else:
188 main.log.report( "ONOS instance may not be up, stop and " +
189 "start ONOS again " )
190 for i in range( main.numCtrls ):
191 stopResult = stopResult and \
192 main.ONOSbench.onosStop( main.ONOSip[ i ] )
193 for i in range( main.numCtrls ):
194 startResult = startResult and \
195 main.ONOSbench.onosStart( main.ONOSip[ i ] )
196 stepResult = onosIsUp and stopResult and startResult
197 utilities.assert_equals( expect=main.TRUE,
198 actual=stepResult,
199 onpass="ONOS service is ready",
200 onfail="ONOS service did not start properly" )
201
YPZhangcbc2a062016-07-11 10:55:44 -0700202 main.step( "Start ONOS cli using thread" )
203 startCliResult = main.TRUE
204 pool = []
205 main.threadID = 0
206 for i in range(int(main.numCtrls)):
207 t = main.Thread(target=main.CLIs[i].startOnosCli,
208 threadID=main.threadID,
209 name="startOnosCli",
210 args=[main.ONOSip[i]],
211 kwargs={"onosStartTimeout": main.timeout})
212 pool.append(t)
213 t.start()
214 main.threadID = main.threadID + 1
215 for t in pool:
216 t.join()
217 startCliResult = startCliResult and t.result
218 time.sleep( main.startUpSleep )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700219
YPZhangcbc2a062016-07-11 10:55:44 -0700220 # config apps
YPZhangcbc2a062016-07-11 10:55:44 -0700221 main.CLIs[0].setCfg( "org.onosproject.net.intent.impl.IntentManager",
222 "skipReleaseResourcesOnWithdrawal " + main.skipRelRsrc )
223 main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(int(main.numCtrls*10)) )
224 main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "topoShape linear" )
225 main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled true" )
YPZhange6ef82a2016-07-05 16:48:15 -0700226 if main.flowObj:
YPZhangcbc2a062016-07-11 10:55:44 -0700227 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
228 "useFlowObjectives", value="true")
You Wang106d0fa2017-05-15 17:22:15 -0700229 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
230 "defaultFlowObjectiveCompiler",
231 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler')
YPZhangcbc2a062016-07-11 10:55:44 -0700232 time.sleep( main.startUpSleep )
cameron@onlab.useae03dc2015-07-29 11:51:28 -0700233
YPZhangcbc2a062016-07-11 10:55:44 -0700234 # balanceMasters
235 main.CLIs[0].balanceMasters()
236 time.sleep( main.startUpSleep )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700237
YPZhangcbc2a062016-07-11 10:55:44 -0700238 def CASE2(self, main):
jenkins3af0cd82015-03-24 10:27:16 -0700239 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700240
YPZhangcbc2a062016-07-11 10:55:44 -0700241 main.log.info( "Cluster Count = " + str( main.numCtrls ) )
242 # adjust neighbors
243 if main.numCtrls == 1:
244 main.neighbors = "0"
245 main.log.info( "Neighbors: 0" )
246 elif main.neighbors != "0":
247 main.neighbors = "0"
248 main.log.info( "Neighbors: 0" )
249 elif main.neighbors == "0":
250 main.neighbors = str( main.numCtrls - 1 )
251 main.log.info( "Neighbors: " + main.neighbors )
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700252
YPZhangcbc2a062016-07-11 10:55:44 -0700253 main.log.info( "Config intent-perf app" )
254 main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numKeys " + main.numKeys )
255 main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numNeighbors " + str( main.neighbors ) )
256 main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "cyclePeriod " + main.cyclePeriod )
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700257
YPZhangcbc2a062016-07-11 10:55:44 -0700258 main.log.info( "Starting intent-perf test for " + str(main.testDuration) + " seconds..." )
259 main.CLIs[0].sendline( "intent-perf-start" )
260 stop = time.time() + float( main.testDuration )
andrew@onlab.us10332202015-03-11 15:04:43 -0700261
YPZhangcbc2a062016-07-11 10:55:44 -0700262 while time.time() < stop:
263 time.sleep(15)
264 result = main.CLIs[0].getIntentPerfSummary()
265 if result:
266 for ip in main.ONOSip:
267 main.log.info( "Node {} Overall Rate: {}".format( ip, result[ip] ) )
268 main.log.info( "Stop intent-perf" )
269 for node in main.CLIs:
270 node.sendline( "intent-perf-stop" )
271 if result:
272 for ip in main.ONOSip:
273 main.log.info( "Node {} final Overall Rate: {}".format( ip, result[ip] ) )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800274
YPZhangcbc2a062016-07-11 10:55:44 -0700275 with open( main.dbFileName, "a" ) as resultDB:
276 for nodes in range( 0, len( main.ONOSip ) ):
277 resultString = "'" + main.commit + "',"
278 resultString += "'1gig',"
279 resultString += str(main.numCtrls) + ","
280 resultString += "'baremetal" + str( nodes+1 ) + "',"
281 resultString += main.neighbors + ","
282 resultString += result[ main.ONOSip[ nodes ] ]+","
283 resultString += str(0) + "\n" # no stddev
284 resultDB.write( resultString )
285 resultDB.close()