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