kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 1 | |
| 2 | # Testing network scalability, this test suite scales up a network topology |
| 3 | # using mininet and verifies ONOS stability |
| 4 | |
GlennRC | 1c5df3c | 2015-08-27 16:12:09 -0700 | [diff] [blame] | 5 | class SCPFscaleTopo: |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 6 | |
| 7 | def __init__( self ): |
| 8 | self.default = '' |
| 9 | |
| 10 | def CASE1( self, main ): |
| 11 | import time |
| 12 | import os |
| 13 | import imp |
Jon Hall | f632d20 | 2015-07-30 15:45:11 -0700 | [diff] [blame] | 14 | import re |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 15 | |
| 16 | """ |
| 17 | - Construct tests variables |
| 18 | - GIT ( optional ) |
| 19 | - Checkout ONOS master branch |
| 20 | - Pull latest ONOS code |
| 21 | - Building ONOS ( optional ) |
| 22 | - Install ONOS package |
| 23 | - Build ONOS package |
| 24 | """ |
| 25 | |
| 26 | main.case( "Constructing test variables and building ONOS package" ) |
| 27 | main.step( "Constructing test variables" ) |
| 28 | stepResult = main.FALSE |
| 29 | |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 30 | try: |
| 31 | main.testOnDirectory = os.path.dirname( os.getcwd ( ) ) |
| 32 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 33 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 34 | main.dependencyPath = main.testOnDirectory + \ |
| 35 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 36 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 37 | main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ] |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 38 | main.torus = main.params[ 'DEPENDENCY' ][ 'torus' ] |
| 39 | main.spine = main.params[ 'DEPENDENCY' ][ 'spine' ] |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 40 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
| 41 | if main.ONOSbench.maxNodes: |
| 42 | main.maxNodes = int( main.ONOSbench.maxNodes ) |
| 43 | else: |
| 44 | main.maxNodes = 0 |
| 45 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 46 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 47 | wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ] |
| 48 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 49 | main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] ) |
| 50 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 51 | main.cellData = {} # for creating cell file |
| 52 | main.hostsData = {} |
| 53 | main.CLIs = [] |
| 54 | main.ONOSip = [] |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 55 | |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 56 | main.ONOSip = main.ONOSbench.getOnosIps() |
| 57 | print main.ONOSip |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 58 | |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 59 | # Assigning ONOS cli handles to a list |
| 60 | for i in range( 1, main.maxNodes + 1 ): |
| 61 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 62 | |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 63 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 64 | main.startUp = imp.load_source( wrapperFile1, |
| 65 | main.dependencyPath + |
| 66 | wrapperFile1 + |
| 67 | ".py" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 68 | |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 69 | main.scaleTopoFunction = imp.load_source( wrapperFile2, |
| 70 | main.dependencyPath + |
| 71 | wrapperFile2 + |
| 72 | ".py" ) |
| 73 | |
| 74 | main.topo = imp.load_source( wrapperFile3, |
| 75 | main.dependencyPath + |
| 76 | wrapperFile3 + |
| 77 | ".py" ) |
| 78 | |
| 79 | copyResult1 = main.ONOSbench.scp( main.Mininet1, |
| 80 | main.dependencyPath + |
| 81 | main.topology, |
| 82 | main.Mininet1.home, |
| 83 | direction="to" ) |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 84 | time.sleep(3) |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 85 | copyResult2 = main.ONOSbench.scp( main.Mininet1, |
| 86 | main.dependencyPath + |
| 87 | main.multiovs, |
| 88 | main.Mininet1.home, |
| 89 | direction="to" ) |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 90 | time.sleep(3) |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 91 | if main.CLIs: |
| 92 | stepResult = main.TRUE |
| 93 | else: |
| 94 | main.log.error( "Did not properly created list of " + |
| 95 | "ONOS CLI handle" ) |
| 96 | stepResult = main.FALSE |
| 97 | |
| 98 | except Exception as e: |
| 99 | main.log.exception(e) |
| 100 | main.cleanup() |
| 101 | main.exit() |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 102 | |
| 103 | utilities.assert_equals( expect=main.TRUE, |
| 104 | actual=stepResult, |
| 105 | onpass="Successfully construct " + |
| 106 | "test variables ", |
| 107 | onfail="Failed to construct test variables" ) |
| 108 | |
| 109 | if gitPull == 'True': |
| 110 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 111 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 112 | stepResult = onosBuildResult |
| 113 | utilities.assert_equals( expect=main.TRUE, |
| 114 | actual=stepResult, |
| 115 | onpass="Successfully compiled " + |
| 116 | "latest ONOS", |
| 117 | onfail="Failed to compile " + |
| 118 | "latest ONOS" ) |
| 119 | else: |
| 120 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 121 | "clean install" ) |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 122 | main.ONOSbench.getVersion( report=True ) |
| 123 | if gitPull == 'True': |
| 124 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 125 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 126 | stepResult = onosBuildResult |
| 127 | utilities.assert_equals( expect=main.TRUE, |
| 128 | actual=stepResult, |
| 129 | onpass="Successfully compiled " + |
| 130 | "latest ONOS", |
| 131 | onfail="Failed to compile " + |
| 132 | "latest ONOS" ) |
| 133 | else: |
| 134 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 135 | "clean install" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 136 | |
| 137 | def CASE2( self, main ): |
| 138 | """ |
| 139 | - Set up cell |
| 140 | - Create cell file |
| 141 | - Set cell file |
| 142 | - Verify cell file |
| 143 | - Kill ONOS process |
| 144 | - Uninstall ONOS cluster |
| 145 | - Verify ONOS start up |
| 146 | - Install ONOS cluster |
| 147 | - Connect to cli |
| 148 | """ |
| 149 | |
| 150 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 151 | main.numCtrls = int( main.scale[ 0 ] ) |
| 152 | |
| 153 | main.case( "Starting up " + str( main.numCtrls ) + |
| 154 | " node(s) ONOS cluster" ) |
| 155 | |
| 156 | #kill off all onos processes |
| 157 | main.log.info( "Safety check, killing all ONOS processes" + |
| 158 | " before initiating enviornment setup" ) |
| 159 | |
| 160 | for i in range( main.maxNodes ): |
| 161 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 162 | |
| 163 | print "NODE COUNT = ", main.numCtrls |
| 164 | |
| 165 | tempOnosIp = [] |
| 166 | for i in range( main.numCtrls ): |
| 167 | tempOnosIp.append( main.ONOSip[i] ) |
| 168 | |
| 169 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 170 | "temp", main.Mininet1.ip_address, |
| 171 | main.apps, |
| 172 | tempOnosIp ) |
| 173 | |
| 174 | main.step( "Apply cell to environment" ) |
| 175 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 176 | verifyResult = main.ONOSbench.verifyCell() |
| 177 | stepResult = cellResult and verifyResult |
| 178 | utilities.assert_equals( expect=main.TRUE, |
| 179 | actual=stepResult, |
| 180 | onpass="Successfully applied cell to " + \ |
| 181 | "environment", |
| 182 | onfail="Failed to apply cell to environment " ) |
| 183 | |
| 184 | main.step( "Creating ONOS package" ) |
| 185 | packageResult = main.ONOSbench.onosPackage() |
| 186 | stepResult = packageResult |
| 187 | utilities.assert_equals( expect=main.TRUE, |
| 188 | actual=stepResult, |
| 189 | onpass="Successfully created ONOS package", |
| 190 | onfail="Failed to create ONOS package" ) |
| 191 | |
| 192 | |
| 193 | # Remove the first element in main.scale list |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 194 | #main.scale.remove( main.scale[ 0 ] ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 195 | |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 196 | def CASE8( self, main ): |
| 197 | """ |
| 198 | Compare Topo |
| 199 | """ |
| 200 | import json |
| 201 | |
| 202 | main.case( "Compare ONOS Topology view to Mininet topology" ) |
| 203 | main.caseExplanation = "Compare topology elements between Mininet" +\ |
| 204 | " and ONOS" |
| 205 | |
| 206 | main.step( "Gathering topology information" ) |
| 207 | # TODO: add a paramaterized sleep here |
| 208 | devicesResults = main.TRUE |
| 209 | linksResults = main.TRUE |
| 210 | hostsResults = main.TRUE |
| 211 | devices = main.topo.getAllDevices( main ) |
| 212 | hosts = main.topo.getAllHosts( main ) |
| 213 | ports = main.topo.getAllPorts( main ) |
| 214 | links = main.topo.getAllLinks( main ) |
| 215 | clusters = main.topo.getAllClusters( main ) |
| 216 | |
| 217 | mnSwitches = main.Mininet1.getSwitches() |
| 218 | mnLinks = main.Mininet1.getLinks() |
| 219 | mnHosts = main.Mininet1.getHosts() |
| 220 | |
| 221 | main.step( "Conmparing MN topology to ONOS topology" ) |
| 222 | for controller in range( main.numCtrls ): |
| 223 | controllerStr = str( controller + 1 ) |
| 224 | if devices[ controller ] and ports[ controller ] and\ |
| 225 | "Error" not in devices[ controller ] and\ |
| 226 | "Error" not in ports[ controller ]: |
| 227 | |
| 228 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 229 | mnSwitches, |
| 230 | json.loads( devices[ controller ] ), |
| 231 | json.loads( ports[ controller ] ) ) |
| 232 | else: |
| 233 | currentDevicesResult = main.FALSE |
| 234 | utilities.assert_equals( expect=main.TRUE, |
| 235 | actual=currentDevicesResult, |
| 236 | onpass="ONOS" + controllerStr + |
| 237 | " Switches view is correct", |
| 238 | onfail="ONOS" + controllerStr + |
| 239 | " Switches view is incorrect" ) |
| 240 | |
| 241 | if links[ controller ] and "Error" not in links[ controller ]: |
| 242 | currentLinksResult = main.Mininet1.compareLinks( |
| 243 | mnSwitches, mnLinks, |
| 244 | json.loads( links[ controller ] ) ) |
| 245 | else: |
| 246 | currentLinksResult = main.FALSE |
| 247 | utilities.assert_equals( expect=main.TRUE, |
| 248 | actual=currentLinksResult, |
| 249 | onpass="ONOS" + controllerStr + |
| 250 | " links view is correct", |
| 251 | onfail="ONOS" + controllerStr + |
| 252 | " links view is incorrect" ) |
| 253 | |
| 254 | if hosts[ controller ] or "Error" not in hosts[ controller ]: |
| 255 | currentHostsResult = main.Mininet1.compareHosts( |
| 256 | mnHosts, |
| 257 | json.loads( hosts[ controller ] ) ) |
| 258 | else: |
| 259 | currentHostsResult = main.FALSE |
| 260 | utilities.assert_equals( expect=main.TRUE, |
| 261 | actual=currentHostsResult, |
| 262 | onpass="ONOS" + controllerStr + |
| 263 | " hosts exist in Mininet", |
| 264 | onfail="ONOS" + controllerStr + |
| 265 | " hosts don't match Mininet" ) |
| 266 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 267 | def CASE9( self, main ): |
| 268 | ''' |
| 269 | Report errors/warnings/exceptions |
| 270 | ''' |
| 271 | main.log.info("Error report: \n" ) |
| 272 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 273 | [ "INFO", |
| 274 | "FOLLOWER", |
| 275 | "WARN", |
| 276 | "flow", |
| 277 | "ERROR", |
| 278 | "Except" ], |
| 279 | "s" ) |
| 280 | |
| 281 | def CASE11( self, main ): |
| 282 | """ |
| 283 | Start mininet |
| 284 | """ |
| 285 | main.log.report( "Start Mininet topology" ) |
| 286 | main.log.case( "Start Mininet topology" ) |
| 287 | |
| 288 | main.step( "Starting Mininet Topology" ) |
GlennRC | 1c5df3c | 2015-08-27 16:12:09 -0700 | [diff] [blame] | 289 | topology = main.dependencyPath + main.topology |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 290 | topoResult = main.Mininet1.startNet( topoFile=topology ) |
| 291 | stepResult = topoResult |
| 292 | utilities.assert_equals( expect=main.TRUE, |
| 293 | actual=stepResult, |
| 294 | onpass="Successfully loaded topology", |
| 295 | onfail="Failed to load topology" ) |
| 296 | # Exit if topology did not load properly |
| 297 | if not topoResult: |
| 298 | main.cleanup() |
| 299 | main.exit() |
| 300 | |
| 301 | def CASE1001( self, main ): |
| 302 | """ |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 303 | Topology test |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 304 | """ |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 305 | import time |
| 306 | main.topoName = "SPINE" |
| 307 | main.case( "Spine topology test" ) |
| 308 | main.step( main.topoName + " topology" ) |
| 309 | mnCmd = "sudo mn --custom " + main.dependencyPath +\ |
| 310 | main.multiovs + " --switch=ovsm --custom " +\ |
| 311 | main.dependencyPath + main.topology +\ |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 312 | " --topo " + main.spine + " --controller=remote,ip=" +\ |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 313 | main.ONOSip[ 0 ] + " --mac" |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 314 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 315 | stepResult = main.scaleTopoFunction.testTopology( main, |
| 316 | mnCmd=mnCmd, |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 317 | timeout=900, |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 318 | clean=False ) |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 319 | |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 320 | time.sleep(3) |
GlennRC | 781b43b | 2015-08-31 16:26:28 -0700 | [diff] [blame] | 321 | |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 322 | utilities.assert_equals( expect=main.TRUE, |
| 323 | actual=stepResult, |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 324 | onpass=main.spine + " topology successful", |
| 325 | onfail=main.spine + |
GlennRC | 1c5df3c | 2015-08-27 16:12:09 -0700 | [diff] [blame] | 326 | "Spine topology failed" ) |
GlennRC | 781b43b | 2015-08-31 16:26:28 -0700 | [diff] [blame] | 327 | |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 328 | time.sleep(60) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 329 | |
GlennRC | 4cc1118 | 2015-09-01 15:19:15 -0700 | [diff] [blame] | 330 | ''' |
| 331 | main.ONOSbench.scp( main.Mininet1, |
| 332 | "~/mininet/custom/spine.json", |
| 333 | "/tmp/", |
| 334 | direction="to" ) |
| 335 | ''' |
| 336 | |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 337 | def CASE1002( self, main ): |
| 338 | """ |
| 339 | Topology test |
| 340 | """ |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 341 | main.topoName = "TORUS" |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 342 | main.case( "Topology discovery test" ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 343 | stepResult = main.TRUE |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 344 | main.step( main.torus + " topology" ) |
GlennRC | 1c5df3c | 2015-08-27 16:12:09 -0700 | [diff] [blame] | 345 | mnCmd = "sudo mn --custom=mininet/custom/multiovs.py " +\ |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 346 | "--switch=ovsm --topo " + main.torus +\ |
| 347 | " --controller=remote,ip=" + main.ONOSip[ 0 ] +" --mac" |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 348 | stepResult = main.scaleTopoFunction.testTopology( main, |
| 349 | mnCmd=mnCmd, |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 350 | timeout=900, |
GlennRC | 781b43b | 2015-08-31 16:26:28 -0700 | [diff] [blame] | 351 | clean=True ) |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 352 | utilities.assert_equals( expect=main.TRUE, |
| 353 | actual=stepResult, |
GlennRC | 8f545df | 2015-08-28 09:26:38 -0700 | [diff] [blame] | 354 | onpass=main.torus + " topology successful", |
| 355 | onfail=main.torus + " topology failed" ) |