Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2015 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 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 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 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 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 21 | # Testing the functionality of SDN-IP with single ONOS instance |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 22 | |
| 23 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 24 | class USECASE_SdnipFunctionCluster: |
| 25 | |
| 26 | def __init__( self ): |
| 27 | self.default = '' |
| 28 | global branchName |
| 29 | |
| 30 | def CASE100( self, main ): |
| 31 | """ |
| 32 | Start mininet |
| 33 | """ |
| 34 | import imp |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 35 | main.case( "Setup the Mininet testbed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 36 | main.dependencyPath = main.testDir + \ |
| 37 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 38 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 39 | |
| 40 | main.step( "Starting Mininet Topology" ) |
| 41 | topology = main.dependencyPath + main.topology |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 42 | topoResult = main.Mininet.startNet( topoFile=topology ) |
| 43 | utilities.assert_equals( expect=main.TRUE, |
| 44 | actual=topoResult, |
| 45 | onpass="Successfully loaded topology", |
| 46 | onfail="Failed to load topology" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 47 | # Exit if topology did not load properly |
| 48 | if not topoResult: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 49 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 50 | main.step( "Connect switches to controllers" ) |
| 51 | |
| 52 | # connect all switches to controllers |
| 53 | swResult = main.TRUE |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 54 | for i in range( 1, int( main.params[ 'config' ][ 'switchNum' ] ) + 1 ): |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 55 | sw = "sw%s" % ( i ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 56 | swResult = swResult and \ |
| 57 | main.Mininet.assignSwController( sw, main.Cluster.getIps() ) |
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 ONOS", |
| 61 | onfail="Failed to connect all switches to ONOS" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 62 | if not swResult: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 63 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 64 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 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......" ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [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..." ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [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 ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 131 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 132 | This test case is to load the methods from other Python files, and create |
| 133 | tunnels from mininet host to onos nodes. |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 134 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 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 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 144 | for i in range( main.Cluster.numCtrls ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 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 ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 159 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 160 | ping test from 3 bgp peers to BGP speaker |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 161 | """ |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 162 | main.case( "Ping between BGP peers and speakers" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 163 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
| 164 | peers=[ "p64514", "p64515", "p64516" ], |
| 165 | expectAllSuccess=True ) |
| 166 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 167 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ], |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 168 | peers=[ p64514, p64515, p64516 ], |
| 169 | expectAllSuccess=True ) |
| 170 | |
| 171 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ], |
| 172 | peers=[ "p64519", "p64520" ], |
| 173 | expectAllSuccess=True ) |
| 174 | |
| 175 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk4" ], |
| 176 | peers=[ "p64517", "p64518" ], |
| 177 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 178 | |
| 179 | def CASE2( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 180 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 181 | point-to-point intents test for each BGP peer and BGP speaker pair |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 182 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 183 | main.sdnBase.pToPIntentTest( 12 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 184 | |
| 185 | def CASE3( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 186 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 187 | routes and intents check to all BGP peers |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 188 | """ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 189 | import time |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 190 | main.case( "Check routes and M2S intents to all BGP peers" ) |
| 191 | |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 192 | main.step( "Check routes installed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 193 | allRoutesExpected = [] |
| 194 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 195 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 196 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 197 | allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" ) |
| 198 | allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" ) |
| 199 | allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" ) |
| 200 | allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 201 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 202 | main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 203 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 204 | def CASE4( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 205 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 206 | Ping test in data plane for each route |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 207 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 208 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
| 209 | main.Functions.pingHostToHost( main, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 210 | hosts=[ "h64514", "h64515", "h64516" ], |
| 211 | expectAllSuccess=True ) |
| 212 | main.Functions.pingHostToHost( main, |
| 213 | hosts=[ "h64517", "h64518" ], |
| 214 | expectAllSuccess=True ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 215 | main.Functions.pingHostToHost( main, |
| 216 | hosts=[ "h64519", "h64520" ], |
| 217 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 218 | |
| 219 | def CASE5( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 220 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 221 | Cut links to peers one by one, check routes/intents |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 222 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 223 | main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516", |
| 224 | 6, 6, 5, 5, 4, 4, |
| 225 | "spk1", [ "h64514", "h64515", "h64516" ], |
| 226 | "down" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 227 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 228 | def CASE6( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 229 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 230 | Recover links to peers one by one, check routes/intents |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 231 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 232 | main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516", |
| 233 | 5, 5, 6, 6, 7, 7, |
| 234 | "spk1", [ "h64514", "h64515", "h64516" ], |
| 235 | "up" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 236 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 237 | def CASE7( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 238 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 239 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 240 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 241 | import time |
| 242 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
| 243 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 244 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 245 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 246 | onpass="Stopping switch succeeded!", |
| 247 | onfail="Stopping switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 248 | |
| 249 | if result == main.TRUE: |
| 250 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 251 | main.Functions.checkRouteNum( main, 6 ) |
| 252 | main.Functions.checkM2SintentNum( main, 6 ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 253 | main.Functions.checkP2PintentNum( main, 48 ) # 14 * 2 |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 254 | else: |
| 255 | main.log.error( "Stopping switch failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 256 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 257 | |
| 258 | main.step( "Check ping between hosts behind BGP peers" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 259 | result1 = main.Mininet.pingHost( src="h64514", target="h64515" ) |
| 260 | result2 = main.Mininet.pingHost( src="h64515", target="h64516" ) |
| 261 | result3 = main.Mininet.pingHost( src="h64514", target="h64516" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 262 | |
| 263 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 264 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 265 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 266 | onpass="Ping test result is correct", |
| 267 | onfail="Ping test result is wrong" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 268 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 269 | if not pingResult1: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 270 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 271 | |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 272 | main.step( "Check ping between BGP peers and spk1" ) |
| 273 | result4 = main.Mininet.pingHost( src="spk1", target="p64514" ) |
| 274 | result5 = main.Mininet.pingHost( src="spk1", target="p64515" ) |
| 275 | result6 = main.Mininet.pingHost( src="spk1", target="p64516" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 276 | |
| 277 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 278 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 279 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 280 | onpass="Speaker1 ping peers successful", |
| 281 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 282 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 283 | if not pingResult2: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 284 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 285 | |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 286 | main.step( "Check ping between BGP peers and spk2" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 287 | # TODO |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 288 | result7 = main.Mininet.pingHost( src="spk2", target=p64514 ) |
| 289 | result8 = main.Mininet.pingHost( src="spk2", target=p64515 ) |
| 290 | result9 = main.Mininet.pingHost( src="spk2", target=p64516 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 291 | |
| 292 | pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \ |
| 293 | and ( result9 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 294 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 295 | onpass="Speaker2 ping peers successful", |
| 296 | onfail="Speaker2 ping peers NOT successful" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 297 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 298 | if not pingResult3: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 299 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 300 | |
| 301 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 302 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 303 | main.FALSE, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 304 | kwargs={ 'isPENDING': False }, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 305 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 306 | utilities.assert_equals( expect=main.TRUE, |
| 307 | actual=flowCheck, |
| 308 | onpass="Flow status is correct!", |
| 309 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 310 | |
| 311 | def CASE8( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 312 | """ |
| 313 | Bring up the edge switch ( sw32 ) which was shut down in CASE7, |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 314 | check P-2-P and M-2-S intents, ping test |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 315 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 316 | import time |
| 317 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
| 318 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 319 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 320 | utilities.assert_equals( expect=main.TRUE, |
| 321 | actual=result1, |
| 322 | onpass="Starting switch succeeded!", |
| 323 | onfail="Starting switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 324 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 325 | result2 = main.Mininet.assignSwController( "sw32", main.Cluster.active( 0 ).ipAddress ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 326 | utilities.assert_equals( expect=main.TRUE, |
| 327 | actual=result2, |
| 328 | onpass="Connect switch to ONOS succeeded!", |
| 329 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 330 | |
| 331 | if result1 and result2: |
| 332 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 333 | main.Functions.checkRouteNum( main, 7 ) |
| 334 | main.Functions.checkM2SintentNum( main, 7 ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 335 | main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18*2 |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 336 | else: |
| 337 | main.log.error( "Starting switch failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 338 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 339 | |
| 340 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 341 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 342 | main.FALSE, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 343 | kwargs={ 'isPENDING': False }, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 344 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 345 | utilities.assert_equals( expect=main.TRUE, |
| 346 | actual=flowCheck, |
| 347 | onpass="Flow status is correct!", |
| 348 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 349 | |
| 350 | # Ping test |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 351 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 352 | peers=[ "p64514", "p64515", "p64516" ], |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 353 | expectAllSuccess=True ) |
| 354 | |
| 355 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ], |
| 356 | peers=[ p64514, p64515, p64516 ], |
| 357 | expectAllSuccess=True ) |
| 358 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 359 | main.Functions.pingHostToHost( main, |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 360 | hosts=[ "h64514", "h64515", "h64516" ], |
| 361 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 362 | |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 363 | def CASE9( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 364 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 365 | Bring down a switch in best path, check: |
| 366 | route number, P2P intent number, M2S intent number, ping test |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 367 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 368 | main.case( "Stop sw11 located in best path, \ |
| 369 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 370 | |
| 371 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 372 | main.Functions.checkFlowNum( main, "sw11", 49 ) |
| 373 | main.Functions.checkFlowNum( main, "sw1", 7 ) |
| 374 | main.Functions.checkFlowNum( main, "sw7", 34 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 375 | main.log.info( main.Mininet.checkFlows( "sw11" ) ) |
| 376 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 377 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 378 | |
| 379 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 380 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 381 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 382 | onpass="Stopping switch succeeded!", |
| 383 | onfail="Stopping switch failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 384 | if result: |
| 385 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 386 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 387 | main.Functions.checkRouteNum( main, 7 ) |
| 388 | main.Functions.checkM2SintentNum( main, 7 ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 389 | main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18 * 2 |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 390 | else: |
| 391 | main.log.error( "Stopping switch failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 392 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 393 | |
| 394 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 395 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 396 | main.FALSE, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 397 | kwargs={ 'isPENDING': False }, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 398 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 399 | utilities.assert_equals( expect=main.TRUE, |
| 400 | actual=flowCheck, |
| 401 | onpass="Flow status is correct!", |
| 402 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 403 | # Ping test |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 404 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
| 405 | peers=[ "p64514", "p64515", "p64516" ], |
| 406 | expectAllSuccess=True ) |
| 407 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ], |
| 408 | peers=[ p64514, p64515, p64516 ], |
| 409 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 410 | main.Functions.pingHostToHost( main, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 411 | hosts=[ "h64514", "h64515", "h64516" ], |
| 412 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 413 | |
| 414 | def CASE10( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 415 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 416 | Bring up the switch which was stopped in CASE9, check: |
| 417 | route number, P2P intent number, M2S intent number, ping test |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 418 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 419 | main.case( "Start sw11 which was stopped in CASE9, \ |
| 420 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 421 | |
| 422 | main.log.info( "Check the flow status before starting sw11" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 423 | main.Functions.checkFlowNum( main, "sw1", 36 ) |
| 424 | main.Functions.checkFlowNum( main, "sw7", 30 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 425 | main.log.info( main.Mininet.checkFlows( "sw1" ) ) |
| 426 | main.log.info( main.Mininet.checkFlows( "sw7" ) ) |
| 427 | |
| 428 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 429 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 430 | utilities.assert_equals( expect=main.TRUE, actual=result1, |
| 431 | onpass="Starting switch succeeded!", |
| 432 | onfail="Starting switch failed!" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 433 | result2 = main.Mininet.assignSwController( "sw11", main.Cluster.active( 0 ).ipAddress ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 434 | utilities.assert_equals( expect=main.TRUE, actual=result2, |
| 435 | onpass="Connect switch to ONOS succeeded!", |
| 436 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 437 | if result1 and result2: |
| 438 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 439 | main.Functions.checkRouteNum( main, 7 ) |
| 440 | main.Functions.checkM2SintentNum( main, 7 ) |
| 441 | main.Functions.checkP2PintentNum( main, 30 * 2 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 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!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 448 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 449 | |
| 450 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 451 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 452 | main.FALSE, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 453 | kwargs={ 'isPENDING': False }, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 454 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 455 | utilities.assert_equals( expect=main.TRUE, |
| 456 | actual=flowCheck, |
| 457 | onpass="Flow status is correct!", |
| 458 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 459 | # Ping test |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 460 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
| 461 | peers=[ "p64514", "p64515", "p64516" ], |
| 462 | expectAllSuccess=True ) |
| 463 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ], |
| 464 | peers=[ p64514, p64515, p64516 ], |
| 465 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 466 | main.Functions.pingHostToHost( main, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 467 | hosts=[ "h64514", "h64515", "h64516" ], |
| 468 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 469 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 470 | def CASE11( self, main ): |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 471 | import time |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 472 | main.case( "Kill spk1, check:\ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 473 | route number, P2P intent number, M2S intent number, ping test" ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 474 | main.log.info( "Check network status before killing spk1" ) |
| 475 | main.Functions.checkRouteNum( main, 7 ) |
| 476 | main.Functions.checkM2SintentNum( main, 7 ) |
| 477 | main.Functions.checkP2PintentNum( main, 30 * 2 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 478 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 479 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 480 | main.FALSE, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 481 | kwargs={ 'isPENDING': False }, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 482 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 483 | utilities.assert_equals( expect=main.TRUE, |
| 484 | actual=flowCheck, |
| 485 | onpass="Flow status is correct!", |
| 486 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 487 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 488 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
| 489 | peers=[ "p64514", "p64515", "p64516" ], |
| 490 | expectAllSuccess=True ) |
| 491 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ], |
| 492 | peers=[ p64514, p64515, p64516 ], |
| 493 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 494 | main.Functions.pingHostToHost( main, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 495 | hosts=[ "h64514", "h64515", "h64516" ], |
| 496 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 497 | |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 498 | main.step( "Kill spk1" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 499 | command1 = "ps -e | grep bgp -c" |
| 500 | result1 = main.Mininet.node( "root", command1 ) |
| 501 | |
| 502 | # The total BGP daemon number in this test environment is 5. |
| 503 | if "5" in result1: |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 504 | main.log.debug( "Before kill spk1, 5 BGP daemons - correct" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 505 | else: |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 506 | main.log.warn( "Before kill spk1, number of BGP daemons is wrong" ) |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 507 | main.log.info( result1 ) |
| 508 | |
| 509 | command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`" |
| 510 | result2 = main.Mininet.node( "root", command2 ) |
| 511 | |
| 512 | result3 = main.Mininet.node( "root", command1 ) |
| 513 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 514 | utilities.assert_equals( expect=True, |
| 515 | actual=( "4" in result3 ), |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 516 | onpass="Kill spk1 succeeded", |
| 517 | onfail="Kill spk1 failed" ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 518 | if ( "4" not in result3 ): |
pingping-lin | 145cd0a | 2015-10-09 17:44:34 -0700 | [diff] [blame] | 519 | main.log.info( result3 ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 520 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 521 | |
| 522 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 523 | main.Functions.checkRouteNum( main, 7 ) |
| 524 | main.Functions.checkM2SintentNum( main, 7 ) |
| 525 | main.Functions.checkP2PintentNum( main, 30 * 2 ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 526 | |
| 527 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 528 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 529 | main.FALSE, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 530 | kwargs={ 'isPENDING': False }, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 531 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 532 | utilities.assert_equals( expect=main.TRUE, |
| 533 | actual=flowCheck, |
| 534 | onpass="Flow status is correct!", |
| 535 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 536 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 537 | """ |
| 538 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
| 539 | peers=[ "p64514", "p64515", "p64516" ], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 540 | expectAllSuccess=False ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 541 | """ |
| 542 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ], |
| 543 | peers=[ p64514, p64515, p64516 ], |
| 544 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 545 | main.Functions.pingHostToHost( main, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 546 | hosts=[ "h64514", "h64515", "h64516" ], |
| 547 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 548 | |
| 549 | def CASE12( self, main ): |
| 550 | import time |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 551 | import json |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 552 | main.case( "Bring down leader ONOS node, check: \ |
| 553 | route number, P2P intent number, M2S intent number, ping test" ) |
| 554 | main.step( "Find out ONOS leader node" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 555 | result = main.Cluster.active( 0 ).CLI.leaders() |
pingping-lin | 3f932a7 | 2015-10-09 16:44:50 -0700 | [diff] [blame] | 556 | jsonResult = json.loads( result ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 557 | leaderIP = "" |
| 558 | for entry in jsonResult: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 559 | if entry[ "topic" ] == "org.onosproject.sdnip": |
| 560 | leaderIP = entry[ "leader" ] |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 561 | main.log.info( "leaderIP is: " ) |
| 562 | main.log.info( leaderIP ) |
| 563 | |
| 564 | main.step( "Uninstall ONOS/SDN-IP leader node" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 565 | for ip in main.Cluster.getIps(): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 566 | if leaderIP == ip: |
| 567 | uninstallResult = main.ONOSbench.onosStop( ip ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 568 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 569 | utilities.assert_equals( expect=main.TRUE, |
| 570 | actual=uninstallResult, |
| 571 | onpass="Uninstall ONOS leader succeeded", |
| 572 | onfail="Uninstall ONOS leader failed" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 573 | if uninstallResult != main.TRUE: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 574 | main.cleanAndExit() |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 575 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 576 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 577 | if leaderIP == main.Cluster.active( 0 ).ipAddress: |
| 578 | main.Functions.checkRouteNum( main, 7, node=2 ) |
| 579 | main.Functions.checkM2SintentNum( main, 7, node=2 ) |
| 580 | main.Functions.checkP2PintentNum( main, 30 * 2, node=2 ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 581 | |
| 582 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 583 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 584 | main.FALSE, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 585 | kwargs={ 'isPENDING': False }, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 586 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 587 | utilities.assert_equals( expect=main.TRUE, |
| 588 | actual=flowCheck, |
| 589 | onpass="Flow status is correct!", |
| 590 | onfail="Flow status is wrong!" ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 591 | else: |
alison | 62006dd | 2016-12-15 16:21:28 -0800 | [diff] [blame] | 592 | main.Functions.checkRouteNum( main, 7 ) |
| 593 | main.Functions.checkM2SintentNum( main, 7 ) |
| 594 | main.Functions.checkP2PintentNum( main, 30 * 2 ) |
pingping-lin | a14c7c8 | 2015-10-09 15:44:36 -0700 | [diff] [blame] | 595 | |
| 596 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 597 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 598 | main.FALSE, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 599 | kwargs={ 'isPENDING': False }, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 600 | attempts=10 ) |
Jon Hall | 362aa92 | 2016-03-31 09:39:26 -0700 | [diff] [blame] | 601 | utilities.assert_equals( expect=main.TRUE, |
| 602 | actual=flowCheck, |
| 603 | onpass="Flow status is correct!", |
| 604 | onfail="Flow status is wrong!" ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 605 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 606 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
| 607 | peers=[ "p64514", "p64515", "p64516" ], |
| 608 | expectAllSuccess=True ) |
| 609 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ], |
| 610 | peers=[ p64514, p64515, p64516 ], |
| 611 | expectAllSuccess=True ) |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 612 | main.Functions.pingHostToHost( main, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 613 | hosts=[ "h64514", "h64515", "h64516" ], |
| 614 | expectAllSuccess=True ) |