blob: 499df34f6430557f61d7d69424c360ce236f8cce [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 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-linea32cf82015-10-08 22:37:37 -070021# Testing the functionality of SDN-IP with single ONOS instance
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070022
23
pingping-linea32cf82015-10-08 22:37:37 -070024class USECASE_SdnipFunctionCluster:
25
26 def __init__( self ):
27 self.default = ''
28 global branchName
29
30 def CASE100( self, main ):
31 """
32 Start mininet
33 """
34 import imp
Jon Hall362aa922016-03-31 09:39:26 -070035 main.case( "Setup the Mininet testbed" )
pingping-linea32cf82015-10-08 22:37:37 -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-linea32cf82015-10-08 22:37:37 -070047 # Exit if topology did not load properly
48 if not topoResult:
Devin Lim44075962017-08-11 10:56:37 -070049 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -070050 main.step( "Connect switches to controllers" )
51
52 # connect all switches to controllers
53 swResult = main.TRUE
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070054 for i in range( 1, int( main.params[ 'config' ][ 'switchNum' ] ) + 1 ):
pingping-linea32cf82015-10-08 22:37:37 -070055 sw = "sw%s" % ( i )
Devin Lim142b5342017-07-20 15:22:39 -070056 swResult = swResult and \
57 main.Mininet.assignSwController( sw, main.Cluster.getIps() )
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-linea32cf82015-10-08 22:37:37 -070062 if not swResult:
Devin Lim44075962017-08-11 10:56:37 -070063 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -070064
pingping-linea32cf82015-10-08 22:37:37 -070065 def CASE101( self, main ):
66 """
67 Package ONOS and install it
68 Startup sequence:
69 cell <name>
70 onos-verify-cell
71 onos-package
72 onos-install -f
73 onos-wait-for-start
74 """
75 import json
76 import time
77 import os
78 from operator import eq
alison62006dd2016-12-15 16:21:28 -080079 global p64514
80 global p64515
81 global p64516
Devin Lim58046fa2017-07-05 16:55:00 -070082 p64514 = main.params[ 'config' ][ 'p64514' ]
83 p64515 = main.params[ 'config' ][ 'p64515' ]
84 p64516 = main.params[ 'config' ][ 'p64516' ]
pingping-linea32cf82015-10-08 22:37:37 -070085
Devin Lim58046fa2017-07-05 16:55:00 -070086 try:
87 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
88 except ImportError:
89 main.log.error( "sdnBase not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070090 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070091 try:
92 main.sdnBase
93 except ( NameError, AttributeError ):
94 main.sdnBase = SdnBase()
95
96 main.sdnBase.initSetup()
pingping-linea32cf82015-10-08 22:37:37 -070097
pingping-linea32cf82015-10-08 22:37:37 -070098 def CASE200( self, main ):
99 main.case( "Activate sdn-ip application" )
100 main.log.info( "waiting link discovery......" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700101 time.sleep( int( main.params[ 'timers' ][ 'TopoDiscovery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700102
Jon Hall362aa922016-03-31 09:39:26 -0700103 main.step( "Get links in the network" )
Devin Lim142b5342017-07-20 15:22:39 -0700104 summaryResult = main.Cluster.active( 0 ).CLI.summary()
pingping-linea32cf82015-10-08 22:37:37 -0700105 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall362aa922016-03-31 09:39:26 -0700106 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
pingping-linea32cf82015-10-08 22:37:37 -0700107 if linkNum < 100:
Jon Hall362aa922016-03-31 09:39:26 -0700108 main.log.error( "Link number is wrong! Retrying..." )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700109 time.sleep( int( main.params[ 'timers' ][ 'TopoDiscovery' ] ) )
Devin Lim142b5342017-07-20 15:22:39 -0700110 summaryResult = main.Cluster.active( 0 ).CLI.summary()
Jon Hall362aa922016-03-31 09:39:26 -0700111 linkNum = json.loads( summaryResult )[ "links" ]
112 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
113 utilities.assert_equals( expect=100,
114 actual=linkNum,
115 onpass="ONOS correctly discovered all links",
116 onfail="ONOS Failed to discover all links" )
117 if linkNum < 100:
Devin Lim44075962017-08-11 10:56:37 -0700118 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700119
pingping-linea32cf82015-10-08 22:37:37 -0700120 main.step( "Activate sdn-ip application" )
Devin Lim142b5342017-07-20 15:22:39 -0700121 activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800122 utilities.assert_equals( expect=main.TRUE,
123 actual=activeSDNIPresult,
124 onpass="Activate SDN-IP succeeded",
125 onfail="Activate SDN-IP failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700126 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800127 main.log.info( "Activate SDN-IP failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700128 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700129
pingping-linea32cf82015-10-08 22:37:37 -0700130 def CASE102( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700131 """
pingping-linea32cf82015-10-08 22:37:37 -0700132 This test case is to load the methods from other Python files, and create
133 tunnels from mininet host to onos nodes.
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700134 """
pingping-linea32cf82015-10-08 22:37:37 -0700135 import time
136 main.case( "Load methods from other Python file and create tunnels" )
137 # load the methods from other file
138 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
139 main.Functions = imp.load_source( wrapperFile1,
140 main.dependencyPath +
141 wrapperFile1 +
142 ".py" )
143 # Create tunnels
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700144 for i in range( main.Cluster.numCtrls ):
Devin Lim142b5342017-07-20 15:22:39 -0700145 main.Functions.setupTunnel( main,
146 '1.1.1.' + str( ( i + 1 ) * 2 ),
147 2000,
148 main.Cluster.active( i ).ipAddress, 2000 )
pingping-linea32cf82015-10-08 22:37:37 -0700149
150 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
151 and the BGP paths in data plane are ready..." )
152 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
153
154 main.log.info( "Wait Quagga to finish delivery all routes to each \
155 other and to sdn-ip, plus finish installing all intents..." )
156 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700157
158 def CASE1( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700159 """
pingping-linea32cf82015-10-08 22:37:37 -0700160 ping test from 3 bgp peers to BGP speaker
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700161 """
Jon Hall362aa922016-03-31 09:39:26 -0700162 main.case( "Ping between BGP peers and speakers" )
alison62006dd2016-12-15 16:21:28 -0800163 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
164 peers=[ "p64514", "p64515", "p64516" ],
165 expectAllSuccess=True )
166
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700167 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
alison62006dd2016-12-15 16:21:28 -0800168 peers=[ p64514, p64515, p64516 ],
169 expectAllSuccess=True )
170
171 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ],
172 peers=[ "p64519", "p64520" ],
173 expectAllSuccess=True )
174
175 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk4" ],
176 peers=[ "p64517", "p64518" ],
177 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700178
179 def CASE2( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700180 """
pingping-linea32cf82015-10-08 22:37:37 -0700181 point-to-point intents test for each BGP peer and BGP speaker pair
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700182 """
Devin Lim58046fa2017-07-05 16:55:00 -0700183 main.sdnBase.pToPIntentTest( 12 )
pingping-linea32cf82015-10-08 22:37:37 -0700184
185 def CASE3( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700186 """
pingping-linea32cf82015-10-08 22:37:37 -0700187 routes and intents check to all BGP peers
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700188 """
Jon Hall6e9897d2016-02-29 14:41:32 -0800189 import time
pingping-linea32cf82015-10-08 22:37:37 -0700190 main.case( "Check routes and M2S intents to all BGP peers" )
191
Jon Hall362aa922016-03-31 09:39:26 -0700192 main.step( "Check routes installed" )
pingping-linea32cf82015-10-08 22:37:37 -0700193 allRoutesExpected = []
194 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
195 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
196 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
alison62006dd2016-12-15 16:21:28 -0800197 allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" )
198 allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" )
199 allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
200 allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
pingping-linea32cf82015-10-08 22:37:37 -0700201
Devin Lim58046fa2017-07-05 16:55:00 -0700202 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
pingping-linea32cf82015-10-08 22:37:37 -0700203
pingping-linea32cf82015-10-08 22:37:37 -0700204 def CASE4( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700205 """
pingping-linea32cf82015-10-08 22:37:37 -0700206 Ping test in data plane for each route
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700207 """
pingping-linea32cf82015-10-08 22:37:37 -0700208 main.case( "Ping test for each route, all hosts behind BGP peers" )
209 main.Functions.pingHostToHost( main,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700210 hosts=[ "h64514", "h64515", "h64516" ],
211 expectAllSuccess=True )
212 main.Functions.pingHostToHost( main,
213 hosts=[ "h64517", "h64518" ],
214 expectAllSuccess=True )
Devin Lim58046fa2017-07-05 16:55:00 -0700215 main.Functions.pingHostToHost( main,
216 hosts=[ "h64519", "h64520" ],
217 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700218
219 def CASE5( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700220 """
pingping-linea32cf82015-10-08 22:37:37 -0700221 Cut links to peers one by one, check routes/intents
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700222 """
Devin Lim58046fa2017-07-05 16:55:00 -0700223 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
224 6, 6, 5, 5, 4, 4,
225 "spk1", [ "h64514", "h64515", "h64516" ],
226 "down" )
pingping-linea32cf82015-10-08 22:37:37 -0700227
pingping-linea32cf82015-10-08 22:37:37 -0700228 def CASE6( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700229 """
pingping-linea32cf82015-10-08 22:37:37 -0700230 Recover links to peers one by one, check routes/intents
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700231 """
Devin Lim58046fa2017-07-05 16:55:00 -0700232 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
233 5, 5, 6, 6, 7, 7,
234 "spk1", [ "h64514", "h64515", "h64516" ],
235 "up" )
pingping-linea32cf82015-10-08 22:37:37 -0700236
pingping-linea32cf82015-10-08 22:37:37 -0700237 def CASE7( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700238 """
pingping-linea32cf82015-10-08 22:37:37 -0700239 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700240 """
pingping-linea32cf82015-10-08 22:37:37 -0700241 import time
242 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
243 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800244 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700245 utilities.assert_equals( expect=main.TRUE, actual=result,
246 onpass="Stopping switch succeeded!",
247 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700248
249 if result == main.TRUE:
250 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800251 main.Functions.checkRouteNum( main, 6 )
252 main.Functions.checkM2SintentNum( main, 6 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700253 main.Functions.checkP2PintentNum( main, 48 ) # 14 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700254 else:
255 main.log.error( "Stopping switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700256 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700257
258 main.step( "Check ping between hosts behind BGP peers" )
alison62006dd2016-12-15 16:21:28 -0800259 result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
260 result2 = main.Mininet.pingHost( src="h64515", target="h64516" )
261 result3 = main.Mininet.pingHost( src="h64514", target="h64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700262
263 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
264 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800265 utilities.assert_equals( expect=True, actual=pingResult1,
266 onpass="Ping test result is correct",
267 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700268
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700269 if not pingResult1:
Devin Lim44075962017-08-11 10:56:37 -0700270 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700271
alison62006dd2016-12-15 16:21:28 -0800272 main.step( "Check ping between BGP peers and spk1" )
273 result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
274 result5 = main.Mininet.pingHost( src="spk1", target="p64515" )
275 result6 = main.Mininet.pingHost( src="spk1", target="p64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700276
277 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
278 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800279 utilities.assert_equals( expect=True, actual=pingResult2,
280 onpass="Speaker1 ping peers successful",
281 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700282
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700283 if not pingResult2:
Devin Lim44075962017-08-11 10:56:37 -0700284 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700285
alison62006dd2016-12-15 16:21:28 -0800286 main.step( "Check ping between BGP peers and spk2" )
pingping-linea32cf82015-10-08 22:37:37 -0700287 # TODO
alison62006dd2016-12-15 16:21:28 -0800288 result7 = main.Mininet.pingHost( src="spk2", target=p64514 )
289 result8 = main.Mininet.pingHost( src="spk2", target=p64515 )
290 result9 = main.Mininet.pingHost( src="spk2", target=p64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700291
292 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
293 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800294 utilities.assert_equals( expect=True, actual=pingResult2,
295 onpass="Speaker2 ping peers successful",
296 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700297
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700298 if not pingResult3:
Devin Lim44075962017-08-11 10:56:37 -0700299 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700300
301 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700302 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800303 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700304 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800305 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700306 utilities.assert_equals( expect=main.TRUE,
307 actual=flowCheck,
308 onpass="Flow status is correct!",
309 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700310
311 def CASE8( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700312 """
313 Bring up the edge switch ( sw32 ) which was shut down in CASE7,
pingping-linea32cf82015-10-08 22:37:37 -0700314 check P-2-P and M-2-S intents, ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700315 """
pingping-linea32cf82015-10-08 22:37:37 -0700316 import time
317 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
318 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800319 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700320 utilities.assert_equals( expect=main.TRUE,
321 actual=result1,
322 onpass="Starting switch succeeded!",
323 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700324
Devin Lim142b5342017-07-20 15:22:39 -0700325 result2 = main.Mininet.assignSwController( "sw32", main.Cluster.active( 0 ).ipAddress )
Jon Hall362aa922016-03-31 09:39:26 -0700326 utilities.assert_equals( expect=main.TRUE,
327 actual=result2,
328 onpass="Connect switch to ONOS succeeded!",
329 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700330
331 if result1 and result2:
332 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800333 main.Functions.checkRouteNum( main, 7 )
334 main.Functions.checkM2SintentNum( main, 7 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700335 main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18*2
pingping-linea32cf82015-10-08 22:37:37 -0700336 else:
337 main.log.error( "Starting switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700338 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700339
340 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,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700343 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800344 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700345 utilities.assert_equals( expect=main.TRUE,
346 actual=flowCheck,
347 onpass="Flow status is correct!",
348 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700349
350 # Ping test
alison62006dd2016-12-15 16:21:28 -0800351 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700352 peers=[ "p64514", "p64515", "p64516" ],
alison62006dd2016-12-15 16:21:28 -0800353 expectAllSuccess=True )
354
355 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
356 peers=[ p64514, p64515, p64516 ],
357 expectAllSuccess=True )
358
pingping-linea32cf82015-10-08 22:37:37 -0700359 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800360 hosts=[ "h64514", "h64515", "h64516" ],
361 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700362
pingping-linea32cf82015-10-08 22:37:37 -0700363 def CASE9( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700364 """
pingping-linea32cf82015-10-08 22:37:37 -0700365 Bring down a switch in best path, check:
366 route number, P2P intent number, M2S intent number, ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700367 """
pingping-linea32cf82015-10-08 22:37:37 -0700368 main.case( "Stop sw11 located in best path, \
369 check route number, P2P intent number, M2S intent number, ping test" )
370
371 main.log.info( "Check the flow number correctness before stopping sw11" )
alison62006dd2016-12-15 16:21:28 -0800372 main.Functions.checkFlowNum( main, "sw11", 49 )
373 main.Functions.checkFlowNum( main, "sw1", 7 )
374 main.Functions.checkFlowNum( main, "sw7", 34 )
pingping-linea32cf82015-10-08 22:37:37 -0700375 main.log.info( main.Mininet.checkFlows( "sw11" ) )
376 main.log.info( main.Mininet.checkFlows( "sw1" ) )
377 main.log.info( main.Mininet.checkFlows( "sw7" ) )
378
379 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800380 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700381 utilities.assert_equals( expect=main.TRUE, actual=result,
382 onpass="Stopping switch succeeded!",
383 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700384 if result:
385 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
386 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800387 main.Functions.checkRouteNum( main, 7 )
388 main.Functions.checkM2SintentNum( main, 7 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700389 main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700390 else:
391 main.log.error( "Stopping switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700392 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700393
394 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700395 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800396 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700397 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800398 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700399 utilities.assert_equals( expect=main.TRUE,
400 actual=flowCheck,
401 onpass="Flow status is correct!",
402 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700403 # Ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700404 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
405 peers=[ "p64514", "p64515", "p64516" ],
406 expectAllSuccess=True )
407 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
408 peers=[ p64514, p64515, p64516 ],
409 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700410 main.Functions.pingHostToHost( main,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700411 hosts=[ "h64514", "h64515", "h64516" ],
412 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700413
414 def CASE10( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700415 """
pingping-linea32cf82015-10-08 22:37:37 -0700416 Bring up the switch which was stopped in CASE9, check:
417 route number, P2P intent number, M2S intent number, ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700418 """
pingping-linea32cf82015-10-08 22:37:37 -0700419 main.case( "Start sw11 which was stopped in CASE9, \
420 check route number, P2P intent number, M2S intent number, ping test" )
421
422 main.log.info( "Check the flow status before starting sw11" )
alison62006dd2016-12-15 16:21:28 -0800423 main.Functions.checkFlowNum( main, "sw1", 36 )
424 main.Functions.checkFlowNum( main, "sw7", 30 )
pingping-linea32cf82015-10-08 22:37:37 -0700425 main.log.info( main.Mininet.checkFlows( "sw1" ) )
426 main.log.info( main.Mininet.checkFlows( "sw7" ) )
427
428 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800429 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700430 utilities.assert_equals( expect=main.TRUE, actual=result1,
431 onpass="Starting switch succeeded!",
432 onfail="Starting switch failed!" )
Devin Lim142b5342017-07-20 15:22:39 -0700433 result2 = main.Mininet.assignSwController( "sw11", main.Cluster.active( 0 ).ipAddress )
Jon Hall362aa922016-03-31 09:39:26 -0700434 utilities.assert_equals( expect=main.TRUE, actual=result2,
435 onpass="Connect switch to ONOS succeeded!",
436 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700437 if result1 and result2:
438 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800439 main.Functions.checkRouteNum( main, 7 )
440 main.Functions.checkM2SintentNum( main, 7 )
441 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700442
443 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
444 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
445 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
446 else:
447 main.log.error( "Starting switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700448 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700449
450 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700451 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800452 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700453 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800454 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700455 utilities.assert_equals( expect=main.TRUE,
456 actual=flowCheck,
457 onpass="Flow status is correct!",
458 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700459 # Ping test
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700460 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
461 peers=[ "p64514", "p64515", "p64516" ],
462 expectAllSuccess=True )
463 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
464 peers=[ p64514, p64515, p64516 ],
465 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700466 main.Functions.pingHostToHost( main,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700467 hosts=[ "h64514", "h64515", "h64516" ],
468 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700469
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700470 def CASE11( self, main ):
pingping-linea32cf82015-10-08 22:37:37 -0700471 import time
alison62006dd2016-12-15 16:21:28 -0800472 main.case( "Kill spk1, check:\
pingping-linea32cf82015-10-08 22:37:37 -0700473 route number, P2P intent number, M2S intent number, ping test" )
alison62006dd2016-12-15 16:21:28 -0800474 main.log.info( "Check network status before killing spk1" )
475 main.Functions.checkRouteNum( main, 7 )
476 main.Functions.checkM2SintentNum( main, 7 )
477 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700478 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700479 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800480 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700481 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800482 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700483 utilities.assert_equals( expect=main.TRUE,
484 actual=flowCheck,
485 onpass="Flow status is correct!",
486 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700487
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700488 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
489 peers=[ "p64514", "p64515", "p64516" ],
490 expectAllSuccess=True )
491 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
492 peers=[ p64514, p64515, p64516 ],
493 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700494 main.Functions.pingHostToHost( main,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700495 hosts=[ "h64514", "h64515", "h64516" ],
496 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700497
alison62006dd2016-12-15 16:21:28 -0800498 main.step( "Kill spk1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700499 command1 = "ps -e | grep bgp -c"
500 result1 = main.Mininet.node( "root", command1 )
501
502 # The total BGP daemon number in this test environment is 5.
503 if "5" in result1:
alison62006dd2016-12-15 16:21:28 -0800504 main.log.debug( "Before kill spk1, 5 BGP daemons - correct" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700505 else:
alison62006dd2016-12-15 16:21:28 -0800506 main.log.warn( "Before kill spk1, number of BGP daemons is wrong" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700507 main.log.info( result1 )
508
509 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
510 result2 = main.Mininet.node( "root", command2 )
511
512 result3 = main.Mininet.node( "root", command1 )
513
Jon Hall6e9897d2016-02-29 14:41:32 -0800514 utilities.assert_equals( expect=True,
515 actual=( "4" in result3 ),
alison62006dd2016-12-15 16:21:28 -0800516 onpass="Kill spk1 succeeded",
517 onfail="Kill spk1 failed" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700518 if ( "4" not in result3 ):
pingping-lin145cd0a2015-10-09 17:44:34 -0700519 main.log.info( result3 )
Devin Lim44075962017-08-11 10:56:37 -0700520 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700521
522 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800523 main.Functions.checkRouteNum( main, 7 )
524 main.Functions.checkM2SintentNum( main, 7 )
525 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700526
527 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700528 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800529 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700530 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800531 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700532 utilities.assert_equals( expect=main.TRUE,
533 actual=flowCheck,
534 onpass="Flow status is correct!",
535 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700536
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700537 """
538 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
539 peers=[ "p64514", "p64515", "p64516" ],
Jon Hall6e9897d2016-02-29 14:41:32 -0800540 expectAllSuccess=False )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700541 """
542 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
543 peers=[ p64514, p64515, p64516 ],
544 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700545 main.Functions.pingHostToHost( main,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700546 hosts=[ "h64514", "h64515", "h64516" ],
547 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700548
549 def CASE12( self, main ):
550 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700551 import json
pingping-linea32cf82015-10-08 22:37:37 -0700552 main.case( "Bring down leader ONOS node, check: \
553 route number, P2P intent number, M2S intent number, ping test" )
554 main.step( "Find out ONOS leader node" )
Devin Lim142b5342017-07-20 15:22:39 -0700555 result = main.Cluster.active( 0 ).CLI.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700556 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700557 leaderIP = ""
558 for entry in jsonResult:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700559 if entry[ "topic" ] == "org.onosproject.sdnip":
560 leaderIP = entry[ "leader" ]
pingping-lina14c7c82015-10-09 15:44:36 -0700561 main.log.info( "leaderIP is: " )
562 main.log.info( leaderIP )
563
564 main.step( "Uninstall ONOS/SDN-IP leader node" )
Devin Lim142b5342017-07-20 15:22:39 -0700565 for ip in main.Cluster.getIps():
Devin Lim58046fa2017-07-05 16:55:00 -0700566 if leaderIP == ip:
567 uninstallResult = main.ONOSbench.onosStop( ip )
pingping-lina14c7c82015-10-09 15:44:36 -0700568
Jon Hall6e9897d2016-02-29 14:41:32 -0800569 utilities.assert_equals( expect=main.TRUE,
570 actual=uninstallResult,
571 onpass="Uninstall ONOS leader succeeded",
572 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700573 if uninstallResult != main.TRUE:
Devin Lim44075962017-08-11 10:56:37 -0700574 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700575 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700576
Devin Lim142b5342017-07-20 15:22:39 -0700577 if leaderIP == main.Cluster.active( 0 ).ipAddress:
578 main.Functions.checkRouteNum( main, 7, node=2 )
579 main.Functions.checkM2SintentNum( main, 7, node=2 )
580 main.Functions.checkP2PintentNum( main, 30 * 2, node=2 )
pingping-lina14c7c82015-10-09 15:44:36 -0700581
582 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700583 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800584 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700585 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800586 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700587 utilities.assert_equals( expect=main.TRUE,
588 actual=flowCheck,
589 onpass="Flow status is correct!",
590 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700591 else:
alison62006dd2016-12-15 16:21:28 -0800592 main.Functions.checkRouteNum( main, 7 )
593 main.Functions.checkM2SintentNum( main, 7 )
594 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-lina14c7c82015-10-09 15:44:36 -0700595
596 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700597 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800598 main.FALSE,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700599 kwargs={ 'isPENDING': False },
Jon Hall6e9897d2016-02-29 14:41:32 -0800600 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700601 utilities.assert_equals( expect=main.TRUE,
602 actual=flowCheck,
603 onpass="Flow status is correct!",
604 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700605
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700606 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
607 peers=[ "p64514", "p64515", "p64516" ],
608 expectAllSuccess=True )
609 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
610 peers=[ p64514, p64515, p64516 ],
611 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700612 main.Functions.pingHostToHost( main,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700613 hosts=[ "h64514", "h64515", "h64516" ],
614 expectAllSuccess=True )