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