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, |
Devin Lim | 461f087 | 2017-06-05 16:49:33 -0700 | [diff] [blame^] | 106 | cellAppString, ipList, main.ONOScli1.user_name ) |
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 | |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 149 | main.step( "Set up ONOS secure SSH" ) |
| 150 | secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip ) |
| 151 | utilities.assert_equals( expect=main.TRUE, |
| 152 | actual=secureSshResult, |
| 153 | onpass="Set up ONOS secure SSH succeeded", |
| 154 | onfail="Set up ONOS secure SSH failed " ) |
| 155 | |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 156 | main.step( "Checking if ONOS is up yet" ) |
| 157 | onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 ) |
| 158 | utilities.assert_equals( expect=main.TRUE, |
| 159 | actual=onos1UpResult, |
| 160 | onpass="ONOS is up", |
| 161 | onfail="ONOS is NOT up" ) |
| 162 | |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 163 | main.step( "Checking if ONOS CLI is ready" ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 164 | cliResult = main.ONOScli1.startOnosCli( ONOS1Ip, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 165 | commandlineTimeout=100, |
| 166 | onosStartTimeout=600 ) |
| 167 | utilities.assert_equals( expect=main.TRUE, |
| 168 | actual=cliResult, |
| 169 | onpass="ONOS CLI is ready", |
| 170 | onfail="ONOS CLI is not ready" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 171 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 172 | for i in range( 10 ): |
| 173 | ready = True |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 174 | output = main.ONOScli1.summary() |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 175 | if not output: |
| 176 | ready = False |
| 177 | if ready: |
| 178 | break |
| 179 | time.sleep( 30 ) |
| 180 | utilities.assert_equals( expect=True, actual=ready, |
| 181 | onpass="ONOS summary command succeded", |
| 182 | onfail="ONOS summary command failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 183 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 184 | if not ready: |
| 185 | main.log.error( "ONOS startup failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 186 | main.cleanup() |
| 187 | main.exit() |
| 188 | |
| 189 | main.log.info( "Get links in the network" ) |
| 190 | time.sleep( int ( main.params['timers']['TopoDiscovery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 191 | summaryResult = main.ONOScli1.summary() |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 192 | linkNum = json.loads( summaryResult )[ "links" ] |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 193 | listResult = main.ONOScli1.links( jsonFormat=False ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 194 | main.log.info( listResult ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 195 | if linkNum < 100: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 196 | main.log.error( "Link number is wrong!" ) |
| 197 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 198 | listResult = main.ONOScli1.links( jsonFormat=False ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 199 | main.log.info( listResult ) |
| 200 | main.cleanup() |
| 201 | main.exit() |
| 202 | |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 203 | main.step( "Activate sdn-ip application" ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 204 | activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 205 | utilities.assert_equals( expect=main.TRUE, |
| 206 | actual=activeSDNIPresult, |
| 207 | onpass="Activate SDN-IP succeeded", |
| 208 | onfail="Activate SDN-IP failed" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 209 | if not activeSDNIPresult: |
| 210 | main.log.info( "Activate SDN-IP failed!" ) |
| 211 | main.cleanup() |
| 212 | main.exit() |
| 213 | |
| 214 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 215 | main.log.info( "Wait for SDN-IP to finish installing connectivity intents " + |
| 216 | "and for the BGP paths in the data plane to be ready..." ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 217 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 218 | main.log.info( "Wait for Quagga to finish delivery of all routes to each " + |
| 219 | "other and sdn-ip, plus finish installing all intents..." ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 220 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 221 | time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 222 | |
| 223 | |
| 224 | def CASE102( self, main ): |
| 225 | ''' |
| 226 | This test case is to load the methods from other Python files. |
| 227 | ''' |
| 228 | main.case( "Loading methods from other Python file" ) |
| 229 | # load the methods from other file |
| 230 | wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 231 | main.Functions = imp.load_source( wrapperFile, |
| 232 | main.dependencyPath + |
| 233 | wrapperFile + |
| 234 | ".py" ) |
| 235 | |
| 236 | |
| 237 | def CASE1( self, main ): |
| 238 | ''' |
| 239 | ping test from 3 bgp peers to BGP speaker |
| 240 | ''' |
| 241 | |
| 242 | main.case( "Ping tests between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 243 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 244 | peers=["pr64514", "pr64515", "pr64516"], |
| 245 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 246 | |
| 247 | |
| 248 | def CASE2( self, main ): |
| 249 | ''' |
| 250 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 251 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 252 | import time |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 253 | main.case( "Check point-to-point intents" ) |
| 254 | main.log.info( "There are %s BGP peers in total " |
| 255 | % main.params[ 'config' ][ 'peerNum' ] ) |
| 256 | main.step( "Check P2P intents number from ONOS CLI" ) |
| 257 | |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 258 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 259 | bgpIntentsActualNum = \ |
| 260 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 261 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 262 | if bgpIntentsActualNum != bgpIntentsExpectedNum: |
| 263 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 264 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 265 | bgpIntentsActualNum = \ |
| 266 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 267 | main.log.info( "bgpIntentsExpected num is:" ) |
| 268 | main.log.info( bgpIntentsExpectedNum ) |
| 269 | main.log.info( "bgpIntentsActual num is:" ) |
| 270 | main.log.info( bgpIntentsActualNum ) |
| 271 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 272 | expect=True, |
| 273 | actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 274 | onpass="PointToPointIntent Intent Num is correct!", |
| 275 | onfail="PointToPointIntent Intent Num is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 276 | |
| 277 | |
| 278 | def CASE3( self, main ): |
| 279 | ''' |
| 280 | routes and intents check to all BGP peers |
| 281 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 282 | import time |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 283 | main.case( "Check routes and M2S intents to all BGP peers" ) |
| 284 | |
| 285 | allRoutesExpected = [] |
| 286 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 287 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 288 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 289 | |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 290 | getRoutesResult = main.ONOScli1.routes( jsonFormat=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 291 | allRoutesActual = \ |
| 292 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 293 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 294 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 295 | if allRoutesStrActual != allRoutesStrExpected: |
| 296 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 297 | getRoutesResult = main.ONOScli1.routes( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 298 | allRoutesActual = \ |
| 299 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 300 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 301 | |
| 302 | main.step( "Check routes installed" ) |
| 303 | main.log.info( "Routes expected:" ) |
| 304 | main.log.info( allRoutesStrExpected ) |
| 305 | main.log.info( "Routes get from ONOS CLI:" ) |
| 306 | main.log.info( allRoutesStrActual ) |
| 307 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 308 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 309 | onpass="Routes are correct!", |
| 310 | onfail="Routes are wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 311 | |
| 312 | main.step( "Check M2S intents installed" ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 313 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 314 | routeIntentsActualNum = \ |
| 315 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 316 | routeIntentsExpectedNum = 3 |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 317 | if routeIntentsActualNum != routeIntentsExpectedNum: |
| 318 | time.sleep( int( main.params['timers']['RouteDelivery'] ) ) |
suibin zhang | c2a4b01 | 2016-05-23 16:48:19 -0700 | [diff] [blame] | 319 | getIntentsResult = main.ONOScli1.intents( jsonFormat=True ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 320 | routeIntentsActualNum = \ |
| 321 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 322 | |
| 323 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 324 | main.log.info( routeIntentsExpectedNum ) |
| 325 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 326 | main.log.info( routeIntentsActualNum ) |
| 327 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 328 | expect=routeIntentsExpectedNum, |
| 329 | actual=routeIntentsActualNum, |
| 330 | onpass="MultiPointToSinglePoint Intent Num is correct!", |
| 331 | onfail="MultiPointToSinglePoint Intent Num is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 332 | |
| 333 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 334 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 335 | main.FALSE, |
| 336 | kwargs={'isPENDING':False}, |
| 337 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 338 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 339 | expect=main.TRUE, |
| 340 | actual=flowCheck, |
| 341 | onpass="Flow status is correct!", |
| 342 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 343 | |
| 344 | |
| 345 | def CASE4( self, main ): |
| 346 | ''' |
| 347 | Ping test in data plane for each route |
| 348 | ''' |
| 349 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
| 350 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 351 | hosts=["host64514", "host64515", "host64516"], |
| 352 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 353 | |
| 354 | |
| 355 | def CASE5( self, main ): |
| 356 | ''' |
| 357 | Cut links to peers one by one, check routes/intents |
| 358 | ''' |
| 359 | import time |
| 360 | main.case( "Bring down links and check routes/intents" ) |
| 361 | main.step( "Bring down the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 362 | linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514", |
| 363 | OPTION="down" ) |
| 364 | utilities.assertEquals( expect=main.TRUE, |
| 365 | actual=linkResult1, |
| 366 | onpass="Bring down link succeeded!", |
| 367 | onfail="Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 368 | |
| 369 | if linkResult1 == main.TRUE: |
| 370 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 371 | main.Functions.checkRouteNum( main, 2 ) |
| 372 | main.Functions.checkM2SintentNum( main, 2 ) |
| 373 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 374 | main.log.error( "Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 375 | main.cleanup() |
| 376 | main.exit() |
| 377 | |
| 378 | main.step( "Bring down the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 379 | linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515", |
| 380 | OPTION="down" ) |
| 381 | utilities.assertEquals( expect=main.TRUE, |
| 382 | actual=linkResult2, |
| 383 | onpass="Bring down link succeeded!", |
| 384 | onfail="Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 385 | if linkResult2 == main.TRUE: |
| 386 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 387 | main.Functions.checkRouteNum( main, 1 ) |
| 388 | main.Functions.checkM2SintentNum( main, 1 ) |
| 389 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 390 | main.log.error( "Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 391 | main.cleanup() |
| 392 | main.exit() |
| 393 | |
| 394 | main.step( "Bring down the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 395 | linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516", |
| 396 | OPTION="down" ) |
| 397 | utilities.assertEquals( expect=main.TRUE, |
| 398 | actual=linkResult3, |
| 399 | onpass="Bring down link succeeded!", |
| 400 | onfail="Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 401 | if linkResult3 == main.TRUE: |
| 402 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 403 | main.Functions.checkRouteNum( main, 0 ) |
| 404 | main.Functions.checkM2SintentNum( main, 0 ) |
| 405 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 406 | main.log.error( "Bring down link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 407 | main.cleanup() |
| 408 | main.exit() |
| 409 | |
| 410 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 411 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 412 | main.FALSE, |
| 413 | kwargs={'isPENDING':False}, |
| 414 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 415 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 416 | expect=main.TRUE, |
| 417 | actual=flowCheck, |
| 418 | onpass="Flow status is correct!", |
| 419 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 420 | |
| 421 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 422 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 423 | peers=["pr64514", "pr64515", "pr64516"], |
| 424 | expectAllSuccess=False ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 425 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 426 | hosts=["host64514", "host64515", "host64516"], |
| 427 | expectAllSuccess=False ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 428 | |
| 429 | |
| 430 | def CASE6( self, main ): |
| 431 | ''' |
| 432 | Recover links to peers one by one, check routes/intents |
| 433 | ''' |
| 434 | import time |
| 435 | main.case( "Bring up links and check routes/intents" ) |
| 436 | main.step( "Bring up the link between sw32 and peer64514" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 437 | linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514", |
| 438 | OPTION="up" ) |
| 439 | utilities.assertEquals( expect=main.TRUE, |
| 440 | actual=linkResult1, |
| 441 | onpass="Bring up link succeeded!", |
| 442 | onfail="Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 443 | if linkResult1 == main.TRUE: |
| 444 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 445 | main.Functions.checkRouteNum( main, 1 ) |
| 446 | main.Functions.checkM2SintentNum( main, 1 ) |
| 447 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 448 | main.log.error( "Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 449 | main.cleanup() |
| 450 | main.exit() |
| 451 | |
| 452 | main.step( "Bring up the link between sw8 and peer64515" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 453 | linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515", |
| 454 | OPTION="up" ) |
| 455 | utilities.assertEquals( expect=main.TRUE, |
| 456 | actual=linkResult2, |
| 457 | onpass="Bring up link succeeded!", |
| 458 | onfail="Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 459 | if linkResult2 == main.TRUE: |
| 460 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 461 | main.Functions.checkRouteNum( main, 2 ) |
| 462 | main.Functions.checkM2SintentNum( main, 2 ) |
| 463 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 464 | main.log.error( "Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 465 | main.cleanup() |
| 466 | main.exit() |
| 467 | |
| 468 | main.step( "Bring up the link between sw28 and peer64516" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 469 | linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516", |
| 470 | OPTION="up" ) |
| 471 | utilities.assertEquals( expect=main.TRUE, |
| 472 | actual=linkResult3, |
| 473 | onpass="Bring up link succeeded!", |
| 474 | onfail="Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 475 | if linkResult3 == main.TRUE: |
| 476 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 477 | main.Functions.checkRouteNum( main, 3 ) |
| 478 | main.Functions.checkM2SintentNum( main, 3 ) |
| 479 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 480 | main.log.error( "Bring up link failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 481 | main.cleanup() |
| 482 | main.exit() |
| 483 | |
| 484 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 485 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 486 | main.FALSE, |
| 487 | kwargs={'isPENDING':False}, |
| 488 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 489 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 490 | expect=main.TRUE, |
| 491 | actual=flowCheck, |
| 492 | onpass="Flow status is correct!", |
| 493 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 494 | |
| 495 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 496 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 497 | peers=["pr64514", "pr64515", "pr64516"], |
| 498 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 499 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 500 | hosts=["host64514", "host64515", "host64516"], |
| 501 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 502 | |
| 503 | |
| 504 | def CASE7( self, main ): |
| 505 | ''' |
| 506 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
| 507 | ''' |
| 508 | import time |
| 509 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
| 510 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 511 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
| 512 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 513 | onpass="Stopping switch succeeded!", |
| 514 | onfail="Stopping switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 515 | |
| 516 | if result == main.TRUE: |
| 517 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 518 | main.Functions.checkRouteNum( main, 2 ) |
| 519 | main.Functions.checkM2SintentNum( main, 2 ) |
| 520 | main.Functions.checkP2PintentNum( main, 12 ) |
| 521 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 522 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 523 | main.cleanup() |
| 524 | main.exit() |
| 525 | |
| 526 | main.step( "Check ping between hosts behind BGP peers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 527 | result1 = main.Mininet.pingHost( src="host64514", target="host64515" ) |
| 528 | result2 = main.Mininet.pingHost( src="host64515", target="host64516" ) |
| 529 | result3 = main.Mininet.pingHost( src="host64514", target="host64516" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 530 | |
| 531 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 532 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 533 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 534 | onpass="Ping test result is correct", |
| 535 | onfail="Ping test result is wrong" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 536 | |
| 537 | if pingResult1 == False: |
| 538 | main.cleanup() |
| 539 | main.exit() |
| 540 | |
| 541 | main.step( "Check ping between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 542 | result4 = main.Mininet.pingHost( src="speaker1", target="pr64514" ) |
| 543 | result5 = main.Mininet.pingHost( src="speaker1", target="pr64515" ) |
| 544 | result6 = main.Mininet.pingHost( src="speaker1", target="pr64516" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 545 | |
| 546 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 547 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 548 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 549 | onpass="Speaker1 ping peers successful", |
| 550 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 551 | |
| 552 | if pingResult2 == False: |
| 553 | main.cleanup() |
| 554 | main.exit() |
| 555 | |
| 556 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 557 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 558 | main.FALSE, |
| 559 | kwargs={'isPENDING':False}, |
| 560 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 561 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 562 | expect=main.TRUE, |
| 563 | actual=flowCheck, |
| 564 | onpass="Flow status is correct!", |
| 565 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 566 | |
| 567 | |
| 568 | def CASE8( self, main ): |
| 569 | ''' |
| 570 | Bring up the edge switch (sw32) which was shut down in CASE7, |
| 571 | check P-2-P and M-2-S intents, ping test |
| 572 | ''' |
| 573 | import time |
| 574 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
| 575 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 576 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 577 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 578 | expect=main.TRUE, |
| 579 | actual=result1, |
| 580 | onpass="Starting switch succeeded!", |
| 581 | onfail="Starting switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 582 | |
pingping-lin | 6cae442 | 2016-01-04 10:00:35 -0800 | [diff] [blame] | 583 | result2 = main.Mininet.assignSwController( "sw32", fsfwIp, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 584 | port=fsfwPort ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 585 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 586 | expect=main.TRUE, |
| 587 | actual=result2, |
| 588 | onpass="Connect switch to FSFW succeeded!", |
| 589 | onfail="Connect switch to FSFW failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 590 | |
| 591 | if result1 and result2: |
| 592 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 593 | main.Functions.checkRouteNum( main, 3 ) |
| 594 | main.Functions.checkM2SintentNum( main, 3 ) |
| 595 | main.Functions.checkP2PintentNum( main, 18 ) |
| 596 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 597 | main.log.error( "Starting switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 598 | main.cleanup() |
| 599 | main.exit() |
| 600 | |
| 601 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 602 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 603 | main.FALSE, |
| 604 | kwargs={'isPENDING':False}, |
| 605 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 606 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 607 | expect=main.TRUE, |
| 608 | actual=flowCheck, |
| 609 | onpass="Flow status is correct!", |
| 610 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 611 | |
| 612 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 613 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 614 | peers=["pr64514", "pr64515", "pr64516"], |
| 615 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 616 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 617 | hosts=["host64514", "host64515", "host64516"], |
| 618 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 619 | |
| 620 | |
| 621 | def CASE9( self, main ): |
| 622 | ''' |
| 623 | Bring down a switch in best path, check: |
| 624 | route number, P2P intent number, M2S intent number, ping test |
| 625 | ''' |
| 626 | main.case( "Stop sw11 located in best path, \ |
| 627 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 628 | |
| 629 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
suibin zhang | c349f3c | 2016-05-24 16:21:24 -0700 | [diff] [blame] | 630 | main.Functions.checkFlowNum( main, "sw11", 19 ) |
| 631 | main.Functions.checkFlowNum( main, "sw1", 9 ) |
| 632 | main.Functions.checkFlowNum( main, "sw7", 6 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 633 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 634 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 635 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 636 | |
| 637 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 638 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
| 639 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 640 | onpass="Stopping switch succeeded!", |
| 641 | onfail="Stopping switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 642 | if result: |
| 643 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 644 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 645 | main.Functions.checkRouteNum( main, 3 ) |
| 646 | main.Functions.checkM2SintentNum( main, 3 ) |
| 647 | main.Functions.checkP2PintentNum( main, 18 ) |
| 648 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 649 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 650 | main.cleanup() |
| 651 | main.exit() |
| 652 | |
| 653 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 654 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 655 | main.FALSE, |
| 656 | kwargs={'isPENDING':False}, |
| 657 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 658 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 659 | expect=main.TRUE, |
| 660 | actual=flowCheck, |
| 661 | onpass="Flow status is correct!", |
| 662 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 663 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 664 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 665 | peers=["pr64514", "pr64515", "pr64516"], |
| 666 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 667 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 668 | hosts=["host64514", "host64515", "host64516"], |
| 669 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 670 | |
| 671 | |
| 672 | def CASE10( self, main ): |
| 673 | ''' |
| 674 | Bring up the switch which was stopped in CASE9, check: |
| 675 | route number, P2P intent number, M2S intent number, ping test |
| 676 | ''' |
| 677 | main.case( "Start sw11 which was stopped in CASE9, \ |
| 678 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 679 | |
| 680 | main.log.info( "Check the flow status before starting sw11" ) |
suibin zhang | c349f3c | 2016-05-24 16:21:24 -0700 | [diff] [blame] | 681 | main.Functions.checkFlowNum( main, "sw1", 17 ) |
| 682 | main.Functions.checkFlowNum( main, "sw7", 8 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 683 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 684 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 685 | |
| 686 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 687 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
| 688 | utilities.assertEquals( expect=main.TRUE, actual=result1, |
| 689 | onpass="Starting switch succeeded!", |
| 690 | onfail="Starting switch failed!" ) |
pingping-lin | 6cae442 | 2016-01-04 10:00:35 -0800 | [diff] [blame] | 691 | result2 = main.Mininet.assignSwController( "sw11", fsfwIp, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 692 | port=fsfwPort ) |
| 693 | utilities.assertEquals( expect=main.TRUE, actual=result2, |
| 694 | onpass="Connect switch to FSFW succeeded!", |
| 695 | onfail="Connect switch to FSFW failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 696 | if result1 and result2: |
| 697 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 698 | main.Functions.checkRouteNum( main, 3 ) |
| 699 | main.Functions.checkM2SintentNum( main, 3 ) |
| 700 | main.Functions.checkP2PintentNum( main, 18 ) |
| 701 | |
| 702 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 703 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 704 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
| 705 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 706 | main.log.error( "Starting switch failed!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 707 | main.cleanup() |
| 708 | main.exit() |
| 709 | |
| 710 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 711 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 712 | main.FALSE, |
| 713 | kwargs={'isPENDING':False}, |
| 714 | attempts=10 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 715 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 716 | expect=main.TRUE, |
| 717 | actual=flowCheck, |
| 718 | onpass="Flow status is correct!", |
| 719 | onfail="Flow status is wrong!" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 720 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 721 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 722 | peers=["pr64514", "pr64515", "pr64516"], |
| 723 | expectAllSuccess=True ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 724 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 725 | hosts=["host64514", "host64515", "host64516"], |
| 726 | expectAllSuccess=True ) |