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