YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 1 | ''' |
| 2 | SCPFintentEventTp |
| 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.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 6 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 7 | yunpeng@onlab.us |
| 8 | ''' |
| 9 | |
cameron@onlab.us | aaecfd7 | 2015-07-08 12:27:26 -0700 | [diff] [blame] | 10 | import time |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 11 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 12 | |
suibin | 7f2c9cd | 2015-07-08 17:34:59 -0700 | [diff] [blame] | 13 | class SCPFintentEventTp: |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 14 | def __init__( self ): |
| 15 | self.default = '' |
| 16 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 17 | 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.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 29 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 30 | main.case( "Pull onos branch and build onos on Teststation." ) |
cameron@onlab.us | aaecfd7 | 2015-07-08 12:27:26 -0700 | [diff] [blame] | 31 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 32 | 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() |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 40 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 41 | 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.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 48 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 49 | 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(",") |
| 67 | main.flowRuleBU = main.params['TEST']['flowRuleBUEnabled'] |
| 68 | main.skipRelRsrc = main.params['TEST']['skipReleaseResourcesOnWithdrawal'] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 69 | main.flowObj = main.params['TEST']['flowObj'] |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 70 | main.startUpSleep = int(main.params['SLEEP']['startup']) |
| 71 | main.installSleep = int(main.params['SLEEP']['install']) |
| 72 | main.verifySleep = int(main.params['SLEEP']['verify']) |
| 73 | main.scale = (main.params['SCALE']).split(",") |
| 74 | main.testDuration = main.params[ 'TEST' ][ 'duration' ] |
| 75 | main.logInterval = main.params[ 'TEST' ][ 'log_interval' ] |
| 76 | main.debug = main.params[ 'debugMode' ] |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 77 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 78 | main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 79 | if main.flowObj == "True": |
| 80 | main.flowObj = True |
| 81 | main.dbFileName = main.params['DATABASE']['dbFlowObj'] |
You Wang | e142733 | 2017-02-06 17:16:20 -0800 | [diff] [blame] | 82 | main.numKeys = main.params[ 'TEST' ][ 'numKeysFlowObj' ] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 83 | else: |
| 84 | main.flowObj = False |
| 85 | main.dbFileName = main.params['DATABASE']['dbName'] |
You Wang | e142733 | 2017-02-06 17:16:20 -0800 | [diff] [blame] | 86 | main.numKeys = main.params[ 'TEST' ][ 'numKeys' ] |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 87 | # Create DataBase file |
| 88 | main.log.info( "Create Database file " + main.dbFileName ) |
| 89 | resultsDB = open( main.dbFileName, "w+" ) |
| 90 | resultsDB.close() |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 91 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 92 | # set neighbors |
| 93 | main.neighbors = "1" |
cameron@onlab.us | 412e956 | 2015-05-13 16:04:34 -0700 | [diff] [blame] | 94 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 95 | def CASE1( self, main ): |
| 96 | # Clean up test environment and set up |
| 97 | import time |
| 98 | main.log.info( "Get ONOS cluster IP" ) |
| 99 | print( main.scale ) |
| 100 | main.numCtrls = int( main.scale.pop(0) ) |
| 101 | main.ONOSip = [] |
| 102 | main.maxNumBatch = 0 |
| 103 | main.AllONOSip = main.ONOSbench.getOnosIps() |
| 104 | for i in range( main.numCtrls ): |
| 105 | main.ONOSip.append( main.AllONOSip[i] ) |
| 106 | main.log.info( main.ONOSip ) |
| 107 | main.CLIs = [] |
| 108 | main.log.info( "Creating list of ONOS cli handles" ) |
| 109 | for i in range( main.numCtrls ): |
| 110 | main.CLIs.append( getattr( main, 'ONOS%scli' % (i + 1) ) ) |
cameron@onlab.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 111 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 112 | if not main.CLIs: |
| 113 | main.log.error( "Failed to create the list of ONOS cli handles" ) |
| 114 | main.cleanup() |
| 115 | main.exit() |
cameron@onlab.us | c5bf819 | 2015-07-13 13:36:05 -0700 | [diff] [blame] | 116 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 117 | main.commit = main.ONOSbench.getVersion( report=True ) |
| 118 | main.commit = main.commit.split(" ")[1] |
| 119 | main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls ) |
| 120 | main.log.info("Safety check, killing all ONOS processes" + |
| 121 | " before initiating environment setup") |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 122 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 123 | for i in range( main.numCtrls ): |
You Wang | b98a9fa | 2017-02-15 17:27:42 -0800 | [diff] [blame] | 124 | main.ONOSbench.onosStop( main.ONOSip[i] ) |
| 125 | main.ONOSbench.onosKill( main.ONOSip[i] ) |
jenkins | 15b2b13 | 2015-06-23 14:04:09 -0700 | [diff] [blame] | 126 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 127 | main.log.info( "NODE COUNT = %s" % main.numCtrls ) |
| 128 | main.ONOSbench.createCellFile(main.ONOSbench.ip_address, |
| 129 | main.cellName, |
| 130 | main.MN1Ip, |
| 131 | main.Apps, |
| 132 | main.ONOSip) |
| 133 | main.step( "Apply cell to environment" ) |
| 134 | cellResult = main.ONOSbench.setCell( main.cellName ) |
| 135 | verifyResult = main.ONOSbench.verifyCell() |
| 136 | stepResult = cellResult and verifyResult |
| 137 | utilities.assert_equals(expect=main.TRUE, |
| 138 | actual=stepResult, |
| 139 | onpass="Successfully applied cell to " + \ |
| 140 | "environment", |
| 141 | onfail="Failed to apply cell to environment ") |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 142 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 143 | main.step( "Creating ONOS package" ) |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 144 | packageResult = main.ONOSbench.buckBuild() |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 145 | stepResult = packageResult |
| 146 | utilities.assert_equals(expect=main.TRUE, |
| 147 | actual=stepResult, |
| 148 | onpass="Successfully created ONOS package", |
| 149 | onfail="Failed to create ONOS package") |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 150 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 151 | main.step( "Uninstall ONOS package on all Nodes" ) |
| 152 | uninstallResult = main.TRUE |
| 153 | for i in range( int( main.numCtrls ) ): |
| 154 | main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] ) |
| 155 | u_result = main.ONOSbench.onosUninstall( main.ONOSip[i] ) |
| 156 | utilities.assert_equals(expect=main.TRUE, actual=u_result, |
| 157 | onpass="Test step PASS", |
| 158 | onfail="Test step FAIL") |
| 159 | uninstallResult = ( uninstallResult and u_result ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 160 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 161 | main.step( "Install ONOS package on all Nodes" ) |
| 162 | installResult = main.TRUE |
| 163 | for i in range( int( main.numCtrls ) ): |
| 164 | main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] ) |
| 165 | i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i]) |
| 166 | utilities.assert_equals(expect=main.TRUE, actual=i_result, |
| 167 | onpass="Test step PASS", |
| 168 | onfail="Test step FAIL") |
| 169 | installResult = installResult and i_result |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 170 | |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 171 | main.step( "Set up ONOS secure SSH" ) |
| 172 | secureSshResult = main.TRUE |
| 173 | for i in range( int( main.numCtrls ) ): |
| 174 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] ) |
| 175 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 176 | onpass="Test step PASS", |
| 177 | onfail="Test step FAIL" ) |
| 178 | |
You Wang | 0357c43 | 2017-01-09 16:13:33 -0800 | [diff] [blame] | 179 | time.sleep( main.startUpSleep ) |
| 180 | main.step( "Starting ONOS service" ) |
| 181 | stopResult = main.TRUE |
| 182 | startResult = main.TRUE |
| 183 | onosIsUp = main.TRUE |
| 184 | for i in range( main.numCtrls ): |
| 185 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 186 | if onosIsUp == main.TRUE: |
| 187 | main.log.report( "ONOS instance is up and ready" ) |
| 188 | else: |
| 189 | main.log.report( "ONOS instance may not be up, stop and " + |
| 190 | "start ONOS again " ) |
| 191 | for i in range( main.numCtrls ): |
| 192 | stopResult = stopResult and \ |
| 193 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 194 | for i in range( main.numCtrls ): |
| 195 | startResult = startResult and \ |
| 196 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 197 | stepResult = onosIsUp and stopResult and startResult |
| 198 | utilities.assert_equals( expect=main.TRUE, |
| 199 | actual=stepResult, |
| 200 | onpass="ONOS service is ready", |
| 201 | onfail="ONOS service did not start properly" ) |
| 202 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 203 | main.step( "Start ONOS cli using thread" ) |
| 204 | startCliResult = main.TRUE |
| 205 | pool = [] |
| 206 | main.threadID = 0 |
| 207 | for i in range(int(main.numCtrls)): |
| 208 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 209 | threadID=main.threadID, |
| 210 | name="startOnosCli", |
| 211 | args=[main.ONOSip[i]], |
| 212 | kwargs={"onosStartTimeout": main.timeout}) |
| 213 | pool.append(t) |
| 214 | t.start() |
| 215 | main.threadID = main.threadID + 1 |
| 216 | for t in pool: |
| 217 | t.join() |
| 218 | startCliResult = startCliResult and t.result |
| 219 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 220 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 221 | # config apps |
| 222 | main.CLIs[0].setCfg( "org.onosproject.store.flow.impl.DistributedFlowRuleStore", |
| 223 | "backupEnabled " + main.flowRuleBU ) |
| 224 | main.CLIs[0].setCfg( "org.onosproject.net.intent.impl.IntentManager", |
| 225 | "skipReleaseResourcesOnWithdrawal " + main.skipRelRsrc ) |
| 226 | main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(int(main.numCtrls*10)) ) |
| 227 | main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "topoShape linear" ) |
| 228 | main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled true" ) |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 229 | if main.flowObj: |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 230 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 231 | "useFlowObjectives", value="true") |
| 232 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | eae03dc | 2015-07-29 11:51:28 -0700 | [diff] [blame] | 233 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 234 | # balanceMasters |
| 235 | main.CLIs[0].balanceMasters() |
| 236 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | aaecfd7 | 2015-07-08 12:27:26 -0700 | [diff] [blame] | 237 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 238 | def CASE2(self, main): |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 239 | import numpy |
cameron@onlab.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 240 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 241 | 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.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 252 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 253 | 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.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 257 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 258 | 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.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 261 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 262 | 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.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 274 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 275 | 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() |