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 | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 22 | # Testing the functionality of SDN-IP with single ONOS instance |
| 23 | class USECASE_SdnipFunctionCluster_fsfw: |
| 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 | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 34 | main.case( "Setup the Mininet testbed" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [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 | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 46 | # Exit if topology did not load properly |
| 47 | if not topoResult: |
| 48 | main.cleanup() |
| 49 | main.exit() |
pingping-lin | 1477663 | 2015-12-16 12:05:30 -0800 | [diff] [blame] | 50 | main.step( "Connect switches to FSFW" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 51 | |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 52 | swResult = main.TRUE |
| 53 | for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ): |
| 54 | sw = "sw%s" % ( i ) |
pingping-lin | 1477663 | 2015-12-16 12:05:30 -0800 | [diff] [blame] | 55 | swResult = swResult and main.Mininet.assignSwController( sw, fsfwIp, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 56 | port=fsfwPort ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 57 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 58 | utilities.assert_equals( expect=main.TRUE, |
| 59 | actual=swResult, |
| 60 | onpass="Successfully connect all switches to FSFW", |
| 61 | onfail="Failed to connect all switches to FSFW" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 62 | if not swResult: |
| 63 | main.cleanup() |
| 64 | main.exit() |
| 65 | |
| 66 | |
| 67 | def CASE101( self, main ): |
| 68 | """ |
| 69 | Package ONOS and install it |
| 70 | Startup sequence: |
| 71 | cell <name> |
| 72 | onos-verify-cell |
| 73 | onos-package |
| 74 | onos-install -f |
| 75 | onos-wait-for-start |
| 76 | """ |
| 77 | import json |
| 78 | import time |
| 79 | import os |
| 80 | from operator import eq |
pingping-lin | 1477663 | 2015-12-16 12:05:30 -0800 | [diff] [blame] | 81 | global pr64514 |
| 82 | global pr64515 |
| 83 | global pr64516 |
| 84 | pr64514 = main.params['config']['pr64514'] |
| 85 | pr64515 = main.params['config']['pr64515'] |
| 86 | pr64516 = main.params['config']['pr64516'] |
| 87 | |
| 88 | global fsfwIp |
| 89 | global fsfwPort |
| 90 | fsfwIp = main.params[ 'CTRL' ][ 'fsfwIp' ] |
| 91 | fsfwPort = main.params[ 'CTRL' ][ 'fsfwPort' ] |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 92 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 93 | try: |
| 94 | from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase |
| 95 | except ImportError: |
| 96 | main.log.error( "sdnBase not found. exiting the test" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 97 | main.exit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 98 | try: |
| 99 | main.sdnBase |
| 100 | except ( NameError, AttributeError ): |
| 101 | main.sdnBase = SdnBase() |
| 102 | |
| 103 | main.sdnBase.initSetup() |
| 104 | |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 105 | |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 106 | def CASE200( self, main ): |
| 107 | main.case( "Activate sdn-ip application" ) |
| 108 | main.log.info( "waiting link discovery......" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 109 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 110 | |
| 111 | main.log.info( "Get links in the network" ) |
| 112 | summaryResult = main.ONOScli1.summary() |
| 113 | linkNum = json.loads( summaryResult )[ "links" ] |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 114 | listResult = main.ONOScli1.links( jsonFormat=False ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 115 | main.log.info( listResult ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 116 | if linkNum < 100: |
| 117 | main.log.error( "Link number is wrong!" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 118 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
| 119 | listResult = main.ONOScli1.links( jsonFormat=False ) |
| 120 | main.log.info( listResult ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 121 | main.cleanup() |
| 122 | main.exit() |
| 123 | |
| 124 | main.step( "Activate sdn-ip application" ) |
| 125 | activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 126 | utilities.assert_equals( expect=main.TRUE, |
| 127 | actual=activeSDNIPresult, |
| 128 | onpass="Activate SDN-IP succeeded", |
| 129 | onfail="Activate SDN-IP failed" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 130 | if not activeSDNIPresult: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 131 | main.log.info( "Activate SDN-IP failed!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 132 | main.cleanup() |
| 133 | main.exit() |
| 134 | |
| 135 | |
| 136 | def CASE102( self, main ): |
| 137 | ''' |
| 138 | This test case is to load the methods from other Python files, and create |
| 139 | tunnels from mininet host to onos nodes. |
| 140 | ''' |
| 141 | import time |
| 142 | main.case( "Load methods from other Python file and create tunnels" ) |
| 143 | # load the methods from other file |
| 144 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 145 | main.Functions = imp.load_source( wrapperFile1, |
| 146 | main.dependencyPath + |
| 147 | wrapperFile1 + |
| 148 | ".py" ) |
| 149 | # Create tunnels |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 150 | for i in range ( len( main.ONOSip ) ): |
| 151 | main.Functions.setupTunnel( main, '1.1.1.' + str( ( i + 1 ) * 2 ), 2000, main.ONOSip[ i ], 2000 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 152 | |
| 153 | main.log.info( "Wait SDN-IP to finish installing connectivity intents \ |
| 154 | and the BGP paths in data plane are ready..." ) |
| 155 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
| 156 | |
| 157 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 158 | other and to sdn-ip, plus finish installing all intents..." ) |
| 159 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 160 | |
| 161 | def CASE1( self, main ): |
| 162 | ''' |
| 163 | ping test from 3 bgp peers to BGP speaker |
| 164 | ''' |
| 165 | |
| 166 | main.case( "Ping tests between BGP peers and speakers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 167 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 168 | peers=["pr64514", "pr64515", "pr64516"], |
| 169 | expectAllSuccess=True ) |
| 170 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 171 | peers=[pr64514, pr64515, pr64516], |
| 172 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 173 | |
| 174 | def CASE2( self, main ): |
| 175 | ''' |
| 176 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 177 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 178 | main.sdnBase.pToPIntentTest( 12 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 179 | |
| 180 | |
| 181 | def CASE3( self, main ): |
| 182 | ''' |
| 183 | routes and intents check to all BGP peers |
| 184 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 185 | import time |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 186 | main.case( "Check routes and M2S intents to all BGP peers" ) |
| 187 | |
| 188 | allRoutesExpected = [] |
| 189 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 190 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 191 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 192 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 193 | main.sdnBase.routeAndIntentCheck( allRoutesExpected, 3 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 194 | |
| 195 | |
| 196 | def CASE4( self, main ): |
| 197 | ''' |
| 198 | Ping test in data plane for each route |
| 199 | ''' |
| 200 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
| 201 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 202 | hosts=["host64514", "host64515", "host64516"], |
| 203 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 204 | |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 205 | def CASE5( self, main ): |
| 206 | ''' |
| 207 | Cut links to peers one by one, check routes/intents |
| 208 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 209 | main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516", |
| 210 | 2, 2, 1, 1, 0, 0, |
| 211 | "speaker1", [ "host64514", "host64515", "host64516" ], |
| 212 | "down" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 213 | |
| 214 | def CASE6( self, main ): |
| 215 | ''' |
| 216 | Recover links to peers one by one, check routes/intents |
| 217 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 218 | main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516", |
| 219 | 1, 1, 2, 2, 3, 3, |
| 220 | "speaker1", [ "host64514", "host64515", "host64516" ], |
| 221 | "up" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 222 | |
| 223 | def CASE7( self, main ): |
| 224 | ''' |
| 225 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
| 226 | ''' |
| 227 | import time |
| 228 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
| 229 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 230 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
| 231 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 232 | onpass="Stopping switch succeeded!", |
| 233 | onfail="Stopping switch failed!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 234 | |
| 235 | if result == main.TRUE: |
| 236 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 237 | main.Functions.checkRouteNum( main, 2 ) |
| 238 | main.Functions.checkM2SintentNum( main, 2 ) |
| 239 | main.Functions.checkP2PintentNum( main, 12 * 2 ) |
| 240 | else: |
| 241 | main.log.error( "Stopping switch failed!" ) |
| 242 | main.cleanup() |
| 243 | main.exit() |
| 244 | |
| 245 | main.step( "Check ping between hosts behind BGP peers" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 246 | result1 = main.Mininet.pingHost( src="host64514", target="host64515" ) |
| 247 | result2 = main.Mininet.pingHost( src="host64515", target="host64516" ) |
| 248 | result3 = main.Mininet.pingHost( src="host64514", target="host64516" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 249 | |
| 250 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 251 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 252 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 253 | onpass="Ping test result is correct", |
| 254 | onfail="Ping test result is wrong" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 255 | |
| 256 | if pingResult1 == False: |
| 257 | main.cleanup() |
| 258 | main.exit() |
| 259 | |
| 260 | main.step( "Check ping between BGP peers and speaker1" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 261 | result4 = main.Mininet.pingHost( src="speaker1", target="pr64514" ) |
| 262 | result5 = main.Mininet.pingHost( src="speaker1", target="pr64515" ) |
| 263 | result6 = main.Mininet.pingHost( src="speaker1", target="pr64516" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 264 | |
| 265 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 266 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 267 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 268 | onpass="Speaker1 ping peers successful", |
| 269 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 270 | |
| 271 | if pingResult2 == False: |
| 272 | main.cleanup() |
| 273 | main.exit() |
| 274 | |
| 275 | main.step( "Check ping between BGP peers and speaker2" ) |
| 276 | # TODO |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 277 | result7 = main.Mininet.pingHost( src="speaker2", target=pr64514 ) |
| 278 | result8 = main.Mininet.pingHost( src="speaker2", target=pr64515 ) |
| 279 | result9 = main.Mininet.pingHost( src="speaker2", target=pr64516 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 280 | |
| 281 | pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \ |
| 282 | and ( result9 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 283 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 284 | onpass="Speaker2 ping peers successful", |
| 285 | onfail="Speaker2 ping peers NOT successful" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 286 | |
| 287 | if pingResult3 == False: |
| 288 | main.cleanup() |
| 289 | main.exit() |
| 290 | |
| 291 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 292 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 293 | main.FALSE, |
| 294 | kwargs={'isPENDING':False}, |
| 295 | attempts=10 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 296 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 297 | expect=main.TRUE, |
| 298 | actual=flowCheck, |
| 299 | onpass="Flow status is correct!", |
| 300 | onfail="Flow status is wrong!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 301 | |
| 302 | |
| 303 | def CASE8( self, main ): |
| 304 | ''' |
| 305 | Bring up the edge switch (sw32) which was shut down in CASE7, |
| 306 | check P-2-P and M-2-S intents, ping test |
| 307 | ''' |
| 308 | import time |
| 309 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
| 310 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 311 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 312 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 313 | expect=main.TRUE, |
| 314 | actual=result1, |
| 315 | onpass="Starting switch succeeded!", |
| 316 | onfail="Starting switch failed!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 317 | |
pingping-lin | 3806f11 | 2016-01-04 10:38:25 -0800 | [diff] [blame] | 318 | result2 = main.Mininet.assignSwController( "sw32", fsfwIp, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 319 | port=fsfwPort ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 320 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 321 | expect=main.TRUE, |
| 322 | actual=result2, |
| 323 | onpass="Connect switch to FSFW succeeded!", |
| 324 | onfail="Connect switch to FSFW failed!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 325 | |
| 326 | if result1 and result2: |
| 327 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 328 | main.Functions.checkRouteNum( main, 3 ) |
| 329 | main.Functions.checkM2SintentNum( main, 3 ) |
| 330 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 331 | else: |
| 332 | main.log.error( "Starting switch failed!" ) |
| 333 | main.cleanup() |
| 334 | main.exit() |
| 335 | |
| 336 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 337 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 338 | main.FALSE, |
| 339 | kwargs={'isPENDING':False}, |
| 340 | attempts=10 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 341 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 342 | expect=main.TRUE, |
| 343 | actual=flowCheck, |
| 344 | onpass="Flow status is correct!", |
| 345 | onfail="Flow status is wrong!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 346 | |
| 347 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 348 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 349 | peers=["pr64514", "pr64515", "pr64516"], |
| 350 | expectAllSuccess=True ) |
| 351 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 352 | peers=[pr64514, pr64515, pr64516], |
| 353 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 354 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 355 | hosts=["host64514", "host64515", "host64516"], |
| 356 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 357 | |
| 358 | |
| 359 | def CASE9( self, main ): |
| 360 | ''' |
| 361 | Bring down a switch in best path, check: |
| 362 | route number, P2P intent number, M2S intent number, ping test |
| 363 | ''' |
| 364 | main.case( "Stop sw11 located in best path, \ |
| 365 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 366 | |
| 367 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
| 368 | main.Functions.checkFlowNum( main, "sw11", 19 ) |
| 369 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
| 370 | main.Functions.checkFlowNum( main, "sw7", 3 ) |
| 371 | main.log.info( main.Mininet.checkFlows( "sw11" ) ) |
| 372 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 373 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 374 | |
| 375 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 376 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
| 377 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 378 | onpass="Stopping switch succeeded!", |
| 379 | onfail="Stopping switch failed!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 380 | if result: |
| 381 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 382 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 383 | main.Functions.checkRouteNum( main, 3 ) |
| 384 | main.Functions.checkM2SintentNum( main, 3 ) |
| 385 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 386 | else: |
| 387 | main.log.error( "Stopping switch failed!" ) |
| 388 | main.cleanup() |
| 389 | main.exit() |
| 390 | |
| 391 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 392 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 393 | main.FALSE, |
| 394 | kwargs={'isPENDING':False}, |
| 395 | attempts=10 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 396 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 397 | expect=main.TRUE, |
| 398 | actual=flowCheck, |
| 399 | onpass="Flow status is correct!", |
| 400 | onfail="Flow status is wrong!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 401 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 402 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 403 | peers=["pr64514", "pr64515", "pr64516"], |
| 404 | expectAllSuccess=True ) |
| 405 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 406 | peers=[pr64514, pr64515, pr64516], |
| 407 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 408 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 409 | hosts=["host64514", "host64515", "host64516"], |
| 410 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 411 | |
| 412 | |
| 413 | def CASE10( self, main ): |
| 414 | ''' |
| 415 | Bring up the switch which was stopped in CASE9, check: |
| 416 | route number, P2P intent number, M2S intent number, ping test |
| 417 | ''' |
| 418 | main.case( "Start sw11 which was stopped in CASE9, \ |
| 419 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 420 | |
| 421 | main.log.info( "Check the flow status before starting sw11" ) |
| 422 | main.Functions.checkFlowNum( main, "sw1", 17 ) |
| 423 | main.Functions.checkFlowNum( main, "sw7", 5 ) |
| 424 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 425 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 426 | |
| 427 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 428 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
| 429 | utilities.assertEquals( expect=main.TRUE, actual=result1, |
| 430 | onpass="Starting switch succeeded!", |
| 431 | onfail="Starting switch failed!" ) |
pingping-lin | 3806f11 | 2016-01-04 10:38:25 -0800 | [diff] [blame] | 432 | result2 = main.Mininet.assignSwController( "sw11", fsfwIp, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 433 | port=fsfwPort ) |
| 434 | utilities.assertEquals( expect=main.TRUE, actual=result2, |
| 435 | onpass="Connect switch to FSFW succeeded!", |
| 436 | onfail="Connect switch to FSFW failed!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 437 | if result1 and result2: |
| 438 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 439 | main.Functions.checkRouteNum( main, 3 ) |
| 440 | main.Functions.checkM2SintentNum( main, 3 ) |
| 441 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 442 | |
| 443 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 444 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 445 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
| 446 | else: |
| 447 | main.log.error( "Starting switch failed!" ) |
| 448 | main.cleanup() |
| 449 | main.exit() |
| 450 | |
| 451 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 452 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 453 | main.FALSE, |
| 454 | kwargs={'isPENDING':False}, |
| 455 | attempts=10 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 456 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 457 | expect=main.TRUE, |
| 458 | actual=flowCheck, |
| 459 | onpass="Flow status is correct!", |
| 460 | onfail="Flow status is wrong!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 461 | # Ping test |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 462 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 463 | peers=["pr64514", "pr64515", "pr64516"], |
| 464 | expectAllSuccess=True ) |
| 465 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 466 | peers=[pr64514, pr64515, pr64516], |
| 467 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 468 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 469 | hosts=["host64514", "host64515", "host64516"], |
| 470 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 471 | |
| 472 | |
| 473 | def CASE11(self, main): |
| 474 | import time |
| 475 | main.case( "Kill speaker1, check:\ |
| 476 | route number, P2P intent number, M2S intent number, ping test" ) |
| 477 | main.log.info( "Check network status before killing speaker1" ) |
| 478 | main.Functions.checkRouteNum( main, 3 ) |
| 479 | main.Functions.checkM2SintentNum( main, 3 ) |
| 480 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 481 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 482 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 483 | main.FALSE, |
| 484 | kwargs={'isPENDING':False}, |
| 485 | attempts=10 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 486 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 487 | expect=main.TRUE, |
| 488 | actual=flowCheck, |
| 489 | onpass="Flow status is correct!", |
| 490 | onfail="Flow status is wrong!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 491 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 492 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 493 | peers=["pr64514", "pr64515", "pr64516"], |
| 494 | expectAllSuccess=True ) |
| 495 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 496 | peers=[pr64514, pr64515, pr64516], |
| 497 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 498 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 499 | hosts=["host64514", "host64515", "host64516"], |
| 500 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 501 | |
| 502 | main.step( "Kill speaker1" ) |
| 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: |
| 508 | main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" ) |
| 509 | else: |
| 510 | main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" ) |
| 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 ), |
| 520 | onpass="Kill speaker1 succeeded", |
| 521 | onfail="Kill speaker1 failed" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 522 | if ( "4" not in result3 ) : |
| 523 | main.log.info( result3 ) |
| 524 | main.cleanup() |
| 525 | main.exit() |
| 526 | |
| 527 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 528 | main.Functions.checkRouteNum( main, 3 ) |
| 529 | main.Functions.checkM2SintentNum( main, 3 ) |
| 530 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 531 | |
| 532 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 533 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 534 | main.FALSE, |
| 535 | kwargs={'isPENDING':False}, |
| 536 | attempts=10 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 537 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 538 | expect=main.TRUE, |
| 539 | actual=flowCheck, |
| 540 | onpass="Flow status is correct!", |
| 541 | onfail="Flow status is wrong!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 542 | |
| 543 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 544 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 545 | peers=["pr64514", "pr64515", "pr64516"], |
| 546 | expectAllSuccess=False ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 547 | ''' |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 548 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 549 | peers=[pr64514, pr64515, pr64516], |
| 550 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 551 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 552 | hosts=["host64514", "host64515", "host64516"], |
| 553 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 554 | |
| 555 | |
| 556 | def CASE12( self, main ): |
| 557 | import time |
| 558 | import json |
| 559 | main.case( "Bring down leader ONOS node, check: \ |
| 560 | route number, P2P intent number, M2S intent number, ping test" ) |
| 561 | main.step( "Find out ONOS leader node" ) |
| 562 | result = main.ONOScli1.leaders() |
| 563 | jsonResult = json.loads( result ) |
| 564 | leaderIP = "" |
| 565 | for entry in jsonResult: |
| 566 | if entry["topic"] == "org.onosproject.sdnip": |
| 567 | leaderIP = entry["leader"] |
| 568 | main.log.info( "leaderIP is: " ) |
| 569 | main.log.info( leaderIP ) |
| 570 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 571 | main.step( "Uninstall ONOS/SDN-IP leader node" ) |
| 572 | for ip in main.ONOSip: |
| 573 | if leaderIP == ip: |
| 574 | uninstallResult = main.ONOSbench.onosStop( ip ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 575 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 576 | utilities.assert_equals( expect=main.TRUE, |
| 577 | actual=uninstallResult, |
| 578 | onpass="Uninstall ONOS leader succeeded", |
| 579 | onfail="Uninstall ONOS leader failed" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 580 | if uninstallResult != main.TRUE: |
| 581 | main.cleanup() |
| 582 | main.exit() |
| 583 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 584 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 585 | if leaderIP == main.ONOSip[ 0 ]: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 586 | main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" ) |
| 587 | main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" ) |
| 588 | main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 589 | |
| 590 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 591 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 592 | main.FALSE, |
| 593 | kwargs={'isPENDING':False}, |
| 594 | attempts=10 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 595 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 596 | expect=main.TRUE, |
| 597 | actual=flowCheck, |
| 598 | onpass="Flow status is correct!", |
| 599 | onfail="Flow status is wrong!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 600 | else: |
| 601 | main.Functions.checkRouteNum( main, 3 ) |
| 602 | main.Functions.checkM2SintentNum( main, 3 ) |
| 603 | main.Functions.checkP2PintentNum( main, 18 * 2 ) |
| 604 | |
| 605 | main.step( "Check whether all flow status are ADDED" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 606 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
| 607 | main.FALSE, |
| 608 | kwargs={'isPENDING':False}, |
| 609 | attempts=10 ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 610 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 611 | expect=main.TRUE, |
| 612 | actual=flowCheck, |
| 613 | onpass="Flow status is correct!", |
| 614 | onfail="Flow status is wrong!" ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 615 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 616 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"], |
| 617 | peers=["pr64514", "pr64515", "pr64516"], |
| 618 | expectAllSuccess=True ) |
| 619 | main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"], |
| 620 | peers=[pr64514, pr64515, pr64516], |
| 621 | expectAllSuccess=True ) |
pingping-lin | 26990f0 | 2015-11-30 15:48:06 -0800 | [diff] [blame] | 622 | main.Functions.pingHostToHost( main, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 623 | hosts=["host64514", "host64515", "host64516"], |
| 624 | expectAllSuccess=True ) |