blob: 93f07352d795717be386aca1001ec5fbcd71742a [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:
Devin Lim44075962017-08-11 10:56:37 -070048 main.cleanAndExit()
pingping-lin5bb663b2015-09-24 11:47:50 -070049 main.step( "Connect switches to controller" )
50
pingping-lin5bb663b2015-09-24 11:47:50 -070051 # connect all switches to controller
52 swResult = main.TRUE
53 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
54 sw = "sw%s" % ( i )
Devin Lim142b5342017-07-20 15:22:39 -070055 swResult = swResult and \
56 main.Mininet.assignSwController( sw, main.Cluster.active( 0 ).ipAddress )
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:
Devin Lim44075962017-08-11 10:56:37 -070062 main.cleanAndExit()
pingping-lin5bb663b2015-09-24 11:47:50 -070063
64 main.step( "Set up tunnel from Mininet node to onos node" )
Devin Lim142b5342017-07-20 15:22:39 -070065 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.Cluster.active( 0 ).ipAddress )
pingping-lin5bb663b2015-09-24 11:47:50 -070066 command = 'ssh -nNT -o "PasswordAuthentication no" \
Devin Lim142b5342017-07-20 15:22:39 -070067 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % \
68 ( forwarding1, main.Cluster.active( 0 ).ipAddress )
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) :
Devin Lim44075962017-08-11 10:56:37 -070077 main.cleanAndExit()
pingping-lin5bb663b2015-09-24 11:47:50 -070078
pingping-linb702c602015-09-10 17:00:29 -070079 def CASE101( self, main ):
pingping-lin28e7b212015-09-10 10:14:58 -070080 """
pingping-linea32cf82015-10-08 22:37:37 -070081 Package ONOS and install it
pingping-lin28e7b212015-09-10 10:14:58 -070082 Startup sequence:
83 cell <name>
84 onos-verify-cell
pingping-lin28e7b212015-09-10 10:14:58 -070085 onos-package
86 onos-install -f
87 onos-wait-for-start
88 """
pingping-lin28e7b212015-09-10 10:14:58 -070089 import time
Jon Hall6e9897d2016-02-29 14:41:32 -080090 import os
Devin Lim58046fa2017-07-05 16:55:00 -070091 try:
92 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
93 except ImportError:
94 main.log.error( "sdnBase not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070095 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070096 try:
97 main.sdnBase
98 except ( NameError, AttributeError ):
99 main.sdnBase = SdnBase()
100
101 main.sdnBase.initSetup()
pingping-lin28e7b212015-09-10 10:14:58 -0700102
Jon Hall6e9897d2016-02-29 14:41:32 -0800103 def CASE200( self, main ):
alisone4121a92016-11-22 16:31:36 -0800104 import json
105 import time
106
Jon Hall6e9897d2016-02-29 14:41:32 -0800107 main.case( "Activate sdn-ip application" )
108 main.log.info( "waiting link discovery......" )
109 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
110
pingping-linb3ebd3f2015-09-28 22:17:05 -0700111 main.log.info( "Get links in the network" )
Devin Lim142b5342017-07-20 15:22:39 -0700112 summaryResult = main.Cluster.active( 0 ).CLI.summary()
pingping-lin3f091d62015-09-29 12:00:05 -0700113 linkNum = json.loads( summaryResult )[ "links" ]
Devin Lim142b5342017-07-20 15:22:39 -0700114 listResult = main.Cluster.active( 0 ).CLI.links( jsonFormat=False )
Jon Hall6e9897d2016-02-29 14:41:32 -0800115 main.log.info( listResult )
pingping-lin3f091d62015-09-29 12:00:05 -0700116 if linkNum < 100:
Jon Hall6e9897d2016-02-29 14:41:32 -0800117 main.log.error( "Link number is wrong!" )
118 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Devin Lim142b5342017-07-20 15:22:39 -0700119 listResult = main.Cluster.active( 0 ).CLI.links( jsonFormat=False )
pingping-lin3f091d62015-09-29 12:00:05 -0700120 main.log.info( listResult )
Devin Lim44075962017-08-11 10:56:37 -0700121 main.cleanAndExit()
pingping-lin3f091d62015-09-29 12:00:05 -0700122
pingping-linb3ebd3f2015-09-28 22:17:05 -0700123 main.step( "Activate sdn-ip application" )
Devin Lim142b5342017-07-20 15:22:39 -0700124 activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800125 utilities.assert_equals( expect=main.TRUE,
126 actual=activeSDNIPresult,
127 onpass="Activate SDN-IP succeeded",
128 onfail="Activate SDN-IP failed" )
pingping-lin3f091d62015-09-29 12:00:05 -0700129 if not activeSDNIPresult:
130 main.log.info( "Activate SDN-IP failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700131 main.cleanAndExit()
pingping-lin3f091d62015-09-29 12:00:05 -0700132
pingping-linb3ebd3f2015-09-28 22:17:05 -0700133
134 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
142
pingping-lin4f80c492015-09-15 14:34:42 -0700143 def CASE102( self, main ):
144 '''
145 This test case is to load the methods from other Python files.
146 '''
alisone4121a92016-11-22 16:31:36 -0800147 import imp
148
pingping-linb3ebd3f2015-09-28 22:17:05 -0700149 main.case( "Loading methods from other Python file" )
pingping-lin4f80c492015-09-15 14:34:42 -0700150 # load the methods from other file
151 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
152 main.Functions = imp.load_source( wrapperFile,
153 main.dependencyPath +
154 wrapperFile +
155 ".py" )
156
157
pingping-lin0ce60622015-09-10 14:37:33 -0700158 def CASE1( self, main ):
159 '''
alisone4121a92016-11-22 16:31:36 -0800160 ping test from 7 bgp peers to BGP speaker
pingping-lin0ce60622015-09-10 14:37:33 -0700161 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700162
pingping-linb3ebd3f2015-09-28 22:17:05 -0700163 main.case( "Ping tests between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800164 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
165 peers=[ "p64514", "p64515", "p64516" ],
166 expectAllSuccess=True )
pingping-lin0ce60622015-09-10 14:37:33 -0700167
alisone4121a92016-11-22 16:31:36 -0800168 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
169 peers=[ "p64517", "p64518" ],
170 expectAllSuccess=True )
171
172 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ],
173 peers=[ "p64519", "p64520" ],
174 expectAllSuccess=True )
pingping-lin950b50d2015-09-14 12:00:08 -0700175
pingping-lin0ce60622015-09-10 14:37:33 -0700176 def CASE2( self, main ):
177 '''
178 point-to-point intents test for each BGP peer and BGP speaker pair
179 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700180 main.sdnBase.pToPIntentTest( 6 )
pingping-lin0ce60622015-09-10 14:37:33 -0700181
182
183 def CASE3( self, main ):
184 '''
185 routes and intents check to all BGP peers
186 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700187 main.case( "Check routes and M2S intents to all BGP peers" )
pingping-lin0ce60622015-09-10 14:37:33 -0700188
pingping-lin28e7b212015-09-10 10:14:58 -0700189 allRoutesExpected = []
190 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
191 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
192 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
alisone4121a92016-11-22 16:31:36 -0800193 allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" )
194 allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" )
195 allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
196 allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
197
Devin Lim58046fa2017-07-05 16:55:00 -0700198 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700199
pingping-lin950b50d2015-09-14 12:00:08 -0700200
201 def CASE4( self, main ):
202 '''
203 Ping test in data plane for each route
204 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700205 main.case( "Ping test for each route, all hosts behind BGP peers" )
alisone4121a92016-11-22 16:31:36 -0800206 #No vlan
pingping-lin829428d2015-09-22 20:50:00 -0700207 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800208 hosts=[ "h64514", "h64515", "h64516" ],
209 expectAllSuccess=True )
210 #vlan 10
211 main.Functions.pingHostToHost( main,
212 hosts=[ "h64519", "h64520" ],
213 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700214
alisone4121a92016-11-22 16:31:36 -0800215 # vlan 20
216 main.Functions.pingHostToHost( main,
217 hosts=[ "h64517", "h64518" ],
218 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700219
220 def CASE5( self, main ):
221 '''
222 Cut links to peers one by one, check routes/intents
223 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700224 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
225 6, 6, 5, 5, 4, 4,
226 "spk1", [ "h64514", "h64515", "h64516" ],
227 "down" )
pingping-lin4f80c492015-09-15 14:34:42 -0700228
pingping-lin829428d2015-09-22 20:50:00 -0700229
230 def CASE6( self, main ):
pingping-lin4f80c492015-09-15 14:34:42 -0700231 '''
232 Recover links to peers one by one, check routes/intents
233 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700234 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
235 5, 5, 6, 6, 7, 7,
236 "spk1", [ "h64514", "h64515", "h64516" ],
237 "up" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700238
pingping-lin829428d2015-09-22 20:50:00 -0700239 def CASE7( self, main ):
pingping-lin8244a3b2015-09-16 13:36:56 -0700240 '''
pingping-lin829428d2015-09-22 20:50:00 -0700241 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
pingping-lin8244a3b2015-09-16 13:36:56 -0700242 '''
243 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700244 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700245 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800246 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
247 utilities.assertEquals( expect=main.TRUE, actual=result,
248 onpass="Stopping switch succeeded!",
249 onfail="Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700250
pingping-lin8244a3b2015-09-16 13:36:56 -0700251 if result == main.TRUE:
252 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800253 main.Functions.checkRouteNum( main, 6 ) #stop one sw, which bring one link between peer and sw down.
254 main.Functions.checkM2SintentNum( main, 6 )
255 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 -0700256 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800257 main.log.error( "Stopping switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700258 main.cleanAndExit()
pingping-lin8244a3b2015-09-16 13:36:56 -0700259
pingping-lin829428d2015-09-22 20:50:00 -0700260 main.step( "Check ping between hosts behind BGP peers" )
alisone4121a92016-11-22 16:31:36 -0800261 result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
262 result2 = main.Mininet.pingHost( src="h64515", target="h64516" )
263 result3 = main.Mininet.pingHost( src="h64514", target="h64516" )
pingping-lin829428d2015-09-22 20:50:00 -0700264
265 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
266 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800267 utilities.assert_equals( expect=True, actual=pingResult1,
268 onpass="Ping test result is correct",
269 onfail="Ping test result is wrong" )
pingping-lin829428d2015-09-22 20:50:00 -0700270
271 if pingResult1 == False:
Devin Lim44075962017-08-11 10:56:37 -0700272 main.cleanAndExit()
pingping-lin829428d2015-09-22 20:50:00 -0700273
274 main.step( "Check ping between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800275 result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
276 result5 = main.Mininet.pingHost( src="spk1", target="p64515" )
277 result6 = main.Mininet.pingHost( src="spk1", target="p64516" )
pingping-lin829428d2015-09-22 20:50:00 -0700278
279 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
280 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800281 utilities.assert_equals( expect=True, actual=pingResult2,
282 onpass="Speaker1 ping peers successful",
283 onfail="Speaker1 ping peers NOT successful" )
pingping-lin829428d2015-09-22 20:50:00 -0700284
285 if pingResult2 == False:
Devin Lim44075962017-08-11 10:56:37 -0700286 main.cleanAndExit()
pingping-lin829428d2015-09-22 20:50:00 -0700287
pingping-linbab7f8a2015-09-21 17:33:36 -0700288 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700289 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800290 main.FALSE,
291 kwargs={'isPENDING':False},
292 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700293 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800294 expect=main.TRUE,
295 actual=flowCheck,
296 onpass="Flow status is correct!",
297 onfail="Flow status is wrong!" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700298
pingping-lind791d342015-09-17 18:34:31 -0700299
pingping-lin8244a3b2015-09-16 13:36:56 -0700300 def CASE8( self, main ):
pingping-lind791d342015-09-17 18:34:31 -0700301 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700302 Bring up the edge switch (sw32) which was shut down in CASE7,
pingping-lind791d342015-09-17 18:34:31 -0700303 check P-2-P and M-2-S intents, ping test
304 '''
305 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700306 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700307 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800308 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700309 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800310 expect=main.TRUE,
311 actual=result1,
312 onpass="Starting switch succeeded!",
313 onfail="Starting switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700314
Devin Lim142b5342017-07-20 15:22:39 -0700315 result2 = main.Mininet.assignSwController( "sw32", main.Cluster.active( 0 ).ipAddress )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700316 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800317 expect=main.TRUE,
318 actual=result2,
319 onpass="Connect switch to ONOS succeeded!",
320 onfail="Connect switch to ONOS failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700321
322 if result1 and result2:
323 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800324 main.Functions.checkRouteNum( main, 7 )
325 main.Functions.checkM2SintentNum( main, 7 )
326 main.Functions.checkP2PintentNum( main, 42 )
pingping-lind791d342015-09-17 18:34:31 -0700327 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800328 main.log.error( "Starting switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700329 main.cleanAndExit()
pingping-lin4f80c492015-09-15 14:34:42 -0700330
pingping-linbab7f8a2015-09-21 17:33:36 -0700331 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700332 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800333 main.FALSE,
334 kwargs={'isPENDING':False},
335 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700336 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800337 expect=main.TRUE,
338 actual=flowCheck,
339 onpass="Flow status is correct!",
340 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700341
pingping-lin829428d2015-09-22 20:50:00 -0700342 # Ping test
alisone4121a92016-11-22 16:31:36 -0800343 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
344 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800345 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700346 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800347 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800348 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700349
pingping-lin829428d2015-09-22 20:50:00 -0700350
351 def CASE9( self, main ):
pingping-linbab7f8a2015-09-21 17:33:36 -0700352 '''
353 Bring down a switch in best path, check:
354 route number, P2P intent number, M2S intent number, ping test
355 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700356 main.case( "Stop sw11 located in best path, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700357 check route number, P2P intent number, M2S intent number, ping test" )
358
pingping-lin581a3662015-09-29 17:43:39 -0700359 main.log.info( "Check the flow number correctness before stopping sw11" )
alisone4121a92016-11-22 16:31:36 -0800360 main.Functions.checkFlowNum( main, "sw11", 43 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700361 main.Functions.checkFlowNum( main, "sw1", 3 )
alisone4121a92016-11-22 16:31:36 -0800362 main.Functions.checkFlowNum( main, "sw7", 34 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800363 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
364 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
365 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700366
367 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800368 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
369 utilities.assertEquals( expect=main.TRUE, actual=result,
370 onpass="Stopping switch succeeded!",
371 onfail="Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700372 if result:
373 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700374 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800375 main.Functions.checkRouteNum( main, 7 )
376 main.Functions.checkM2SintentNum( main, 7 )
377 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700378 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800379 main.log.error( "Stopping switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700380 main.cleanAndExit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700381
382 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700383 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800384 main.FALSE,
385 kwargs={'isPENDING':False},
386 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700387 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800388 expect=main.TRUE,
389 actual=flowCheck,
390 onpass="Flow status is correct!",
391 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700392 # Ping test
alisone4121a92016-11-22 16:31:36 -0800393 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
394 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800395 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700396 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800397 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800398 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700399
400
401 def CASE10( self, main ):
402 '''
403 Bring up the switch which was stopped in CASE9, check:
404 route number, P2P intent number, M2S intent number, ping test
405 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700406 main.case( "Start sw11 which was stopped in CASE9, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700407 check route number, P2P intent number, M2S intent number, ping test" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700408
pingping-lin581a3662015-09-29 17:43:39 -0700409 main.log.info( "Check the flow status before starting sw11" )
alisone4121a92016-11-22 16:31:36 -0800410 main.Functions.checkFlowNum( main, "sw1", 33 )
411 main.Functions.checkFlowNum( main, "sw7", 28 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800412 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
413 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700414
pingping-linbab7f8a2015-09-21 17:33:36 -0700415 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800416 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
417 utilities.assertEquals( expect=main.TRUE, actual=result1,
418 onpass="Starting switch succeeded!",
419 onfail="Starting switch failed!" )
Devin Lim142b5342017-07-20 15:22:39 -0700420 result2 = main.Mininet.assignSwController( "sw11", main.Cluster.active( 0 ).ipAddress )
Jon Hall6e9897d2016-02-29 14:41:32 -0800421 utilities.assertEquals( expect=main.TRUE, actual=result2,
422 onpass="Connect switch to ONOS succeeded!",
423 onfail="Connect switch to ONOS failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700424 if result1 and result2:
pingping-linbab7f8a2015-09-21 17:33:36 -0700425 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800426 main.Functions.checkRouteNum( main, 7 )
427 main.Functions.checkM2SintentNum( main, 7 )
428 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700429
pingping-lin3f091d62015-09-29 12:00:05 -0700430 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
431 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
432 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700433 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800434 main.log.error( "Starting switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700435 main.cleanAndExit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700436
437 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700438 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800439 main.FALSE,
440 kwargs={'isPENDING':False},
441 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700442 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800443 expect=main.TRUE,
444 actual=flowCheck,
445 onpass="Flow status is correct!",
446 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700447 # Ping test
alisone4121a92016-11-22 16:31:36 -0800448 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
449 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800450 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700451 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800452 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800453 expectAllSuccess=True )