Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2017 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 21 | """ |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 22 | Testing various connectivity failures for VPLS. |
| 23 | |
| 24 | CASE1: Startup. |
| 25 | CASE2: Load VPLS topology and configurations from demo script. |
| 26 | CASE50: Initial connectivity test. |
| 27 | CASE100: Bring down 1 host at a time and test connectivity. |
| 28 | CASE200: Bring down 1 switch at a time and test connectivity. |
| 29 | CASE300: Stop 1 ONOS node at a time and test connectivity. |
| 30 | CASE310: Kill 1 ONOS node at a time and test connectivity. |
| 31 | CASE400: Bring down 1 link at a time and test connectivity. |
| 32 | """ |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 33 | class VPLSfailsafe: |
| 34 | |
| 35 | def __init__( self ): |
| 36 | self.default = '' |
| 37 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 38 | def CASE1( self, main ): |
| 39 | """ |
| 40 | CASE1 is to compile ONOS and push it to the test machines |
| 41 | |
| 42 | Startup sequence: |
| 43 | cell <name> |
| 44 | onos-verify-cell |
| 45 | NOTE: temporary - onos-remove-raft-logs |
| 46 | onos-uninstall |
| 47 | start mininet |
| 48 | git pull |
| 49 | mvn clean install |
| 50 | onos-package |
| 51 | onos-install -f |
| 52 | onos-wait-for-start |
| 53 | start cli sessions |
| 54 | start tcpdump |
| 55 | """ |
| 56 | import imp |
| 57 | import time |
| 58 | import json |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 59 | try: |
| 60 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 61 | main.testSetUp = ONOSSetup() |
| 62 | except ImportError: |
| 63 | main.log.error( "ONOSSetup not found. exiting the test" ) |
| 64 | main.cleanAndExit() |
| 65 | main.testSetUp.envSetupDescription() |
| 66 | stepResult = main.FALSE |
| 67 | try: |
| 68 | # load some variables from the params file |
| 69 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 70 | main.timeSleep = int( main.params[ 'RETRY' ][ 'sleep' ] ) |
| 71 | main.numAttempts = int( main.params[ 'RETRY' ][ 'attempts' ] ) |
| 72 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 73 | |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 74 | ofPort = main.params[ 'CTRL' ][ 'port' ] |
| 75 | stepResult = main.testSetUp.envSetup() |
| 76 | except Exception as e: |
| 77 | main.testSetUp.envSetupException( e ) |
| 78 | main.testSetUp.evnSetupConclusion( stepResult ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 79 | |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 80 | main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, |
| 81 | cellName=cellName ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 82 | |
| 83 | main.step( "Starting Mininet" ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 84 | # scp topo file to mininet |
| 85 | # TODO: move to params? |
| 86 | topoName = "vpls" |
Jeremy Ronquillo | 31caa48 | 2017-07-18 15:55:31 -0700 | [diff] [blame] | 87 | topoFile = "vpls.py" |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 88 | filePath = main.ONOSbench.home + "/tools/test/topos/" |
| 89 | main.ONOSbench.scp( main.Mininet1, |
| 90 | filePath + topoFile, |
| 91 | main.Mininet1.home, |
| 92 | direction="to" ) |
| 93 | topo = " --custom " + main.Mininet1.home + topoFile + " --topo " + topoName |
| 94 | args = " --switch ovs,protocols=OpenFlow13" |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 95 | for ctrl in main.Cluster.active(): |
| 96 | args += " --controller=remote,ip=" + ctrl.ipAddress |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 97 | mnCmd = "sudo mn" + topo + args |
| 98 | mnResult = main.Mininet1.startNet( mnCmd=mnCmd ) |
| 99 | utilities.assert_equals( expect=main.TRUE, actual=mnResult, |
| 100 | onpass="Mininet Started", |
| 101 | onfail="Error starting Mininet" ) |
| 102 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 103 | main.step( "Activate apps defined in the params file" ) |
| 104 | # get data from the params |
| 105 | apps = main.params.get( 'apps' ) |
| 106 | if apps: |
| 107 | apps = apps.split( ',' ) |
| 108 | main.log.warn( apps ) |
| 109 | activateResult = True |
| 110 | for app in apps: |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 111 | main.Cluster.active( 0 ).CLI.app( app, "Activate" ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 112 | # TODO: check this worked |
| 113 | time.sleep( SLEEP ) # wait for apps to activate |
| 114 | for app in apps: |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 115 | state = main.Cluster.active( 0 ).CLI.appStatus( app ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 116 | if state == "ACTIVE": |
| 117 | activateResult = activateResult and True |
| 118 | else: |
| 119 | main.log.error( "{} is in {} state".format( app, state ) ) |
| 120 | activateResult = False |
| 121 | utilities.assert_equals( expect=True, |
| 122 | actual=activateResult, |
| 123 | onpass="Successfully activated apps", |
| 124 | onfail="Failed to activate apps" ) |
| 125 | else: |
| 126 | main.log.warn( "No apps were specified to be loaded after startup" ) |
| 127 | |
| 128 | main.step( "Set ONOS configurations" ) |
| 129 | config = main.params.get( 'ONOS_Configuration' ) |
| 130 | if config: |
| 131 | main.log.debug( config ) |
| 132 | checkResult = main.TRUE |
| 133 | for component in config: |
| 134 | for setting in config[ component ]: |
| 135 | value = config[ component ][ setting ] |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 136 | check = main.Cluster.active( 0 ).CLI.setCfg( component, setting, value ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 137 | main.log.info( "Value was changed? {}".format( main.TRUE == check ) ) |
| 138 | checkResult = check and checkResult |
| 139 | utilities.assert_equals( expect=main.TRUE, |
| 140 | actual=checkResult, |
| 141 | onpass="Successfully set config", |
| 142 | onfail="Failed to set config" ) |
| 143 | else: |
| 144 | main.log.warn( "No configurations were specified to be changed after startup" ) |
| 145 | |
| 146 | main.step( "App Ids check" ) |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 147 | appCheck = main.Cluster.command( "appToIDCheck", returnBool=True ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 148 | if appCheck is not True: |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 149 | main.log.warn( main.Cluster.active( 0 ).CLI.apps() ) |
| 150 | main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() ) |
| 151 | utilities.assert_equals( expect=True, actual=appCheck, |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 152 | onpass="App Ids seem to be correct", |
| 153 | onfail="Something is wrong with app Ids" ) |
| 154 | |
| 155 | def CASE2( self, main ): |
| 156 | """ |
| 157 | Load and test vpls configurations from json configuration file |
| 158 | """ |
| 159 | import os.path |
| 160 | from tests.USECASE.VPLS.dependencies import vpls |
| 161 | |
| 162 | main.vpls = vpls |
| 163 | pprint = main.ONOSrest1.pprint |
| 164 | hosts = int( main.params[ 'vpls' ][ 'hosts' ] ) |
| 165 | SLEEP = int( main.params[ 'SLEEP' ][ 'netcfg' ] ) |
| 166 | |
| 167 | main.step( "Discover hosts using pings" ) |
| 168 | for i in range( 1, hosts + 1 ): |
| 169 | src = "h" + str( i ) |
| 170 | for j in range( 1, hosts + 1 ): |
| 171 | if j == i: |
| 172 | continue |
| 173 | dst = "h" + str( j ) |
| 174 | pingResult = main.Mininet1.pingHost( SRC=src, TARGET=dst ) |
| 175 | |
| 176 | main.step( "Load VPLS configurations" ) |
| 177 | fileName = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 178 | app = main.params[ 'vpls' ][ 'name' ] |
| 179 | |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 180 | loadVPLSResult = main.ONOSbench.onosNetCfg( main.Cluster.active( 0 ).ipAddress, "", fileName ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 181 | utilities.assert_equals( expect=main.TRUE, |
| 182 | actual=loadVPLSResult, |
| 183 | onpass="Loaded vpls configuration.", |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 184 | onfail="Failed to load vpls configuration." ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 185 | |
| 186 | # Time for netcfg to load data |
| 187 | time.sleep( SLEEP ) |
| 188 | |
| 189 | main.step( "Check VPLS configurations" ) |
| 190 | # 'Master' copy of test configuration |
| 191 | try: |
| 192 | with open( os.path.expanduser( fileName ) ) as dataFile: |
| 193 | originalCfg = json.load( dataFile ) |
| 194 | main.vplsConfig = originalCfg[ 'apps' ].get( app ).get( 'vpls' ).get( 'vplsList' ) |
| 195 | except Exception as e: |
| 196 | main.log.error( "Error loading config file: {}".format( e ) ) |
| 197 | if main.vplsConfig: |
| 198 | result = True |
| 199 | else: |
| 200 | result = False |
| 201 | utilities.assert_equals( expect=True, |
| 202 | actual=result, |
| 203 | onpass="Check vpls configuration succeeded.", |
| 204 | onfail="Check vpls configuration failed." ) |
| 205 | |
| 206 | main.step( "Check interface configurations" ) |
| 207 | result = False |
| 208 | getPorts = utilities.retry( f=main.ONOSrest1.getNetCfg, |
| 209 | retValue=False, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 210 | kwargs={ "subjectClass": "ports" }, |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 211 | sleep=SLEEP ) |
| 212 | onosCfg = pprint( getPorts ) |
| 213 | sentCfg = pprint( originalCfg.get( "ports" ) ) |
| 214 | |
| 215 | if onosCfg == sentCfg: |
| 216 | main.log.info( "ONOS interfaces NetCfg matches what was sent" ) |
| 217 | result = True |
| 218 | else: |
| 219 | main.log.error( "ONOS interfaces NetCfg doesn't match what was sent" ) |
| 220 | main.log.debug( "ONOS config: {}".format( onosCfg ) ) |
| 221 | main.log.debug( "Sent config: {}".format( sentCfg ) ) |
| 222 | utilities.assert_equals( expect=True, |
| 223 | actual=result, |
| 224 | onpass="Net Cfg added for interfaces", |
| 225 | onfail="Net Cfg not added for interfaces" ) |
| 226 | |
| 227 | # Run a bunch of checks to verify functionality based on configs |
| 228 | vpls.verify( main ) |
| 229 | |
| 230 | # This is to avoid a race condition in pushing netcfg's. |
| 231 | main.step( "Loading vpls configuration in case any configuration was missed." ) |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 232 | loadVPLSResult = main.ONOSbench.onosNetCfg( main.Cluster.active( 0 ).ipAddress, "", fileName ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 233 | utilities.assert_equals( expect=main.TRUE, |
| 234 | actual=loadVPLSResult, |
| 235 | onpass="Loaded vpls configuration.", |
| 236 | onfail="Failed to load vpls configuration." ) |
| 237 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 238 | def CASE50( self, main ): |
| 239 | """ |
| 240 | Initial connectivity check |
| 241 | """ |
| 242 | main.case( "Check connectivity before running all other tests." ) |
| 243 | |
| 244 | # Check connectivity before running all other tests |
| 245 | connectCheckResult = main.vpls.testConnectivityVpls( main ) |
| 246 | utilities.assert_equals( expect=main.TRUE, actual=connectCheckResult, |
| 247 | onpass="Connectivity is as expected.", |
| 248 | onfail="Connectivity is NOT as expected." ) |
| 249 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 250 | def CASE100( self, main ): |
| 251 | """ |
| 252 | Bring down 1 host at a time and test connectivity |
| 253 | """ |
| 254 | assert vpls, "vpls not defined" |
| 255 | |
| 256 | main.case( "Bring down one host at a time and test connectivity." ) |
| 257 | result = main.TRUE |
| 258 | |
| 259 | for i in range( 1, hosts + 1 ): |
| 260 | |
| 261 | stri = str( i ) |
| 262 | |
| 263 | # Bring host down |
| 264 | main.step( "Kill link between s" + stri + " and h" + stri + "." ) |
| 265 | linkDownResult = main.Mininet1.link( END1="s" + stri, END2="h" + stri, OPTION="down" ) |
| 266 | |
| 267 | # Check if link was successfully down'd |
| 268 | utilities.assert_equals( expect=main.TRUE, actual=linkDownResult, |
| 269 | onpass="Link down successful.", |
| 270 | onfail="Failed to bring link down." ) |
| 271 | result = result and linkDownResult |
| 272 | |
| 273 | # Check connectivity |
| 274 | connectivityResult = vpls.testConnectivityVpls( main, blacklist=[ "h" + stri ] ) |
| 275 | result = result and connectivityResult |
| 276 | |
| 277 | # Bring host up |
| 278 | main.step( "Re-adding link between s" + stri + " and h" + stri + "." ) |
| 279 | linkUpResult = main.Mininet1.link( END1="s" + stri, END2="h" + stri, OPTION="up" ) |
| 280 | |
| 281 | # Check if link was successfully re-added |
| 282 | utilities.assert_equals( expect=main.TRUE, actual=linkUpResult, |
| 283 | onpass="Link up successful.", |
| 284 | onfail="Failed to bring link up." ) |
| 285 | result = result and linkUpResult |
| 286 | |
| 287 | # Discover host using ping |
| 288 | main.step( "Discover h" + stri + " using ping." ) |
| 289 | main.Mininet1.pingHost( SRC="h" + stri, TARGET="h" + str( ( i % hosts ) + 1 ) ) |
| 290 | |
| 291 | # Check connectivity |
| 292 | connectivityResult = vpls.testConnectivityVpls( main ) |
| 293 | result = result and connectivityResult |
| 294 | |
Jeremy Ronquillo | 2d6c91d | 2017-10-06 12:39:13 -0700 | [diff] [blame] | 295 | if not result: |
| 296 | break |
| 297 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 298 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 299 | onpass="Connectivity is as expected.", |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 300 | onfail="Connectivity is NOT as expected." ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 301 | |
| 302 | def CASE200( self, main ): |
| 303 | """ |
| 304 | Bring down 1 switch at a time and test connectivity |
| 305 | """ |
| 306 | assert vpls, "vpls not defined" |
| 307 | |
| 308 | main.case( "Bring down one switch at a time and test connectivity." ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 309 | links = main.Mininet1.getLinks() # Obtain links here |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 310 | result = main.TRUE |
| 311 | |
| 312 | for i in range( 5, hosts + 1 ): |
| 313 | |
| 314 | stri = str( i ) |
| 315 | |
| 316 | # Bring switch down |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 317 | main.step( "Delete s" + stri + "." ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 318 | delSwitchResult = main.Mininet1.delSwitch( sw="s" + stri ) |
| 319 | |
| 320 | # Check if switch was deleted |
| 321 | utilities.assert_equals( expect=main.TRUE, actual=delSwitchResult, |
| 322 | onpass="Successfully deleted switch.", |
| 323 | onfail="Failed to delete switch." ) |
| 324 | result = result and delSwitchResult |
| 325 | |
| 326 | # Check connectivity |
| 327 | connectivityResult = vpls.testConnectivityVpls( main, blacklist=[ "h" + stri ] ) |
| 328 | result = result and connectivityResult |
| 329 | |
| 330 | # Bring switch up |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 331 | main.step( "Add s" + stri + "." ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 332 | addSwitchResult = main.Mininet1.addSwitch( sw="s" + stri ) |
| 333 | |
| 334 | # Check if switch was added |
| 335 | utilities.assert_equals( expect=main.TRUE, actual=addSwitchResult, |
| 336 | onpass="Successfully added switch.", |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 337 | onfail="Failed to add switch." ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 338 | result = result and addSwitchResult |
| 339 | |
| 340 | # Reconnect links |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 341 | main.step( "Reconnecting links on s" + stri + "." ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 342 | for j in links: |
| 343 | if ( j[ 'node1' ] == "s" + stri and j[ 'node2' ][ 0 ] == "s" ) or \ |
| 344 | ( j[ 'node2' ] == "s" + stri and j[ 'node1' ][ 0 ] == "s" ): |
| 345 | main.Mininet1.addLink( str( j[ 'node1' ] ), str( j[ 'node2' ] ) ) |
| 346 | |
| 347 | # Discover host using ping |
| 348 | main.Mininet1.pingHost( SRC="h" + stri, TARGET="h" + str( ( i % hosts ) + 1 ) ) |
| 349 | |
| 350 | # Check connectivity |
| 351 | connectivityResult = vpls.testConnectivityVpls( main ) |
| 352 | result = result and connectivityResult |
| 353 | |
Jeremy Ronquillo | 2d6c91d | 2017-10-06 12:39:13 -0700 | [diff] [blame] | 354 | if not result: |
| 355 | break |
| 356 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 357 | utilities.assert_equals( expect=main.TRUE, |
| 358 | actual=result, |
| 359 | onpass="Connectivity is as expected.", |
| 360 | onfail="Connectivity is NOT as expected." ) |
| 361 | |
| 362 | def CASE300( self, main ): |
| 363 | """ |
| 364 | Stop 1 ONOS node at a time and test connectivity |
| 365 | """ |
| 366 | from tests.USECASE.VPLS.dependencies import vpls |
| 367 | from tests.HA.dependencies.HA import HA |
| 368 | assert vpls, "vpls not defined" |
| 369 | |
| 370 | main.HA = HA() |
| 371 | main.case( "Stop one ONOS node at a time and test connectivity." ) |
| 372 | |
| 373 | result = main.TRUE |
| 374 | |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 375 | for i in range( 0, main.Cluster.numCtrls ): |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 376 | |
| 377 | stri = str( i ) |
| 378 | |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 379 | ip_address = main.Cluster.active( i ).ipAddress |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 380 | |
| 381 | # Stop an ONOS node: i |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 382 | main.step( "Stop ONOS node " + stri + "." ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 383 | stopResult = main.ONOSbench.onosStop( ip_address ) |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 384 | main.Cluster.runningNodes[ i ].active = False |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 385 | |
| 386 | utilities.assert_equals( expect=main.TRUE, actual=stopResult, |
| 387 | onpass="ONOS nodes stopped successfully.", |
| 388 | onfail="ONOS nodes NOT successfully stopped." ) |
| 389 | |
| 390 | # Check connectivity |
| 391 | connectivityResult = vpls.testConnectivityVpls( main, isNodeUp=False ) |
| 392 | result = result and connectivityResult |
| 393 | |
| 394 | # Restart ONOS node |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 395 | main.step( "Restart ONOS node " + stri + " and checking status of restart." ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 396 | startResult = main.ONOSbench.onosStart( ip_address ) |
| 397 | |
| 398 | utilities.assert_equals( expect=main.TRUE, actual=startResult, |
| 399 | onpass="ONOS nodes started successfully.", |
| 400 | onfail="ONOS nodes NOT successfully started." ) |
| 401 | result = result and startResult |
| 402 | |
| 403 | # Check if ONOS is up yet |
| 404 | main.log.info( "Checking if ONOS node " + stri + " is up." ) |
| 405 | upResult = main.ONOSbench.isup( ip_address ) |
| 406 | |
| 407 | utilities.assert_equals( expect=main.TRUE, actual=upResult, |
| 408 | onpass="ONOS successfully restarted.", |
| 409 | onfail="ONOS did NOT successfully restart." ) |
| 410 | |
| 411 | # Restart CLI |
| 412 | main.log.info( "Restarting ONOS node " + stri + "'s main.CLI." ) |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 413 | cliResults = main.Cluster.active( 0 ).CLI.startOnosCli( ip_address ) |
| 414 | main.Cluster.runningNodes[ i ].active = True |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 415 | |
| 416 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 417 | onpass="ONOS CLI successfully restarted.", |
| 418 | onfail="ONOS CLI did NOT successfully restart." ) |
| 419 | |
| 420 | # Run some basic checks to see if ONOS node truly has succesfully restarted: |
| 421 | |
| 422 | # Checking if all nodes appear with status READY using 'nodes' command |
| 423 | main.step( "Checking ONOS nodes." ) |
Devin Lim | 3ebd5e7 | 2017-11-14 10:38:00 -0800 | [diff] [blame] | 424 | nodeResults = utilities.retry( main.Cluster.nodesCheck, |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 425 | False, |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 426 | sleep=main.timeSleep, |
| 427 | attempts=main.numAttempts ) |
| 428 | |
| 429 | utilities.assert_equals( expect=True, actual=nodeResults, |
| 430 | onpass="Nodes check successful.", |
| 431 | onfail="Nodes check NOT successful." ) |
| 432 | |
| 433 | # All apps that are present are active |
| 434 | main.log.info( "Checking if apps are active." ) |
| 435 | compareAppsResult = vpls.compareApps( main ) |
| 436 | utilities.assert_equals( expect=main.TRUE, |
| 437 | actual=compareAppsResult, |
| 438 | onpass="Apps are the same across all nodes.", |
| 439 | onfail="Apps are NOT the same across all nodes." ) |
| 440 | result = result and compareAppsResult |
| 441 | |
| 442 | # Check connectivity |
| 443 | connectivityResult = vpls.testConnectivityVpls( main ) |
| 444 | result = result and connectivityResult |
| 445 | |
Jeremy Ronquillo | 2d6c91d | 2017-10-06 12:39:13 -0700 | [diff] [blame] | 446 | if not result: |
| 447 | break |
| 448 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 449 | utilities.assert_equals( expect=main.TRUE, |
| 450 | actual=result, |
| 451 | onpass="Connectivity is as expected.", |
| 452 | onfail="Connectivity is NOT as expected." ) |
| 453 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 454 | def CASE310( self, main ): |
| 455 | """ |
| 456 | Kill 1 ONOS node at a time and test connectivity |
| 457 | """ |
| 458 | assert vpls, "vpls not defined" |
| 459 | |
| 460 | main.case( "Kill one ONOS node at a time and test connectivity." ) |
| 461 | killSleep = int( main.params[ 'SLEEP' ][ 'killnode' ] ) |
| 462 | result = main.TRUE |
| 463 | |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 464 | for i in range( 0, main.Cluster.numCtrls ): |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 465 | |
| 466 | # Kill an ONOS node |
| 467 | main.step( "Killing ONOS node " + str( i + 1 ) + "." ) |
Jeremy Ronquillo | d7791d8 | 2017-08-14 16:23:08 +0000 | [diff] [blame] | 468 | killresult = main.ONOSbench.onosKill( main.Cluster.active( i ).ipAddress ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 469 | |
| 470 | # Check if ONOS node has been successfully killed |
| 471 | utilities.assert_equals( expect=main.TRUE, actual=killresult, |
| 472 | onpass="ONOS node killed successfully.", |
| 473 | onfail="ONOS node NOT successfully killed." ) |
| 474 | |
| 475 | main.step( "Waiting for ONOS to restart." ) |
| 476 | main.log.info( "Sleeping for " + str( killSleep ) + " seconds..." ) |
| 477 | time.sleep( killSleep ) |
| 478 | |
| 479 | # Check connectivity |
| 480 | connectivityResult = vpls.testConnectivityVpls( main ) |
| 481 | result = result and connectivityResult |
| 482 | |
Jeremy Ronquillo | 2d6c91d | 2017-10-06 12:39:13 -0700 | [diff] [blame] | 483 | if not result: |
| 484 | break |
| 485 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 486 | utilities.assert_equals( expect=main.TRUE, |
| 487 | actual=result, |
| 488 | onpass="Connectivity is as expected.", |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 489 | onfail="Connectivity is NOT as expected." ) |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 490 | |
| 491 | def CASE400( self, main ): |
| 492 | """ |
| 493 | Bring down 1 link at a time and test connectivity |
| 494 | """ |
| 495 | assert vpls, "vpls not defined" |
| 496 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 497 | main.case( "Bring down one link at a time and test connectivity." ) |
| 498 | |
| 499 | result = main.TRUE |
| 500 | |
| 501 | for link in main.Mininet1.getLinks(): |
| 502 | nodes = [ link[ 'node1' ], link[ 'node2' ] ] |
| 503 | |
| 504 | # Bring down a link |
| 505 | main.step( "Bring down link: " + nodes[ 0 ] + " to " + nodes[ 1 ] ) |
| 506 | delLinkResult = main.Mininet1.link( END1=nodes[ 0 ], END2=nodes[ 1 ], OPTION="down" ) |
| 507 | |
| 508 | # Check if the link has successfully been brought down |
| 509 | utilities.assert_equals( expect=main.TRUE, actual=delLinkResult, |
| 510 | onpass="Successfully deleted link.", |
| 511 | onfail="Failed to delete link." ) |
| 512 | result = result and delLinkResult |
| 513 | |
| 514 | # Add removed host to blacklist if necessary |
| 515 | blacklist = [] |
| 516 | for l in nodes: |
| 517 | if l[ 0 ] == 'h': |
| 518 | blacklist.append( l ) |
| 519 | |
| 520 | # Check intent states, then connectivity |
| 521 | connectivityResult = vpls.testConnectivityVpls( main, blacklist ) |
| 522 | result = result and connectivityResult |
| 523 | |
| 524 | # Re-add the link |
| 525 | main.step( "Adding link: " + nodes[ 0 ] + " to " + nodes[ 1 ] + "." ) |
| 526 | addLinkResult = main.Mininet1.link( END1=nodes[ 0 ], END2=nodes[ 1 ], OPTION="up" ) |
| 527 | |
| 528 | # Check if the link has successfully been added |
| 529 | utilities.assert_equals( expect=main.TRUE, actual=addLinkResult, |
| 530 | onpass="Successfully added link.", |
| 531 | onfail="Failed to delete link." ) |
| 532 | result = result and addLinkResult |
| 533 | |
| 534 | main.log.debug( main.timeSleep ) |
| 535 | time.sleep( main.timeSleep ) |
| 536 | |
| 537 | # Check intent states, then connectivity |
| 538 | connectivityResult = vpls.testConnectivityVpls( main ) |
| 539 | result = result and connectivityResult |
| 540 | |
Jeremy Ronquillo | 2d6c91d | 2017-10-06 12:39:13 -0700 | [diff] [blame] | 541 | if not result: |
| 542 | break |
| 543 | |
Jeremy Ronquillo | 3008aa3 | 2017-07-07 15:38:57 -0700 | [diff] [blame] | 544 | utilities.assert_equals( expect=main.TRUE, |
| 545 | actual=result, |
| 546 | onpass="Connectivity is as expected.", |
| 547 | onfail="Connectivity is NOT as expected." ) |