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'] ) ) |
| 311 | allRoutesActual = \ |
| 312 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 313 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 314 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 315 | main.log.info( "Routes expected:" ) |
| 316 | main.log.info( allRoutesStrExpected ) |
| 317 | main.log.info( "Routes get from ONOS CLI:" ) |
| 318 | main.log.info( allRoutesStrActual ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 319 | utilities.assert_equals( expect=allRoutesStrExpected, |
| 320 | actual=allRoutesStrActual, |
| 321 | onpass="Routes are correct!", |
| 322 | onfail="Routes are wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 323 | |
| 324 | main.step( "Check M2S intents installed" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 325 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 326 | routeIntentsActualNum = \ |
| 327 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 328 | routeIntentsExpectedNum = 3 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 329 | if routeIntentsActualNum != routeIntentsExpectedNum: |
| 330 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 331 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 332 | routeIntentsActualNum = \ |
| 333 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 334 | |
| 335 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 336 | main.log.info( routeIntentsExpectedNum ) |
| 337 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 338 | main.log.info( routeIntentsActualNum ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 339 | utilities.assert_equals( expect=routeIntentsExpectedNum, |
| 340 | actual=routeIntentsActualNum, |
| 341 | onpass="MultiPointToSinglePoint Intent Num is correct!", |
| 342 | onfail="MultiPointToSinglePoint Intent Num is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 343 | |
| 344 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 345 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 346 | main.FALSE, |
| 347 | kwargs={'isPENDING':False}, |
| 348 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 349 | utilities.assert_equals( expect=main.TRUE, |
| 350 | actual=flowCheck, |
| 351 | onpass="Flow status is correct!", |
| 352 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 353 | |
| 354 | |
| 355 | def CASE4( self, main ): |
| 356 | ''' |
| 357 | Ping test in data plane for each route |
| 358 | ''' |
| 359 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
| 360 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 361 | hosts=["host64514", "host64515", "host64516"], |
| 362 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 363 | |
| 364 | |
| 365 | def CASE5( self, main ): |
| 366 | ''' |
| 367 | Cut links to peers one by one, check routes/intents |
| 368 | ''' |
| 369 | import time |
| 370 | main.case( "Bring down links and check routes/intents" ) |
| 371 | main.step( "Bring down the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 372 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 373 | OPTION="down" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 374 | utilities.assert_equals( expect=main.TRUE, |
| 375 | actual=linkResult1, |
| 376 | onpass="Bring down link succeeded!", |
| 377 | onfail="Bring down link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 378 | |
| 379 | if linkResult1 == main.TRUE: |
| 380 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 381 | main.Functions.checkRouteNum( main, 2 ) |
| 382 | main.Functions.checkM2SintentNum( main, 2 ) |
| 383 | else: |
| 384 | main.log.error( "Bring down link failed!" ) |
| 385 | main.cleanup() |
| 386 | main.exit() |
| 387 | |
| 388 | main.step( "Bring down the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 389 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 390 | OPTION="down" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 391 | utilities.assert_equals( expect=main.TRUE, |
| 392 | actual=linkResult2, |
| 393 | onpass="Bring down link succeeded!", |
| 394 | onfail="Bring down link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 395 | if linkResult2 == main.TRUE: |
| 396 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 397 | main.Functions.checkRouteNum( main, 1 ) |
| 398 | main.Functions.checkM2SintentNum( main, 1 ) |
| 399 | else: |
| 400 | main.log.error( "Bring down link failed!" ) |
| 401 | main.cleanup() |
| 402 | main.exit() |
| 403 | |
| 404 | main.step( "Bring down the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 405 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 406 | OPTION="down" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 407 | utilities.assert_equals( expect=main.TRUE, |
| 408 | actual=linkResult3, |
| 409 | onpass="Bring down link succeeded!", |
| 410 | onfail="Bring down link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 411 | if linkResult3 == main.TRUE: |
| 412 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 413 | main.Functions.checkRouteNum( main, 0 ) |
| 414 | main.Functions.checkM2SintentNum( main, 0 ) |
| 415 | else: |
| 416 | main.log.error( "Bring down link failed!" ) |
| 417 | main.cleanup() |
| 418 | main.exit() |
| 419 | |
| 420 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 421 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 422 | main.FALSE, |
| 423 | kwargs={'isPENDING':False}, |
| 424 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 425 | utilities.assert_equals( expect=main.TRUE, |
| 426 | actual=flowCheck, |
| 427 | onpass="Flow status is correct!", |
| 428 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 429 | |
| 430 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 431 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 432 | peers=["peer64514", "peer64515", "peer64516"], |
| 433 | expectAllSuccess=False ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 434 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 435 | hosts=["host64514", "host64515", "host64516"], |
| 436 | expectAllSuccess=False ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 437 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 438 | def CASE6( self, main ): |
| 439 | ''' |
| 440 | Recover links to peers one by one, check routes/intents |
| 441 | ''' |
| 442 | import time |
| 443 | main.case( "Bring up links and check routes/intents" ) |
| 444 | main.step( "Bring up the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 445 | linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514", |
| 446 | OPTION="up" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 447 | utilities.assert_equals( expect=main.TRUE, |
| 448 | actual=linkResult1, |
| 449 | onpass="Bring up link succeeded!", |
| 450 | onfail="Bring up link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 451 | if linkResult1 == main.TRUE: |
| 452 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 453 | main.Functions.checkRouteNum( main, 1 ) |
| 454 | main.Functions.checkM2SintentNum( main, 1 ) |
| 455 | else: |
| 456 | main.log.error( "Bring up link failed!" ) |
| 457 | main.cleanup() |
| 458 | main.exit() |
| 459 | |
| 460 | main.step( "Bring up the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 461 | linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515", |
| 462 | OPTION="up" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 463 | utilities.assert_equals( expect=main.TRUE, |
| 464 | actual=linkResult2, |
| 465 | onpass="Bring up link succeeded!", |
| 466 | onfail="Bring up link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 467 | if linkResult2 == main.TRUE: |
| 468 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 469 | main.Functions.checkRouteNum( main, 2 ) |
| 470 | main.Functions.checkM2SintentNum( main, 2 ) |
| 471 | else: |
| 472 | main.log.error( "Bring up link failed!" ) |
| 473 | main.cleanup() |
| 474 | main.exit() |
| 475 | |
| 476 | main.step( "Bring up the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 477 | linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516", |
| 478 | OPTION="up" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 479 | utilities.assert_equals( expect=main.TRUE, |
| 480 | actual=linkResult3, |
| 481 | onpass="Bring up link succeeded!", |
| 482 | onfail="Bring up link failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 483 | if linkResult3 == main.TRUE: |
| 484 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 485 | main.Functions.checkRouteNum( main, 3 ) |
| 486 | main.Functions.checkM2SintentNum( main, 3 ) |
| 487 | else: |
| 488 | main.log.error( "Bring up link failed!" ) |
| 489 | main.cleanup() |
| 490 | main.exit() |
| 491 | |
| 492 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 493 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 494 | main.FALSE, |
| 495 | kwargs={'isPENDING':False}, |
| 496 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 497 | utilities.assert_equals( expect=main.TRUE, |
| 498 | actual=flowCheck, |
| 499 | onpass="Flow status is correct!", |
| 500 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 501 | |
| 502 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 503 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 504 | peers=["peer64514", "peer64515", "peer64516"], |
| 505 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 506 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 507 | hosts=["host64514", "host64515", "host64516"], |
| 508 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 509 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 510 | def CASE7( self, main ): |
| 511 | ''' |
| 512 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
| 513 | ''' |
| 514 | import time |
| 515 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
| 516 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 517 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 518 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 519 | onpass="Stopping switch succeeded!", |
| 520 | onfail="Stopping switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 521 | |
| 522 | if result == main.TRUE: |
| 523 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 524 | main.Functions.checkRouteNum( main, 2 ) |
| 525 | main.Functions.checkM2SintentNum( main, 2 ) |
| 526 | main.Functions.checkP2PintentNum( main, 12 * 2 ) |
| 527 | else: |
| 528 | main.log.error( "Stopping switch failed!" ) |
| 529 | main.cleanup() |
| 530 | main.exit() |
| 531 | |
| 532 | main.step( "Check ping between hosts behind BGP peers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 533 | result1 = main.Mininet.pingHost( src="host64514", target="host64515" ) |
| 534 | result2 = main.Mininet.pingHost( src="host64515", target="host64516" ) |
| 535 | result3 = main.Mininet.pingHost( src="host64514", target="host64516" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 536 | |
| 537 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 538 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 539 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 540 | onpass="Ping test result is correct", |
| 541 | onfail="Ping test result is wrong" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 542 | |
| 543 | if pingResult1 == False: |
| 544 | main.cleanup() |
| 545 | main.exit() |
| 546 | |
| 547 | main.step( "Check ping between BGP peers and speaker1" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 548 | result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" ) |
| 549 | result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" ) |
| 550 | result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 551 | |
| 552 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 553 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 554 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 555 | onpass="Speaker1 ping peers successful", |
| 556 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 557 | |
| 558 | if pingResult2 == False: |
| 559 | main.cleanup() |
| 560 | main.exit() |
| 561 | |
| 562 | main.step( "Check ping between BGP peers and speaker2" ) |
| 563 | # TODO |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 564 | result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 ) |
| 565 | result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 ) |
| 566 | result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 567 | |
| 568 | pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \ |
| 569 | and ( result9 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 570 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 571 | onpass="Speaker2 ping peers successful", |
| 572 | onfail="Speaker2 ping peers NOT successful" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 573 | |
| 574 | if pingResult3 == False: |
| 575 | main.cleanup() |
| 576 | main.exit() |
| 577 | |
| 578 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 579 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 580 | main.FALSE, |
| 581 | kwargs={'isPENDING':False}, |
| 582 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 583 | utilities.assert_equals( expect=main.TRUE, |
| 584 | actual=flowCheck, |
| 585 | onpass="Flow status is correct!", |
| 586 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 587 | |
| 588 | def CASE8( self, main ): |
| 589 | ''' |
| 590 | Bring up the edge switch (sw32) which was shut down in CASE7, |
| 591 | check P-2-P and M-2-S intents, ping test |
| 592 | ''' |
| 593 | import time |
| 594 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
| 595 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 596 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 597 | utilities.assert_equals( expect=main.TRUE, |
| 598 | actual=result1, |
| 599 | onpass="Starting switch succeeded!", |
| 600 | onfail="Starting switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 601 | |
| 602 | result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 603 | utilities.assert_equals( expect=main.TRUE, |
| 604 | actual=result2, |
| 605 | onpass="Connect switch to ONOS succeeded!", |
| 606 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 607 | |
| 608 | if result1 and result2: |
| 609 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 610 | main.Functions.checkRouteNum( main, 3 ) |
| 611 | main.Functions.checkM2SintentNum( main, 3 ) |
| 612 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 613 | else: |
| 614 | main.log.error( "Starting switch failed!" ) |
| 615 | main.cleanup() |
| 616 | main.exit() |
| 617 | |
| 618 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 619 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 620 | main.FALSE, |
| 621 | kwargs={'isPENDING':False}, |
| 622 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 623 | utilities.assert_equals( expect=main.TRUE, |
| 624 | actual=flowCheck, |
| 625 | onpass="Flow status is correct!", |
| 626 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 627 | |
| 628 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 629 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 630 | peers=["peer64514", "peer64515", "peer64516"], |
| 631 | expectAllSuccess=True ) |
| 632 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 633 | peers=[peer64514, peer64515, peer64516], |
| 634 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 635 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 636 | hosts=["host64514", "host64515", "host64516"], |
| 637 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 638 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 639 | def CASE9( self, main ): |
| 640 | ''' |
| 641 | Bring down a switch in best path, check: |
| 642 | route number, P2P intent number, M2S intent number, ping test |
| 643 | ''' |
| 644 | main.case( "Stop sw11 located in best path, \ |
| 645 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 646 | |
| 647 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
| 648 | main.Functions.checkFlowNum( main, "sw11", 19 ) |
| 649 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
| 650 | main.Functions.checkFlowNum( main, "sw7", 3 ) |
| 651 | main.log.info( main.Mininet.checkFlows( "sw11" ) ) |
| 652 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 653 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 654 | |
| 655 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 656 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 657 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 658 | onpass="Stopping switch succeeded!", |
| 659 | onfail="Stopping switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 660 | if result: |
| 661 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 662 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 663 | main.Functions.checkRouteNum( main, 3 ) |
| 664 | main.Functions.checkM2SintentNum( main, 3 ) |
| 665 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 666 | else: |
| 667 | main.log.error( "Stopping switch failed!" ) |
| 668 | main.cleanup() |
| 669 | main.exit() |
| 670 | |
| 671 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 672 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 673 | main.FALSE, |
| 674 | kwargs={'isPENDING':False}, |
| 675 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 676 | utilities.assert_equals( expect=main.TRUE, |
| 677 | actual=flowCheck, |
| 678 | onpass="Flow status is correct!", |
| 679 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 680 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 681 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 682 | peers=["peer64514", "peer64515", "peer64516"], |
| 683 | expectAllSuccess=True ) |
| 684 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 685 | peers=[peer64514, peer64515, peer64516], |
| 686 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 687 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 688 | hosts=["host64514", "host64515", "host64516"], |
| 689 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 690 | |
| 691 | |
| 692 | def CASE10( self, main ): |
| 693 | ''' |
| 694 | Bring up the switch which was stopped in CASE9, check: |
| 695 | route number, P2P intent number, M2S intent number, ping test |
| 696 | ''' |
| 697 | main.case( "Start sw11 which was stopped in CASE9, \ |
| 698 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 699 | |
| 700 | main.log.info( "Check the flow status before starting sw11" ) |
| 701 | main.Functions.checkFlowNum( main, "sw1", 17 ) |
| 702 | main.Functions.checkFlowNum( main, "sw7", 5 ) |
| 703 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 704 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 705 | |
| 706 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 707 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 708 | utilities.assert_equals( expect=main.TRUE, actual=result1, |
| 709 | onpass="Starting switch succeeded!", |
| 710 | onfail="Starting switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 711 | result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 712 | utilities.assert_equals( expect=main.TRUE, actual=result2, |
| 713 | onpass="Connect switch to ONOS succeeded!", |
| 714 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 715 | if result1 and result2: |
| 716 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 717 | main.Functions.checkRouteNum( main, 3 ) |
| 718 | main.Functions.checkM2SintentNum( main, 3 ) |
| 719 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 720 | |
| 721 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 722 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 723 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
| 724 | else: |
| 725 | main.log.error( "Starting switch failed!" ) |
| 726 | main.cleanup() |
| 727 | main.exit() |
| 728 | |
| 729 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 730 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 731 | main.FALSE, |
| 732 | kwargs={'isPENDING':False}, |
| 733 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 734 | utilities.assert_equals( expect=main.TRUE, |
| 735 | actual=flowCheck, |
| 736 | onpass="Flow status is correct!", |
| 737 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 738 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 739 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 740 | peers=["peer64514", "peer64515", "peer64516"], |
| 741 | expectAllSuccess=True ) |
| 742 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 743 | peers=[peer64514, peer64515, peer64516], |
| 744 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 745 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 746 | hosts=["host64514", "host64515", "host64516"], |
| 747 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 748 | |
| 749 | |
| 750 | def CASE11(self, main): |
| 751 | import time |
| 752 | main.case( "Kill speaker1, check:\ |
| 753 | route number, P2P intent number, M2S intent number, ping test" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 754 | main.log.info( "Check network status before killing speaker1" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 755 | main.Functions.checkRouteNum( main, 3 ) |
| 756 | main.Functions.checkM2SintentNum( main, 3 ) |
| 757 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 758 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 759 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 760 | main.FALSE, |
| 761 | kwargs={'isPENDING':False}, |
| 762 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 763 | utilities.assert_equals( expect=main.TRUE, |
| 764 | actual=flowCheck, |
| 765 | onpass="Flow status is correct!", |
| 766 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 767 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 768 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 769 | peers=["peer64514", "peer64515", "peer64516"], |
| 770 | expectAllSuccess=True ) |
| 771 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 772 | peers=[peer64514, peer64515, peer64516], |
| 773 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 774 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 775 | hosts=["host64514", "host64515", "host64516"], |
| 776 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 777 | |
| 778 | main.step( "Kill speaker1" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 779 | command1 = "ps -e | grep bgp -c" |
| 780 | result1 = main.Mininet.node( "root", command1 ) |
| 781 | |
| 782 | # The total BGP daemon number in this test environment is 5. |
| 783 | if "5" in result1: |
| 784 | main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" ) |
| 785 | else: |
| 786 | main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" ) |
| 787 | main.log.info( result1 ) |
| 788 | |
| 789 | command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`" |
| 790 | result2 = main.Mininet.node( "root", command2 ) |
| 791 | |
| 792 | result3 = main.Mininet.node( "root", command1 ) |
| 793 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 794 | utilities.assert_equals( expect=True, |
| 795 | actual=( "4" in result3 ), |
| 796 | onpass="Kill speaker1 succeeded", |
| 797 | onfail="Kill speaker1 failed" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 798 | if ( "4" not in result3 ) : |
| 799 | main.log.info( result3 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 800 | main.cleanup() |
| 801 | main.exit() |
| 802 | |
| 803 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 804 | main.Functions.checkRouteNum( main, 3 ) |
| 805 | main.Functions.checkM2SintentNum( main, 3 ) |
| 806 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 807 | |
| 808 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 809 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 810 | main.FALSE, |
| 811 | kwargs={'isPENDING':False}, |
| 812 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 813 | utilities.assert_equals( expect=main.TRUE, |
| 814 | actual=flowCheck, |
| 815 | onpass="Flow status is correct!", |
| 816 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 817 | |
| 818 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 819 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 820 | peers=["peer64514", "peer64515", "peer64516"], |
| 821 | expectAllSuccess=False ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 822 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 823 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 824 | peers=[peer64514, peer64515, peer64516], |
| 825 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 826 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 827 | hosts=["host64514", "host64515", "host64516"], |
| 828 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 829 | |
| 830 | |
| 831 | def CASE12( self, main ): |
| 832 | import time |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 833 | import json |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 834 | main.case( "Bring down leader ONOS node, check: \ |
| 835 | route number, P2P intent number, M2S intent number, ping test" ) |
| 836 | main.step( "Find out ONOS leader node" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 837 | result = main.ONOScli1.leaders() |
pingping-lin | 3f932a7 | 2015-10-09 16:44:50 -0700 | [diff] [blame] | 838 | jsonResult = json.loads( result ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 839 | leaderIP = "" |
| 840 | for entry in jsonResult: |
| 841 | if entry["topic"] == "org.onosproject.sdnip": |
| 842 | leaderIP = entry["leader"] |
| 843 | main.log.info( "leaderIP is: " ) |
| 844 | main.log.info( leaderIP ) |
| 845 | |
| 846 | main.step( "Uninstall ONOS/SDN-IP leader node" ) |
| 847 | if leaderIP == ONOS1Ip: |
| 848 | uninstallResult = main.ONOSbench.onosStop( ONOS1Ip ) |
| 849 | elif leaderIP == ONOS2Ip: |
| 850 | uninstallResult = main.ONOSbench.onosStop( ONOS2Ip ) |
| 851 | else: |
| 852 | uninstallResult = main.ONOSbench.onosStop( ONOS3Ip ) |
| 853 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 854 | utilities.assert_equals( expect=main.TRUE, |
| 855 | actual=uninstallResult, |
| 856 | onpass="Uninstall ONOS leader succeeded", |
| 857 | onfail="Uninstall ONOS leader failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 858 | if uninstallResult != main.TRUE: |
| 859 | main.cleanup() |
| 860 | main.exit() |
| 861 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 862 | |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 863 | if leaderIP == ONOS1Ip: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 864 | main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" ) |
| 865 | main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" ) |
| 866 | main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 867 | |
| 868 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 869 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 870 | main.FALSE, |
| 871 | kwargs={'isPENDING':False}, |
| 872 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 873 | utilities.assert_equals( expect=main.TRUE, |
| 874 | actual=flowCheck, |
| 875 | onpass="Flow status is correct!", |
| 876 | onfail="Flow status is wrong!" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 877 | else: |
| 878 | main.Functions.checkRouteNum( main, 3 ) |
| 879 | main.Functions.checkM2SintentNum( main, 3 ) |
| 880 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 881 | |
| 882 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 883 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 884 | main.FALSE, |
| 885 | kwargs={'isPENDING':False}, |
| 886 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 887 | utilities.assert_equals( expect=main.TRUE, |
| 888 | actual=flowCheck, |
| 889 | onpass="Flow status is correct!", |
| 890 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 891 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 892 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 893 | peers=["peer64514", "peer64515", "peer64516"], |
| 894 | expectAllSuccess=True ) |
| 895 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 896 | peers=[peer64514, peer64515, peer64516], |
| 897 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 898 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 899 | hosts=["host64514", "host64515", "host64516"], |
| 900 | expectAllSuccess=True ) |