blob: 48b0a6651c11291a30410fb7e8127f0dbb691230 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2016 Open Networking Foundation (ONF)
3
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
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-lin28e7b212015-09-10 10:14:58 -070022# Testing the functionality of SDN-IP with single ONOS instance
pingping-lin5bb663b2015-09-24 11:47:50 -070023class USECASE_SdnipFunction:
pingping-lin28e7b212015-09-10 10:14:58 -070024
25 def __init__( self ):
26 self.default = ''
27 global branchName
28
pingping-linb702c602015-09-10 17:00:29 -070029 def CASE100( self, main ):
30 """
31 Start mininet
32 """
33 import os
Jon Hall70b768c2016-04-19 08:38:29 -070034 main.case( "Setup the Mininet testbed" )
pingping-linb702c602015-09-10 17:00:29 -070035 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 Hall6e9897d2016-02-29 14:41:32 -080041 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-linb702c602015-09-10 17:00:29 -070046 # Exit if topology did not load properly
47 if not topoResult:
48 main.cleanup()
49 main.exit()
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
54 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
55 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:
63 main.cleanup()
64 main.exit()
65
66 main.step( "Set up tunnel from Mininet node to onos node" )
Devin Lim142b5342017-07-20 15:22:39 -070067 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.Cluster.active( 0 ).ipAddress )
pingping-lin5bb663b2015-09-24 11:47:50 -070068 command = 'ssh -nNT -o "PasswordAuthentication no" \
Devin Lim142b5342017-07-20 15:22:39 -070069 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % \
70 ( forwarding1, main.Cluster.active( 0 ).ipAddress )
pingping-lin5bb663b2015-09-24 11:47:50 -070071
72 tunnelResult = main.TRUE
73 tunnelResult = main.Mininet.node( "root", command )
Jon Hall6e9897d2016-02-29 14:41:32 -080074 utilities.assert_equals( expect=True,
75 actual=( "PasswordAuthentication" in tunnelResult ),
76 onpass="Created tunnel succeeded",
77 onfail="Create tunnel failed" )
pingping-linb3ebd3f2015-09-28 22:17:05 -070078 if ("PasswordAuthentication" not in tunnelResult) :
pingping-lin5bb663b2015-09-24 11:47:50 -070079 main.cleanup()
80 main.exit()
pingping-lin5bb663b2015-09-24 11:47:50 -070081
pingping-linb702c602015-09-10 17:00:29 -070082 def CASE101( self, main ):
pingping-lin28e7b212015-09-10 10:14:58 -070083 """
pingping-linea32cf82015-10-08 22:37:37 -070084 Package ONOS and install it
pingping-lin28e7b212015-09-10 10:14:58 -070085 Startup sequence:
86 cell <name>
87 onos-verify-cell
pingping-lin28e7b212015-09-10 10:14:58 -070088 onos-package
89 onos-install -f
90 onos-wait-for-start
91 """
pingping-lin28e7b212015-09-10 10:14:58 -070092 import time
Jon Hall6e9897d2016-02-29 14:41:32 -080093 import os
Devin Lim58046fa2017-07-05 16:55:00 -070094 try:
95 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
96 except ImportError:
97 main.log.error( "sdnBase not found. exiting the test" )
pingping-lin28e7b212015-09-10 10:14:58 -070098 main.exit()
Devin Lim58046fa2017-07-05 16:55:00 -070099 try:
100 main.sdnBase
101 except ( NameError, AttributeError ):
102 main.sdnBase = SdnBase()
103
104 main.sdnBase.initSetup()
pingping-lin28e7b212015-09-10 10:14:58 -0700105
Jon Hall6e9897d2016-02-29 14:41:32 -0800106 def CASE200( self, main ):
alisone4121a92016-11-22 16:31:36 -0800107 import json
108 import time
109
Jon Hall6e9897d2016-02-29 14:41:32 -0800110 main.case( "Activate sdn-ip application" )
111 main.log.info( "waiting link discovery......" )
112 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
113
pingping-linb3ebd3f2015-09-28 22:17:05 -0700114 main.log.info( "Get links in the network" )
Devin Lim142b5342017-07-20 15:22:39 -0700115 summaryResult = main.Cluster.active( 0 ).CLI.summary()
pingping-lin3f091d62015-09-29 12:00:05 -0700116 linkNum = json.loads( summaryResult )[ "links" ]
Devin Lim142b5342017-07-20 15:22:39 -0700117 listResult = main.Cluster.active( 0 ).CLI.links( jsonFormat=False )
Jon Hall6e9897d2016-02-29 14:41:32 -0800118 main.log.info( listResult )
pingping-lin3f091d62015-09-29 12:00:05 -0700119 if linkNum < 100:
Jon Hall6e9897d2016-02-29 14:41:32 -0800120 main.log.error( "Link number is wrong!" )
121 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Devin Lim142b5342017-07-20 15:22:39 -0700122 listResult = main.Cluster.active( 0 ).CLI.links( jsonFormat=False )
pingping-lin3f091d62015-09-29 12:00:05 -0700123 main.log.info( listResult )
124 main.cleanup()
125 main.exit()
126
pingping-linb3ebd3f2015-09-28 22:17:05 -0700127 main.step( "Activate sdn-ip application" )
Devin Lim142b5342017-07-20 15:22:39 -0700128 activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800129 utilities.assert_equals( expect=main.TRUE,
130 actual=activeSDNIPresult,
131 onpass="Activate SDN-IP succeeded",
132 onfail="Activate SDN-IP failed" )
pingping-lin3f091d62015-09-29 12:00:05 -0700133 if not activeSDNIPresult:
134 main.log.info( "Activate SDN-IP failed!" )
135 main.cleanup()
136 main.exit()
137
pingping-linb3ebd3f2015-09-28 22:17:05 -0700138
139 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
pingping-linb702c602015-09-10 17:00:29 -0700140 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700141 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700142 main.log.info( "Wait Quagga to finish delivery all routes to each \
143 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700144 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
145 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
146
147
pingping-lin4f80c492015-09-15 14:34:42 -0700148 def CASE102( self, main ):
149 '''
150 This test case is to load the methods from other Python files.
151 '''
alisone4121a92016-11-22 16:31:36 -0800152 import imp
153
pingping-linb3ebd3f2015-09-28 22:17:05 -0700154 main.case( "Loading methods from other Python file" )
pingping-lin4f80c492015-09-15 14:34:42 -0700155 # 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-lin0ce60622015-09-10 14:37:33 -0700163 def CASE1( self, main ):
164 '''
alisone4121a92016-11-22 16:31:36 -0800165 ping test from 7 bgp peers to BGP speaker
pingping-lin0ce60622015-09-10 14:37:33 -0700166 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700167
pingping-linb3ebd3f2015-09-28 22:17:05 -0700168 main.case( "Ping tests between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800169 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
170 peers=[ "p64514", "p64515", "p64516" ],
171 expectAllSuccess=True )
pingping-lin0ce60622015-09-10 14:37:33 -0700172
alisone4121a92016-11-22 16:31:36 -0800173 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-lin950b50d2015-09-14 12:00:08 -0700180
pingping-lin0ce60622015-09-10 14:37:33 -0700181 def CASE2( self, main ):
182 '''
183 point-to-point intents test for each BGP peer and BGP speaker pair
184 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700185 main.sdnBase.pToPIntentTest( 6 )
pingping-lin0ce60622015-09-10 14:37:33 -0700186
187
188 def CASE3( self, main ):
189 '''
190 routes and intents check to all BGP peers
191 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700192 main.case( "Check routes and M2S intents to all BGP peers" )
pingping-lin0ce60622015-09-10 14:37:33 -0700193
pingping-lin28e7b212015-09-10 10:14:58 -0700194 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" )
alisone4121a92016-11-22 16:31:36 -0800198 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 Lim58046fa2017-07-05 16:55:00 -0700203 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700204
pingping-lin950b50d2015-09-14 12:00:08 -0700205
206 def CASE4( self, main ):
207 '''
208 Ping test in data plane for each route
209 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700210 main.case( "Ping test for each route, all hosts behind BGP peers" )
alisone4121a92016-11-22 16:31:36 -0800211 #No vlan
pingping-lin829428d2015-09-22 20:50:00 -0700212 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800213 hosts=[ "h64514", "h64515", "h64516" ],
214 expectAllSuccess=True )
215 #vlan 10
216 main.Functions.pingHostToHost( main,
217 hosts=[ "h64519", "h64520" ],
218 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700219
alisone4121a92016-11-22 16:31:36 -0800220 # vlan 20
221 main.Functions.pingHostToHost( main,
222 hosts=[ "h64517", "h64518" ],
223 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700224
225 def CASE5( self, main ):
226 '''
227 Cut links to peers one by one, check routes/intents
228 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700229 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
230 6, 6, 5, 5, 4, 4,
231 "spk1", [ "h64514", "h64515", "h64516" ],
232 "down" )
pingping-lin4f80c492015-09-15 14:34:42 -0700233
pingping-lin829428d2015-09-22 20:50:00 -0700234
235 def CASE6( self, main ):
pingping-lin4f80c492015-09-15 14:34:42 -0700236 '''
237 Recover links to peers one by one, check routes/intents
238 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700239 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
240 5, 5, 6, 6, 7, 7,
241 "spk1", [ "h64514", "h64515", "h64516" ],
242 "up" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700243
pingping-lin829428d2015-09-22 20:50:00 -0700244 def CASE7( self, main ):
pingping-lin8244a3b2015-09-16 13:36:56 -0700245 '''
pingping-lin829428d2015-09-22 20:50:00 -0700246 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
pingping-lin8244a3b2015-09-16 13:36:56 -0700247 '''
248 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700249 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700250 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800251 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-linb3ebd3f2015-09-28 22:17:05 -0700255
pingping-lin8244a3b2015-09-16 13:36:56 -0700256 if result == main.TRUE:
257 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800258 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-lin8244a3b2015-09-16 13:36:56 -0700261 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800262 main.log.error( "Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700263 main.cleanup()
264 main.exit()
pingping-lin8244a3b2015-09-16 13:36:56 -0700265
pingping-lin829428d2015-09-22 20:50:00 -0700266 main.step( "Check ping between hosts behind BGP peers" )
alisone4121a92016-11-22 16:31:36 -0800267 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-lin829428d2015-09-22 20:50:00 -0700270
271 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
272 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800273 utilities.assert_equals( expect=True, actual=pingResult1,
274 onpass="Ping test result is correct",
275 onfail="Ping test result is wrong" )
pingping-lin829428d2015-09-22 20:50:00 -0700276
277 if pingResult1 == False:
278 main.cleanup()
279 main.exit()
280
281 main.step( "Check ping between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800282 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-lin829428d2015-09-22 20:50:00 -0700285
286 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
287 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800288 utilities.assert_equals( expect=True, actual=pingResult2,
289 onpass="Speaker1 ping peers successful",
290 onfail="Speaker1 ping peers NOT successful" )
pingping-lin829428d2015-09-22 20:50:00 -0700291
292 if pingResult2 == False:
293 main.cleanup()
294 main.exit()
295
pingping-linbab7f8a2015-09-21 17:33:36 -0700296 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700297 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800298 main.FALSE,
299 kwargs={'isPENDING':False},
300 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700301 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800302 expect=main.TRUE,
303 actual=flowCheck,
304 onpass="Flow status is correct!",
305 onfail="Flow status is wrong!" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700306
pingping-lind791d342015-09-17 18:34:31 -0700307
pingping-lin8244a3b2015-09-16 13:36:56 -0700308 def CASE8( self, main ):
pingping-lind791d342015-09-17 18:34:31 -0700309 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700310 Bring up the edge switch (sw32) which was shut down in CASE7,
pingping-lind791d342015-09-17 18:34:31 -0700311 check P-2-P and M-2-S intents, ping test
312 '''
313 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700314 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700315 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800316 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700317 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800318 expect=main.TRUE,
319 actual=result1,
320 onpass="Starting switch succeeded!",
321 onfail="Starting switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700322
Devin Lim142b5342017-07-20 15:22:39 -0700323 result2 = main.Mininet.assignSwController( "sw32", main.Cluster.active( 0 ).ipAddress )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700324 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800325 expect=main.TRUE,
326 actual=result2,
327 onpass="Connect switch to ONOS succeeded!",
328 onfail="Connect switch to ONOS failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700329
330 if result1 and result2:
331 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800332 main.Functions.checkRouteNum( main, 7 )
333 main.Functions.checkM2SintentNum( main, 7 )
334 main.Functions.checkP2PintentNum( main, 42 )
pingping-lind791d342015-09-17 18:34:31 -0700335 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800336 main.log.error( "Starting switch failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700337 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700338 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700339
pingping-linbab7f8a2015-09-21 17:33:36 -0700340 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700341 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800342 main.FALSE,
343 kwargs={'isPENDING':False},
344 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700345 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800346 expect=main.TRUE,
347 actual=flowCheck,
348 onpass="Flow status is correct!",
349 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700350
pingping-lin829428d2015-09-22 20:50:00 -0700351 # Ping test
alisone4121a92016-11-22 16:31:36 -0800352 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
353 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800354 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700355 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800356 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800357 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700358
pingping-lin829428d2015-09-22 20:50:00 -0700359
360 def CASE9( self, main ):
pingping-linbab7f8a2015-09-21 17:33:36 -0700361 '''
362 Bring down a switch in best path, check:
363 route number, P2P intent number, M2S intent number, ping test
364 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700365 main.case( "Stop sw11 located in best path, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700366 check route number, P2P intent number, M2S intent number, ping test" )
367
pingping-lin581a3662015-09-29 17:43:39 -0700368 main.log.info( "Check the flow number correctness before stopping sw11" )
alisone4121a92016-11-22 16:31:36 -0800369 main.Functions.checkFlowNum( main, "sw11", 43 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700370 main.Functions.checkFlowNum( main, "sw1", 3 )
alisone4121a92016-11-22 16:31:36 -0800371 main.Functions.checkFlowNum( main, "sw7", 34 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800372 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
373 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
374 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700375
376 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800377 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-linbab7f8a2015-09-21 17:33:36 -0700381 if result:
382 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700383 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800384 main.Functions.checkRouteNum( main, 7 )
385 main.Functions.checkM2SintentNum( main, 7 )
386 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700387 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800388 main.log.error( "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700389 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700390 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700391
392 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700393 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800394 main.FALSE,
395 kwargs={'isPENDING':False},
396 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700397 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800398 expect=main.TRUE,
399 actual=flowCheck,
400 onpass="Flow status is correct!",
401 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700402 # Ping test
alisone4121a92016-11-22 16:31:36 -0800403 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
404 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800405 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700406 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800407 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800408 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700409
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-linb3ebd3f2015-09-28 22:17:05 -0700416 main.case( "Start sw11 which was stopped in CASE9, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700417 check route number, P2P intent number, M2S intent number, ping test" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700418
pingping-lin581a3662015-09-29 17:43:39 -0700419 main.log.info( "Check the flow status before starting sw11" )
alisone4121a92016-11-22 16:31:36 -0800420 main.Functions.checkFlowNum( main, "sw1", 33 )
421 main.Functions.checkFlowNum( main, "sw7", 28 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800422 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
423 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700424
pingping-linbab7f8a2015-09-21 17:33:36 -0700425 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800426 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 Lim142b5342017-07-20 15:22:39 -0700430 result2 = main.Mininet.assignSwController( "sw11", main.Cluster.active( 0 ).ipAddress )
Jon Hall6e9897d2016-02-29 14:41:32 -0800431 utilities.assertEquals( expect=main.TRUE, actual=result2,
432 onpass="Connect switch to ONOS succeeded!",
433 onfail="Connect switch to ONOS failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700434 if result1 and result2:
pingping-linbab7f8a2015-09-21 17:33:36 -0700435 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800436 main.Functions.checkRouteNum( main, 7 )
437 main.Functions.checkM2SintentNum( main, 7 )
438 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700439
pingping-lin3f091d62015-09-29 12:00:05 -0700440 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
441 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
442 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700443 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800444 main.log.error( "Starting switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700445 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700446 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700447
448 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700449 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800450 main.FALSE,
451 kwargs={'isPENDING':False},
452 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700453 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800454 expect=main.TRUE,
455 actual=flowCheck,
456 onpass="Flow status is correct!",
457 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700458 # Ping test
alisone4121a92016-11-22 16:31:36 -0800459 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
460 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800461 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700462 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800463 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800464 expectAllSuccess=True )