pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 1 | # Testing the functionality of SDN-IP with single ONOS instance |
| 2 | class USECASE_SdnipFunction_fsfw: |
| 3 | |
| 4 | def __init__( self ): |
| 5 | self.default = '' |
| 6 | global branchName |
| 7 | |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 8 | def CASE100( self, main ): |
| 9 | """ |
| 10 | Start mininet |
| 11 | """ |
| 12 | import os |
| 13 | import imp |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 14 | main.case( "Setup the Mininet testbed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 15 | main.dependencyPath = main.testDir + \ |
| 16 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 17 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 18 | |
| 19 | main.step( "Starting Mininet Topology" ) |
| 20 | topology = main.dependencyPath + main.topology |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 21 | topoResult = main.Mininet.startNet( topoFile=topology ) |
| 22 | utilities.assert_equals( expect=main.TRUE, |
| 23 | actual=topoResult, |
| 24 | onpass="Successfully loaded topology", |
| 25 | onfail="Failed to load topology" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 26 | # Exit if topology did not load properly |
| 27 | if not topoResult: |
| 28 | main.cleanup() |
| 29 | main.exit() |
pingping-lin | 1477663 | 2015-12-16 12:05:30 -0800 | [diff] [blame] | 30 | main.step( "Connect switches to FSFW" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 31 | |
| 32 | global ONOS1Ip |
| 33 | ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
pingping-lin | 8c17880 | 2015-11-30 17:25:43 -0800 | [diff] [blame] | 34 | global fsfwIp |
pingping-lin | e9107e4 | 2015-11-30 19:19:38 -0800 | [diff] [blame] | 35 | # TDOO: there is some setup sequence issue, will fix it later |
| 36 | # fsfwIp = os.getenv( main.params[ 'CTRL' ][ 'ipN' ] ) |
| 37 | fsfwIp = main.params[ 'CTRL' ][ 'fsfwIp' ] |
pingping-lin | 15fa4be | 2015-11-30 18:27:58 -0800 | [diff] [blame] | 38 | global fsfwPort |
pingping-lin | e9107e4 | 2015-11-30 19:19:38 -0800 | [diff] [blame] | 39 | fsfwPort = main.params[ 'CTRL' ][ 'fsfwPort' ] |
pingping-lin | 8c17880 | 2015-11-30 17:25:43 -0800 | [diff] [blame] | 40 | |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 41 | # connect all switches to controller |
| 42 | swResult = main.TRUE |
| 43 | for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ): |
| 44 | sw = "sw%s" % ( i ) |
pingping-lin | 15fa4be | 2015-11-30 18:27:58 -0800 | [diff] [blame] | 45 | swResult = swResult and main.Mininet.assignSwController( sw, fsfwIp, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 46 | port=fsfwPort ) |
| 47 | utilities.assert_equals( expect=main.TRUE, |
| 48 | actual=swResult, |
| 49 | onpass="Successfully connect all switches to ONOS", |
| 50 | onfail="Failed to connect all switches to ONOS" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 51 | if not swResult: |
| 52 | main.cleanup() |
| 53 | main.exit() |
| 54 | |
| 55 | main.step( "Set up tunnel from Mininet node to onos node" ) |
| 56 | forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 57 | command = 'ssh -nNT -o "PasswordAuthentication no"' |
| 58 | command += ' -o "StrictHostKeyChecking no" -l sdn' |
| 59 | command += ' -L %s %s & ' % ( forwarding1, ONOS1Ip ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 60 | |
| 61 | tunnelResult = main.TRUE |
| 62 | tunnelResult = main.Mininet.node( "root", command ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 63 | utilities.assert_equals( expect=True, |
| 64 | actual=( "PasswordAuthentication" in tunnelResult ), |
| 65 | onpass="Created tunnel succeeded", |
| 66 | onfail="Create tunnel failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 67 | if ("PasswordAuthentication" not in tunnelResult) : |
| 68 | main.cleanup() |
| 69 | main.exit() |
| 70 | |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 71 | def CASE101( self, main ): |
| 72 | """ |
| 73 | Package ONOS and install it |
| 74 | Startup sequence: |
| 75 | cell <name> |
| 76 | onos-verify-cell |
| 77 | onos-package |
| 78 | onos-install -f |
| 79 | onos-wait-for-start |
| 80 | """ |
| 81 | import json |
| 82 | import time |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 83 | import os |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 84 | from operator import eq |
| 85 | |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 86 | main.case( "Setting up ONOS environment" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 87 | |
| 88 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 89 | global ONOS1Ip |
| 90 | ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 91 | ipList = [ ONOS1Ip ] |
| 92 | |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 93 | main.step( "Copying config files" ) |
| 94 | src = os.path.dirname( main.testFile ) + "/network-cfg.json" |
| 95 | dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json" |
| 96 | status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" ) |
| 97 | utilities.assert_equals( expect=main.TRUE, |
| 98 | actual=status, |
| 99 | onpass="Copy config file succeeded", |
| 100 | onfail="Copy config file failed" ) |
| 101 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 102 | main.step( "Create cell file" ) |
| 103 | cellAppString = main.params[ 'ENV' ][ 'appString' ] |
| 104 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName, |
| 105 | main.Mininet.ip_address, |
| 106 | cellAppString, ipList ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 107 | |
| 108 | main.step( "Applying cell variable to environment" ) |
| 109 | cellResult = main.ONOSbench.setCell( cellName ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 110 | utilities.assert_equals( expect=main.TRUE, |
| 111 | actual=cellResult, |
| 112 | onpass="Set cell succeeded", |
| 113 | onfail="Set cell failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 114 | |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 115 | main.step( "Verify cell connectivity" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 116 | verifyResult = main.ONOSbench.verifyCell() |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 117 | utilities.assert_equals( expect=main.TRUE, |
| 118 | actual=verifyResult, |
| 119 | onpass="Verify cell succeeded", |
| 120 | onfail="Verify cell failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 121 | |
| 122 | branchName = main.ONOSbench.getBranchName() |
| 123 | main.log.report( "ONOS is on branch: " + branchName ) |
| 124 | |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 125 | main.step( "Uninstalling ONOS" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 126 | uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 127 | utilities.assert_equals( expect=main.TRUE, |
| 128 | actual=uninstallResult, |
| 129 | onpass="Uninstall ONOS succeeded", |
| 130 | onfail="Uninstall ONOS failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 131 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 132 | main.ONOSbench.getVersion( report=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 133 | |
| 134 | main.step( "Creating ONOS package" ) |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 135 | packageResult = main.ONOSbench.buckBuild() |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 136 | utilities.assert_equals( expect=main.TRUE, |
| 137 | actual=packageResult, |
| 138 | onpass="Package ONOS succeeded", |
| 139 | onfail="Package ONOS failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 140 | |
| 141 | main.step( "Installing ONOS package" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 142 | onos1InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 143 | node=ONOS1Ip ) |
| 144 | utilities.assert_equals( expect=main.TRUE, |
| 145 | actual=onos1InstallResult, |
| 146 | onpass="Install ONOS succeeded", |
| 147 | onfail="Install ONOS failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 148 | |
| 149 | main.step( "Checking if ONOS is up yet" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 150 | onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 ) |
| 151 | utilities.assert_equals( expect=main.TRUE, |
| 152 | actual=onos1UpResult, |
| 153 | onpass="ONOS is up", |
| 154 | onfail="ONOS is NOT up" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 155 | |
| 156 | main.step( "Checking if ONOS CLI is ready" ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 157 | cliResult = main.ONOScli1.startOnosCli( ONOS1Ip, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 158 | commandlineTimeout=100, |
| 159 | onosStartTimeout=600 ) |
| 160 | utilities.assert_equals( expect=main.TRUE, |
| 161 | actual=cliResult, |
| 162 | onpass="ONOS CLI is ready", |
| 163 | onfail="ONOS CLI is not ready" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 164 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 165 | for i in range( 10 ): |
| 166 | ready = True |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 167 | output = main.ONOScli1.summary() |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 168 | if not output: |
| 169 | ready = False |
| 170 | if ready: |
| 171 | break |
| 172 | time.sleep( 30 ) |
| 173 | utilities.assert_equals( expect=True, actual=ready, |
| 174 | onpass="ONOS summary command succeded", |
| 175 | onfail="ONOS summary command failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 176 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 177 | if not ready: |
| 178 | main.log.error( "ONOS startup failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 179 | main.cleanup() |
| 180 | main.exit() |
| 181 | |
| 182 | main.log.info( "Get links in the network" ) |
| 183 | time.sleep( int ( main.params['timers']['TopoDiscovery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 184 | summaryResult = main.ONOScli1.summary() |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 185 | linkNum = json.loads( summaryResult )[ "links" ] |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 186 | listResult = main.ONOScli1.links( jsonFormat=False ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 187 | main.log.info( listResult ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 188 | if linkNum < 100: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 189 | main.log.error( "Link number is wrong!" ) |
| 190 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 191 | listResult = main.ONOScli1.links( jsonFormat=False ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 192 | main.log.info( listResult ) |
| 193 | main.cleanup() |
| 194 | main.exit() |
| 195 | |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 196 | main.step( "Activate sdn-ip application" ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 197 | activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 198 | utilities.assert_equals( expect=main.TRUE, |
| 199 | actual=activeSDNIPresult, |
| 200 | onpass="Activate SDN-IP succeeded", |
| 201 | onfail="Activate SDN-IP failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 202 | if not activeSDNIPresult: |
| 203 | main.log.info( "Activate SDN-IP failed!" ) |
| 204 | main.cleanup() |
| 205 | main.exit() |
| 206 | |
| 207 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 208 | main.log.info( "Wait for SDN-IP to finish installing connectivity intents " + |
| 209 | "and for the BGP paths in the data plane to be ready..." ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 210 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 211 | main.log.info( "Wait for Quagga to finish delivery of all routes to each " + |
| 212 | "other and sdn-ip, plus finish installing all intents..." ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 213 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 214 | time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 215 | |
| 216 | |
| 217 | def CASE102( self, main ): |
| 218 | ''' |
| 219 | This test case is to load the methods from other Python files. |
| 220 | ''' |
| 221 | main.case( "Loading methods from other Python file" ) |
| 222 | # load the methods from other file |
| 223 | wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 224 | main.Functions = imp.load_source( wrapperFile, |
| 225 | main.dependencyPath + |
| 226 | wrapperFile + |
| 227 | ".py" ) |
| 228 | |
| 229 | |
| 230 | def CASE1( self, main ): |
| 231 | ''' |
| 232 | ping test from 3 bgp peers to BGP speaker |
| 233 | ''' |
| 234 | |
| 235 | main.case( "Ping tests between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 236 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 237 | peers=["pr64514", "pr64515", "pr64516"], |
| 238 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 239 | |
| 240 | |
| 241 | def CASE2( self, main ): |
| 242 | ''' |
| 243 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 244 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 245 | import time |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 246 | main.case( "Check point-to-point intents" ) |
| 247 | main.log.info( "There are %s BGP peers in total " |
| 248 | % main.params[ 'config' ][ 'peerNum' ] ) |
| 249 | main.step( "Check P2P intents number from ONOS CLI" ) |
| 250 | |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 251 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 252 | bgpIntentsActualNum = \ |
| 253 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 254 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 255 | if bgpIntentsActualNum != bgpIntentsExpectedNum: |
| 256 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 257 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 258 | bgpIntentsActualNum = \ |
| 259 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 260 | main.log.info( "bgpIntentsExpected num is:" ) |
| 261 | main.log.info( bgpIntentsExpectedNum ) |
| 262 | main.log.info( "bgpIntentsActual num is:" ) |
| 263 | main.log.info( bgpIntentsActualNum ) |
| 264 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 265 | expect=True, |
| 266 | actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 267 | onpass="PointToPointIntent Intent Num is correct!", |
| 268 | onfail="PointToPointIntent Intent Num is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 269 | |
| 270 | |
| 271 | def CASE3( self, main ): |
| 272 | ''' |
| 273 | routes and intents check to all BGP peers |
| 274 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 275 | import time |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 276 | main.case( "Check routes and M2S intents to all BGP peers" ) |
| 277 | |
| 278 | allRoutesExpected = [] |
| 279 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 280 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 281 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 282 | |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 283 | getRoutesResult = main.ONOScli1.routes( jsonFormat=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 284 | allRoutesActual = \ |
| 285 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 286 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 287 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 288 | if allRoutesStrActual != allRoutesStrExpected: |
| 289 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 290 | getRoutesResult = main.ONOScli1.routes( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 291 | allRoutesActual = \ |
| 292 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 293 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 294 | |
| 295 | main.step( "Check routes installed" ) |
| 296 | main.log.info( "Routes expected:" ) |
| 297 | main.log.info( allRoutesStrExpected ) |
| 298 | main.log.info( "Routes get from ONOS CLI:" ) |
| 299 | main.log.info( allRoutesStrActual ) |
| 300 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 301 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 302 | onpass="Routes are correct!", |
| 303 | onfail="Routes are wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 304 | |
| 305 | main.step( "Check M2S intents installed" ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 306 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 307 | routeIntentsActualNum = \ |
| 308 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 309 | routeIntentsExpectedNum = 3 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 310 | if routeIntentsActualNum != routeIntentsExpectedNum: |
| 311 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 312 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 313 | routeIntentsActualNum = \ |
| 314 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 315 | |
| 316 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 317 | main.log.info( routeIntentsExpectedNum ) |
| 318 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 319 | main.log.info( routeIntentsActualNum ) |
| 320 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 321 | expect=routeIntentsExpectedNum, |
| 322 | actual=routeIntentsActualNum, |
| 323 | onpass="MultiPointToSinglePoint Intent Num is correct!", |
| 324 | onfail="MultiPointToSinglePoint Intent Num is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 325 | |
| 326 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 327 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 328 | main.FALSE, |
| 329 | kwargs={'isPENDING':False}, |
| 330 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 331 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 332 | expect=main.TRUE, |
| 333 | actual=flowCheck, |
| 334 | onpass="Flow status is correct!", |
| 335 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 336 | |
| 337 | |
| 338 | def CASE4( self, main ): |
| 339 | ''' |
| 340 | Ping test in data plane for each route |
| 341 | ''' |
| 342 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
| 343 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 344 | hosts=["host64514", "host64515", "host64516"], |
| 345 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 346 | |
| 347 | |
| 348 | def CASE5( self, main ): |
| 349 | ''' |
| 350 | Cut links to peers one by one, check routes/intents |
| 351 | ''' |
| 352 | import time |
| 353 | main.case( "Bring down links and check routes/intents" ) |
| 354 | main.step( "Bring down the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 355 | linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514", |
| 356 | OPTION="down" ) |
| 357 | utilities.assertEquals( expect=main.TRUE, |
| 358 | actual=linkResult1, |
| 359 | onpass="Bring down link succeeded!", |
| 360 | onfail="Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 361 | |
| 362 | if linkResult1 == main.TRUE: |
| 363 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 364 | main.Functions.checkRouteNum( main, 2 ) |
| 365 | main.Functions.checkM2SintentNum( main, 2 ) |
| 366 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 367 | main.log.error( "Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 368 | main.cleanup() |
| 369 | main.exit() |
| 370 | |
| 371 | main.step( "Bring down the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 372 | linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515", |
| 373 | OPTION="down" ) |
| 374 | utilities.assertEquals( expect=main.TRUE, |
| 375 | actual=linkResult2, |
| 376 | onpass="Bring down link succeeded!", |
| 377 | onfail="Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 378 | if linkResult2 == main.TRUE: |
| 379 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 380 | main.Functions.checkRouteNum( main, 1 ) |
| 381 | main.Functions.checkM2SintentNum( main, 1 ) |
| 382 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 383 | main.log.error( "Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 384 | main.cleanup() |
| 385 | main.exit() |
| 386 | |
| 387 | main.step( "Bring down the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 388 | linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516", |
| 389 | OPTION="down" ) |
| 390 | utilities.assertEquals( expect=main.TRUE, |
| 391 | actual=linkResult3, |
| 392 | onpass="Bring down link succeeded!", |
| 393 | onfail="Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 394 | if linkResult3 == main.TRUE: |
| 395 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 396 | main.Functions.checkRouteNum( main, 0 ) |
| 397 | main.Functions.checkM2SintentNum( main, 0 ) |
| 398 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 399 | main.log.error( "Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 400 | main.cleanup() |
| 401 | main.exit() |
| 402 | |
| 403 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 404 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 405 | main.FALSE, |
| 406 | kwargs={'isPENDING':False}, |
| 407 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 408 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 409 | expect=main.TRUE, |
| 410 | actual=flowCheck, |
| 411 | onpass="Flow status is correct!", |
| 412 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 413 | |
| 414 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 415 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 416 | peers=["pr64514", "pr64515", "pr64516"], |
| 417 | expectAllSuccess=False ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 418 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 419 | hosts=["host64514", "host64515", "host64516"], |
| 420 | expectAllSuccess=False ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 421 | |
| 422 | |
| 423 | def CASE6( self, main ): |
| 424 | ''' |
| 425 | Recover links to peers one by one, check routes/intents |
| 426 | ''' |
| 427 | import time |
| 428 | main.case( "Bring up links and check routes/intents" ) |
| 429 | main.step( "Bring up the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 430 | linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514", |
| 431 | OPTION="up" ) |
| 432 | utilities.assertEquals( expect=main.TRUE, |
| 433 | actual=linkResult1, |
| 434 | onpass="Bring up link succeeded!", |
| 435 | onfail="Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 436 | if linkResult1 == main.TRUE: |
| 437 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 438 | main.Functions.checkRouteNum( main, 1 ) |
| 439 | main.Functions.checkM2SintentNum( main, 1 ) |
| 440 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 441 | main.log.error( "Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 442 | main.cleanup() |
| 443 | main.exit() |
| 444 | |
| 445 | main.step( "Bring up the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 446 | linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515", |
| 447 | OPTION="up" ) |
| 448 | utilities.assertEquals( expect=main.TRUE, |
| 449 | actual=linkResult2, |
| 450 | onpass="Bring up link succeeded!", |
| 451 | onfail="Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 452 | if linkResult2 == main.TRUE: |
| 453 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 454 | main.Functions.checkRouteNum( main, 2 ) |
| 455 | main.Functions.checkM2SintentNum( main, 2 ) |
| 456 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 457 | main.log.error( "Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 458 | main.cleanup() |
| 459 | main.exit() |
| 460 | |
| 461 | main.step( "Bring up the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 462 | linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516", |
| 463 | OPTION="up" ) |
| 464 | utilities.assertEquals( expect=main.TRUE, |
| 465 | actual=linkResult3, |
| 466 | onpass="Bring up link succeeded!", |
| 467 | onfail="Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 468 | if linkResult3 == main.TRUE: |
| 469 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 470 | main.Functions.checkRouteNum( main, 3 ) |
| 471 | main.Functions.checkM2SintentNum( main, 3 ) |
| 472 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 473 | main.log.error( "Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 474 | main.cleanup() |
| 475 | main.exit() |
| 476 | |
| 477 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 478 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 479 | main.FALSE, |
| 480 | kwargs={'isPENDING':False}, |
| 481 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 482 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 483 | expect=main.TRUE, |
| 484 | actual=flowCheck, |
| 485 | onpass="Flow status is correct!", |
| 486 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 487 | |
| 488 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 489 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 490 | peers=["pr64514", "pr64515", "pr64516"], |
| 491 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 492 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 493 | hosts=["host64514", "host64515", "host64516"], |
| 494 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 495 | |
| 496 | |
| 497 | def CASE7( self, main ): |
| 498 | ''' |
| 499 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
| 500 | ''' |
| 501 | import time |
| 502 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
| 503 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 504 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
| 505 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 506 | onpass="Stopping switch succeeded!", |
| 507 | onfail="Stopping switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 508 | |
| 509 | if result == main.TRUE: |
| 510 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 511 | main.Functions.checkRouteNum( main, 2 ) |
| 512 | main.Functions.checkM2SintentNum( main, 2 ) |
| 513 | main.Functions.checkP2PintentNum( main, 12 ) |
| 514 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 515 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 516 | main.cleanup() |
| 517 | main.exit() |
| 518 | |
| 519 | main.step( "Check ping between hosts behind BGP peers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 520 | result1 = main.Mininet.pingHost( src="host64514", target="host64515" ) |
| 521 | result2 = main.Mininet.pingHost( src="host64515", target="host64516" ) |
| 522 | result3 = main.Mininet.pingHost( src="host64514", target="host64516" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 523 | |
| 524 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 525 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 526 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 527 | onpass="Ping test result is correct", |
| 528 | onfail="Ping test result is wrong" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 529 | |
| 530 | if pingResult1 == False: |
| 531 | main.cleanup() |
| 532 | main.exit() |
| 533 | |
| 534 | main.step( "Check ping between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 535 | result4 = main.Mininet.pingHost( src="speaker1", target="pr64514" ) |
| 536 | result5 = main.Mininet.pingHost( src="speaker1", target="pr64515" ) |
| 537 | result6 = main.Mininet.pingHost( src="speaker1", target="pr64516" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 538 | |
| 539 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 540 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 541 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 542 | onpass="Speaker1 ping peers successful", |
| 543 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 544 | |
| 545 | if pingResult2 == False: |
| 546 | main.cleanup() |
| 547 | main.exit() |
| 548 | |
| 549 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 550 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 551 | main.FALSE, |
| 552 | kwargs={'isPENDING':False}, |
| 553 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 554 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 555 | expect=main.TRUE, |
| 556 | actual=flowCheck, |
| 557 | onpass="Flow status is correct!", |
| 558 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 559 | |
| 560 | |
| 561 | def CASE8( self, main ): |
| 562 | ''' |
| 563 | Bring up the edge switch (sw32) which was shut down in CASE7, |
| 564 | check P-2-P and M-2-S intents, ping test |
| 565 | ''' |
| 566 | import time |
| 567 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
| 568 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 569 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 570 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 571 | expect=main.TRUE, |
| 572 | actual=result1, |
| 573 | onpass="Starting switch succeeded!", |
| 574 | onfail="Starting switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 575 | |
pingping-lin | 6cae442 | 2016-01-04 10:00:35 -0800 | [diff] [blame] | 576 | result2 = main.Mininet.assignSwController( "sw32", fsfwIp, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 577 | port=fsfwPort ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 578 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 579 | expect=main.TRUE, |
| 580 | actual=result2, |
| 581 | onpass="Connect switch to FSFW succeeded!", |
| 582 | onfail="Connect switch to FSFW failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 583 | |
| 584 | if result1 and result2: |
| 585 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 586 | main.Functions.checkRouteNum( main, 3 ) |
| 587 | main.Functions.checkM2SintentNum( main, 3 ) |
| 588 | main.Functions.checkP2PintentNum( main, 18 ) |
| 589 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 590 | main.log.error( "Starting switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 591 | main.cleanup() |
| 592 | main.exit() |
| 593 | |
| 594 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 595 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 596 | main.FALSE, |
| 597 | kwargs={'isPENDING':False}, |
| 598 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 599 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 600 | expect=main.TRUE, |
| 601 | actual=flowCheck, |
| 602 | onpass="Flow status is correct!", |
| 603 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 604 | |
| 605 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 606 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 607 | peers=["pr64514", "pr64515", "pr64516"], |
| 608 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 609 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 610 | hosts=["host64514", "host64515", "host64516"], |
| 611 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 612 | |
| 613 | |
| 614 | def CASE9( self, main ): |
| 615 | ''' |
| 616 | Bring down a switch in best path, check: |
| 617 | route number, P2P intent number, M2S intent number, ping test |
| 618 | ''' |
| 619 | main.case( "Stop sw11 located in best path, \ |
| 620 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 621 | |
| 622 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
suibin zhang | c349f3c | 2016-05-24 16:21:24 -0700 | [diff] [blame] | 623 | main.Functions.checkFlowNum( main, "sw11", 19 ) |
| 624 | main.Functions.checkFlowNum( main, "sw1", 9 ) |
| 625 | main.Functions.checkFlowNum( main, "sw7", 6 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 626 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 627 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 628 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 629 | |
| 630 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 631 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
| 632 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 633 | onpass="Stopping switch succeeded!", |
| 634 | onfail="Stopping switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 635 | if result: |
| 636 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 637 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 638 | main.Functions.checkRouteNum( main, 3 ) |
| 639 | main.Functions.checkM2SintentNum( main, 3 ) |
| 640 | main.Functions.checkP2PintentNum( main, 18 ) |
| 641 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 642 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 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 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 651 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 652 | expect=main.TRUE, |
| 653 | actual=flowCheck, |
| 654 | onpass="Flow status is correct!", |
| 655 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 656 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 657 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 658 | peers=["pr64514", "pr64515", "pr64516"], |
| 659 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 660 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 661 | hosts=["host64514", "host64515", "host64516"], |
| 662 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 663 | |
| 664 | |
| 665 | def CASE10( self, main ): |
| 666 | ''' |
| 667 | Bring up the switch which was stopped in CASE9, check: |
| 668 | route number, P2P intent number, M2S intent number, ping test |
| 669 | ''' |
| 670 | main.case( "Start sw11 which was stopped in CASE9, \ |
| 671 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 672 | |
| 673 | main.log.info( "Check the flow status before starting sw11" ) |
suibin zhang | c349f3c | 2016-05-24 16:21:24 -0700 | [diff] [blame] | 674 | main.Functions.checkFlowNum( main, "sw1", 17 ) |
| 675 | main.Functions.checkFlowNum( main, "sw7", 8 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 676 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 677 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 678 | |
| 679 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 680 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
| 681 | utilities.assertEquals( expect=main.TRUE, actual=result1, |
| 682 | onpass="Starting switch succeeded!", |
| 683 | onfail="Starting switch failed!" ) |
pingping-lin | 6cae442 | 2016-01-04 10:00:35 -0800 | [diff] [blame] | 684 | result2 = main.Mininet.assignSwController( "sw11", fsfwIp, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 685 | port=fsfwPort ) |
| 686 | utilities.assertEquals( expect=main.TRUE, actual=result2, |
| 687 | onpass="Connect switch to FSFW succeeded!", |
| 688 | onfail="Connect switch to FSFW failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 689 | if result1 and result2: |
| 690 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 691 | main.Functions.checkRouteNum( main, 3 ) |
| 692 | main.Functions.checkM2SintentNum( main, 3 ) |
| 693 | main.Functions.checkP2PintentNum( main, 18 ) |
| 694 | |
| 695 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 696 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 697 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
| 698 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 699 | main.log.error( "Starting switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 700 | main.cleanup() |
| 701 | main.exit() |
| 702 | |
| 703 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 704 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 705 | main.FALSE, |
| 706 | kwargs={'isPENDING':False}, |
| 707 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 708 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 709 | expect=main.TRUE, |
| 710 | actual=flowCheck, |
| 711 | onpass="Flow status is correct!", |
| 712 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 713 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 714 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 715 | peers=["pr64514", "pr64515", "pr64516"], |
| 716 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 717 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 718 | hosts=["host64514", "host64515", "host64516"], |
| 719 | expectAllSuccess=True ) |