suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 1 | class COMPflow: |
| 2 | |
| 3 | def __init__( self ): |
| 4 | self.default = '' |
| 5 | |
| 6 | def CASE1( self, main ): |
| 7 | import time |
| 8 | import os |
| 9 | import imp |
| 10 | |
| 11 | """ |
| 12 | - Construct tests variables |
| 13 | - GIT ( optional ) |
| 14 | - Checkout ONOS master branch |
| 15 | - Pull latest ONOS code |
| 16 | - Building ONOS ( optional ) |
| 17 | - Install ONOS package |
| 18 | - Build ONOS package |
| 19 | """ |
| 20 | |
| 21 | main.case( "Constructing test variables and building ONOS package" ) |
| 22 | main.step( "Constructing test variables" ) |
| 23 | stepResult = main.FALSE |
| 24 | |
| 25 | # Test variables |
| 26 | main.testOnDirectory = os.path.dirname( os.getcwd ( ) ) |
| 27 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 28 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 29 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 30 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 31 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 32 | main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] ) |
| 33 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 34 | main.startMNSleep = int( main.params[ 'SLEEP' ][ 'startMN' ] ) |
| 35 | main.addFlowSleep = int( main.params[ 'SLEEP' ][ 'addFlow' ] ) |
| 36 | main.delFlowSleep = int( main.params[ 'SLEEP' ][ 'delFlow' ] ) |
| 37 | main.debug = main.params['DEBUG'] |
| 38 | #main.swDPID = main.params[ 'TEST' ][ 'swDPID' ] |
| 39 | main.cellData = {} # for creating cell file |
| 40 | main.CLIs = [] |
| 41 | main.ONOSip = [] |
| 42 | |
| 43 | main.debug = True if "on" in main.debug else False |
| 44 | |
| 45 | main.ONOSip = main.ONOSbench.getOnosIps() |
| 46 | |
| 47 | # Assigning ONOS cli handles to a list |
| 48 | for i in range( 1, main.maxNodes + 1 ): |
| 49 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 50 | |
| 51 | |
| 52 | if main.CLIs: |
| 53 | stepResult = main.TRUE |
| 54 | else: |
| 55 | main.log.error( "Did not properly created list of ONOS CLI handle" ) |
| 56 | stepResult = main.FALSE |
| 57 | |
| 58 | utilities.assert_equals( expect=main.TRUE, |
| 59 | actual=stepResult, |
| 60 | onpass="Successfully construct " + |
| 61 | "test variables ", |
| 62 | onfail="Failed to construct test variables" ) |
| 63 | |
| 64 | if gitPull == 'True': |
| 65 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 66 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 67 | stepResult = onosBuildResult |
| 68 | utilities.assert_equals( expect=main.TRUE, |
| 69 | actual=stepResult, |
| 70 | onpass="Successfully compiled " + |
| 71 | "latest ONOS", |
| 72 | onfail="Failed to compile " + |
| 73 | "latest ONOS" ) |
| 74 | else: |
| 75 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 76 | "clean install" ) |
| 77 | |
| 78 | def CASE2( self, main ): |
| 79 | """ |
| 80 | - Set up cell |
| 81 | - Create cell file |
| 82 | - Set cell file |
| 83 | - Verify cell file |
| 84 | - Kill ONOS process |
| 85 | - Uninstall ONOS cluster |
| 86 | - Verify ONOS start up |
| 87 | - Install ONOS cluster |
| 88 | - Connect to cli |
| 89 | """ |
| 90 | |
| 91 | main.numCtrls = int( main.maxNodes ) |
| 92 | |
| 93 | main.case( "Starting up " + str( main.numCtrls ) + |
| 94 | " node(s) ONOS cluster" ) |
| 95 | |
| 96 | #kill off all onos processes |
| 97 | main.log.info( "Safety check, killing all ONOS processes" + |
| 98 | " before initiating environment setup" ) |
| 99 | |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 100 | |
| 101 | print "NODE COUNT = ", main.numCtrls |
| 102 | |
| 103 | tempOnosIp = [] |
| 104 | for i in range( main.numCtrls ): |
| 105 | tempOnosIp.append( main.ONOSip[i] ) |
| 106 | |
suibin zhang | 9a8264f | 2016-04-03 21:18:59 -0700 | [diff] [blame] | 107 | |
suibin zhang | 5c735ca | 2016-03-30 16:01:06 -0700 | [diff] [blame] | 108 | main.log.info("Apps in cell file: " + main.apps) |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 109 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, "temp", main.Mininet1.ip_address, main.apps, tempOnosIp ) |
| 110 | |
| 111 | main.step( "Apply cell to environment" ) |
| 112 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 113 | verifyResult = main.ONOSbench.verifyCell() |
| 114 | stepResult = cellResult and verifyResult |
| 115 | utilities.assert_equals( expect=main.TRUE, |
| 116 | actual=stepResult, |
| 117 | onpass="Successfully applied cell to " + \ |
| 118 | "environment", |
| 119 | onfail="Failed to apply cell to environment " ) |
| 120 | |
suibin zhang | 9a8264f | 2016-04-03 21:18:59 -0700 | [diff] [blame] | 121 | if main.params['CASE2']['incPackaging'] == main.TRUE: |
| 122 | main.step( "Creating ONOS package" ) |
| 123 | packageResult = main.ONOSbench.onosPackage(opTimeout=240) |
| 124 | stepResult = packageResult |
| 125 | utilities.assert_equals( expect=main.TRUE, |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 126 | actual=stepResult, |
| 127 | onpass="Successfully created ONOS package", |
| 128 | onfail="Failed to create ONOS package" ) |
| 129 | |
| 130 | time.sleep( main.startUpSleep ) |
| 131 | main.step( "Uninstalling ONOS package" ) |
| 132 | onosUninstallResult = main.TRUE |
| 133 | for i in range( main.numCtrls ): |
| 134 | onosUninstallResult = onosUninstallResult and \ |
| 135 | main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] ) |
| 136 | stepResult = onosUninstallResult |
| 137 | utilities.assert_equals( expect=main.TRUE, |
| 138 | actual=stepResult, |
| 139 | onpass="Successfully uninstalled ONOS package", |
| 140 | onfail="Failed to uninstall ONOS package" ) |
| 141 | |
| 142 | time.sleep( main.startUpSleep ) |
| 143 | main.step( "Installing ONOS package" ) |
| 144 | onosInstallResult = main.TRUE |
| 145 | for i in range( main.numCtrls ): |
| 146 | onosInstallResult = onosInstallResult and \ |
| 147 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 148 | stepResult = onosInstallResult |
| 149 | utilities.assert_equals( expect=main.TRUE, |
| 150 | actual=stepResult, |
| 151 | onpass="Successfully installed ONOS package", |
| 152 | onfail="Failed to install ONOS package" ) |
| 153 | |
| 154 | time.sleep( main.startUpSleep ) |
| 155 | main.step( "Starting ONOS service" ) |
| 156 | stopResult = main.TRUE |
| 157 | startResult = main.TRUE |
| 158 | onosIsUp = main.TRUE |
| 159 | |
| 160 | for i in range( main.numCtrls ): |
| 161 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 162 | if onosIsUp == main.TRUE: |
| 163 | main.log.report( "ONOS instance is up and ready" ) |
| 164 | else: |
| 165 | main.log.report( "ONOS instance may not be up, stop and " + |
| 166 | "start ONOS again " ) |
| 167 | for i in range( main.numCtrls ): |
| 168 | stopResult = stopResult and \ |
| 169 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 170 | for i in range( main.numCtrls ): |
| 171 | startResult = startResult and \ |
| 172 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 173 | stepResult = onosIsUp and stopResult and startResult |
| 174 | utilities.assert_equals( expect=main.TRUE, |
| 175 | actual=stepResult, |
| 176 | onpass="ONOS service is ready", |
| 177 | onfail="ONOS service did not start properly" ) |
| 178 | |
suibin zhang | 9a8264f | 2016-04-03 21:18:59 -0700 | [diff] [blame] | 179 | main.step( "Start ONOS cli" ) |
| 180 | cliResult = main.TRUE |
| 181 | for i in range( i, main.numCtrls ): |
| 182 | cliResult = cliResult and \ |
| 183 | main.CLIs[ i ].startOnosCli( ONOSIp=main.ONOSip[ i ] ) |
| 184 | main.log.info("ONOSip is: " + main.ONOSip[i]) |
| 185 | stepResult = cliResult |
| 186 | utilities.assert_equals( expect=main.TRUE, |
| 187 | actual=stepResult, |
| 188 | onpass="Successfully start ONOS cli", |
| 189 | onfail="Failed to start ONOS cli" ) |
| 190 | |
| 191 | |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 192 | |
| 193 | def CASE10( self, main ): |
| 194 | ''' |
| 195 | Start Mininet |
| 196 | ''' |
suibin zhang | 5c735ca | 2016-03-30 16:01:06 -0700 | [diff] [blame] | 197 | import time |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 198 | |
| 199 | main.numSw = int(main.params['CASE10']['numSw']) |
suibin zhang | 5c735ca | 2016-03-30 16:01:06 -0700 | [diff] [blame] | 200 | main.case( "Enable openflow-base on onos and start Mininet." ) |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 201 | main.caseExplanation = "Start mininet with custom topology and compare topology " +\ |
| 202 | "elements between Mininet and ONOS" |
| 203 | |
suibin zhang | 5c735ca | 2016-03-30 16:01:06 -0700 | [diff] [blame] | 204 | main.step("Activate openflow-base App") |
| 205 | stepResult = main.ONOSbench.onosCli( ONOSIp = main.ONOSip[0], cmdstr = "app activate org.onosproject.openflow-base" ) |
| 206 | time.sleep(10) |
| 207 | print stepResult |
suibin zhang | 34f0137 | 2016-04-07 15:40:15 -0700 | [diff] [blame^] | 208 | time.sleep(5 |
suibin zhang | 5c735ca | 2016-03-30 16:01:06 -0700 | [diff] [blame] | 209 | |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 210 | main.step( "Setup Mininet Linear Topology with " + str(main.numSw) + " switches" ) |
| 211 | stepResult = main.Mininet1.startNet( args = main.params['CASE10']['mnArgs'] ) |
| 212 | |
| 213 | utilities.assert_equals( expect=main.TRUE, |
| 214 | actual=stepResult, |
| 215 | onpass="Successfully loaded topology", |
| 216 | onfail="Failed to load topology" ) |
| 217 | |
suibin zhang | 5c735ca | 2016-03-30 16:01:06 -0700 | [diff] [blame] | 218 | time.sleep(int(main.params['SLEEP']['startMN'])) |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 219 | main.step( "Assign switches to controller" ) |
| 220 | for i in range(1, main.numSw + 1): |
| 221 | main.Mininet1.assignSwController( "s" + str(i), main.ONOSip[0] ) |
| 222 | |
| 223 | utilities.assert_equals( expect=main.TRUE, |
| 224 | actual=stepResult, |
| 225 | onpass="Successfully assigned switch to controller", |
| 226 | onfail="Failed to assign switch to controller" ) |
| 227 | |
suibin zhang | 5c735ca | 2016-03-30 16:01:06 -0700 | [diff] [blame] | 228 | main.deviceIdPrefix = "of:" |
| 229 | |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 230 | time.sleep( main.startMNSleep ) |
| 231 | |
suibin zhang | 5c735ca | 2016-03-30 16:01:06 -0700 | [diff] [blame] | 232 | def CASE11( self, main ): |
| 233 | ''' |
| 234 | Start Null Provider |
| 235 | ''' |
| 236 | import time |
| 237 | |
| 238 | main.numSw = int(main.params['CASE11']['numSw']) |
| 239 | |
| 240 | main.case("Activate Null Provider App") |
| 241 | stepResult = main.ONOSbench.onosCli( ONOSIp = main.ONOSip[0], cmdstr = "app activate org.onosproject.null" ) |
| 242 | time.sleep(10) |
| 243 | print stepResult |
| 244 | time.sleep(5) |
| 245 | |
| 246 | main.case( "Setup Null Provider for linear Topology" ) |
| 247 | main.step( "Setup Null Provider Linear Topology with " + str(main.numSw) + " devices." ) |
| 248 | main.ONOSbench.onosCfgSet( main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(main.numSw)) |
| 249 | main.ONOSbench.onosCfgSet( main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "topoShape " + main.params['CASE11']['nullTopo'] ) |
| 250 | main.ONOSbench.onosCfgSet( main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "enabled " + main.params['CASE11']['nullStart']) |
| 251 | time.sleep(5) |
| 252 | |
| 253 | main.log.info("Check to make sure null providers are configured correctly.") |
| 254 | main.ONOSbench.handle.sendline("onos $OC1 summary") |
| 255 | stepResult = main.ONOSbench.handle.expect(":~") |
| 256 | main.log.info("ONOS Summary: " + main.ONOSbench.handle.before) |
| 257 | |
| 258 | main.deviceIdPrefix = "null:" |
| 259 | |
| 260 | time.sleep( main.startMNSleep ) |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 261 | |
| 262 | |
| 263 | |
| 264 | def CASE1000( self, main ): |
| 265 | ''' |
| 266 | create JSON object with batched flows |
| 267 | ''' |
| 268 | import numpy |
| 269 | import time |
suibin zhang | 570cb45 | 2016-03-29 19:03:15 -0700 | [diff] [blame] | 270 | from pprint import pprint |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 271 | |
| 272 | main.case( "Create a json object for the batched flows" ) |
| 273 | |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 274 | main.step( "Parse batch creation information" ) |
suibin zhang | a82fe3f | 2016-03-29 11:26:21 -0700 | [diff] [blame] | 275 | main.batchSize = int(main.params['CASE1000']['batchSize']) |
| 276 | main.log.info("Number of flows in a batch is:" + str(main.batchSize)) |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 277 | |
| 278 | main.flowJsonBatchList = [] |
| 279 | postTimes = [] |
suibin zhang | a82fe3f | 2016-03-29 11:26:21 -0700 | [diff] [blame] | 280 | startSw = 1 |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 281 | |
| 282 | main.step("Creating a full list of batches") |
| 283 | for index in range(1, int(main.params['CASE1000']['batches']) + 1): |
suibin zhang | a82fe3f | 2016-03-29 11:26:21 -0700 | [diff] [blame] | 284 | if startSw <= main.numSw: |
suibin zhang | ff4abfe | 2016-03-29 11:52:08 -0700 | [diff] [blame] | 285 | ind = startSw |
| 286 | else: |
| 287 | startSw = 1 |
| 288 | ind = startSw |
| 289 | |
| 290 | main.log.info("Creating batch: " + str(index)) |
| 291 | flowJsonBatch = main.ONOSrest.createFlowBatch( numSw = main.numSw, |
| 292 | swIndex = ind, |
suibin zhang | a82fe3f | 2016-03-29 11:26:21 -0700 | [diff] [blame] | 293 | batchSize = main.batchSize, |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 294 | batchIndex = index, |
suibin zhang | 5c735ca | 2016-03-30 16:01:06 -0700 | [diff] [blame] | 295 | deviceIdpreFix=main.deviceIdPrefix, |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 296 | ingressPort = 2, |
| 297 | egressPort = 3) |
suibin zhang | ff4abfe | 2016-03-29 11:52:08 -0700 | [diff] [blame] | 298 | main.flowJsonBatchList.append(flowJsonBatch) |
suibin zhang | a82fe3f | 2016-03-29 11:26:21 -0700 | [diff] [blame] | 299 | |
suibin zhang | ff4abfe | 2016-03-29 11:52:08 -0700 | [diff] [blame] | 300 | startSw += 1 |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 301 | main.log.info( "Number of items created in the batch list is: " + str(len(main.flowJsonBatchList))) |
suibin zhang | ff4abfe | 2016-03-29 11:52:08 -0700 | [diff] [blame] | 302 | |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 303 | def CASE2100(self, main): |
| 304 | ''' |
| 305 | Posting flow batches using threads |
| 306 | ''' |
| 307 | main.case("Using REST API /flows/{} to post flow batch - multi-threads") |
| 308 | main.step("Using REST API /flows/{} to post flow batch - multi-threads") |
| 309 | |
| 310 | from Queue import Queue |
| 311 | from threading import Thread |
| 312 | import time |
| 313 | |
| 314 | main.threadID = 0 |
| 315 | main.addedBatchList = [] |
| 316 | q = Queue() |
| 317 | tAllAdded = 0 |
| 318 | |
suibin zhang | 34f0137 | 2016-04-07 15:40:15 -0700 | [diff] [blame^] | 319 | |
| 320 | main.step( "Disable AdaptiveFlowSampling ") |
| 321 | main.ONOSbench.onosCfgSet( main.ONOSip[0], "org.onosproject.provider.of.flow.impl.OpenFlowRuleProvider", |
| 322 | "adaptiveFlowSampling " + main.params['CASE2100']['adaptiveFlowenabled']) |
| 323 | |
| 324 | |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 325 | def postWorker(id): |
| 326 | while True: |
| 327 | item = q.get() |
| 328 | status,response = main.ONOSrest.sendFlowBatch(batch = item) |
| 329 | main.log.info("Thread {} is working on posting. ".format(id)) |
| 330 | main.addedBatchList.append(response[1]) |
| 331 | q.task_done() |
| 332 | |
| 333 | for i in range( int( main.params['CASE2100']['numThreads'])): |
| 334 | threadID = "ThreadID-" + str(i) |
| 335 | t = Thread(target = postWorker, name = threadID, args=(threadID,) ) |
| 336 | t.daemon = True |
| 337 | t.start() |
| 338 | |
| 339 | tStartPost = time.time() |
| 340 | for item in main.flowJsonBatchList: |
| 341 | q.put(item) |
| 342 | |
| 343 | q.join() |
| 344 | tLastPostEnd = time.time() |
| 345 | |
| 346 | main.step("Check to ensure all flows are in added state.") |
| 347 | #pprint(main.addedBatchList) |
| 348 | resp = main.FALSE |
| 349 | while resp != main.TRUE and ( tAllAdded - tLastPostEnd < int (main.params['CASE2100']['chkFlowTO']) ): |
suibin zhang | 9a8264f | 2016-04-03 21:18:59 -0700 | [diff] [blame] | 350 | if main.params['CASE2100']['RESTchkFlow'] == main.TRUE: |
| 351 | resp = main.ONOSrest.checkFlowsState() |
| 352 | else: |
| 353 | handle = main.CLIs[0].flows(state = " |grep PEND|wc -l", jsonFormat=False) |
| 354 | main.log.info("handle returns PENDING flows: " + handle) |
| 355 | if handle == "0": |
| 356 | resp = main.TRUE |
| 357 | |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 358 | time.sleep( float(main.params['SLEEP']['chkFlow']) ) |
| 359 | tAllAdded = time.time() |
| 360 | |
| 361 | if tAllAdded - tLastPostEnd >= int (main.params['CASE2100']['chkFlowTO']): |
| 362 | main.log.warn("ONOS Flows still in pending state after: {} seconds.".format(tAllAdded - tLastPostEnd)) |
| 363 | |
| 364 | main.numFlows = int(main.params['CASE1000']['batches']) *\ |
| 365 | int(main.params['CASE1000']['batchSize']) |
| 366 | main.log.info("Total number of flows: " + str (main.numFlows) ) |
suibin zhang | 9a8264f | 2016-04-03 21:18:59 -0700 | [diff] [blame] | 367 | #main.log.info("Sum of each POST elapse time: " + str(numpy.sum(postTimes)) ) |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 368 | main.log.info("Total POST elapse time: " + str(tLastPostEnd-tStartPost)) |
| 369 | main.log.info("Rate of ADD Controller response: " + str(main.numFlows / (tLastPostEnd - tStartPost))) |
| 370 | |
| 371 | duration = tAllAdded - tLastPostEnd |
| 372 | main.log.info("Elapse time from end of last REST POST to Flows in ADDED state: " +\ |
| 373 | str(duration)) |
| 374 | main.log.info("Rate of Confirmed Batch Flow ADD is (flows/sec): " + str( main.numFlows / duration)) |
| 375 | main.log.info("Number of flow Batches in the addedBatchList is: " + str( len(main.addedBatchList))) |
| 376 | |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 377 | def CASE3100(self, main): |
| 378 | ''' |
| 379 | DELETE flow batches using threads |
| 380 | ''' |
| 381 | main.case("Using REST API /flows/{} to delete flow batch - multi-threads") |
| 382 | main.step("Using REST API /flows/{} to delete flow batch - multi-threads") |
| 383 | |
| 384 | from Queue import Queue |
| 385 | from threading import Thread |
| 386 | import time |
| 387 | import json |
| 388 | |
| 389 | main.threadID = 0 |
| 390 | q = Queue() |
| 391 | tAllRemoved = 0 |
| 392 | |
| 393 | main.log.info("Number of flow batches at start of remove: " + str( len( main.addedBatchList))) |
| 394 | def removeWorker(id): |
| 395 | while True: |
| 396 | item = q.get() |
| 397 | response = main.ONOSrest.removeFlowBatch(batch = json.loads(item) ) |
| 398 | main.log.info("Thread {} is working on deleting. ".format(id)) |
| 399 | q.task_done() |
| 400 | |
| 401 | for i in range( int( main.params['CASE2100']['numThreads'])): |
| 402 | threadID = "ThreadID-" + str(i) |
| 403 | t = Thread(target = removeWorker, name = threadID, args=(threadID,) ) |
| 404 | t.daemon = True |
| 405 | t.start() |
| 406 | |
| 407 | tStartDelete = time.time() |
| 408 | for item in main.addedBatchList: |
| 409 | q.put(item) |
| 410 | |
| 411 | q.join() |
| 412 | tLastDeleteEnd = time.time() |
| 413 | main.log.info("Number of flow batches at end of remove: " + str( len( main.addedBatchList))) |
| 414 | |
| 415 | main.step("Check to ensure all flows are in added state.") |
| 416 | #pprint(main.addedBatchList) |
| 417 | resp = main.FALSE |
| 418 | while resp != main.TRUE and ( tAllRemoved - tLastDeleteEnd < int (main.params['CASE3100']['chkFlowTO']) ): |
suibin zhang | 9a8264f | 2016-04-03 21:18:59 -0700 | [diff] [blame] | 419 | if main.params['CASE3100']['RESTchkFlow'] == main.TRUE: |
| 420 | resp = main.ONOSrest.checkFlowsState() |
| 421 | else: |
| 422 | handle = main.CLIs[0].flows(state = " |grep PEND|wc -l", jsonFormat=False) |
| 423 | main.log.info("handle returns PENDING flows: " + handle) |
| 424 | if handle == "0": |
| 425 | resp = main.TRUE |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 426 | time.sleep( float(main.params['SLEEP']['chkFlow']) ) |
| 427 | tAllRemoved = time.time() |
| 428 | |
| 429 | if tLastDeleteEnd - tLastDeleteEnd >= int (main.params['CASE2100']['chkFlowTO']): |
suibin zhang | 9a8264f | 2016-04-03 21:18:59 -0700 | [diff] [blame] | 430 | main.log.warn("ONOS Flows still in pending state after: {} seconds.".format(tAllRemoved - tLastDeleteEnd)) |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 431 | |
| 432 | main.numFlows = int(main.params['CASE1000']['batches']) *\ |
| 433 | int(main.params['CASE1000']['batchSize']) |
| 434 | main.log.info("Total number of flows: " + str (main.numFlows) ) |
suibin zhang | 9a8264f | 2016-04-03 21:18:59 -0700 | [diff] [blame] | 435 | #main.log.info("Sum of each DELETE elapse time: " + str(numpy.sum(postTimes)) ) |
suibin zhang | a5875da | 2016-04-02 20:54:50 -0700 | [diff] [blame] | 436 | main.log.info("Total DELETE elapse time: " + str(tLastDeleteEnd-tStartDelete)) |
| 437 | main.log.info("Rate of DELETE Controller response: " + str(main.numFlows / (tLastDeleteEnd-tStartDelete))) |
| 438 | |
| 439 | duration = tAllRemoved - tLastDeleteEnd |
| 440 | main.log.info("Elapse time from end of last REST DELETE to Flows in REMOVED state: " +\ |
| 441 | str(duration)) |
| 442 | main.log.info("Rate of Confirmed Batch Flow REMOVED is (flows/sec): " + str( main.numFlows / duration)) |
| 443 | |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 444 | def CASE100(self,main): |
| 445 | from pprint import pprint |
| 446 | |
| 447 | main.case( "Check to ensure onos flows." ) |
| 448 | |
| 449 | resp = main.ONOSrest.checkFlowsState() |
suibin zhang | dec01c5 | 2016-03-29 19:23:33 -0700 | [diff] [blame] | 450 | #pprint(resp) |
suibin zhang | d0f09b3 | 2016-03-29 00:57:57 -0700 | [diff] [blame] | 451 | |
| 452 | |
| 453 | def CASE110( self, main ): |
| 454 | ''' |
| 455 | Report errors/warnings/exceptions |
| 456 | ''' |
| 457 | main.log.info("Error report: \n" ) |
| 458 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 459 | [ "INFO", |
| 460 | "FOLLOWER", |
| 461 | "WARN", |
| 462 | "flow", |
| 463 | "ERROR", |
| 464 | "Except" ], |
| 465 | "s" ) |
| 466 | main.stop() |
| 467 | |