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 | else: |
Devin Lim | 8d7c778 | 2017-06-07 16:21:20 -0700 | [diff] [blame] | 50 | main.log.warn( "Skipped pulling onos" ) |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 51 | |
| 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(",") |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 59 | main.skipRelRsrc = main.params['TEST']['skipReleaseResourcesOnWithdrawal'] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 60 | main.flowObj = main.params['TEST']['flowObj'] |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 61 | 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' ] |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 68 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 69 | main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 70 | if main.flowObj == "True": |
| 71 | main.flowObj = True |
| 72 | main.dbFileName = main.params['DATABASE']['dbFlowObj'] |
You Wang | e142733 | 2017-02-06 17:16:20 -0800 | [diff] [blame] | 73 | main.numKeys = main.params[ 'TEST' ][ 'numKeysFlowObj' ] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 74 | else: |
| 75 | main.flowObj = False |
| 76 | main.dbFileName = main.params['DATABASE']['dbName'] |
You Wang | e142733 | 2017-02-06 17:16:20 -0800 | [diff] [blame] | 77 | main.numKeys = main.params[ 'TEST' ][ 'numKeys' ] |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 78 | # Create DataBase file |
| 79 | main.log.info( "Create Database file " + main.dbFileName ) |
| 80 | resultsDB = open( main.dbFileName, "w+" ) |
| 81 | resultsDB.close() |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 82 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 83 | # set neighbors |
| 84 | main.neighbors = "1" |
cameron@onlab.us | 412e956 | 2015-05-13 16:04:34 -0700 | [diff] [blame] | 85 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 86 | 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 Lim | 2870684 | 2017-06-08 10:23:48 -0700 | [diff] [blame] | 101 | main.CLIs.append( getattr( main, 'ONOScli%s' % (i + 1) ) ) |
cameron@onlab.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 102 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 103 | 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.us | c5bf819 | 2015-07-13 13:36:05 -0700 | [diff] [blame] | 107 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 108 | 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.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 113 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 114 | for i in range( main.numCtrls ): |
You Wang | b98a9fa | 2017-02-15 17:27:42 -0800 | [diff] [blame] | 115 | main.ONOSbench.onosStop( main.ONOSip[i] ) |
| 116 | main.ONOSbench.onosKill( main.ONOSip[i] ) |
jenkins | 15b2b13 | 2015-06-23 14:04:09 -0700 | [diff] [blame] | 117 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 118 | 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 Lim | 461f087 | 2017-06-05 16:49:33 -0700 | [diff] [blame] | 123 | main.ONOSip, |
Devin Lim | dc78e20 | 2017-06-09 18:30:07 -0700 | [diff] [blame^] | 124 | main.ONOScli1.karafUser ) |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 125 | 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.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 134 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 135 | main.step( "Creating ONOS package" ) |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 136 | packageResult = main.ONOSbench.buckBuild() |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 137 | 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.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 142 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 143 | 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 Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 152 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 153 | 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.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 162 | |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 163 | 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 Wang | 0357c43 | 2017-01-09 16:13:33 -0800 | [diff] [blame] | 171 | 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 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 195 | 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.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 212 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 213 | # config apps |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 214 | 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" ) |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 219 | if main.flowObj: |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 220 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 221 | "useFlowObjectives", value="true") |
You Wang | 106d0fa | 2017-05-15 17:22:15 -0700 | [diff] [blame] | 222 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 223 | "defaultFlowObjectiveCompiler", |
| 224 | value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler') |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 225 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | eae03dc | 2015-07-29 11:51:28 -0700 | [diff] [blame] | 226 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 227 | # balanceMasters |
| 228 | main.CLIs[0].balanceMasters() |
| 229 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | aaecfd7 | 2015-07-08 12:27:26 -0700 | [diff] [blame] | 230 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 231 | def CASE2(self, main): |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 232 | import numpy |
cameron@onlab.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 233 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 234 | 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.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 245 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 246 | 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.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 250 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 251 | 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.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 254 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 255 | 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.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 267 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 268 | 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() |