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