blob: 5e269323745c1cb92f1b2bae3ce350c3c5efa5bc [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 Lim58046fa2017-07-05 16:55:00 -070056 swResult = swResult and main.Mininet.assignSwController( sw, main.ONOSip[ 0 ] )
Jon Hall6e9897d2016-02-29 14:41:32 -080057 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-lin5bb663b2015-09-24 11:47:50 -070061 if not swResult:
62 main.cleanup()
63 main.exit()
64
65 main.step( "Set up tunnel from Mininet node to onos node" )
Devin Lim58046fa2017-07-05 16:55:00 -070066 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.ONOSip[ 0 ] )
pingping-lin5bb663b2015-09-24 11:47:50 -070067 command = 'ssh -nNT -o "PasswordAuthentication no" \
Devin Lim58046fa2017-07-05 16:55:00 -070068 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, main.ONOSip[ 0 ] )
pingping-lin5bb663b2015-09-24 11:47:50 -070069
70 tunnelResult = main.TRUE
71 tunnelResult = main.Mininet.node( "root", command )
Jon Hall6e9897d2016-02-29 14:41:32 -080072 utilities.assert_equals( expect=True,
73 actual=( "PasswordAuthentication" in tunnelResult ),
74 onpass="Created tunnel succeeded",
75 onfail="Create tunnel failed" )
pingping-linb3ebd3f2015-09-28 22:17:05 -070076 if ("PasswordAuthentication" not in tunnelResult) :
pingping-lin5bb663b2015-09-24 11:47:50 -070077 main.cleanup()
78 main.exit()
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" )
pingping-lin28e7b212015-09-10 10:14:58 -070096 main.exit()
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......" )
110 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
111
pingping-linb3ebd3f2015-09-28 22:17:05 -0700112 main.log.info( "Get links in the network" )
Devin Lim58046fa2017-07-05 16:55:00 -0700113 summaryResult = main.ONOScli1.summary()
pingping-lin3f091d62015-09-29 12:00:05 -0700114 linkNum = json.loads( summaryResult )[ "links" ]
Devin Lim58046fa2017-07-05 16:55:00 -0700115 listResult = main.ONOScli1.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!" )
119 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Devin Lim58046fa2017-07-05 16:55:00 -0700120 listResult = main.ONOScli1.links( jsonFormat=False )
pingping-lin3f091d62015-09-29 12:00:05 -0700121 main.log.info( listResult )
122 main.cleanup()
123 main.exit()
124
pingping-linb3ebd3f2015-09-28 22:17:05 -0700125 main.step( "Activate sdn-ip application" )
Devin Lim58046fa2017-07-05 16:55:00 -0700126 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800127 utilities.assert_equals( expect=main.TRUE,
128 actual=activeSDNIPresult,
129 onpass="Activate SDN-IP succeeded",
130 onfail="Activate SDN-IP failed" )
pingping-lin3f091d62015-09-29 12:00:05 -0700131 if not activeSDNIPresult:
132 main.log.info( "Activate SDN-IP failed!" )
133 main.cleanup()
134 main.exit()
135
pingping-linb3ebd3f2015-09-28 22:17:05 -0700136
137 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
pingping-linb702c602015-09-10 17:00:29 -0700138 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700139 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700140 main.log.info( "Wait Quagga to finish delivery all routes to each \
141 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700142 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
143 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
144
145
pingping-lin4f80c492015-09-15 14:34:42 -0700146 def CASE102( self, main ):
147 '''
148 This test case is to load the methods from other Python files.
149 '''
alisone4121a92016-11-22 16:31:36 -0800150 import imp
151
pingping-linb3ebd3f2015-09-28 22:17:05 -0700152 main.case( "Loading methods from other Python file" )
pingping-lin4f80c492015-09-15 14:34:42 -0700153 # 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-lin0ce60622015-09-10 14:37:33 -0700161 def CASE1( self, main ):
162 '''
alisone4121a92016-11-22 16:31:36 -0800163 ping test from 7 bgp peers to BGP speaker
pingping-lin0ce60622015-09-10 14:37:33 -0700164 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700165
pingping-linb3ebd3f2015-09-28 22:17:05 -0700166 main.case( "Ping tests between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800167 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
168 peers=[ "p64514", "p64515", "p64516" ],
169 expectAllSuccess=True )
pingping-lin0ce60622015-09-10 14:37:33 -0700170
alisone4121a92016-11-22 16:31:36 -0800171 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-lin950b50d2015-09-14 12:00:08 -0700178
pingping-lin0ce60622015-09-10 14:37:33 -0700179 def CASE2( self, main ):
180 '''
181 point-to-point intents test for each BGP peer and BGP speaker pair
182 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700183 main.sdnBase.pToPIntentTest( 6 )
pingping-lin0ce60622015-09-10 14:37:33 -0700184
185
186 def CASE3( self, main ):
187 '''
188 routes and intents check to all BGP peers
189 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700190 main.case( "Check routes and M2S intents to all BGP peers" )
pingping-lin0ce60622015-09-10 14:37:33 -0700191
pingping-lin28e7b212015-09-10 10:14:58 -0700192 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" )
alisone4121a92016-11-22 16:31:36 -0800196 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 Lim58046fa2017-07-05 16:55:00 -0700201 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700202
pingping-lin950b50d2015-09-14 12:00:08 -0700203
204 def CASE4( self, main ):
205 '''
206 Ping test in data plane for each route
207 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700208 main.case( "Ping test for each route, all hosts behind BGP peers" )
alisone4121a92016-11-22 16:31:36 -0800209 #No vlan
pingping-lin829428d2015-09-22 20:50:00 -0700210 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800211 hosts=[ "h64514", "h64515", "h64516" ],
212 expectAllSuccess=True )
213 #vlan 10
214 main.Functions.pingHostToHost( main,
215 hosts=[ "h64519", "h64520" ],
216 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700217
alisone4121a92016-11-22 16:31:36 -0800218 # vlan 20
219 main.Functions.pingHostToHost( main,
220 hosts=[ "h64517", "h64518" ],
221 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700222
223 def CASE5( self, main ):
224 '''
225 Cut links to peers one by one, check routes/intents
226 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700227 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
228 6, 6, 5, 5, 4, 4,
229 "spk1", [ "h64514", "h64515", "h64516" ],
230 "down" )
pingping-lin4f80c492015-09-15 14:34:42 -0700231
pingping-lin829428d2015-09-22 20:50:00 -0700232
233 def CASE6( self, main ):
pingping-lin4f80c492015-09-15 14:34:42 -0700234 '''
235 Recover links to peers one by one, check routes/intents
236 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700237 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
238 5, 5, 6, 6, 7, 7,
239 "spk1", [ "h64514", "h64515", "h64516" ],
240 "up" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700241
pingping-lin829428d2015-09-22 20:50:00 -0700242 def CASE7( self, main ):
pingping-lin8244a3b2015-09-16 13:36:56 -0700243 '''
pingping-lin829428d2015-09-22 20:50:00 -0700244 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
pingping-lin8244a3b2015-09-16 13:36:56 -0700245 '''
246 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700247 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700248 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800249 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-linb3ebd3f2015-09-28 22:17:05 -0700253
pingping-lin8244a3b2015-09-16 13:36:56 -0700254 if result == main.TRUE:
255 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800256 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-lin8244a3b2015-09-16 13:36:56 -0700259 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800260 main.log.error( "Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700261 main.cleanup()
262 main.exit()
pingping-lin8244a3b2015-09-16 13:36:56 -0700263
pingping-lin829428d2015-09-22 20:50:00 -0700264 main.step( "Check ping between hosts behind BGP peers" )
alisone4121a92016-11-22 16:31:36 -0800265 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-lin829428d2015-09-22 20:50:00 -0700268
269 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
270 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800271 utilities.assert_equals( expect=True, actual=pingResult1,
272 onpass="Ping test result is correct",
273 onfail="Ping test result is wrong" )
pingping-lin829428d2015-09-22 20:50:00 -0700274
275 if pingResult1 == False:
276 main.cleanup()
277 main.exit()
278
279 main.step( "Check ping between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800280 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-lin829428d2015-09-22 20:50:00 -0700283
284 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
285 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800286 utilities.assert_equals( expect=True, actual=pingResult2,
287 onpass="Speaker1 ping peers successful",
288 onfail="Speaker1 ping peers NOT successful" )
pingping-lin829428d2015-09-22 20:50:00 -0700289
290 if pingResult2 == False:
291 main.cleanup()
292 main.exit()
293
pingping-linbab7f8a2015-09-21 17:33:36 -0700294 main.step( "Check whether all flow status are ADDED" )
Devin Lim58046fa2017-07-05 16:55:00 -0700295 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800296 main.FALSE,
297 kwargs={'isPENDING':False},
298 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700299 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800300 expect=main.TRUE,
301 actual=flowCheck,
302 onpass="Flow status is correct!",
303 onfail="Flow status is wrong!" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700304
pingping-lind791d342015-09-17 18:34:31 -0700305
pingping-lin8244a3b2015-09-16 13:36:56 -0700306 def CASE8( self, main ):
pingping-lind791d342015-09-17 18:34:31 -0700307 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700308 Bring up the edge switch (sw32) which was shut down in CASE7,
pingping-lind791d342015-09-17 18:34:31 -0700309 check P-2-P and M-2-S intents, ping test
310 '''
311 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700312 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700313 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800314 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700315 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800316 expect=main.TRUE,
317 actual=result1,
318 onpass="Starting switch succeeded!",
319 onfail="Starting switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700320
Devin Lim58046fa2017-07-05 16:55:00 -0700321 result2 = main.Mininet.assignSwController( "sw32", main.ONOSip[ 0 ] )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700322 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800323 expect=main.TRUE,
324 actual=result2,
325 onpass="Connect switch to ONOS succeeded!",
326 onfail="Connect switch to ONOS failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700327
328 if result1 and result2:
329 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800330 main.Functions.checkRouteNum( main, 7 )
331 main.Functions.checkM2SintentNum( main, 7 )
332 main.Functions.checkP2PintentNum( main, 42 )
pingping-lind791d342015-09-17 18:34:31 -0700333 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800334 main.log.error( "Starting switch failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700335 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700336 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700337
pingping-linbab7f8a2015-09-21 17:33:36 -0700338 main.step( "Check whether all flow status are ADDED" )
Devin Lim58046fa2017-07-05 16:55:00 -0700339 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800340 main.FALSE,
341 kwargs={'isPENDING':False},
342 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700343 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800344 expect=main.TRUE,
345 actual=flowCheck,
346 onpass="Flow status is correct!",
347 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700348
pingping-lin829428d2015-09-22 20:50:00 -0700349 # Ping test
alisone4121a92016-11-22 16:31:36 -0800350 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
351 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800352 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700353 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800354 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800355 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700356
pingping-lin829428d2015-09-22 20:50:00 -0700357
358 def CASE9( self, main ):
pingping-linbab7f8a2015-09-21 17:33:36 -0700359 '''
360 Bring down a switch in best path, check:
361 route number, P2P intent number, M2S intent number, ping test
362 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700363 main.case( "Stop sw11 located in best path, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700364 check route number, P2P intent number, M2S intent number, ping test" )
365
pingping-lin581a3662015-09-29 17:43:39 -0700366 main.log.info( "Check the flow number correctness before stopping sw11" )
alisone4121a92016-11-22 16:31:36 -0800367 main.Functions.checkFlowNum( main, "sw11", 43 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700368 main.Functions.checkFlowNum( main, "sw1", 3 )
alisone4121a92016-11-22 16:31:36 -0800369 main.Functions.checkFlowNum( main, "sw7", 34 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800370 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
371 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
372 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700373
374 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800375 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-linbab7f8a2015-09-21 17:33:36 -0700379 if result:
380 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700381 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800382 main.Functions.checkRouteNum( main, 7 )
383 main.Functions.checkM2SintentNum( main, 7 )
384 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700385 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800386 main.log.error( "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700387 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700388 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700389
390 main.step( "Check whether all flow status are ADDED" )
Devin Lim58046fa2017-07-05 16:55:00 -0700391 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800392 main.FALSE,
393 kwargs={'isPENDING':False},
394 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700395 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800396 expect=main.TRUE,
397 actual=flowCheck,
398 onpass="Flow status is correct!",
399 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700400 # Ping test
alisone4121a92016-11-22 16:31:36 -0800401 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
402 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800403 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700404 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800405 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800406 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700407
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-linb3ebd3f2015-09-28 22:17:05 -0700414 main.case( "Start sw11 which was stopped in CASE9, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700415 check route number, P2P intent number, M2S intent number, ping test" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700416
pingping-lin581a3662015-09-29 17:43:39 -0700417 main.log.info( "Check the flow status before starting sw11" )
alisone4121a92016-11-22 16:31:36 -0800418 main.Functions.checkFlowNum( main, "sw1", 33 )
419 main.Functions.checkFlowNum( main, "sw7", 28 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800420 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
421 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700422
pingping-linbab7f8a2015-09-21 17:33:36 -0700423 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800424 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 Lim58046fa2017-07-05 16:55:00 -0700428 result2 = main.Mininet.assignSwController( "sw11", main.ONOSip[ 0 ] )
Jon Hall6e9897d2016-02-29 14:41:32 -0800429 utilities.assertEquals( expect=main.TRUE, actual=result2,
430 onpass="Connect switch to ONOS succeeded!",
431 onfail="Connect switch to ONOS failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700432 if result1 and result2:
pingping-linbab7f8a2015-09-21 17:33:36 -0700433 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800434 main.Functions.checkRouteNum( main, 7 )
435 main.Functions.checkM2SintentNum( main, 7 )
436 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700437
pingping-lin3f091d62015-09-29 12:00:05 -0700438 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
439 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
440 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700441 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800442 main.log.error( "Starting switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700443 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700444 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700445
446 main.step( "Check whether all flow status are ADDED" )
Devin Lim58046fa2017-07-05 16:55:00 -0700447 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800448 main.FALSE,
449 kwargs={'isPENDING':False},
450 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700451 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800452 expect=main.TRUE,
453 actual=flowCheck,
454 onpass="Flow status is correct!",
455 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700456 # Ping test
alisone4121a92016-11-22 16:31:36 -0800457 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
458 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800459 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700460 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800461 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800462 expectAllSuccess=True )