Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2015 Open Networking Foundation (ONF) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
| 21 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 22 | # Testing the functionality of SDN-IP with single ONOS instance |
| 23 | class USECASE_SdnipFunctionCluster: |
| 24 | |
| 25 | def __init__( self ): |
| 26 | self.default = '' |
| 27 | global branchName |
| 28 | |
| 29 | def CASE100( self, main ): |
| 30 | """ |
| 31 | Start mininet |
| 32 | """ |
| 33 | import imp |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 34 | main.case( "Setup the Mininet testbed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 35 | main.dependencyPath = main.testDir + \ |
| 36 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 37 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 38 | |
| 39 | main.step( "Starting Mininet Topology" ) |
| 40 | topology = main.dependencyPath + main.topology |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 41 | topoResult = main.Mininet.startNet( topoFile=topology ) |
| 42 | utilities.assert_equals( expect=main.TRUE, |
| 43 | actual=topoResult, |
| 44 | onpass="Successfully loaded topology", |
| 45 | onfail="Failed to load topology" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 46 | # Exit if topology did not load properly |
| 47 | if not topoResult: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 48 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 49 | main.step( "Connect switches to controllers" ) |
| 50 | |
| 51 | # connect all switches to controllers |
| 52 | swResult = main.TRUE |
| 53 | for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ): |
| 54 | sw = "sw%s" % ( i ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 55 | swResult = swResult and \ |
| 56 | main.Mininet.assignSwController( sw, main.Cluster.getIps() ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 57 | utilities.assert_equals( expect=main.TRUE, |
| 58 | actual=swResult, |
| 59 | onpass="Successfully connect all switches to ONOS", |
| 60 | onfail="Failed to connect all switches to ONOS" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 61 | if not swResult: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 62 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 63 | |
| 64 | |
| 65 | def CASE101( self, main ): |
| 66 | """ |
| 67 | Package ONOS and install it |
| 68 | Startup sequence: |
| 69 | cell <name> |
| 70 | onos-verify-cell |
| 71 | onos-package |
| 72 | onos-install -f |
| 73 | onos-wait-for-start |
| 74 | """ |
| 75 | import json |
| 76 | import time |
| 77 | import os |
| 78 | from operator import eq |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 79 | global p64514 |
| 80 | global p64515 |
| 81 | global p64516 |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 82 | p64514 = main.params[ 'config' ][ 'p64514' ] |
| 83 | p64515 = main.params[ 'config' ][ 'p64515' ] |
| 84 | p64516 = main.params[ 'config' ][ 'p64516' ] |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 85 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 86 | try: |
| 87 | from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase |
| 88 | except ImportError: |
| 89 | main.log.error( "sdnBase not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 90 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 91 | try: |
| 92 | main.sdnBase |
| 93 | except ( NameError, AttributeError ): |
| 94 | main.sdnBase = SdnBase() |
| 95 | |
| 96 | main.sdnBase.initSetup() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 97 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 98 | def CASE200( self, main ): |
| 99 | main.case( "Activate sdn-ip application" ) |
| 100 | main.log.info( "waiting link discovery......" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 101 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 102 | |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 103 | main.step( "Get links in the network" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 104 | summaryResult = main.Cluster.active( 0 ).CLI.summary() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 105 | linkNum = json.loads( summaryResult )[ "links" ] |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 106 | main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 107 | if linkNum < 100: |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 108 | main.log.error( "Link number is wrong! Retrying..." ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 109 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 110 | summaryResult = main.Cluster.active( 0 ).CLI.summary() |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 111 | linkNum = json.loads( summaryResult )[ "links" ] |
| 112 | main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) ) |
| 113 | utilities.assert_equals( expect=100, |
| 114 | actual=linkNum, |
| 115 | onpass="ONOS correctly discovered all links", |
| 116 | onfail="ONOS Failed to discover all links" ) |
| 117 | if linkNum < 100: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 118 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 119 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 120 | main.step( "Activate sdn-ip application" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 121 | activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 122 | utilities.assert_equals( expect=main.TRUE, |
| 123 | actual=activeSDNIPresult, |
| 124 | onpass="Activate SDN-IP succeeded", |
| 125 | onfail="Activate SDN-IP failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 126 | if not activeSDNIPresult: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 127 | main.log.info( "Activate SDN-IP failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 128 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 129 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 130 | def CASE102( self, main ): |
| 131 | ''' |
| 132 | This test case is to load the methods from other Python files, and create |
| 133 | tunnels from mininet host to onos nodes. |
| 134 | ''' |
| 135 | import time |
| 136 | main.case( "Load methods from other Python file and create tunnels" ) |
| 137 | # load the methods from other file |
| 138 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 139 | main.Functions = imp.load_source( wrapperFile1, |
| 140 | main.dependencyPath + |
| 141 | wrapperFile1 + |
| 142 | ".py" ) |
| 143 | # Create tunnels |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 144 | for i in range ( main.Cluster.numCtrls ): |
| 145 | main.Functions.setupTunnel( main, |
| 146 | '1.1.1.' + str( ( i + 1 ) * 2 ), |
| 147 | 2000, |
| 148 | main.Cluster.active( i ).ipAddress, 2000 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 149 | |
| 150 | main.log.info( "Wait SDN-IP to finish installing connectivity intents \ |
| 151 | and the BGP paths in data plane are ready..." ) |
| 152 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
| 153 | |
| 154 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 155 | other and to sdn-ip, plus finish installing all intents..." ) |
| 156 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 157 | |
| 158 | def CASE1( self, main ): |
| 159 | ''' |
| 160 | ping test from 3 bgp peers to BGP speaker |
| 161 | ''' |
| 162 | |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 163 | main.case( "Ping between BGP peers and speakers" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 164 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
| 165 | peers=[ "p64514", "p64515", "p64516" ], |
| 166 | expectAllSuccess=True ) |
| 167 | |
| 168 | main.Functions.pingSpeakerToPeer( main, speakers=["spk2"], |
| 169 | peers=[ p64514, p64515, p64516 ], |
| 170 | expectAllSuccess=True ) |
| 171 | |
| 172 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ], |
| 173 | peers=[ "p64519", "p64520" ], |
| 174 | expectAllSuccess=True ) |
| 175 | |
| 176 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk4" ], |
| 177 | peers=[ "p64517", "p64518" ], |
| 178 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 179 | |
| 180 | def CASE2( self, main ): |
| 181 | ''' |
| 182 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 183 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 184 | main.sdnBase.pToPIntentTest( 12 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 185 | |
| 186 | def CASE3( self, main ): |
| 187 | ''' |
| 188 | routes and intents check to all BGP peers |
| 189 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 190 | import time |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 191 | main.case( "Check routes and M2S intents to all BGP peers" ) |
| 192 | |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 193 | main.step( "Check routes installed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 194 | allRoutesExpected = [] |
| 195 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 196 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 197 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 198 | allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" ) |
| 199 | allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" ) |
| 200 | allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" ) |
| 201 | allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 202 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 203 | main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 204 | |
| 205 | |
| 206 | def CASE4( self, main ): |
| 207 | ''' |
| 208 | Ping test in data plane for each route |
| 209 | ''' |
| 210 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
| 211 | main.Functions.pingHostToHost( main, |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 212 | hosts=["h64514", "h64515", "h64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 213 | expectAllSuccess=True ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 214 | main.Functions.pingHostToHost(main, |
| 215 | hosts=["h64517", "h64518"], |
| 216 | expectAllSuccess=True) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 217 | main.Functions.pingHostToHost( main, |
| 218 | hosts=[ "h64519", "h64520" ], |
| 219 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 220 | |
| 221 | def CASE5( self, main ): |
| 222 | ''' |
| 223 | Cut links to peers one by one, check routes/intents |
| 224 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 225 | main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516", |
| 226 | 6, 6, 5, 5, 4, 4, |
| 227 | "spk1", [ "h64514", "h64515", "h64516" ], |
| 228 | "down" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 229 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 230 | def CASE6( self, main ): |
| 231 | ''' |
| 232 | Recover links to peers one by one, check routes/intents |
| 233 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 234 | main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516", |
| 235 | 5, 5, 6, 6, 7, 7, |
| 236 | "spk1", [ "h64514", "h64515", "h64516" ], |
| 237 | "up" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 238 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 239 | def CASE7( self, main ): |
| 240 | ''' |
| 241 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
| 242 | ''' |
| 243 | import time |
| 244 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
| 245 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 246 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 247 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 248 | onpass="Stopping switch succeeded!", |
| 249 | onfail="Stopping switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 250 | |
| 251 | if result == main.TRUE: |
| 252 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 253 | main.Functions.checkRouteNum( main, 6 ) |
| 254 | main.Functions.checkM2SintentNum( main, 6 ) |
| 255 | main.Functions.checkP2PintentNum( main, 48 ) #14 * 2 |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 256 | else: |
| 257 | main.log.error( "Stopping switch failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 258 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 259 | |
| 260 | main.step( "Check ping between hosts behind BGP peers" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 261 | result1 = main.Mininet.pingHost( src="h64514", target="h64515" ) |
| 262 | result2 = main.Mininet.pingHost( src="h64515", target="h64516" ) |
| 263 | result3 = main.Mininet.pingHost( src="h64514", target="h64516" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 264 | |
| 265 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 266 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 267 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 268 | onpass="Ping test result is correct", |
| 269 | onfail="Ping test result is wrong" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 270 | |
| 271 | if pingResult1 == False: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 272 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 273 | |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 274 | main.step( "Check ping between BGP peers and spk1" ) |
| 275 | result4 = main.Mininet.pingHost( src="spk1", target="p64514" ) |
| 276 | result5 = main.Mininet.pingHost( src="spk1", target="p64515" ) |
| 277 | result6 = main.Mininet.pingHost( src="spk1", target="p64516" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 278 | |
| 279 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 280 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 281 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 282 | onpass="Speaker1 ping peers successful", |
| 283 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 284 | |
| 285 | if pingResult2 == False: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 286 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 287 | |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 288 | main.step( "Check ping between BGP peers and spk2" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 289 | # TODO |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 290 | result7 = main.Mininet.pingHost( src="spk2", target=p64514 ) |
| 291 | result8 = main.Mininet.pingHost( src="spk2", target=p64515 ) |
| 292 | result9 = main.Mininet.pingHost( src="spk2", target=p64516 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 293 | |
| 294 | pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \ |
| 295 | and ( result9 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 296 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 297 | onpass="Speaker2 ping peers successful", |
| 298 | onfail="Speaker2 ping peers NOT successful" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 299 | |
| 300 | if pingResult3 == False: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 301 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 302 | |
| 303 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 304 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 305 | main.FALSE, |
| 306 | kwargs={'isPENDING':False}, |
| 307 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 308 | utilities.assert_equals( expect=main.TRUE, |
| 309 | actual=flowCheck, |
| 310 | onpass="Flow status is correct!", |
| 311 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 312 | |
| 313 | def CASE8( self, main ): |
| 314 | ''' |
| 315 | Bring up the edge switch (sw32) which was shut down in CASE7, |
| 316 | check P-2-P and M-2-S intents, ping test |
| 317 | ''' |
| 318 | import time |
| 319 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
| 320 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 321 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 322 | utilities.assert_equals( expect=main.TRUE, |
| 323 | actual=result1, |
| 324 | onpass="Starting switch succeeded!", |
| 325 | onfail="Starting switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 326 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 327 | result2 = main.Mininet.assignSwController( "sw32", main.Cluster.active( 0 ).ipAddress ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 328 | utilities.assert_equals( expect=main.TRUE, |
| 329 | actual=result2, |
| 330 | onpass="Connect switch to ONOS succeeded!", |
| 331 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 332 | |
| 333 | if result1 and result2: |
| 334 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 335 | main.Functions.checkRouteNum( main, 7 ) |
| 336 | main.Functions.checkM2SintentNum( main, 7 ) |
| 337 | main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18*2 |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 338 | else: |
| 339 | main.log.error( "Starting switch failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 340 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 341 | |
| 342 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 343 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 344 | main.FALSE, |
| 345 | kwargs={'isPENDING':False}, |
| 346 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 347 | utilities.assert_equals( expect=main.TRUE, |
| 348 | actual=flowCheck, |
| 349 | onpass="Flow status is correct!", |
| 350 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 351 | |
| 352 | # Ping test |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 353 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
| 354 | peers=["p64514", "p64515", "p64516"], |
| 355 | expectAllSuccess=True ) |
| 356 | |
| 357 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ], |
| 358 | peers=[ p64514, p64515, p64516 ], |
| 359 | expectAllSuccess=True ) |
| 360 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 361 | main.Functions.pingHostToHost( main, |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 362 | hosts=[ "h64514", "h64515", "h64516" ], |
| 363 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 364 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 365 | def CASE9( self, main ): |
| 366 | ''' |
| 367 | Bring down a switch in best path, check: |
| 368 | route number, P2P intent number, M2S intent number, ping test |
| 369 | ''' |
| 370 | main.case( "Stop sw11 located in best path, \ |
| 371 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 372 | |
| 373 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 374 | main.Functions.checkFlowNum( main, "sw11", 49 ) |
| 375 | main.Functions.checkFlowNum( main, "sw1", 7 ) |
| 376 | main.Functions.checkFlowNum( main, "sw7", 34 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 377 | main.log.info( main.Mininet.checkFlows( "sw11" ) ) |
| 378 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 379 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 380 | |
| 381 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 382 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 383 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 384 | onpass="Stopping switch succeeded!", |
| 385 | onfail="Stopping switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 386 | if result: |
| 387 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 388 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 389 | main.Functions.checkRouteNum( main, 7 ) |
| 390 | main.Functions.checkM2SintentNum( main, 7 ) |
| 391 | main.Functions.checkP2PintentNum( main, 30 * 2 ) #18 * 2 |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 392 | else: |
| 393 | main.log.error( "Stopping switch failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 394 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 395 | |
| 396 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 397 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 398 | main.FALSE, |
| 399 | kwargs={'isPENDING':False}, |
| 400 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 401 | utilities.assert_equals( expect=main.TRUE, |
| 402 | actual=flowCheck, |
| 403 | onpass="Flow status is correct!", |
| 404 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 405 | # Ping test |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 406 | main.Functions.pingSpeakerToPeer( main, speakers=["spk1"], |
| 407 | peers=["p64514", "p64515", "p64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 408 | expectAllSuccess=True ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 409 | main.Functions.pingSpeakerToPeer( main, speakers=["spk2"], |
| 410 | peers=[p64514, p64515, p64516], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 411 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 412 | main.Functions.pingHostToHost( main, |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 413 | hosts=["h64514", "h64515", "h64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 414 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 415 | |
| 416 | |
| 417 | def CASE10( self, main ): |
| 418 | ''' |
| 419 | Bring up the switch which was stopped in CASE9, check: |
| 420 | route number, P2P intent number, M2S intent number, ping test |
| 421 | ''' |
| 422 | main.case( "Start sw11 which was stopped in CASE9, \ |
| 423 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 424 | |
| 425 | main.log.info( "Check the flow status before starting sw11" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 426 | main.Functions.checkFlowNum( main, "sw1", 36 ) |
| 427 | main.Functions.checkFlowNum( main, "sw7", 30 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 428 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 429 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 430 | |
| 431 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 432 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 433 | utilities.assert_equals( expect=main.TRUE, actual=result1, |
| 434 | onpass="Starting switch succeeded!", |
| 435 | onfail="Starting switch failed!" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 436 | result2 = main.Mininet.assignSwController( "sw11", main.Cluster.active( 0 ).ipAddress ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 437 | utilities.assert_equals( expect=main.TRUE, actual=result2, |
| 438 | onpass="Connect switch to ONOS succeeded!", |
| 439 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 440 | if result1 and result2: |
| 441 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 442 | main.Functions.checkRouteNum( main, 7 ) |
| 443 | main.Functions.checkM2SintentNum( main, 7 ) |
| 444 | main.Functions.checkP2PintentNum( main, 30 * 2 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 445 | |
| 446 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 447 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 448 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
| 449 | else: |
| 450 | main.log.error( "Starting switch failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 451 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 452 | |
| 453 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 454 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 455 | main.FALSE, |
| 456 | kwargs={'isPENDING':False}, |
| 457 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 458 | utilities.assert_equals( expect=main.TRUE, |
| 459 | actual=flowCheck, |
| 460 | onpass="Flow status is correct!", |
| 461 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 462 | # Ping test |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 463 | main.Functions.pingSpeakerToPeer( main, speakers=["spk1"], |
| 464 | peers=["p64514", "p64515", "p64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 465 | expectAllSuccess=True ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 466 | main.Functions.pingSpeakerToPeer( main, speakers=["spk2"], |
| 467 | peers=[p64514, p64515, p64516], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 468 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 469 | main.Functions.pingHostToHost( main, |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 470 | hosts=["h64514", "h64515", "h64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 471 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 472 | |
| 473 | |
| 474 | def CASE11(self, main): |
| 475 | import time |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 476 | main.case( "Kill spk1, check:\ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 477 | route number, P2P intent number, M2S intent number, ping test" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 478 | main.log.info( "Check network status before killing spk1" ) |
| 479 | main.Functions.checkRouteNum( main, 7 ) |
| 480 | main.Functions.checkM2SintentNum( main, 7 ) |
| 481 | main.Functions.checkP2PintentNum( main, 30 * 2 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 482 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 483 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 484 | main.FALSE, |
| 485 | kwargs={'isPENDING':False}, |
| 486 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 487 | utilities.assert_equals( expect=main.TRUE, |
| 488 | actual=flowCheck, |
| 489 | onpass="Flow status is correct!", |
| 490 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 491 | |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 492 | main.Functions.pingSpeakerToPeer( main, speakers=["spk1"], |
| 493 | peers=["p64514", "p64515", "p64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 494 | expectAllSuccess=True ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 495 | main.Functions.pingSpeakerToPeer( main, speakers=["spk2"], |
| 496 | peers=[p64514, p64515, p64516], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 497 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 498 | main.Functions.pingHostToHost( main, |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 499 | hosts=["h64514", "h64515", "h64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 500 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 501 | |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 502 | main.step( "Kill spk1" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 503 | command1 = "ps -e | grep bgp -c" |
| 504 | result1 = main.Mininet.node( "root", command1 ) |
| 505 | |
| 506 | # The total BGP daemon number in this test environment is 5. |
| 507 | if "5" in result1: |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 508 | main.log.debug( "Before kill spk1, 5 BGP daemons - correct" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 509 | else: |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 510 | main.log.warn( "Before kill spk1, number of BGP daemons is wrong" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 511 | main.log.info( result1 ) |
| 512 | |
| 513 | command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`" |
| 514 | result2 = main.Mininet.node( "root", command2 ) |
| 515 | |
| 516 | result3 = main.Mininet.node( "root", command1 ) |
| 517 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 518 | utilities.assert_equals( expect=True, |
| 519 | actual=( "4" in result3 ), |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 520 | onpass="Kill spk1 succeeded", |
| 521 | onfail="Kill spk1 failed" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 522 | if ( "4" not in result3 ) : |
| 523 | main.log.info( result3 ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 524 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 525 | |
| 526 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 527 | main.Functions.checkRouteNum( main, 7 ) |
| 528 | main.Functions.checkM2SintentNum( main, 7 ) |
| 529 | main.Functions.checkP2PintentNum( main, 30 * 2 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 530 | |
| 531 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 532 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 533 | main.FALSE, |
| 534 | kwargs={'isPENDING':False}, |
| 535 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 536 | utilities.assert_equals( expect=main.TRUE, |
| 537 | actual=flowCheck, |
| 538 | onpass="Flow status is correct!", |
| 539 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 540 | |
| 541 | ''' |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 542 | main.Functions.pingSpeakerToPeer( main, speakers=["spk1"], |
| 543 | peers=["p64514", "p64515", "p64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 544 | expectAllSuccess=False ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 545 | ''' |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 546 | main.Functions.pingSpeakerToPeer( main, speakers=["spk2"], |
| 547 | peers=[p64514, p64515, p64516], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 548 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 549 | main.Functions.pingHostToHost( main, |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 550 | hosts=["h64514", "h64515", "h64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 551 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 552 | |
| 553 | |
| 554 | def CASE12( self, main ): |
| 555 | import time |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 556 | import json |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 557 | main.case( "Bring down leader ONOS node, check: \ |
| 558 | route number, P2P intent number, M2S intent number, ping test" ) |
| 559 | main.step( "Find out ONOS leader node" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 560 | result = main.Cluster.active( 0 ).CLI.leaders() |
pingping-lin | 3f932a7 | 2015-10-09 16:44:50 -0700 | [diff] [blame] | 561 | jsonResult = json.loads( result ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 562 | leaderIP = "" |
| 563 | for entry in jsonResult: |
| 564 | if entry["topic"] == "org.onosproject.sdnip": |
| 565 | leaderIP = entry["leader"] |
| 566 | main.log.info( "leaderIP is: " ) |
| 567 | main.log.info( leaderIP ) |
| 568 | |
| 569 | main.step( "Uninstall ONOS/SDN-IP leader node" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 570 | for ip in main.Cluster.getIps(): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 571 | if leaderIP == ip: |
| 572 | uninstallResult = main.ONOSbench.onosStop( ip ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 573 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 574 | utilities.assert_equals( expect=main.TRUE, |
| 575 | actual=uninstallResult, |
| 576 | onpass="Uninstall ONOS leader succeeded", |
| 577 | onfail="Uninstall ONOS leader failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 578 | if uninstallResult != main.TRUE: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 579 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 580 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 581 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 582 | if leaderIP == main.Cluster.active( 0 ).ipAddress: |
| 583 | main.Functions.checkRouteNum( main, 7, node=2 ) |
| 584 | main.Functions.checkM2SintentNum( main, 7, node=2 ) |
| 585 | main.Functions.checkP2PintentNum( main, 30 * 2, node=2 ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 586 | |
| 587 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 588 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 589 | main.FALSE, |
| 590 | kwargs={'isPENDING':False}, |
| 591 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 592 | utilities.assert_equals( expect=main.TRUE, |
| 593 | actual=flowCheck, |
| 594 | onpass="Flow status is correct!", |
| 595 | onfail="Flow status is wrong!" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 596 | else: |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 597 | main.Functions.checkRouteNum( main, 7 ) |
| 598 | main.Functions.checkM2SintentNum( main, 7 ) |
| 599 | main.Functions.checkP2PintentNum( main, 30 * 2 ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 600 | |
| 601 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 602 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 603 | main.FALSE, |
| 604 | kwargs={'isPENDING':False}, |
| 605 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 606 | utilities.assert_equals( expect=main.TRUE, |
| 607 | actual=flowCheck, |
| 608 | onpass="Flow status is correct!", |
| 609 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 610 | |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 611 | main.Functions.pingSpeakerToPeer( main, speakers=["spk1"], |
| 612 | peers=["p64514", "p64515", "p64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 613 | expectAllSuccess=True ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 614 | main.Functions.pingSpeakerToPeer( main, speakers=["spk2"], |
| 615 | peers=[p64514, p64515, p64516], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 616 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 617 | main.Functions.pingHostToHost( main, |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 618 | hosts=["h64514", "h64515", "h64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 619 | expectAllSuccess=True ) |