Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2016 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 | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 22 | # Testing the functionality of SDN-IP with single ONOS instance |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 23 | class USECASE_SdnipFunction: |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 24 | |
| 25 | def __init__( self ): |
| 26 | self.default = '' |
| 27 | global branchName |
| 28 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 29 | def CASE100( self, main ): |
| 30 | """ |
| 31 | Start mininet |
| 32 | """ |
| 33 | import os |
Jon Hall | 70b768c | 2016-04-19 08:38:29 -0700 | [diff] [blame] | 34 | main.case( "Setup the Mininet testbed" ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 35 | main.dependencyPath = main.testDir + \ |
| 36 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 37 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 38 | |
| 39 | main.step( "Starting Mininet Topology" ) |
| 40 | topology = main.dependencyPath + main.topology |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 41 | topoResult = main.Mininet.startNet( topoFile=topology ) |
| 42 | utilities.assert_equals( expect=main.TRUE, |
| 43 | actual=topoResult, |
| 44 | onpass="Successfully loaded topology", |
| 45 | onfail="Failed to load topology" ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 46 | # Exit if topology did not load properly |
| 47 | if not topoResult: |
| 48 | main.cleanup() |
| 49 | main.exit() |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 50 | main.step( "Connect switches to controller" ) |
| 51 | |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 52 | # connect all switches to controller |
| 53 | swResult = main.TRUE |
| 54 | for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ): |
| 55 | sw = "sw%s" % ( i ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 56 | swResult = swResult and main.Mininet.assignSwController( sw, main.ONOSip[ 0 ] ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 57 | utilities.assert_equals( expect=main.TRUE, |
| 58 | actual=swResult, |
| 59 | onpass="Successfully connect all switches to ONOS", |
| 60 | onfail="Failed to connect all switches to ONOS" ) |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 61 | if not swResult: |
| 62 | main.cleanup() |
| 63 | main.exit() |
| 64 | |
| 65 | main.step( "Set up tunnel from Mininet node to onos node" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 66 | forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.ONOSip[ 0 ] ) |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 67 | command = 'ssh -nNT -o "PasswordAuthentication no" \ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 68 | -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, main.ONOSip[ 0 ] ) |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 69 | |
| 70 | tunnelResult = main.TRUE |
| 71 | tunnelResult = main.Mininet.node( "root", command ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 72 | utilities.assert_equals( expect=True, |
| 73 | actual=( "PasswordAuthentication" in tunnelResult ), |
| 74 | onpass="Created tunnel succeeded", |
| 75 | onfail="Create tunnel failed" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 76 | if ("PasswordAuthentication" not in tunnelResult) : |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 77 | main.cleanup() |
| 78 | main.exit() |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 79 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 80 | def CASE101( self, main ): |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 81 | """ |
pingping-lin | ea32cf8 | 2015-10-08 22:37:37 -0700 | [diff] [blame] | 82 | Package ONOS and install it |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 83 | Startup sequence: |
| 84 | cell <name> |
| 85 | onos-verify-cell |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 86 | onos-package |
| 87 | onos-install -f |
| 88 | onos-wait-for-start |
| 89 | """ |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 90 | import time |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 91 | import os |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 92 | try: |
| 93 | from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase |
| 94 | except ImportError: |
| 95 | main.log.error( "sdnBase not found. exiting the test" ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 96 | main.exit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 97 | try: |
| 98 | main.sdnBase |
| 99 | except ( NameError, AttributeError ): |
| 100 | main.sdnBase = SdnBase() |
| 101 | |
| 102 | main.sdnBase.initSetup() |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 103 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 104 | def CASE200( self, main ): |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 105 | import json |
| 106 | import time |
| 107 | |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 108 | main.case( "Activate sdn-ip application" ) |
| 109 | main.log.info( "waiting link discovery......" ) |
| 110 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
| 111 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 112 | main.log.info( "Get links in the network" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 113 | summaryResult = main.ONOScli1.summary() |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 114 | linkNum = json.loads( summaryResult )[ "links" ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 115 | listResult = main.ONOScli1.links( jsonFormat=False ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 116 | main.log.info( listResult ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 117 | if linkNum < 100: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 118 | main.log.error( "Link number is wrong!" ) |
| 119 | time.sleep( int( main.params['timers']['TopoDiscovery'] ) ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 120 | listResult = main.ONOScli1.links( jsonFormat=False ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 121 | main.log.info( listResult ) |
| 122 | main.cleanup() |
| 123 | main.exit() |
| 124 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 125 | main.step( "Activate sdn-ip application" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 126 | activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 127 | utilities.assert_equals( expect=main.TRUE, |
| 128 | actual=activeSDNIPresult, |
| 129 | onpass="Activate SDN-IP succeeded", |
| 130 | onfail="Activate SDN-IP failed" ) |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 131 | if not activeSDNIPresult: |
| 132 | main.log.info( "Activate SDN-IP failed!" ) |
| 133 | main.cleanup() |
| 134 | main.exit() |
| 135 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 136 | |
| 137 | main.log.info( "Wait SDN-IP to finish installing connectivity intents \ |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 138 | and the BGP paths in data plane are ready..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 139 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 140 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 141 | other and to sdn-ip, plus finish installing all intents..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 142 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 143 | time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 144 | |
| 145 | |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 146 | def CASE102( self, main ): |
| 147 | ''' |
| 148 | This test case is to load the methods from other Python files. |
| 149 | ''' |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 150 | import imp |
| 151 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 152 | main.case( "Loading methods from other Python file" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 153 | # load the methods from other file |
| 154 | wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 155 | main.Functions = imp.load_source( wrapperFile, |
| 156 | main.dependencyPath + |
| 157 | wrapperFile + |
| 158 | ".py" ) |
| 159 | |
| 160 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 161 | def CASE1( self, main ): |
| 162 | ''' |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 163 | ping test from 7 bgp peers to BGP speaker |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 164 | ''' |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 165 | |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 166 | main.case( "Ping tests between BGP peers and speakers" ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 167 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ], |
| 168 | peers=[ "p64514", "p64515", "p64516" ], |
| 169 | expectAllSuccess=True ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 170 | |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 171 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ], |
| 172 | peers=[ "p64517", "p64518" ], |
| 173 | expectAllSuccess=True ) |
| 174 | |
| 175 | main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ], |
| 176 | peers=[ "p64519", "p64520" ], |
| 177 | expectAllSuccess=True ) |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 178 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 179 | def CASE2( self, main ): |
| 180 | ''' |
| 181 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 182 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 183 | main.sdnBase.pToPIntentTest( 6 ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 184 | |
| 185 | |
| 186 | def CASE3( self, main ): |
| 187 | ''' |
| 188 | routes and intents check to all BGP peers |
| 189 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 190 | main.case( "Check routes and M2S intents to all BGP peers" ) |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 191 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 192 | allRoutesExpected = [] |
| 193 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 194 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 195 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 196 | allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" ) |
| 197 | allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" ) |
| 198 | allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" ) |
| 199 | allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" ) |
| 200 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 201 | main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 202 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame] | 203 | |
| 204 | def CASE4( self, main ): |
| 205 | ''' |
| 206 | Ping test in data plane for each route |
| 207 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 208 | main.case( "Ping test for each route, all hosts behind BGP peers" ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 209 | #No vlan |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 210 | main.Functions.pingHostToHost( main, |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 211 | hosts=[ "h64514", "h64515", "h64516" ], |
| 212 | expectAllSuccess=True ) |
| 213 | #vlan 10 |
| 214 | main.Functions.pingHostToHost( main, |
| 215 | hosts=[ "h64519", "h64520" ], |
| 216 | expectAllSuccess=True ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 217 | |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 218 | # vlan 20 |
| 219 | main.Functions.pingHostToHost( main, |
| 220 | hosts=[ "h64517", "h64518" ], |
| 221 | expectAllSuccess=True ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 222 | |
| 223 | def CASE5( self, main ): |
| 224 | ''' |
| 225 | Cut links to peers one by one, check routes/intents |
| 226 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 227 | main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516", |
| 228 | 6, 6, 5, 5, 4, 4, |
| 229 | "spk1", [ "h64514", "h64515", "h64516" ], |
| 230 | "down" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 231 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 232 | |
| 233 | def CASE6( self, main ): |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 234 | ''' |
| 235 | Recover links to peers one by one, check routes/intents |
| 236 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 237 | main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516", |
| 238 | 5, 5, 6, 6, 7, 7, |
| 239 | "spk1", [ "h64514", "h64515", "h64516" ], |
| 240 | "up" ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 241 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 242 | def CASE7( self, main ): |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 243 | ''' |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 244 | Shut down a edge switch, check P-2-P and M-2-S intents, ping test |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 245 | ''' |
| 246 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 247 | main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 248 | main.step( "Stop sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 249 | result = main.Mininet.switch( SW="sw32", OPTION="stop" ) |
| 250 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 251 | onpass="Stopping switch succeeded!", |
| 252 | onfail="Stopping switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 253 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 254 | if result == main.TRUE: |
| 255 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 256 | main.Functions.checkRouteNum( main, 6 ) #stop one sw, which bring one link between peer and sw down. |
| 257 | main.Functions.checkM2SintentNum( main, 6 ) |
| 258 | main.Functions.checkP2PintentNum( main, 36 ) #6 intents from sw to speakers x 6 intents to sw x 2 intents between them |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 259 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 260 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 261 | main.cleanup() |
| 262 | main.exit() |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 263 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 264 | main.step( "Check ping between hosts behind BGP peers" ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 265 | result1 = main.Mininet.pingHost( src="h64514", target="h64515" ) |
| 266 | result2 = main.Mininet.pingHost( src="h64515", target="h64516" ) |
| 267 | result3 = main.Mininet.pingHost( src="h64514", target="h64516" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 268 | |
| 269 | pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \ |
| 270 | and ( result3 == main.FALSE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 271 | utilities.assert_equals( expect=True, actual=pingResult1, |
| 272 | onpass="Ping test result is correct", |
| 273 | onfail="Ping test result is wrong" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 274 | |
| 275 | if pingResult1 == False: |
| 276 | main.cleanup() |
| 277 | main.exit() |
| 278 | |
| 279 | main.step( "Check ping between BGP peers and speakers" ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 280 | result4 = main.Mininet.pingHost( src="spk1", target="p64514" ) |
| 281 | result5 = main.Mininet.pingHost( src="spk1", target="p64515" ) |
| 282 | result6 = main.Mininet.pingHost( src="spk1", target="p64516" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 283 | |
| 284 | pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \ |
| 285 | and ( result6 == main.TRUE ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 286 | utilities.assert_equals( expect=True, actual=pingResult2, |
| 287 | onpass="Speaker1 ping peers successful", |
| 288 | onfail="Speaker1 ping peers NOT successful" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 289 | |
| 290 | if pingResult2 == False: |
| 291 | main.cleanup() |
| 292 | main.exit() |
| 293 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 294 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 295 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 296 | main.FALSE, |
| 297 | kwargs={'isPENDING':False}, |
| 298 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 299 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 300 | expect=main.TRUE, |
| 301 | actual=flowCheck, |
| 302 | onpass="Flow status is correct!", |
| 303 | onfail="Flow status is wrong!" ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 304 | |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 305 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 306 | def CASE8( self, main ): |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 307 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 308 | Bring up the edge switch (sw32) which was shut down in CASE7, |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 309 | check P-2-P and M-2-S intents, ping test |
| 310 | ''' |
| 311 | import time |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 312 | main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 313 | main.step( "Start sw32" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 314 | result1 = main.Mininet.switch( SW="sw32", OPTION="start" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 315 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 316 | expect=main.TRUE, |
| 317 | actual=result1, |
| 318 | onpass="Starting switch succeeded!", |
| 319 | onfail="Starting switch failed!" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 320 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 321 | result2 = main.Mininet.assignSwController( "sw32", main.ONOSip[ 0 ] ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 322 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 323 | expect=main.TRUE, |
| 324 | actual=result2, |
| 325 | onpass="Connect switch to ONOS succeeded!", |
| 326 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 327 | |
| 328 | if result1 and result2: |
| 329 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 330 | main.Functions.checkRouteNum( main, 7 ) |
| 331 | main.Functions.checkM2SintentNum( main, 7 ) |
| 332 | main.Functions.checkP2PintentNum( main, 42 ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 333 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 334 | main.log.error( "Starting switch failed!" ) |
pingping-lin | d791d34 | 2015-09-17 18:34:31 -0700 | [diff] [blame] | 335 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 336 | main.exit() |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 337 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 338 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 339 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 340 | main.FALSE, |
| 341 | kwargs={'isPENDING':False}, |
| 342 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 343 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 344 | expect=main.TRUE, |
| 345 | actual=flowCheck, |
| 346 | onpass="Flow status is correct!", |
| 347 | onfail="Flow status is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 348 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 349 | # Ping test |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 350 | main.Functions.pingSpeakerToPeer( main, speakers=["spk1"], |
| 351 | peers=["p64514", "p64515", "p64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 352 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 353 | main.Functions.pingHostToHost( main, |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 354 | hosts=["h64514", "h64515", "h64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 355 | expectAllSuccess=True ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 356 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 357 | |
| 358 | def CASE9( self, main ): |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 359 | ''' |
| 360 | Bring down a switch in best path, check: |
| 361 | route number, P2P intent number, M2S intent number, ping test |
| 362 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 363 | main.case( "Stop sw11 located in best path, \ |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 364 | check route number, P2P intent number, M2S intent number, ping test" ) |
| 365 | |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 366 | main.log.info( "Check the flow number correctness before stopping sw11" ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 367 | main.Functions.checkFlowNum( main, "sw11", 43 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 368 | main.Functions.checkFlowNum( main, "sw1", 3 ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 369 | main.Functions.checkFlowNum( main, "sw7", 34 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 370 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 371 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 372 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 373 | |
| 374 | main.step( "Stop sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 375 | result = main.Mininet.switch( SW="sw11", OPTION="stop" ) |
| 376 | utilities.assertEquals( expect=main.TRUE, actual=result, |
| 377 | onpass="Stopping switch succeeded!", |
| 378 | onfail="Stopping switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 379 | if result: |
| 380 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 381 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 382 | main.Functions.checkRouteNum( main, 7 ) |
| 383 | main.Functions.checkM2SintentNum( main, 7 ) |
| 384 | main.Functions.checkP2PintentNum( main, 42 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 385 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 386 | main.log.error( "Stopping switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 387 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 388 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 389 | |
| 390 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 391 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 392 | main.FALSE, |
| 393 | kwargs={'isPENDING':False}, |
| 394 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 395 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 396 | expect=main.TRUE, |
| 397 | actual=flowCheck, |
| 398 | onpass="Flow status is correct!", |
| 399 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 400 | # Ping test |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 401 | main.Functions.pingSpeakerToPeer( main, speakers=["spk1"], |
| 402 | peers=["p64514", "p64515", "p64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 403 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 404 | main.Functions.pingHostToHost( main, |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 405 | hosts=["h64514", "h64515", "h64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 406 | expectAllSuccess=True ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 407 | |
| 408 | |
| 409 | def CASE10( self, main ): |
| 410 | ''' |
| 411 | Bring up the switch which was stopped in CASE9, check: |
| 412 | route number, P2P intent number, M2S intent number, ping test |
| 413 | ''' |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 414 | main.case( "Start sw11 which was stopped in CASE9, \ |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 415 | check route number, P2P intent number, M2S intent number, ping test" ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 416 | |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 417 | main.log.info( "Check the flow status before starting sw11" ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 418 | main.Functions.checkFlowNum( main, "sw1", 33 ) |
| 419 | main.Functions.checkFlowNum( main, "sw7", 28 ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 420 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 421 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 422 | |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 423 | main.step( "Start sw11" ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 424 | result1 = main.Mininet.switch( SW="sw11", OPTION="start" ) |
| 425 | utilities.assertEquals( expect=main.TRUE, actual=result1, |
| 426 | onpass="Starting switch succeeded!", |
| 427 | onfail="Starting switch failed!" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 428 | result2 = main.Mininet.assignSwController( "sw11", main.ONOSip[ 0 ] ) |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 429 | utilities.assertEquals( expect=main.TRUE, actual=result2, |
| 430 | onpass="Connect switch to ONOS succeeded!", |
| 431 | onfail="Connect switch to ONOS failed!" ) |
pingping-lin | 0351dee | 2015-09-28 13:26:35 -0700 | [diff] [blame] | 432 | if result1 and result2: |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 433 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 434 | main.Functions.checkRouteNum( main, 7 ) |
| 435 | main.Functions.checkM2SintentNum( main, 7 ) |
| 436 | main.Functions.checkP2PintentNum( main, 42 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 437 | |
pingping-lin | 3f091d6 | 2015-09-29 12:00:05 -0700 | [diff] [blame] | 438 | main.log.debug( main.Mininet.checkFlows( "sw11" ) ) |
| 439 | main.log.debug( main.Mininet.checkFlows( "sw1" ) ) |
| 440 | main.log.debug( main.Mininet.checkFlows( "sw7" ) ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 441 | else: |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 442 | main.log.error( "Starting switch failed!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 443 | main.cleanup() |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 444 | main.exit() |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 445 | |
| 446 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 447 | flowCheck = utilities.retry( main.ONOScli1.checkFlowsState, |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 448 | main.FALSE, |
| 449 | kwargs={'isPENDING':False}, |
| 450 | attempts=10 ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 451 | utilities.assertEquals( \ |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 452 | expect=main.TRUE, |
| 453 | actual=flowCheck, |
| 454 | onpass="Flow status is correct!", |
| 455 | onfail="Flow status is wrong!" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 456 | # Ping test |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 457 | main.Functions.pingSpeakerToPeer( main, speakers=["spk1"], |
| 458 | peers=["p64514", "p64515", "p64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 459 | expectAllSuccess=True ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 460 | main.Functions.pingHostToHost( main, |
alison | e4121a9 | 2016-11-22 16:31:36 -0800 | [diff] [blame] | 461 | hosts=["h64514", "h64515", "h64516"], |
Jon Hall | 6e9897d | 2016-02-29 14:41:32 -0800 | [diff] [blame] | 462 | expectAllSuccess=True ) |