GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 1 | |
| 2 | # This is a performance scale intent that test onos to see how many intents can |
| 3 | # be installed and rerouted using the null provider and mininet. |
| 4 | |
| 5 | class SCPFmaxIntents: |
| 6 | |
| 7 | def __init__( self ): |
| 8 | self.default = '' |
| 9 | |
| 10 | def CASE0( self, main ): |
| 11 | import time |
| 12 | import os |
| 13 | import imp |
| 14 | |
| 15 | """ |
| 16 | - Construct tests variables |
| 17 | - GIT ( optional ) |
| 18 | - Checkout ONOS master branch |
| 19 | - Pull latest ONOS code |
| 20 | - Building ONOS ( optional ) |
| 21 | - Install ONOS package |
| 22 | - Build ONOS package |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 23 | - Set up cell |
| 24 | - Create cell file |
| 25 | - Set cell file |
| 26 | - Verify cell file |
| 27 | - Kill ONOS process |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 28 | """ |
| 29 | |
| 30 | main.case( "Constructing test variables and building ONOS package" ) |
| 31 | main.step( "Constructing test variables" ) |
| 32 | stepResult = main.FALSE |
| 33 | |
| 34 | # Test variables |
| 35 | main.testOnDirectory = os.path.dirname( os.getcwd ( ) ) |
| 36 | main.dependencyPath = main.testOnDirectory + \ |
| 37 | main.params['DEPENDENCY']['path'] |
| 38 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 39 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 40 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 41 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
| 42 | main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] ) |
| 43 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 44 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 45 | main.minIntents = int(main.params['TEST']['min_intents']) |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 46 | main.maxIntents = int(main.params['TEST']['max_intents']) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 47 | main.checkInterval = int(main.params['TEST']['check_interval']) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 48 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 49 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 50 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
| 51 | main.rerouteSleep = int ( main.params['SLEEP']['reroute'] ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 52 | main.batchSize = int(main.params['TEST']['batch_size']) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 53 | main.dbFileName = main.params['DATABASE']['file'] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 54 | main.cellData = {} # for creating cell file |
| 55 | main.CLIs = [] |
| 56 | main.ONOSip = [] |
| 57 | main.maxNumBatch = 0 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 58 | main.ONOSip = main.ONOSbench.getOnosIps() |
| 59 | main.log.info(main.ONOSip) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 60 | main.setupSkipped = False |
| 61 | |
| 62 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 63 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 64 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 65 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 66 | nic = main.params['DATABASE']['nic'] |
| 67 | node = main.params['DATABASE']['node'] |
| 68 | nic = main.params['DATABASE']['nic'] |
| 69 | node = main.params['DATABASE']['node'] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 70 | |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 71 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 72 | main.numCtrls = int( main.scale[ 0 ] ) |
| 73 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 74 | main.log.info("Creating list of ONOS cli handles") |
| 75 | for i in range(main.maxNodes): |
| 76 | main.CLIs.append( getattr( main, 'ONOScli' + str( i+1 ))) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 77 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 78 | if not main.CLIs: |
| 79 | main.log.error("Failed to create the list of ONOS cli handles") |
| 80 | main.cleanup() |
| 81 | main.exit() |
| 82 | |
| 83 | main.log.info("Loading wrapper files") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 84 | main.startUp = imp.load_source( wrapperFile1, |
| 85 | main.dependencyPath + |
| 86 | wrapperFile1 + |
| 87 | ".py" ) |
| 88 | |
| 89 | main.intentFunctions = imp.load_source( wrapperFile2, |
| 90 | main.dependencyPath + |
| 91 | wrapperFile2 + |
| 92 | ".py" ) |
| 93 | |
| 94 | copyResult = main.ONOSbench.copyMininetFile( main.topology, |
| 95 | main.dependencyPath, |
| 96 | main.Mininet1.user_name, |
| 97 | main.Mininet1.ip_address ) |
| 98 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 99 | commit = main.ONOSbench.getVersion(report=True) |
| 100 | commit = commit.split(" ")[1] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 101 | |
| 102 | if gitPull == 'True': |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 103 | if not main.startUp.onosBuild( main, gitBranch ): |
| 104 | main.log.error("Failed to build ONOS") |
| 105 | main.cleanup() |
| 106 | main.exit() |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 107 | else: |
| 108 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 109 | "clean install" ) |
| 110 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 111 | main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 112 | main.log.info( "Safety check, killing all ONOS processes" + |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame^] | 113 | " before initiating environment setup" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 114 | |
| 115 | for i in range( main.maxNodes ): |
| 116 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 117 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 118 | main.log.info( "NODE COUNT = %s" % main.numCtrls) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 119 | |
| 120 | tempOnosIp = [] |
| 121 | for i in range( main.numCtrls ): |
| 122 | tempOnosIp.append( main.ONOSip[i] ) |
| 123 | |
| 124 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 125 | "temp", |
| 126 | main.Mininet1.ip_address, |
| 127 | main.apps, |
| 128 | tempOnosIp ) |
| 129 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 130 | main.log.info( "Applying cell to environment" ) |
| 131 | cell = main.ONOSbench.setCell( "temp" ) |
| 132 | verify = main.ONOSbench.verifyCell() |
| 133 | if not cell or not verify: |
| 134 | main.log.error("Failed to apply cell to environment") |
| 135 | main.cleanup() |
| 136 | main.exit() |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 137 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 138 | main.log.info( "Creating ONOS package" ) |
| 139 | if not main.ONOSbench.onosPackage(): |
| 140 | main.log.error("Failed to create ONOS package") |
| 141 | main.cleanup() |
| 142 | main.exit() |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 143 | |
GlennRC | 58ea254 | 2015-09-02 14:23:34 -0700 | [diff] [blame] | 144 | main.log.info("Creating DB file") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 145 | with open(main.dbFileName, "w+") as dbFile: |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 146 | temp = "'" + commit + "'," |
GlennRC | 58ea254 | 2015-09-02 14:23:34 -0700 | [diff] [blame] | 147 | temp += "'" + nic + "'," |
| 148 | temp += str(main.numCtrls) + "," |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 149 | temp += "'" + node + "1" + "'" |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 150 | dbFile.write(temp) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 151 | |
| 152 | def CASE1( self, main ): |
| 153 | """ |
| 154 | - Uninstall ONOS cluster |
| 155 | - Verify ONOS start up |
| 156 | - Install ONOS cluster |
| 157 | - Connect to cli |
| 158 | """ |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 159 | |
| 160 | main.log.info( "Uninstalling ONOS package" ) |
| 161 | main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[i] ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 162 | for i in range( main.maxNodes ): |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 163 | if not main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[i] ): |
| 164 | main.log.error("Failed to uninstall onos on node %s" % (i+1)) |
| 165 | main.cleanup() |
| 166 | main.exit() |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 167 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 168 | main.log.info( "Installing ONOS package" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 169 | for i in range( main.numCtrls ): |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 170 | if not main.ONOSbench.onosInstall( node=main.ONOSip[i] ): |
| 171 | main.log.error("Failed to install onos on node %s" % (i+1)) |
| 172 | main.cleanup() |
| 173 | main.exit() |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 174 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 175 | main.log.info( "Starting ONOS service" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 176 | for i in range( main.numCtrls ): |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 177 | start = main.ONOSbench.onosStart( main.ONOSip[i] ) |
| 178 | isup = main.ONOSbench.isup( main.ONOSip[i] ) |
| 179 | if not start or not isup: |
| 180 | main.log.error("Failed to start onos service on node %s" % (i+1)) |
| 181 | main.cleanup() |
| 182 | main.exit() |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 183 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 184 | main.log.info( "Starting ONOS cli" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 185 | for i in range( main.numCtrls ): |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 186 | if not main.CLIs[i].startOnosCli( main.ONOSip[i] ): |
| 187 | main.log.error("Failed to start onos cli on node %s" % (i+1)) |
| 188 | main.cleanup() |
| 189 | main.exit() |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 190 | |
| 191 | def CASE10( self, main ): |
| 192 | """ |
| 193 | Setting up null-provider |
| 194 | """ |
| 195 | import json |
| 196 | import pexpect |
| 197 | |
| 198 | # Activate apps |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 199 | main.log.info("Activating null-provider") |
| 200 | appStatus = main.CLIs[0].activateApp('org.onosproject.null') |
| 201 | if not appStatus: |
| 202 | main.log.error("Failed to activate null-provider") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 203 | |
| 204 | # Setup the null-provider |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 205 | main.log.info("Configuring null-provider") |
| 206 | cfgStatus = main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 207 | 'org.onosproject.provider.nil.NullProviders', 'deviceCount 3' ) |
| 208 | cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 209 | 'org.onosproject.provider.nil.NullProviders', 'topoShape reroute' ) |
| 210 | cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 211 | 'org.onosproject.provider.nil.NullProviders', 'enabled true' ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 212 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 213 | if not cfgStatus: |
| 214 | main.log.error("Failed to configure null-provider") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 215 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 216 | # give onos some time to settle |
| 217 | time.sleep(main.startUpSleep) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 218 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 219 | main.defaultFlows = 0 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 220 | main.ingress = ":0000000000000001/3" |
| 221 | main.egress = ":0000000000000003/2" |
| 222 | main.switch = "null" |
| 223 | main.linkUpCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 up" |
| 224 | main.linkDownCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 down" |
| 225 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 226 | if not appStatus or not cfgStatus: |
| 227 | main.setupSkipped = True |
| 228 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 229 | def CASE11( self, main ): |
| 230 | ''' |
| 231 | Setting up mininet |
| 232 | ''' |
| 233 | import json |
| 234 | import time |
| 235 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 236 | main.log.step("Activating openflow") |
| 237 | appStatus = main.CLIs[0].activateApp('org.onosproject.openflow') |
| 238 | if appStatus: |
| 239 | main.log.error("Failed to activate openflow") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 240 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 241 | time.sleep(main.startUpSleep) |
| 242 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 243 | main.log.info('Starting mininet topology') |
| 244 | mnStatus = main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py') |
| 245 | if mnStatus: |
| 246 | main.log.error("Failed to start mininet") |
| 247 | |
| 248 | main.log.info("Assinging masters to switches") |
| 249 | swStatus = main.Mininet1.assignSwController(sw='s1', ip=main.ONOSip[0]) |
| 250 | swStatus = swStatus and main.Mininet1.assignSwController(sw='s2', ip=main.ONOSip[0]) |
| 251 | swStatus = swStatus and main.Mininet1.assignSwController(sw='s3', ip=main.ONOSip[0]) |
| 252 | if not swStatus: |
| 253 | main.log.info("Failed to assign masters to switches") |
| 254 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 255 | time.sleep(main.startUpSleep) |
| 256 | |
| 257 | jsonSum = json.loads(main.CLIs[0].summary()) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 258 | sumStatus = (jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 259 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 260 | main.log.step("Getting default flows") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 261 | jsonSum = json.loads(main.CLIs[0].summary()) |
| 262 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 263 | main.defaultFlows = jsonSum["flows"] |
| 264 | main.ingress = ":0000000000000001/3" |
| 265 | main.egress = ":0000000000000003/2" |
| 266 | main.switch = "of" |
| 267 | main.linkDownCmd = 'link s1 s3 down' |
| 268 | main.linkUpCmd = 'link s1 s3 up' |
| 269 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 270 | if not appStatus or not mnStatus or not swStatus or not sumStatus: |
| 271 | main.setupSkipped = True |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 272 | |
| 273 | def CASE20( self, main ): |
| 274 | import pexpect |
| 275 | ''' |
| 276 | Pushing intents |
| 277 | ''' |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 278 | |
| 279 | # check if the setup case has been skipped |
| 280 | if main.setupSkipped: |
| 281 | main.setupSkipped = False |
| 282 | main.skipCase() |
| 283 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 284 | # the index where the next intents will be installed |
| 285 | offset = 0 |
| 286 | # the number of intents we expect to be in the installed state |
| 287 | expectedIntents = 0 |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 288 | # keeps track of how many intents have been installed |
| 289 | maxIntents = 0 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 290 | # the number of flows we expect to be in the added state |
| 291 | expectedFlows = main.defaultFlows |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 292 | # keeps track of how many flows have been installed |
| 293 | maxFlows = main.defaultFlows |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 294 | # limit for the number of intents that can be installed |
| 295 | limit = main.maxIntents / main.batchSize |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 296 | |
| 297 | for i in range(limit): |
| 298 | # Push intents |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 299 | main.log.info("Pushing intents") |
| 300 | main.intentFunctions.pushIntents( main, |
| 301 | main.switch, |
| 302 | main.ingress, |
| 303 | main.egress, |
| 304 | main.batchSize, |
| 305 | offset, |
| 306 | sleep=main.installSleep, |
| 307 | timeout=main.timeout, |
| 308 | options="-i" ) |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 309 | |
| 310 | offset += main.batchSize |
| 311 | expectedIntents = offset |
| 312 | expectedFlows += main.batchSize*2 |
| 313 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 314 | main.log.info("Grabbing number of installed intents and flows") |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 315 | maxIntents = main.intentFunctions.getIntents( main ) |
| 316 | maxFlows = main.intentFunctions.getFlows( main ) |
| 317 | |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 318 | if offset >= main.minIntents and offset % main.checkInterval == 0 or expectedIntents == main.maxIntents: |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 319 | # Verifying intents |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 320 | main.log.info("Verifying intents\nExpected intents: " + str(expectedIntents)) |
| 321 | intentStatus = main.intentFunctions.verifyIntents( main, |
| 322 | expectedIntents, |
| 323 | sleep=main.verifySleep, |
| 324 | timeout=main.timeout) |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 325 | # Verfying flows |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 326 | main.log.info("Verifying flows\nExpected Flows: " + str(expectedFlows)) |
| 327 | flowStatus = main.intentFunctions.verifyFlows( main, |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 328 | expectedFlows, |
| 329 | sleep=main.verifySleep, |
| 330 | timeout=main.timeout) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 331 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 332 | if not flowStatus or not intentsStataus: |
| 333 | main.log.error("Failed to verify") |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 334 | break |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 335 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 336 | main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 337 | main.log.info("Installed intents: " + str(maxIntents) + |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 338 | " Added flows: " + str(maxFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 339 | |
GlennRC | 58ea254 | 2015-09-02 14:23:34 -0700 | [diff] [blame] | 340 | main.log.info("Writing results to DB file") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 341 | with open(dbFileName, "a") as dbFile: |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 342 | temp = "," + str(maxIntents) |
| 343 | temp += "," + str(maxFlows) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 344 | dbFile.write(temp) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 345 | |
| 346 | # Stopping mininet |
| 347 | if main.switch == "of": |
| 348 | main.log.info("Stopping mininet") |
| 349 | main.Mininet1.stopNet() |
| 350 | |
| 351 | def CASE21( self, main ): |
| 352 | import pexpect |
| 353 | import time |
| 354 | ''' |
| 355 | Reroute |
| 356 | ''' |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 357 | |
| 358 | # check if the setup case has been skipped |
| 359 | if main.setupSkipped: |
| 360 | main.setupSkipped = False |
| 361 | main.skipCase() |
| 362 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 363 | # the index where the next intents will be installed |
| 364 | offset = 0 |
| 365 | # the number of intents we expect to be in the installed state |
| 366 | expectedIntents = 0 |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 367 | # keeps track of how many intents have been installed |
| 368 | maxIntents = 0 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 369 | # the number of flows we expect to be in the added state |
| 370 | expectedFlows = main.defaultFlows |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 371 | # keeps track of how many flows have been installed |
| 372 | maxFlows = main.defaultFlows |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 373 | # limit for the number of intents that can be installed |
| 374 | limit = main.maxIntents / main.batchSize |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 375 | |
| 376 | for i in range(limit): |
| 377 | # Push intents |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 378 | main.log.info("Pushing intents") |
| 379 | main.intentFunctions.pushIntents( main, |
| 380 | main.switch, |
| 381 | main.ingress, |
| 382 | main.egress, |
| 383 | main.batchSize, |
| 384 | offset, |
| 385 | sleep=main.installSleep, |
| 386 | timeout=main.timeout, |
| 387 | options="-i" ) |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 388 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 389 | offset += main.batchSize |
| 390 | expectedIntents = offset |
| 391 | expectedFlows += main.batchSize*2 |
| 392 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 393 | main.log.info("Grabbing number of installed intents and flows") |
| 394 | maxIntents = main.intentFunctions.getIntents( main ) |
| 395 | maxFlows = main.intentFunctions.getFlows( main ) |
| 396 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 397 | # Verifying intents |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 398 | main.log.info("Verifying intents\n\tExpected intents: " + str(expectedIntents)) |
| 399 | intentStatus = main.intentFunctions.verifyIntents( main, |
| 400 | expectedIntents, |
| 401 | sleep=main.verifySleep, |
| 402 | timeout=main.timeout) |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 403 | # Verfying flows |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 404 | main.log.info("Verifying flows\n\tExpected Flows: " + str(expectedFlows)) |
| 405 | flowStatus = main.intentFunctions.verifyFlows( main, |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 406 | expectedFlows, |
| 407 | sleep=main.verifySleep, |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 408 | timeout=main.timeout) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 409 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 410 | if not flowStatus or not intentsStataus: |
| 411 | main.log.error("Failed to verify\n\tSkipping case") |
| 412 | main.log.skipCase() |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 413 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 414 | # tear down a link |
| 415 | main.log.step("Tearing down link") |
| 416 | if main.switch == "of": |
| 417 | main.log.info("Sending: " + main.linkDownCmd) |
| 418 | main.Mininet1.handle.sendline(main.linkDownCmd) |
| 419 | main.Mininet1.handle.expect('mininet>') |
| 420 | else: |
| 421 | main.log.info("Sending: " + main.linkDownCmd) |
| 422 | main.CLIs[0].handle.sendline(main.linkDownCmd) |
| 423 | main.CLIs[0].handle.expect('onos>') |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 424 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 425 | time.sleep(main.rerouteSleep) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 426 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 427 | # rerouting adds a 1000 flows |
| 428 | expectedFlows += 1000 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 429 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 430 | main.log.info("Grabbing number of added flows") |
| 431 | maxFlows = main.intentFunctions.getFlows( main ) |
| 432 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 433 | # Verfying flows |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 434 | main.log.info("Verifying flows\n\tExpected Flows: " + str(expectedFlows)) |
| 435 | flowStatus = main.intentFunctions.verifyFlows( main, |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 436 | expectedFlows, |
| 437 | sleep=main.verifySleep, |
| 438 | timeout=main.timeout) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 439 | if not flowStatus: |
| 440 | main.log.error("Failed to verify flows\n\tSkipping case") |
| 441 | main.skipCase() |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 442 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 443 | # Bring link back up |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 444 | main.log.step("Bringing link back up") |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 445 | if main.switch == "of": |
| 446 | main.log.info("Sending: " + main.linkUpCmd) |
| 447 | main.Mininet1.handle.sendline(main.linkUpCmd) |
| 448 | main.Mininet1.handle.expect('mininet>') |
| 449 | else: |
| 450 | main.log.info("Sending: " + main.linkUpCmd) |
| 451 | main.CLIs[0].handle.sendline(main.linkUpCmd) |
| 452 | main.CLIs[0].handle.expect('onos>') |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 453 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 454 | time.sleep(main.rerouteSleep) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 455 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 456 | main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 457 | main.log.info("Installed intents: " + str(maxIntents) + |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 458 | " Added flows: " + str(maxFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 459 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 460 | with open(main.dbFileName, "a") as dbFile: |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 461 | temp = "," + str(maxIntents) |
| 462 | temp += "," + str(maxFlows) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 463 | dbFile.write(temp) |
GlennRC | 14d54f7 | 2015-09-03 10:51:37 -0700 | [diff] [blame] | 464 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 465 | # Stopping mininet |
| 466 | if main.switch == "of": |
| 467 | main.log.info("Stopping mininet") |
| 468 | main.Mininet1.stopNet() |
| 469 | |
| 470 | def CASE100( self, main ): |
| 471 | ''' |
| 472 | Report errors/warnings/exceptions |
| 473 | ''' |
| 474 | main.log.info("Error report: \n") |
| 475 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 476 | [ "INFO", |
| 477 | "FOLLOWER", |
| 478 | "WARN", |
| 479 | "flow", |
| 480 | "ERROR", |
| 481 | "Except" ], |
| 482 | "s" ) |