pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 1 | # Testing the functionality of SDN-IP with single ONOS instance |
| 2 | class USECASE_SdnipFunctionCluster: |
| 3 | |
| 4 | def __init__( self ): |
| 5 | self.default = '' |
| 6 | global branchName |
| 7 | |
| 8 | def CASE100( self, main ): |
| 9 | """ |
| 10 | Start mininet |
| 11 | """ |
| 12 | import imp |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 13 | main.case( "Setup the Mininet testbed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 14 | main.dependencyPath = main.testDir + \ |
| 15 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 16 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 17 | |
| 18 | main.step( "Starting Mininet Topology" ) |
| 19 | topology = main.dependencyPath + main.topology |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 20 | topoResult = main.Mininet.startNet( topoFile=topology ) |
| 21 | utilities.assert_equals( expect=main.TRUE, |
| 22 | actual=topoResult, |
| 23 | onpass="Successfully loaded topology", |
| 24 | onfail="Failed to load topology" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 25 | # Exit if topology did not load properly |
| 26 | if not topoResult: |
| 27 | main.cleanup() |
| 28 | main.exit() |
| 29 | main.step( "Connect switches to controllers" ) |
| 30 | |
| 31 | # connect all switches to controllers |
| 32 | swResult = main.TRUE |
| 33 | for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ): |
| 34 | sw = "sw%s" % ( i ) |
| 35 | swResult = swResult and main.Mininet.assignSwController( sw, |
| 36 | [ONOS1Ip, ONOS2Ip, ONOS3Ip] ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 37 | utilities.assert_equals( expect=main.TRUE, |
| 38 | actual=swResult, |
| 39 | onpass="Successfully connect all switches to ONOS", |
| 40 | onfail="Failed to connect all switches to ONOS" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 41 | if not swResult: |
| 42 | main.cleanup() |
| 43 | main.exit() |
| 44 | |
| 45 | |
| 46 | def CASE101( self, main ): |
| 47 | """ |
| 48 | Package ONOS and install it |
| 49 | Startup sequence: |
| 50 | cell <name> |
| 51 | onos-verify-cell |
| 52 | onos-package |
| 53 | onos-install -f |
| 54 | onos-wait-for-start |
| 55 | """ |
| 56 | import json |
| 57 | import time |
| 58 | import os |
| 59 | from operator import eq |
| 60 | |
| 61 | main.case( "Setting up ONOS environment" ) |
| 62 | |
| 63 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 64 | global ONOS1Ip |
| 65 | global ONOS2Ip |
| 66 | global ONOS3Ip |
| 67 | ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 68 | ONOS2Ip = os.getenv( main.params[ 'CTRL' ][ 'ip2' ] ) |
| 69 | ONOS3Ip = os.getenv( main.params[ 'CTRL' ][ 'ip3' ] ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 70 | ipList = [ ONOS1Ip, ONOS2Ip, ONOS3Ip ] |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 71 | |
| 72 | global peer64514 |
| 73 | global peer64515 |
| 74 | global peer64516 |
| 75 | peer64514 = main.params['config']['peer64514'] |
| 76 | peer64515 = main.params['config']['peer64515'] |
| 77 | peer64516 = main.params['config']['peer64516'] |
| 78 | |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 79 | main.step( "Copying config files" ) |
| 80 | src = os.path.dirname( main.testFile ) + "/network-cfg.json" |
| 81 | dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json" |
| 82 | status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" ) |
| 83 | utilities.assert_equals( expect=main.TRUE, |
| 84 | actual=status, |
| 85 | onpass="Copy config file succeeded", |
| 86 | onfail="Copy config file failed" ) |
| 87 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 88 | main.step( "Create cell file" ) |
| 89 | cellAppString = main.params[ 'ENV' ][ 'appString' ] |
| 90 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName, |
| 91 | main.Mininet.ip_address, |
| 92 | cellAppString, ipList ) |
| 93 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 94 | main.step( "Applying cell variable to environment" ) |
| 95 | cellResult = main.ONOSbench.setCell( cellName ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 96 | utilities.assert_equals( expect=main.TRUE, |
| 97 | actual=cellResult, |
| 98 | onpass="Set cell succeeded", |
| 99 | onfail="Set cell failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 100 | |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 101 | main.step( "Verify cell connectivity" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 102 | verifyResult = main.ONOSbench.verifyCell() |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 103 | utilities.assert_equals( expect=main.TRUE, |
| 104 | actual=verifyResult, |
| 105 | onpass="Verify cell succeeded", |
| 106 | onfail="Verify cell failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 107 | |
| 108 | branchName = main.ONOSbench.getBranchName() |
| 109 | main.log.report( "ONOS is on branch: " + branchName ) |
| 110 | |
| 111 | main.log.step( "Uninstalling ONOS" ) |
| 112 | uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) \ |
| 113 | and main.ONOSbench.onosUninstall( ONOS2Ip ) \ |
| 114 | and main.ONOSbench.onosUninstall( ONOS3Ip ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 115 | utilities.assert_equals( expect=main.TRUE, |
| 116 | actual=uninstallResult, |
| 117 | onpass="Uninstall ONOS from nodes succeeded", |
| 118 | onfail="Uninstall ONOS form nodes failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 119 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 120 | main.ONOSbench.getVersion( report=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 121 | |
| 122 | main.step( "Creating ONOS package" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 123 | packageResult = main.ONOSbench.onosPackage( opTimeout=500 ) |
| 124 | utilities.assert_equals( expect=main.TRUE, |
| 125 | actual=packageResult, |
| 126 | onpass="Package ONOS succeeded", |
| 127 | onfail="Package ONOS failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 128 | |
| 129 | main.step( "Installing ONOS package" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 130 | onos1InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 131 | node=ONOS1Ip ) |
| 132 | onos2InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 133 | node=ONOS2Ip ) |
| 134 | onos3InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 135 | node=ONOS3Ip ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 136 | onosInstallResult = onos1InstallResult and onos2InstallResult \ |
| 137 | and onos3InstallResult |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 138 | utilities.assert_equals( expect=main.TRUE, |
| 139 | actual=onosInstallResult, |
| 140 | onpass="Install ONOS to nodes succeeded", |
| 141 | onfail="Install ONOS to nodes failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 142 | |
| 143 | main.step( "Checking if ONOS is up yet" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 144 | onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 ) |
| 145 | onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 ) |
| 146 | onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout=420 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 147 | onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 148 | utilities.assert_equals( expect=main.TRUE, |
| 149 | actual=onosUpResult, |
| 150 | onpass="ONOS nodes are up", |
| 151 | onfail="ONOS nodes are NOT up" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 152 | |
| 153 | main.step( "Checking if ONOS CLI is ready" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 154 | main.CLIs = [] |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 155 | cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 156 | commandlineTimeout=100, onosStartTimeout=600 ) |
| 157 | main.CLIs.append( main.ONOScli1 ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 158 | cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 159 | commandlineTimeout=100, onosStartTimeout=600 ) |
| 160 | main.CLIs.append( main.ONOScli2 ) |
| 161 | cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip, |
| 162 | commandlineTimeout=100, onosStartTimeout=600 ) |
| 163 | main.CLIs.append( main.ONOScli3 ) |
| 164 | cliResult = cliResult1 and cliResult2 and cliResult3 |
| 165 | utilities.assert_equals( expect=main.TRUE, |
| 166 | actual=cliResult, |
| 167 | onpass="ONOS CLIs are ready", |
| 168 | onfail="ONOS CLIs are not ready" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 169 | |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 170 | main.step( "Checking if ONOS CLI is ready for issuing commands" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 171 | for i in range( 10 ): |
| 172 | ready = True |
| 173 | for cli in main.CLIs: |
| 174 | output = cli.summary() |
| 175 | if not output: |
| 176 | ready = False |
| 177 | if ready: |
| 178 | break |
| 179 | time.sleep( 30 ) |
| 180 | utilities.assert_equals( expect=True, actual=ready, |
| 181 | onpass="ONOS summary command succeded", |
| 182 | onfail="ONOS summary command failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 183 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 184 | if not ready: |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 185 | main.log.error( "ONOS startup failed!" ) |
| 186 | main.cleanup() |
| 187 | main.exit() |
| 188 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 189 | def CASE200( self, main ): |
| 190 | main.case( "Activate sdn-ip application" ) |
| 191 | main.log.info( "waiting link discovery......" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 192 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 193 | |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 194 | main.step( "Get links in the network" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 195 | summaryResult = main.ONOScli1.summary() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 196 | linkNum = json.loads( summaryResult )[ "links" ] |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 197 | main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 198 | if linkNum < 100: |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 199 | main.log.error( "Link number is wrong! Retrying..." ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 200 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 201 | summaryResult = main.ONOScli1.summary() |
| 202 | linkNum = json.loads( summaryResult )[ "links" ] |
| 203 | main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) ) |
| 204 | utilities.assert_equals( expect=100, |
| 205 | actual=linkNum, |
| 206 | onpass="ONOS correctly discovered all links", |
| 207 | onfail="ONOS Failed to discover all links" ) |
| 208 | if linkNum < 100: |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 209 | main.cleanup() |
| 210 | main.exit() |
| 211 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 212 | main.step( "Activate sdn-ip application" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 213 | activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 214 | utilities.assert_equals( expect=main.TRUE, |
| 215 | actual=activeSDNIPresult, |
| 216 | onpass="Activate SDN-IP succeeded", |
| 217 | onfail="Activate SDN-IP failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 218 | if not activeSDNIPresult: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 219 | main.log.info( "Activate SDN-IP failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 220 | main.cleanup() |
| 221 | main.exit() |
| 222 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 223 | |
| 224 | def CASE102( self, main ): |
| 225 | ''' |
| 226 | This test case is to load the methods from other Python files, and create |
| 227 | tunnels from mininet host to onos nodes. |
| 228 | ''' |
| 229 | import time |
| 230 | main.case( "Load methods from other Python file and create tunnels" ) |
| 231 | # load the methods from other file |
| 232 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 233 | main.Functions = imp.load_source( wrapperFile1, |
| 234 | main.dependencyPath + |
| 235 | wrapperFile1 + |
| 236 | ".py" ) |
| 237 | # Create tunnels |
| 238 | main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 ) |
| 239 | main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 ) |
| 240 | main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 ) |
| 241 | |
| 242 | main.log.info( "Wait SDN-IP to finish installing connectivity intents \ |
| 243 | and the BGP paths in data plane are ready..." ) |
| 244 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
| 245 | |
| 246 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 247 | other and to sdn-ip, plus finish installing all intents..." ) |
| 248 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 249 | |
| 250 | def CASE1( self, main ): |
| 251 | ''' |
| 252 | ping test from 3 bgp peers to BGP speaker |
| 253 | ''' |
| 254 | |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 255 | main.case( "Ping between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 256 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 257 | peers=["peer64514", "peer64515", "peer64516"], |
| 258 | expectAllSuccess=True ) |
| 259 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 260 | peers=[peer64514, peer64515, peer64516], |
| 261 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 262 | |
| 263 | def CASE2( self, main ): |
| 264 | ''' |
| 265 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 266 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 267 | import time |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 268 | main.case( "Check point-to-point intents" ) |
| 269 | main.log.info( "There are %s BGP peers in total " |
| 270 | % main.params[ 'config' ][ 'peerNum' ] ) |
| 271 | main.step( "Check P2P intents number from ONOS CLI" ) |
| 272 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 273 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 274 | bgpIntentsActualNum = \ |
| 275 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 276 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 277 | if bgpIntentsActualNum != bgpIntentsExpectedNum: |
| 278 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 279 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 280 | bgpIntentsActualNum = \ |
| 281 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 282 | main.log.info( "bgpIntentsExpected num is:" ) |
| 283 | main.log.info( bgpIntentsExpectedNum ) |
| 284 | main.log.info( "bgpIntentsActual num is:" ) |
| 285 | main.log.info( bgpIntentsActualNum ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 286 | utilities.assert_equals( expect=bgpIntentsExpectedNum, |
| 287 | actual=bgpIntentsActualNum, |
| 288 | onpass="PointToPointIntent Intent Num is correct!", |
| 289 | onfail="PointToPointIntent Intent Num is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 290 | |
| 291 | def CASE3( self, main ): |
| 292 | ''' |
| 293 | routes and intents check to all BGP peers |
| 294 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 295 | import time |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 296 | main.case( "Check routes and M2S intents to all BGP peers" ) |
| 297 | |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 298 | main.step( "Check routes installed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 299 | allRoutesExpected = [] |
| 300 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 301 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 302 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 303 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 304 | getRoutesResult = main.ONOScli1.routes( jsonFormat=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 305 | allRoutesActual = \ |
| 306 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 307 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 308 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 309 | if allRoutesStrActual != allRoutesStrExpected: |
| 310 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
Jon Hall | fabd7e5 | 2016-04-19 19:20:59 -0700 | [diff] [blame^] | 311 | getRoutesResult = main.ONOScli1.routes( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 312 | allRoutesActual = \ |
| 313 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 314 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 315 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 316 | main.log.info( "Routes expected:" ) |
| 317 | main.log.info( allRoutesStrExpected ) |
| 318 | main.log.info( "Routes get from ONOS CLI:" ) |
| 319 | main.log.info( allRoutesStrActual ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 320 | utilities.assert_equals( expect=allRoutesStrExpected, |
| 321 | actual=allRoutesStrActual, |
| 322 | onpass="Routes are correct!", |
| 323 | onfail="Routes are wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 324 | |
| 325 | main.step( "Check M2S intents installed" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 326 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 327 | routeIntentsActualNum = \ |
| 328 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 329 | routeIntentsExpectedNum = 3 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 330 | if routeIntentsActualNum != routeIntentsExpectedNum: |
| 331 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 332 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 333 | routeIntentsActualNum = \ |
| 334 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 335 | |
| 336 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 337 | main.log.info( routeIntentsExpectedNum ) |
| 338 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 339 | main.log.info( routeIntentsActualNum ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 340 | utilities.assert_equals( expect=routeIntentsExpectedNum, |
| 341 | actual=routeIntentsActualNum, |
| 342 | onpass="MultiPointToSinglePoint Intent Num is correct!", |
| 343 | onfail="MultiPointToSinglePoint Intent Num is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 344 | |
| 345 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 346 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 347 | main.FALSE, |
| 348 | kwargs={'isPENDING':False}, |
| 349 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 350 | utilities.assert_equals( expect=main.TRUE, |
| 351 | actual=flowCheck, |
| 352 | onpass="Flow status is correct!", |
| 353 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 354 | |
| 355 | |
| 356 | def CASE4( self, main ): |
| 357 | ''' |
| 358 | Ping test in data plane for each route |
| 359 | ''' |
| 360 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
| 361 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 362 | hosts=["host64514", "host64515", "host64516"], |
| 363 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 364 | |
| 365 | |
| 366 | def CASE5( self, main ): |
| 367 | ''' |
| 368 | Cut links to peers one by one, check routes/intents |
| 369 | ''' |
| 370 | import time |
| 371 | main.case( "Bring down links and check routes/intents" ) |
| 372 | main.step( "Bring down the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 373 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 374 | OPTION="down" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 375 | utilities.assert_equals( expect=main.TRUE, |
| 376 | actual=linkResult1, |
| 377 | onpass="Bring down link succeeded!", |
| 378 | onfail="Bring down link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 379 | |
| 380 | if linkResult1 == main.TRUE: |
| 381 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 382 | main.Functions.checkRouteNum( main, 2 ) |
| 383 | main.Functions.checkM2SintentNum( main, 2 ) |
| 384 | else: |
| 385 | main.log.error( "Bring down link failed!" ) |
| 386 | main.cleanup() |
| 387 | main.exit() |
| 388 | |
| 389 | main.step( "Bring down the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 390 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 391 | OPTION="down" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 392 | utilities.assert_equals( expect=main.TRUE, |
| 393 | actual=linkResult2, |
| 394 | onpass="Bring down link succeeded!", |
| 395 | onfail="Bring down link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 396 | if linkResult2 == main.TRUE: |
| 397 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 398 | main.Functions.checkRouteNum( main, 1 ) |
| 399 | main.Functions.checkM2SintentNum( main, 1 ) |
| 400 | else: |
| 401 | main.log.error( "Bring down link failed!" ) |
| 402 | main.cleanup() |
| 403 | main.exit() |
| 404 | |
| 405 | main.step( "Bring down the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 406 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 407 | OPTION="down" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 408 | utilities.assert_equals( expect=main.TRUE, |
| 409 | actual=linkResult3, |
| 410 | onpass="Bring down link succeeded!", |
| 411 | onfail="Bring down link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 412 | if linkResult3 == main.TRUE: |
| 413 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 414 | main.Functions.checkRouteNum( main, 0 ) |
| 415 | main.Functions.checkM2SintentNum( main, 0 ) |
| 416 | else: |
| 417 | main.log.error( "Bring down link failed!" ) |
| 418 | main.cleanup() |
| 419 | main.exit() |
| 420 | |
| 421 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 422 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 423 | main.FALSE, |
| 424 | kwargs={'isPENDING':False}, |
| 425 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 426 | utilities.assert_equals( expect=main.TRUE, |
| 427 | actual=flowCheck, |
| 428 | onpass="Flow status is correct!", |
| 429 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 430 | |
| 431 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 432 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 433 | peers=["peer64514", "peer64515", "peer64516"], |
| 434 | expectAllSuccess=False ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 435 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 436 | hosts=["host64514", "host64515", "host64516"], |
| 437 | expectAllSuccess=False ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 438 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 439 | def CASE6( self, main ): |
| 440 | ''' |
| 441 | Recover links to peers one by one, check routes/intents |
| 442 | ''' |
| 443 | import time |
| 444 | main.case( "Bring up links and check routes/intents" ) |
| 445 | main.step( "Bring up the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 446 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 447 | OPTION="up" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 448 | utilities.assert_equals( expect=main.TRUE, |
| 449 | actual=linkResult1, |
| 450 | onpass="Bring up link succeeded!", |
| 451 | onfail="Bring up link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 452 | if linkResult1 == main.TRUE: |
| 453 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 454 | main.Functions.checkRouteNum( main, 1 ) |
| 455 | main.Functions.checkM2SintentNum( main, 1 ) |
| 456 | else: |
| 457 | main.log.error( "Bring up link failed!" ) |
| 458 | main.cleanup() |
| 459 | main.exit() |
| 460 | |
| 461 | main.step( "Bring up the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 462 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 463 | OPTION="up" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 464 | utilities.assert_equals( expect=main.TRUE, |
| 465 | actual=linkResult2, |
| 466 | onpass="Bring up link succeeded!", |
| 467 | onfail="Bring up link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 468 | if linkResult2 == main.TRUE: |
| 469 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 470 | main.Functions.checkRouteNum( main, 2 ) |
| 471 | main.Functions.checkM2SintentNum( main, 2 ) |
| 472 | else: |
| 473 | main.log.error( "Bring up link failed!" ) |
| 474 | main.cleanup() |
| 475 | main.exit() |
| 476 | |
| 477 | main.step( "Bring up the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 478 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 479 | OPTION="up" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 480 | utilities.assert_equals( expect=main.TRUE, |
| 481 | actual=linkResult3, |
| 482 | onpass="Bring up link succeeded!", |
| 483 | onfail="Bring up link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 484 | if linkResult3 == main.TRUE: |
| 485 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 486 | main.Functions.checkRouteNum( main, 3 ) |
| 487 | main.Functions.checkM2SintentNum( main, 3 ) |
| 488 | else: |
| 489 | main.log.error( "Bring up link failed!" ) |
| 490 | main.cleanup() |
| 491 | main.exit() |
| 492 | |
| 493 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 494 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 495 | main.FALSE, |
| 496 | kwargs={'isPENDING':False}, |
| 497 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 498 | utilities.assert_equals( expect=main.TRUE, |
| 499 | actual=flowCheck, |
| 500 | onpass="Flow status is correct!", |
| 501 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 502 | |
| 503 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 504 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 505 | peers=["peer64514", "peer64515", "peer64516"], |
| 506 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 507 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 508 | hosts=["host64514", "host64515", "host64516"], |
| 509 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 510 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 511 | def CASE7( self, main ): |
| 512 | ''' |
| 513 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
| 514 | ''' |
| 515 | import time |
| 516 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
| 517 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 518 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 519 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 520 | onpass="Stopping switch succeeded!", |
| 521 | onfail="Stopping switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 522 | |
| 523 | if result == main.TRUE: |
| 524 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 525 | main.Functions.checkRouteNum( main, 2 ) |
| 526 | main.Functions.checkM2SintentNum( main, 2 ) |
| 527 | main.Functions.checkP2PintentNum( main, 12 * 2 ) |
| 528 | else: |
| 529 | main.log.error( "Stopping switch failed!" ) |
| 530 | main.cleanup() |
| 531 | main.exit() |
| 532 | |
| 533 | main.step( "Check ping between hosts behind BGP peers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 534 | result1 = main.Mininet.pingHost( src="host64514", target="host64515" ) |
| 535 | result2 = main.Mininet.pingHost( src="host64515", target="host64516" ) |
| 536 | result3 = main.Mininet.pingHost( src="host64514", target="host64516" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 537 | |
| 538 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 539 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 540 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 541 | onpass="Ping test result is correct", |
| 542 | onfail="Ping test result is wrong" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 543 | |
| 544 | if pingResult1 == False: |
| 545 | main.cleanup() |
| 546 | main.exit() |
| 547 | |
| 548 | main.step( "Check ping between BGP peers and speaker1" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 549 | result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" ) |
| 550 | result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" ) |
| 551 | result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 552 | |
| 553 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 554 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 555 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 556 | onpass="Speaker1 ping peers successful", |
| 557 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 558 | |
| 559 | if pingResult2 == False: |
| 560 | main.cleanup() |
| 561 | main.exit() |
| 562 | |
| 563 | main.step( "Check ping between BGP peers and speaker2" ) |
| 564 | # TODO |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 565 | result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 ) |
| 566 | result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 ) |
| 567 | result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 568 | |
| 569 | pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \ |
| 570 | and ( result9 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 571 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 572 | onpass="Speaker2 ping peers successful", |
| 573 | onfail="Speaker2 ping peers NOT successful" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 574 | |
| 575 | if pingResult3 == False: |
| 576 | main.cleanup() |
| 577 | main.exit() |
| 578 | |
| 579 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 580 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 581 | main.FALSE, |
| 582 | kwargs={'isPENDING':False}, |
| 583 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 584 | utilities.assert_equals( expect=main.TRUE, |
| 585 | actual=flowCheck, |
| 586 | onpass="Flow status is correct!", |
| 587 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 588 | |
| 589 | def CASE8( self, main ): |
| 590 | ''' |
| 591 | Bring up the edge switch (sw32) which was shut down in CASE7, |
| 592 | check P-2-P and M-2-S intents, ping test |
| 593 | ''' |
| 594 | import time |
| 595 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
| 596 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 597 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 598 | utilities.assert_equals( expect=main.TRUE, |
| 599 | actual=result1, |
| 600 | onpass="Starting switch succeeded!", |
| 601 | onfail="Starting switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 602 | |
| 603 | result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 604 | utilities.assert_equals( expect=main.TRUE, |
| 605 | actual=result2, |
| 606 | onpass="Connect switch to ONOS succeeded!", |
| 607 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 608 | |
| 609 | if result1 and result2: |
| 610 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 611 | main.Functions.checkRouteNum( main, 3 ) |
| 612 | main.Functions.checkM2SintentNum( main, 3 ) |
| 613 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 614 | else: |
| 615 | main.log.error( "Starting switch failed!" ) |
| 616 | main.cleanup() |
| 617 | main.exit() |
| 618 | |
| 619 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 620 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 621 | main.FALSE, |
| 622 | kwargs={'isPENDING':False}, |
| 623 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 624 | utilities.assert_equals( expect=main.TRUE, |
| 625 | actual=flowCheck, |
| 626 | onpass="Flow status is correct!", |
| 627 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 628 | |
| 629 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 630 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 631 | peers=["peer64514", "peer64515", "peer64516"], |
| 632 | expectAllSuccess=True ) |
| 633 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 634 | peers=[peer64514, peer64515, peer64516], |
| 635 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 636 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 637 | hosts=["host64514", "host64515", "host64516"], |
| 638 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 639 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 640 | def CASE9( self, main ): |
| 641 | ''' |
| 642 | Bring down a switch in best path, check: |
| 643 | route number, P2P intent number, M2S intent number, ping test |
| 644 | ''' |
| 645 | main.case( "Stop sw11 located in best path, \ |
| 646 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 647 | |
| 648 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
| 649 | main.Functions.checkFlowNum( main, "sw11", 19 ) |
| 650 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
| 651 | main.Functions.checkFlowNum( main, "sw7", 3 ) |
| 652 | main.log.info( main.Mininet.checkFlows( "sw11" ) ) |
| 653 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 654 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 655 | |
| 656 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 657 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 658 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 659 | onpass="Stopping switch succeeded!", |
| 660 | onfail="Stopping switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 661 | if result: |
| 662 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 663 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 664 | main.Functions.checkRouteNum( main, 3 ) |
| 665 | main.Functions.checkM2SintentNum( main, 3 ) |
| 666 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 667 | else: |
| 668 | main.log.error( "Stopping switch failed!" ) |
| 669 | main.cleanup() |
| 670 | main.exit() |
| 671 | |
| 672 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 673 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 674 | main.FALSE, |
| 675 | kwargs={'isPENDING':False}, |
| 676 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 677 | utilities.assert_equals( expect=main.TRUE, |
| 678 | actual=flowCheck, |
| 679 | onpass="Flow status is correct!", |
| 680 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 681 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 682 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 683 | peers=["peer64514", "peer64515", "peer64516"], |
| 684 | expectAllSuccess=True ) |
| 685 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 686 | peers=[peer64514, peer64515, peer64516], |
| 687 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 688 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 689 | hosts=["host64514", "host64515", "host64516"], |
| 690 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 691 | |
| 692 | |
| 693 | def CASE10( self, main ): |
| 694 | ''' |
| 695 | Bring up the switch which was stopped in CASE9, check: |
| 696 | route number, P2P intent number, M2S intent number, ping test |
| 697 | ''' |
| 698 | main.case( "Start sw11 which was stopped in CASE9, \ |
| 699 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 700 | |
| 701 | main.log.info( "Check the flow status before starting sw11" ) |
| 702 | main.Functions.checkFlowNum( main, "sw1", 17 ) |
| 703 | main.Functions.checkFlowNum( main, "sw7", 5 ) |
| 704 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 705 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 706 | |
| 707 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 708 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 709 | utilities.assert_equals( expect=main.TRUE, actual=result1, |
| 710 | onpass="Starting switch succeeded!", |
| 711 | onfail="Starting switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 712 | result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 713 | utilities.assert_equals( expect=main.TRUE, actual=result2, |
| 714 | onpass="Connect switch to ONOS succeeded!", |
| 715 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 716 | if result1 and result2: |
| 717 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 718 | main.Functions.checkRouteNum( main, 3 ) |
| 719 | main.Functions.checkM2SintentNum( main, 3 ) |
| 720 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 721 | |
| 722 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 723 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 724 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
| 725 | else: |
| 726 | main.log.error( "Starting switch failed!" ) |
| 727 | main.cleanup() |
| 728 | main.exit() |
| 729 | |
| 730 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 731 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 732 | main.FALSE, |
| 733 | kwargs={'isPENDING':False}, |
| 734 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 735 | utilities.assert_equals( expect=main.TRUE, |
| 736 | actual=flowCheck, |
| 737 | onpass="Flow status is correct!", |
| 738 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 739 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 740 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 741 | peers=["peer64514", "peer64515", "peer64516"], |
| 742 | expectAllSuccess=True ) |
| 743 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 744 | peers=[peer64514, peer64515, peer64516], |
| 745 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 746 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 747 | hosts=["host64514", "host64515", "host64516"], |
| 748 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 749 | |
| 750 | |
| 751 | def CASE11(self, main): |
| 752 | import time |
| 753 | main.case( "Kill speaker1, check:\ |
| 754 | route number, P2P intent number, M2S intent number, ping test" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 755 | main.log.info( "Check network status before killing speaker1" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 756 | main.Functions.checkRouteNum( main, 3 ) |
| 757 | main.Functions.checkM2SintentNum( main, 3 ) |
| 758 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 759 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 760 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 761 | main.FALSE, |
| 762 | kwargs={'isPENDING':False}, |
| 763 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 764 | utilities.assert_equals( expect=main.TRUE, |
| 765 | actual=flowCheck, |
| 766 | onpass="Flow status is correct!", |
| 767 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 768 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 769 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 770 | peers=["peer64514", "peer64515", "peer64516"], |
| 771 | expectAllSuccess=True ) |
| 772 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 773 | peers=[peer64514, peer64515, peer64516], |
| 774 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 775 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 776 | hosts=["host64514", "host64515", "host64516"], |
| 777 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 778 | |
| 779 | main.step( "Kill speaker1" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 780 | command1 = "ps -e | grep bgp -c" |
| 781 | result1 = main.Mininet.node( "root", command1 ) |
| 782 | |
| 783 | # The total BGP daemon number in this test environment is 5. |
| 784 | if "5" in result1: |
| 785 | main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" ) |
| 786 | else: |
| 787 | main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" ) |
| 788 | main.log.info( result1 ) |
| 789 | |
| 790 | command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`" |
| 791 | result2 = main.Mininet.node( "root", command2 ) |
| 792 | |
| 793 | result3 = main.Mininet.node( "root", command1 ) |
| 794 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 795 | utilities.assert_equals( expect=True, |
| 796 | actual=( "4" in result3 ), |
| 797 | onpass="Kill speaker1 succeeded", |
| 798 | onfail="Kill speaker1 failed" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 799 | if ( "4" not in result3 ) : |
| 800 | main.log.info( result3 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 801 | main.cleanup() |
| 802 | main.exit() |
| 803 | |
| 804 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 805 | main.Functions.checkRouteNum( main, 3 ) |
| 806 | main.Functions.checkM2SintentNum( main, 3 ) |
| 807 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 808 | |
| 809 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 810 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 811 | main.FALSE, |
| 812 | kwargs={'isPENDING':False}, |
| 813 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 814 | utilities.assert_equals( expect=main.TRUE, |
| 815 | actual=flowCheck, |
| 816 | onpass="Flow status is correct!", |
| 817 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 818 | |
| 819 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 820 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 821 | peers=["peer64514", "peer64515", "peer64516"], |
| 822 | expectAllSuccess=False ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 823 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 824 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 825 | peers=[peer64514, peer64515, peer64516], |
| 826 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 827 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 828 | hosts=["host64514", "host64515", "host64516"], |
| 829 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 830 | |
| 831 | |
| 832 | def CASE12( self, main ): |
| 833 | import time |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 834 | import json |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 835 | main.case( "Bring down leader ONOS node, check: \ |
| 836 | route number, P2P intent number, M2S intent number, ping test" ) |
| 837 | main.step( "Find out ONOS leader node" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 838 | result = main.ONOScli1.leaders() |
pingping-lin | 3f932a7 | 2015-10-09 16:44:50 -0700 | [diff] [blame] | 839 | jsonResult = json.loads( result ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 840 | leaderIP = "" |
| 841 | for entry in jsonResult: |
| 842 | if entry["topic"] == "org.onosproject.sdnip": |
| 843 | leaderIP = entry["leader"] |
| 844 | main.log.info( "leaderIP is: " ) |
| 845 | main.log.info( leaderIP ) |
| 846 | |
| 847 | main.step( "Uninstall ONOS/SDN-IP leader node" ) |
| 848 | if leaderIP == ONOS1Ip: |
| 849 | uninstallResult = main.ONOSbench.onosStop( ONOS1Ip ) |
| 850 | elif leaderIP == ONOS2Ip: |
| 851 | uninstallResult = main.ONOSbench.onosStop( ONOS2Ip ) |
| 852 | else: |
| 853 | uninstallResult = main.ONOSbench.onosStop( ONOS3Ip ) |
| 854 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 855 | utilities.assert_equals( expect=main.TRUE, |
| 856 | actual=uninstallResult, |
| 857 | onpass="Uninstall ONOS leader succeeded", |
| 858 | onfail="Uninstall ONOS leader failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 859 | if uninstallResult != main.TRUE: |
| 860 | main.cleanup() |
| 861 | main.exit() |
| 862 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 863 | |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 864 | if leaderIP == ONOS1Ip: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 865 | main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" ) |
| 866 | main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" ) |
| 867 | main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 868 | |
| 869 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 870 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 871 | main.FALSE, |
| 872 | kwargs={'isPENDING':False}, |
| 873 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 874 | utilities.assert_equals( expect=main.TRUE, |
| 875 | actual=flowCheck, |
| 876 | onpass="Flow status is correct!", |
| 877 | onfail="Flow status is wrong!" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 878 | else: |
| 879 | main.Functions.checkRouteNum( main, 3 ) |
| 880 | main.Functions.checkM2SintentNum( main, 3 ) |
| 881 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 882 | |
| 883 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 884 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 885 | main.FALSE, |
| 886 | kwargs={'isPENDING':False}, |
| 887 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 888 | utilities.assert_equals( expect=main.TRUE, |
| 889 | actual=flowCheck, |
| 890 | onpass="Flow status is correct!", |
| 891 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 892 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 893 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 894 | peers=["peer64514", "peer64515", "peer64516"], |
| 895 | expectAllSuccess=True ) |
| 896 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 897 | peers=[peer64514, peer64515, peer64516], |
| 898 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 899 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 900 | hosts=["host64514", "host64515", "host64516"], |
| 901 | expectAllSuccess=True ) |