blob: a45bdef91dd58e4f52a73d7a059195c6d3268cf3 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or 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 Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
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-lin28e7b212015-09-10 10:14:58 -070021# Testing the functionality of SDN-IP with single ONOS instance
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070022
23
pingping-lin5bb663b2015-09-24 11:47:50 -070024class USECASE_SdnipFunction:
pingping-lin28e7b212015-09-10 10:14:58 -070025
26 def __init__( self ):
27 self.default = ''
28 global branchName
29
pingping-linb702c602015-09-10 17:00:29 -070030 def CASE100( self, main ):
31 """
32 Start mininet
33 """
34 import os
Jon Hall70b768c2016-04-19 08:38:29 -070035 main.case( "Setup the Mininet testbed" )
pingping-linb702c602015-09-10 17:00:29 -070036 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 Hall6e9897d2016-02-29 14:41:32 -080042 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-linb702c602015-09-10 17:00:29 -070047 # Exit if topology did not load properly
48 if not topoResult:
Devin Lim44075962017-08-11 10:56:37 -070049 main.cleanAndExit()
pingping-lin5bb663b2015-09-24 11:47:50 -070050 main.step( "Connect switches to controller" )
51
pingping-lin5bb663b2015-09-24 11:47:50 -070052 # connect all switches to controller
53 swResult = main.TRUE
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070054 for i in range( 1, int( main.params[ 'config' ][ 'switchNum' ] ) + 1 ):
pingping-lin5bb663b2015-09-24 11:47:50 -070055 sw = "sw%s" % ( i )
Devin Lim142b5342017-07-20 15:22:39 -070056 swResult = swResult and \
57 main.Mininet.assignSwController( sw, main.Cluster.active( 0 ).ipAddress )
Jon Hall6e9897d2016-02-29 14:41:32 -080058 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-lin5bb663b2015-09-24 11:47:50 -070062 if not swResult:
Devin Lim44075962017-08-11 10:56:37 -070063 main.cleanAndExit()
pingping-lin5bb663b2015-09-24 11:47:50 -070064
65 main.step( "Set up tunnel from Mininet node to onos node" )
Devin Lim142b5342017-07-20 15:22:39 -070066 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.Cluster.active( 0 ).ipAddress )
pingping-lin5bb663b2015-09-24 11:47:50 -070067 command = 'ssh -nNT -o "PasswordAuthentication no" \
Devin Lim142b5342017-07-20 15:22:39 -070068 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % \
69 ( forwarding1, main.Cluster.active( 0 ).ipAddress )
pingping-lin5bb663b2015-09-24 11:47:50 -070070
71 tunnelResult = main.TRUE
72 tunnelResult = main.Mininet.node( "root", command )
Jon Hall6e9897d2016-02-29 14:41:32 -080073 utilities.assert_equals( expect=True,
74 actual=( "PasswordAuthentication" in tunnelResult ),
75 onpass="Created tunnel succeeded",
76 onfail="Create tunnel failed" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070077 if ( "PasswordAuthentication" not in tunnelResult ):
Devin Lim44075962017-08-11 10:56:37 -070078 main.cleanAndExit()
pingping-lin5bb663b2015-09-24 11:47:50 -070079
pingping-linb702c602015-09-10 17:00:29 -070080 def CASE101( self, main ):
pingping-lin28e7b212015-09-10 10:14:58 -070081 """
pingping-linea32cf82015-10-08 22:37:37 -070082 Package ONOS and install it
pingping-lin28e7b212015-09-10 10:14:58 -070083 Startup sequence:
84 cell <name>
85 onos-verify-cell
pingping-lin28e7b212015-09-10 10:14:58 -070086 onos-package
87 onos-install -f
88 onos-wait-for-start
89 """
pingping-lin28e7b212015-09-10 10:14:58 -070090 import time
Jon Hall6e9897d2016-02-29 14:41:32 -080091 import os
Devin Lim58046fa2017-07-05 16:55:00 -070092 try:
93 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
94 except ImportError:
95 main.log.error( "sdnBase not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070096 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070097 try:
98 main.sdnBase
99 except ( NameError, AttributeError ):
100 main.sdnBase = SdnBase()
101
102 main.sdnBase.initSetup()
pingping-lin28e7b212015-09-10 10:14:58 -0700103
Jon Hall6e9897d2016-02-29 14:41:32 -0800104 def CASE200( self, main ):
alisone4121a92016-11-22 16:31:36 -0800105 import json
106 import time
107
Jon Hall6e9897d2016-02-29 14:41:32 -0800108 main.case( "Activate sdn-ip application" )
109 main.log.info( "waiting link discovery......" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700110 time.sleep( int( main.params[ 'timers' ][ 'TopoDiscovery' ] ) )
Jon Hall6e9897d2016-02-29 14:41:32 -0800111
pingping-linb3ebd3f2015-09-28 22:17:05 -0700112 main.log.info( "Get links in the network" )
Devin Lim142b5342017-07-20 15:22:39 -0700113 summaryResult = main.Cluster.active( 0 ).CLI.summary()
pingping-lin3f091d62015-09-29 12:00:05 -0700114 linkNum = json.loads( summaryResult )[ "links" ]
Devin Lim142b5342017-07-20 15:22:39 -0700115 listResult = main.Cluster.active( 0 ).CLI.links( jsonFormat=False )
Jon Hall6e9897d2016-02-29 14:41:32 -0800116 main.log.info( listResult )
pingping-lin3f091d62015-09-29 12:00:05 -0700117 if linkNum < 100:
Jon Hall6e9897d2016-02-29 14:41:32 -0800118 main.log.error( "Link number is wrong!" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700119 time.sleep( int( main.params[ 'timers' ][ 'TopoDiscovery' ] ) )
Devin Lim142b5342017-07-20 15:22:39 -0700120 listResult = main.Cluster.active( 0 ).CLI.links( jsonFormat=False )
pingping-lin3f091d62015-09-29 12:00:05 -0700121 main.log.info( listResult )
Devin Lim44075962017-08-11 10:56:37 -0700122 main.cleanAndExit()
pingping-lin3f091d62015-09-29 12:00:05 -0700123
pingping-linb3ebd3f2015-09-28 22:17:05 -0700124 main.step( "Activate sdn-ip application" )
Devin Lim142b5342017-07-20 15:22:39 -0700125 activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800126 utilities.assert_equals( expect=main.TRUE,
127 actual=activeSDNIPresult,
128 onpass="Activate SDN-IP succeeded",
129 onfail="Activate SDN-IP failed" )
pingping-lin3f091d62015-09-29 12:00:05 -0700130 if not activeSDNIPresult:
131 main.log.info( "Activate SDN-IP failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700132 main.cleanAndExit()
pingping-lin3f091d62015-09-29 12:00:05 -0700133
pingping-linb3ebd3f2015-09-28 22:17:05 -0700134 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
pingping-linb702c602015-09-10 17:00:29 -0700135 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700136 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700137 main.log.info( "Wait Quagga to finish delivery all routes to each \
138 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700139 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
140 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
141
pingping-lin4f80c492015-09-15 14:34:42 -0700142 def CASE102( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700143 """
pingping-lin4f80c492015-09-15 14:34:42 -0700144 This test case is to load the methods from other Python files.
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700145 """
alisone4121a92016-11-22 16:31:36 -0800146 import imp
147
pingping-linb3ebd3f2015-09-28 22:17:05 -0700148 main.case( "Loading methods from other Python file" )
pingping-lin4f80c492015-09-15 14:34:42 -0700149 # load the methods from other file
150 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
151 main.Functions = imp.load_source( wrapperFile,
152 main.dependencyPath +
153 wrapperFile +
154 ".py" )
155
pingping-lin0ce60622015-09-10 14:37:33 -0700156 def CASE1( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700157 """
alisone4121a92016-11-22 16:31:36 -0800158 ping test from 7 bgp peers to BGP speaker
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700159 """
pingping-linb3ebd3f2015-09-28 22:17:05 -0700160 main.case( "Ping tests between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800161 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
162 peers=[ "p64514", "p64515", "p64516" ],
163 expectAllSuccess=True )
pingping-lin0ce60622015-09-10 14:37:33 -0700164
alisone4121a92016-11-22 16:31:36 -0800165 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
166 peers=[ "p64517", "p64518" ],
167 expectAllSuccess=True )
168
169 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ],
170 peers=[ "p64519", "p64520" ],
171 expectAllSuccess=True )
pingping-lin950b50d2015-09-14 12:00:08 -0700172
pingping-lin0ce60622015-09-10 14:37:33 -0700173 def CASE2( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700174 """
pingping-lin0ce60622015-09-10 14:37:33 -0700175 point-to-point intents test for each BGP peer and BGP speaker pair
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700176 """
Devin Lim58046fa2017-07-05 16:55:00 -0700177 main.sdnBase.pToPIntentTest( 6 )
pingping-lin0ce60622015-09-10 14:37:33 -0700178
pingping-lin0ce60622015-09-10 14:37:33 -0700179 def CASE3( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700180 """
pingping-lin0ce60622015-09-10 14:37:33 -0700181 routes and intents check to all BGP peers
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700182 """
pingping-linb3ebd3f2015-09-28 22:17:05 -0700183 main.case( "Check routes and M2S intents to all BGP peers" )
pingping-lin0ce60622015-09-10 14:37:33 -0700184
pingping-lin28e7b212015-09-10 10:14:58 -0700185 allRoutesExpected = []
186 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
187 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
188 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
alisone4121a92016-11-22 16:31:36 -0800189 allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" )
190 allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" )
191 allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
192 allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
193
Devin Lim58046fa2017-07-05 16:55:00 -0700194 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700195
pingping-lin950b50d2015-09-14 12:00:08 -0700196 def CASE4( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700197 """
pingping-lin950b50d2015-09-14 12:00:08 -0700198 Ping test in data plane for each route
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700199 """
pingping-linb3ebd3f2015-09-28 22:17:05 -0700200 main.case( "Ping test for each route, all hosts behind BGP peers" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700201 # No vlan
pingping-lin829428d2015-09-22 20:50:00 -0700202 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800203 hosts=[ "h64514", "h64515", "h64516" ],
204 expectAllSuccess=True )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700205 # vlan 10
alisone4121a92016-11-22 16:31:36 -0800206 main.Functions.pingHostToHost( main,
207 hosts=[ "h64519", "h64520" ],
208 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700209
alisone4121a92016-11-22 16:31:36 -0800210 # vlan 20
211 main.Functions.pingHostToHost( main,
212 hosts=[ "h64517", "h64518" ],
213 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700214
215 def CASE5( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700216 """
pingping-lin4f80c492015-09-15 14:34:42 -0700217 Cut links to peers one by one, check routes/intents
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700218 """
Devin Lim58046fa2017-07-05 16:55:00 -0700219 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
220 6, 6, 5, 5, 4, 4,
221 "spk1", [ "h64514", "h64515", "h64516" ],
222 "down" )
pingping-lin4f80c492015-09-15 14:34:42 -0700223
pingping-lin829428d2015-09-22 20:50:00 -0700224 def CASE6( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700225 """
pingping-lin4f80c492015-09-15 14:34:42 -0700226 Recover links to peers one by one, check routes/intents
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700227 """
Devin Lim58046fa2017-07-05 16:55:00 -0700228 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
229 5, 5, 6, 6, 7, 7,
230 "spk1", [ "h64514", "h64515", "h64516" ],
231 "up" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700232
pingping-lin829428d2015-09-22 20:50:00 -0700233 def CASE7( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700234 """
pingping-lin829428d2015-09-22 20:50:00 -0700235 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700236 """
pingping-lin8244a3b2015-09-16 13:36:56 -0700237 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700238 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700239 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800240 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
241 utilities.assertEquals( expect=main.TRUE, actual=result,
242 onpass="Stopping switch succeeded!",
243 onfail="Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700244
pingping-lin8244a3b2015-09-16 13:36:56 -0700245 if result == main.TRUE:
246 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700247 main.Functions.checkRouteNum( main, 6 ) # stop one sw, which bring one link between peer and sw down.
alisone4121a92016-11-22 16:31:36 -0800248 main.Functions.checkM2SintentNum( main, 6 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700249 main.Functions.checkP2PintentNum( main, 36 ) # 6 intents from sw to speakers x 6 intents to sw x 2 intents between them
pingping-lin8244a3b2015-09-16 13:36:56 -0700250 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800251 main.log.error( "Stopping switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700252 main.cleanAndExit()
pingping-lin8244a3b2015-09-16 13:36:56 -0700253
pingping-lin829428d2015-09-22 20:50:00 -0700254 main.step( "Check ping between hosts behind BGP peers" )
alisone4121a92016-11-22 16:31:36 -0800255 result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
256 result2 = main.Mininet.pingHost( src="h64515", target="h64516" )
257 result3 = main.Mininet.pingHost( src="h64514", target="h64516" )
pingping-lin829428d2015-09-22 20:50:00 -0700258
259 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
260 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800261 utilities.assert_equals( expect=True, actual=pingResult1,
262 onpass="Ping test result is correct",
263 onfail="Ping test result is wrong" )
pingping-lin829428d2015-09-22 20:50:00 -0700264
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700265 if not pingResult1:
Devin Lim44075962017-08-11 10:56:37 -0700266 main.cleanAndExit()
pingping-lin829428d2015-09-22 20:50:00 -0700267
268 main.step( "Check ping between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800269 result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
270 result5 = main.Mininet.pingHost( src="spk1", target="p64515" )
271 result6 = main.Mininet.pingHost( src="spk1", target="p64516" )
pingping-lin829428d2015-09-22 20:50:00 -0700272
273 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
274 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800275 utilities.assert_equals( expect=True, actual=pingResult2,
276 onpass="Speaker1 ping peers successful",
277 onfail="Speaker1 ping peers NOT successful" )
pingping-lin829428d2015-09-22 20:50:00 -0700278
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700279 if not pingResult2:
Devin Lim44075962017-08-11 10:56:37 -0700280 main.cleanAndExit()
pingping-lin829428d2015-09-22 20:50:00 -0700281
pingping-linbab7f8a2015-09-21 17:33:36 -0700282 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700283 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800284 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700285 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800286 attempts=10 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700287 utilities.assertEquals(
Jon Hall6e9897d2016-02-29 14:41:32 -0800288 expect=main.TRUE,
289 actual=flowCheck,
290 onpass="Flow status is correct!",
291 onfail="Flow status is wrong!" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700292
293 def CASE8( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700294 """
295 Bring up the edge switch ( sw32 ) which was shut down in CASE7,
pingping-lind791d342015-09-17 18:34:31 -0700296 check P-2-P and M-2-S intents, ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700297 """
pingping-lind791d342015-09-17 18:34:31 -0700298 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700299 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700300 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800301 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700302 utilities.assertEquals(
Jon Hall6e9897d2016-02-29 14:41:32 -0800303 expect=main.TRUE,
304 actual=result1,
305 onpass="Starting switch succeeded!",
306 onfail="Starting switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700307
Devin Lim142b5342017-07-20 15:22:39 -0700308 result2 = main.Mininet.assignSwController( "sw32", main.Cluster.active( 0 ).ipAddress )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700309 utilities.assertEquals(
Jon Hall6e9897d2016-02-29 14:41:32 -0800310 expect=main.TRUE,
311 actual=result2,
312 onpass="Connect switch to ONOS succeeded!",
313 onfail="Connect switch to ONOS failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700314
315 if result1 and result2:
316 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800317 main.Functions.checkRouteNum( main, 7 )
318 main.Functions.checkM2SintentNum( main, 7 )
319 main.Functions.checkP2PintentNum( main, 42 )
pingping-lind791d342015-09-17 18:34:31 -0700320 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800321 main.log.error( "Starting switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700322 main.cleanAndExit()
pingping-lin4f80c492015-09-15 14:34:42 -0700323
pingping-linbab7f8a2015-09-21 17:33:36 -0700324 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700325 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800326 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700327 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800328 attempts=10 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700329 utilities.assertEquals(
Jon Hall6e9897d2016-02-29 14:41:32 -0800330 expect=main.TRUE,
331 actual=flowCheck,
332 onpass="Flow status is correct!",
333 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700334
pingping-lin829428d2015-09-22 20:50:00 -0700335 # Ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700336 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
337 peers=[ "p64514", "p64515", "p64516" ],
338 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700339 main.Functions.pingHostToHost( main,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700340 hosts=[ "h64514", "h64515", "h64516" ],
341 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700342
343 def CASE9( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700344 """
pingping-linbab7f8a2015-09-21 17:33:36 -0700345 Bring down a switch in best path, check:
346 route number, P2P intent number, M2S intent number, ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700347 """
pingping-linb3ebd3f2015-09-28 22:17:05 -0700348 main.case( "Stop sw11 located in best path, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700349 check route number, P2P intent number, M2S intent number, ping test" )
350
pingping-lin581a3662015-09-29 17:43:39 -0700351 main.log.info( "Check the flow number correctness before stopping sw11" )
alisone4121a92016-11-22 16:31:36 -0800352 main.Functions.checkFlowNum( main, "sw11", 43 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700353 main.Functions.checkFlowNum( main, "sw1", 3 )
alisone4121a92016-11-22 16:31:36 -0800354 main.Functions.checkFlowNum( main, "sw7", 34 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800355 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
356 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
357 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700358
359 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800360 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
361 utilities.assertEquals( expect=main.TRUE, actual=result,
362 onpass="Stopping switch succeeded!",
363 onfail="Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700364 if result:
365 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700366 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800367 main.Functions.checkRouteNum( main, 7 )
368 main.Functions.checkM2SintentNum( main, 7 )
369 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700370 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800371 main.log.error( "Stopping switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700372 main.cleanAndExit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700373
374 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700375 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800376 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700377 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800378 attempts=10 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700379 utilities.assertEquals(
Jon Hall6e9897d2016-02-29 14:41:32 -0800380 expect=main.TRUE,
381 actual=flowCheck,
382 onpass="Flow status is correct!",
383 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700384 # Ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700385 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
386 peers=[ "p64514", "p64515", "p64516" ],
387 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700388 main.Functions.pingHostToHost( main,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700389 hosts=[ "h64514", "h64515", "h64516" ],
390 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700391
392 def CASE10( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700393 """
pingping-linbab7f8a2015-09-21 17:33:36 -0700394 Bring up the switch which was stopped in CASE9, check:
395 route number, P2P intent number, M2S intent number, ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700396 """
pingping-linb3ebd3f2015-09-28 22:17:05 -0700397 main.case( "Start sw11 which was stopped in CASE9, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700398 check route number, P2P intent number, M2S intent number, ping test" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700399
pingping-lin581a3662015-09-29 17:43:39 -0700400 main.log.info( "Check the flow status before starting sw11" )
alisone4121a92016-11-22 16:31:36 -0800401 main.Functions.checkFlowNum( main, "sw1", 33 )
402 main.Functions.checkFlowNum( main, "sw7", 28 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800403 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
404 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700405
pingping-linbab7f8a2015-09-21 17:33:36 -0700406 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800407 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
408 utilities.assertEquals( expect=main.TRUE, actual=result1,
409 onpass="Starting switch succeeded!",
410 onfail="Starting switch failed!" )
Devin Lim142b5342017-07-20 15:22:39 -0700411 result2 = main.Mininet.assignSwController( "sw11", main.Cluster.active( 0 ).ipAddress )
Jon Hall6e9897d2016-02-29 14:41:32 -0800412 utilities.assertEquals( expect=main.TRUE, actual=result2,
413 onpass="Connect switch to ONOS succeeded!",
414 onfail="Connect switch to ONOS failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700415 if result1 and result2:
pingping-linbab7f8a2015-09-21 17:33:36 -0700416 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800417 main.Functions.checkRouteNum( main, 7 )
418 main.Functions.checkM2SintentNum( main, 7 )
419 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700420
pingping-lin3f091d62015-09-29 12:00:05 -0700421 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
422 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
423 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700424 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800425 main.log.error( "Starting switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700426 main.cleanAndExit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700427
428 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700429 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800430 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700431 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800432 attempts=10 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700433 utilities.assertEquals(
Jon Hall6e9897d2016-02-29 14:41:32 -0800434 expect=main.TRUE,
435 actual=flowCheck,
436 onpass="Flow status is correct!",
437 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700438 # Ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700439 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
440 peers=[ "p64514", "p64515", "p64516" ],
441 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700442 main.Functions.pingHostToHost( main,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700443 hosts=[ "h64514", "h64515", "h64516" ],
444 expectAllSuccess=True )