blob: 24d2f756639b9ab8e0719e473406baea24d15e90 [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"""
kelvin-onlabd48a68c2015-07-13 16:01:36 -070021# Testing the basic intent functionality of ONOS
22
Jon Hall78be4962017-05-23 14:53:53 -070023
kelvin-onlabd48a68c2015-07-13 16:01:36 -070024class FUNCintent:
25
26 def __init__( self ):
27 self.default = ''
28
29 def CASE1( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -070030 import imp
Jon Hallf632d202015-07-30 15:45:11 -070031 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070032 """
33 - Construct tests variables
34 - GIT ( optional )
35 - Checkout ONOS master branch
36 - Pull latest ONOS code
37 - Building ONOS ( optional )
38 - Install ONOS package
39 - Build ONOS package
40 """
Devin Lim58046fa2017-07-05 16:55:00 -070041 try:
42 from tests.dependencies.ONOSSetup import ONOSSetup
43 main.testSetUp = ONOSSetup()
44 except ImportError:
45 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070046 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070047 main.testSetUp.envSetupDescription()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070048 stepResult = main.FALSE
49
50 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070051 try:
Jon Halla3e02432015-07-24 15:55:42 -070052 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Jon Halla3e02432015-07-24 15:55:42 -070053 main.dependencyPath = main.testOnDirectory + \
54 main.params[ 'DEPENDENCY' ][ 'path' ]
55 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
56 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
Devin Lim58046fa2017-07-05 16:55:00 -070057
Jon Halla3e02432015-07-24 15:55:42 -070058 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
59 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
60 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
61 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
62 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070063 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070064 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
65 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
Shreyaca8990f2017-03-16 11:43:11 -070066 main.checkConnectionSleep = int( main.params[ 'SLEEP' ][ 'checkConnection' ] )
67 main.checkFlowCountSleep = int( main.params[ 'SLEEP' ][ 'checkFlowCount' ] )
68 main.checkIntentHostSleep = int( main.params[ 'SLEEP' ][ 'checkIntentHost' ] )
69 main.checkIntentPointSleep = int( main.params[ 'SLEEP' ][ 'checkIntentPoint' ] )
acsmars59a4c552015-09-10 18:11:19 -070070 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070071 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
Devin Lima4f95bc2017-08-11 11:13:03 -070072 main.generalAttemptsNum = int( main.params[ 'RETRY' ][ 'generalAttempts' ] )
73 main.middleAttemptsNum = int( main.params[ 'RETRY' ][ 'middleAttempts' ] )
74 main.minimumAttemptsNum = int( main.params[ 'RETRY' ][ 'minimumAttempts' ] )
75 main.checkConnectionAttNum = int( main.params[ 'RETRY' ][ 'checkConnectionAtt' ] )
76 main.removeIntentAttNum = int( main.params[ 'RETRY' ][ 'removeIntentAtt' ] )
Jon Halla3e02432015-07-24 15:55:42 -070077 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
78 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
Jon Halla3e02432015-07-24 15:55:42 -070079 main.hostsData = {}
Jeremy Songster1f39bf02016-01-20 17:17:25 -080080 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
81 main.scapyHosts = [] # List of scapy hosts for iterating
acsmars5d8cc862015-09-25 09:44:50 -070082 main.assertReturnString = '' # Assembled assert return string
Jon Hall78be4962017-05-23 14:53:53 -070083 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlabd48a68c2015-07-13 16:01:36 -070084
Jon Halla3e02432015-07-24 15:55:42 -070085 # -- INIT SECTION, ONLY RUNS ONCE -- #
kelvin-onlabd48a68c2015-07-13 16:01:36 -070086
Jon Hall78be4962017-05-23 14:53:53 -070087 main.intents = imp.load_source( wrapperFile2,
Jon Halla3e02432015-07-24 15:55:42 -070088 main.dependencyPath +
89 wrapperFile2 +
90 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070091
kelvin-onlabd9e23de2015-08-06 10:34:44 -070092 copyResult1 = main.ONOSbench.scp( main.Mininet1,
93 main.dependencyPath +
94 main.topology,
Jeremy Songster1f39bf02016-01-20 17:17:25 -080095 main.Mininet1.home + "custom/",
kelvin-onlabd9e23de2015-08-06 10:34:44 -070096 direction="to" )
Devin Lim58046fa2017-07-05 16:55:00 -070097
Devin Lim142b5342017-07-20 15:22:39 -070098 stepResult = main.testSetUp.envSetup()
Jon Halla3e02432015-07-24 15:55:42 -070099 except Exception as e:
Devin Lim58046fa2017-07-05 16:55:00 -0700100 main.testSetUp.envSetupException( e )
101 main.testSetUp.evnSetupConclusion( stepResult )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700102
103 def CASE2( self, main ):
104 """
105 - Set up cell
106 - Create cell file
107 - Set cell file
108 - Verify cell file
109 - Kill ONOS process
110 - Uninstall ONOS cluster
111 - Verify ONOS start up
112 - Install ONOS cluster
113 - Connect to cli
114 """
Jeremycd872222016-03-29 10:08:34 -0700115 main.flowCompiler = "Flow Rules"
Devin Lim142b5342017-07-20 15:22:39 -0700116 main.initialized = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, True )
Jon Hall78be4962017-05-23 14:53:53 -0700117 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -0700118
Jon Halla3e02432015-07-24 15:55:42 -0700119 def CASE8( self, main ):
120 """
acsmars59a4c552015-09-10 18:11:19 -0700121 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700122 """
Devin Lim58046fa2017-07-05 16:55:00 -0700123 import time
124 try:
125 from tests.dependencies.topology import Topology
126 except ImportError:
127 main.log.error( "Topology not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700128 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700129 try:
130 main.topoRelated
131 except ( NameError, AttributeError ):
132 main.topoRelated = Topology()
133 main.topoRelated.compareTopos( main.Mininet1, main.checkTopoAttempts )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700134
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700135 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700136 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700137 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700138 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700139 if main.initialized == main.FALSE:
140 main.log.error( "Test components did not start correctly, skipping further tests" )
141 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700142 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700143 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700144 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700145 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700146 "switches to test intents, exits out if " +\
147 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700148
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700149 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700150 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700151 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700152 main.topology,
153 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700154 stepResult = topoResult
155 utilities.assert_equals( expect=main.TRUE,
156 actual=stepResult,
157 onpass="Successfully loaded topology",
158 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700159
160 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700161 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700162 main.initialized = main.FALSE
163 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700164
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700165 def CASE11( self, main ):
166 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700167 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700168 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700169 if main.initialized == main.FALSE:
170 main.log.error( "Test components did not start correctly, skipping further tests" )
171 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700172 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700173 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700174 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700175 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700176 "switches to test intents, exits out if " +\
177 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700178
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700179 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700180 args = "--switch ovs,protocols=OpenFlow13"
181 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
182 main.topology,
183 args=args )
184 stepResult = topoResult
185 utilities.assert_equals( expect=main.TRUE,
186 actual=stepResult,
187 onpass="Successfully loaded topology",
188 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700189 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700190 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700191 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700192
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700193 def CASE12( self, main ):
194 """
195 Assign mastership to controllers
196 """
197 import re
198
Jeremyd9e4eb12016-04-13 12:09:06 -0700199 if main.initialized == main.FALSE:
200 main.log.error( "Test components did not start correctly, skipping further tests" )
201 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700202 main.case( "Assign switches to controllers" )
203 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700204 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700205 " switches to ONOS nodes"
206
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700207 switchList = []
208
209 # Creates a list switch name, use getSwitch() function later...
210 for i in range( 1, ( main.numSwitch + 1 ) ):
211 switchList.append( 's' + str( i ) )
212
Devin Lim142b5342017-07-20 15:22:39 -0700213 tempONOSip = main.Cluster.getIps()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700214
215 assignResult = main.Mininet1.assignSwController( sw=switchList,
216 ip=tempONOSip,
alison52b25892016-09-19 10:53:48 -0700217 port="6653" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700218 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700219 main.log.error( "Problem assigning mastership of switches" )
220 main.initialized = main.FALSE
221 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700222
223 for i in range( 1, ( main.numSwitch + 1 ) ):
224 response = main.Mininet1.getSwController( "s" + str( i ) )
Jon Hall860b8152017-05-23 10:35:23 -0700225 main.log.debug( "Response is " + str( response ) )
Devin Lim142b5342017-07-20 15:22:39 -0700226 if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700227 assignResult = assignResult and main.TRUE
228 else:
229 assignResult = main.FALSE
230 stepResult = assignResult
231 utilities.assert_equals( expect=main.TRUE,
232 actual=stepResult,
233 onpass="Successfully assigned switches" +
234 "to controller",
235 onfail="Failed to assign switches to " +
236 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700237 if not stepResult:
238 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700239
Jon Hall78be4962017-05-23 14:53:53 -0700240 def CASE13( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700241 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800242 Create Scapy components
243 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700244 if main.initialized == main.FALSE:
245 main.log.error( "Test components did not start correctly, skipping further tests" )
246 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800247 main.case( "Create scapy components" )
248 main.step( "Create scapy components" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800249 scapyResult = main.TRUE
250 for hostName in main.scapyHostNames:
251 main.Scapy1.createHostComponent( hostName )
252 main.scapyHosts.append( getattr( main, hostName ) )
253
254 main.step( "Start scapy components" )
255 for host in main.scapyHosts:
256 host.startHostCli()
257 host.startScapy()
258 host.updateSelf()
259 main.log.debug( host.name )
260 main.log.debug( host.hostIp )
261 main.log.debug( host.hostMac )
262
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800263 utilities.assert_equals( expect=main.TRUE,
264 actual=scapyResult,
265 onpass="Successfully created Scapy Components",
266 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700267 if not scapyResult:
268 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800269
270 def CASE14( self, main ):
271 """
272 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700273 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700274 if main.initialized == main.FALSE:
275 main.log.error( "Test components did not start correctly, skipping further tests" )
276 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700277 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800278 main.step( "Pingall hosts and confirm ONOS discovery" )
Jon Hall78be4962017-05-23 14:53:53 -0700279 utilities.retry( f=main.intents.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700280
Jon Hall78be4962017-05-23 14:53:53 -0700281 stepResult = utilities.retry( f=main.intents.confirmHostDiscovery, retValue=main.FALSE,
282 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700283 utilities.assert_equals( expect=main.TRUE,
284 actual=stepResult,
285 onpass="Successfully discovered hosts",
286 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700287 if not stepResult:
288 main.initialized = main.FALSE
289 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700290
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800291 main.step( "Populate hostsData" )
Jon Hall78be4962017-05-23 14:53:53 -0700292 stepResult = main.intents.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700293 utilities.assert_equals( expect=main.TRUE,
294 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800295 onpass="Successfully populated hostsData",
296 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700297 if not stepResult:
298 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800299
300 def CASE15( self, main ):
301 """
302 Discover all hosts with scapy arp packets and store its data to a dictionary
303 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700304 if main.initialized == main.FALSE:
305 main.log.error( "Test components did not start correctly, skipping further tests" )
306 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800307 main.case( "Discover all hosts using scapy" )
308 main.step( "Send packets from each host to the first host and confirm onos discovery" )
309
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800310 if len( main.scapyHosts ) < 1:
311 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700312 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800313 main.skipCase()
314
315 # Send ARP packets from each scapy host component
Jon Hall78be4962017-05-23 14:53:53 -0700316 main.intents.sendDiscoveryArp( main, main.scapyHosts )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800317
Jon Hall78be4962017-05-23 14:53:53 -0700318 stepResult = utilities.retry( f=main.intents.confirmHostDiscovery,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800319 retValue=main.FALSE, args=[ main ],
320 attempts=main.checkTopoAttempts, sleep=2 )
321
322 utilities.assert_equals( expect=main.TRUE,
323 actual=stepResult,
324 onpass="ONOS correctly discovered all hosts",
325 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700326 if not stepResult:
327 main.initialized = main.FALSE
328 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800329
330 main.step( "Populate hostsData" )
Jon Hall78be4962017-05-23 14:53:53 -0700331 stepResult = main.intents.populateHostData( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800332 utilities.assert_equals( expect=main.TRUE,
333 actual=stepResult,
334 onpass="Successfully populated hostsData",
335 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700336 if not stepResult:
337 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800338
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800339 def CASE16( self, main ):
340 """
Jeremy42df2e72016-02-23 16:37:46 -0800341 Balance Masters
342 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700343 if main.initialized == main.FALSE:
344 main.log.error( "Test components did not start correctly, skipping further tests" )
345 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800346 main.case( "Balance mastership of switches" )
347 main.step( "Balancing mastership of switches" )
348
Devin Lim142b5342017-07-20 15:22:39 -0700349 balanceResult = utilities.retry( f=main.Cluster.active( 0 ).CLI.balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800350
351 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700352 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800353 onpass="Successfully balanced mastership of switches",
354 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700355 if not balanceResult:
356 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800357
358 def CASE17( self, main ):
359 """
Jeremy6e9748f2016-03-25 15:03:39 -0700360 Use Flow Objectives
361 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700362 if main.initialized == main.FALSE:
363 main.log.error( "Test components did not start correctly, skipping further tests" )
364 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700365 main.case( "Enable intent compilation using Flow Objectives" )
366 main.step( "Enabling Flow Objectives" )
367
368 main.flowCompiler = "Flow Objectives"
369
370 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
371
Devin Lim142b5342017-07-20 15:22:39 -0700372 stepResult = main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700373 propName="useFlowObjectives", value="true" )
Devin Lim142b5342017-07-20 15:22:39 -0700374 stepResult &= main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700375 propName="defaultFlowObjectiveCompiler",
376 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremy6e9748f2016-03-25 15:03:39 -0700377
378 utilities.assert_equals( expect=main.TRUE,
379 actual=stepResult,
380 onpass="Successfully activated Flow Objectives",
381 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700382 if not balanceResult:
383 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700384
385 def CASE18( self, main ):
386 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800387 Stop mininet and remove scapy host
388 """
Devin Lim58046fa2017-07-05 16:55:00 -0700389 try:
390 from tests.dependencies.utils import Utils
391 except ImportError:
392 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700393 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700394 try:
395 main.Utils
396 except ( NameError, AttributeError ):
397 main.Utils = Utils()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800398 main.log.report( "Stop Mininet and Scapy" )
399 main.case( "Stop Mininet and Scapy" )
400 main.caseExplanation = "Stopping the current mininet topology " +\
401 "to start up fresh"
402 main.step( "Stopping and Removing Scapy Host Components" )
403 scapyResult = main.TRUE
404 for host in main.scapyHosts:
405 scapyResult = scapyResult and host.stopScapy()
406 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
407
408 for host in main.scapyHosts:
409 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
410 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
411
412 main.scapyHosts = []
413 main.scapyHostIPs = []
414
415 utilities.assert_equals( expect=main.TRUE,
416 actual=scapyResult,
417 onpass="Successfully stopped scapy and removed host components",
418 onfail="Failed to stop mininet and scapy" )
419
Devin Lim58046fa2017-07-05 16:55:00 -0700420 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700421 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800422 if not ( mininetResult and scapyResult ):
Devin Lim44075962017-08-11 10:56:37 -0700423 main.cleanAndExit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700424
Jeremy Songster17147f22016-05-31 18:30:52 -0700425 def CASE19( self, main ):
426 """
427 Copy the karaf.log files after each testcase cycle
428 """
Devin Lim58046fa2017-07-05 16:55:00 -0700429 try:
430 from tests.dependencies.utils import Utils
431 except ImportError:
432 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700433 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700434 try:
435 main.Utils
436 except ( NameError, AttributeError ):
437 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700438 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700439
kelvin-onlabb769f562015-07-15 17:05:10 -0700440 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700441 """
442 Add host intents between 2 host:
443 - Discover hosts
444 - Add host intents
445 - Check intents
446 - Verify flows
447 - Ping hosts
448 - Reroute
449 - Link down
450 - Verify flows
451 - Check topology
452 - Ping hosts
453 - Link up
454 - Verify flows
455 - Check topology
456 - Ping hosts
457 - Remove intents
458 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700459 if main.initialized == main.FALSE:
460 main.log.error( "Test components did not start correctly, skipping further tests" )
461 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700462 # Assert variables - These variable's name|format must be followed
463 # if you want to use the wrapper function
464 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700465 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700466 assert main.Mininet1
467 except AssertionError:
468 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
469 main.initialized = main.FALSE
470 main.skipCase()
471 try:
472 assert main.numSwitch
473 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700474 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700475 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700476 main.initialized = main.FALSE
477 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700478
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800479 # Save leader candidates
Devin Lim142b5342017-07-20 15:22:39 -0700480 intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates()
acsmarse6b410f2015-07-17 14:39:34 -0700481
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700482 main.testName = "Host Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700483 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700484 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700485 main.caseExplanation = "This test case tests Host intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -0700486 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700487 "Different type of hosts will be tested in " +\
488 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700489 "etc;\nThe test will use OF " + main.OFProtocol +\
490 " OVS running in Mininet and compile intents" +\
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700491 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700492
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700493 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700494 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700495 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
496 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800497 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700498 installResult = main.intents.installHostIntent( main,
499 name="IPV4",
500 onosNode=0,
501 host1=host1,
502 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800503 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700504 testResult = main.intents.testHostIntent( main,
505 name="IPV4",
506 intentId=installResult,
507 onosNode=0,
508 host1=host1,
509 host2=host2,
510 sw1="s5",
511 sw2="s2",
512 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800513 else:
Devin Lim142b5342017-07-20 15:22:39 -0700514 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800515
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700516 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800517 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700518 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700519 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700520
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700521 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700522 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700523 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
Jon Hall78be4962017-05-23 14:53:53 -0700524 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1 " }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800525 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700526 installResult = main.intents.installHostIntent( main,
527 name="DUALSTACK",
528 onosNode=0,
529 host1=host1,
530 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800531
532 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700533 testResult = main.intents.testHostIntent( main,
534 name="DUALSTACK",
535 intentId=installResult,
536 onosNode=0,
537 host1=host1,
538 host2=host2,
539 sw1="s5",
540 sw2="s2",
541 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700542
543 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800544 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700545 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700546 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700547
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700548 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700549 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700550 host1 = { "name": "h1" }
551 host2 = { "name": "h11" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800552 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700553 installResult = main.intents.installHostIntent( main,
554 name="DUALSTACK2",
555 onosNode=0,
556 host1=host1,
557 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800558
559 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700560 testResult = main.intents.testHostIntent( main,
561 name="DUALSTACK2",
562 intentId=installResult,
563 onosNode=0,
564 host1=host1,
565 host2=host2,
566 sw1="s5",
567 sw2="s2",
568 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800569 else:
Devin Lim142b5342017-07-20 15:22:39 -0700570 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700571
572 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800573 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700574 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700575 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700576
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700577 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700578 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall9c888672017-05-15 18:03:54 -0700579 host1 = { "name": "h1" }
580 host2 = { "name": "h3" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800581 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700582 installResult = main.intents.installHostIntent( main,
583 name="1HOP",
584 onosNode=0,
585 host1=host1,
586 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800587
588 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700589 testResult = main.intents.testHostIntent( main,
590 name="1HOP",
591 intentId=installResult,
592 onosNode=0,
593 host1=host1,
594 host2=host2,
595 sw1="s5",
596 sw2="s2",
597 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800598 else:
Devin Lim142b5342017-07-20 15:22:39 -0700599 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700600
601 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800602 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700603 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700604 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700605
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700606 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700607 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700608 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlan": "100" }
609 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800610 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700611 installResult = main.intents.installHostIntent( main,
612 name="VLAN1",
613 onosNode=0,
614 host1=host1,
615 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800616 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700617 testResult = main.intents.testHostIntent( main,
618 name="VLAN1",
619 intentId=installResult,
620 onosNode=0,
621 host1=host1,
622 host2=host2,
623 sw1="s5",
624 sw2="s2",
625 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800626 else:
Devin Lim142b5342017-07-20 15:22:39 -0700627 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700628
629 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800630 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700631 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700632 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700633
Jeremy Songsterff553672016-05-12 17:06:23 -0700634 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
635 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700636 host1 = { "name": "h5", "vlan": "200" }
637 host2 = { "name": "h12", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -0700638 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700639 installResult = main.intents.installHostIntent( main,
640 name="VLAN2",
641 onosNode=0,
642 host1=host1,
643 host2=host2 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700644
645 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700646 testResult = main.intents.testHostIntent( main,
647 name="VLAN2",
648 intentId=installResult,
649 onosNode=0,
650 host1=host1,
651 host2=host2,
652 sw1="s5",
653 sw2="s2",
654 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700655 else:
Devin Lim142b5342017-07-20 15:22:39 -0700656 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -0700657
658 utilities.assert_equals( expect=main.TRUE,
659 actual=testResult,
660 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700661 onfail=main.assertReturnString )
Jeremy Songsterff553672016-05-12 17:06:23 -0700662
Jeremy Songsterc032f162016-08-04 17:14:49 -0700663 main.step( "Encapsulation: Add host intents between h1 and h9" )
664 main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700665 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
666 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -0700667 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700668 installResult = main.intents.installHostIntent( main,
669 name="ENCAPSULATION",
670 onosNode=0,
671 host1=host1,
672 host2=host2,
673 encap="VLAN" )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700674 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700675 testResult = main.intents.testHostIntent( main,
676 name="ENCAPSULATION",
677 intentId=installResult,
678 onosNode=0,
679 host1=host1,
680 host2=host2,
681 sw1="s5",
682 sw2="s2",
683 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700684 else:
Devin Lim142b5342017-07-20 15:22:39 -0700685 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700686
687 utilities.assert_equals( expect=main.TRUE,
688 actual=testResult,
689 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700690 onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700691
Jon Hall78be4962017-05-23 14:53:53 -0700692 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -0700693 # main.step( "Encapsulation: Add host intents between h1 and h9" )
694 # main.assertReturnString = "Assertion Result for MPLS Encapsulated host intent\n"
695 # host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
696 # host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
697 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700698 # installResult = main.intents.installHostIntent( main,
699 # name="ENCAPSULATION",
700 # onosNode=0,
701 # host1=host1,
702 # host2=host2,
703 # encap="MPLS" )
alison52b25892016-09-19 10:53:48 -0700704 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700705 # testResult = main.intents.testHostIntent( main,
706 # name="ENCAPSULATION",
707 # intentId=installResult,
708 # onosNode=0,
709 # host1=host1,
710 # host2=host2,
711 # sw1="s5",
712 # sw2="s2",
713 # expectedLink=18 )
alison52b25892016-09-19 10:53:48 -0700714 # else:
Devin Lim142b5342017-07-20 15:22:39 -0700715 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -0700716 #
717 # utilities.assert_equals( expect=main.TRUE,
718 # actual=testResult,
719 # onpass=main.assertReturnString,
720 # onfail=main.assertReturnString )
721
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700722 main.step( "Confirm that ONOS leadership is unchanged" )
Devin Lim142b5342017-07-20 15:22:39 -0700723 intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jon Hall78be4962017-05-23 14:53:53 -0700724 testResult = main.intents.checkLeaderChange( intentLeadersOld,
725 intentLeadersNew )
acsmarse6b410f2015-07-17 14:39:34 -0700726
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800727 utilities.assert_equals( expect=main.TRUE,
728 actual=testResult,
729 onpass="ONOS Leaders Unchanged",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700730 onfail="ONOS Leader Mismatch" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800731
Jon Hall78be4962017-05-23 14:53:53 -0700732 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -0700733
kelvin-onlabb769f562015-07-15 17:05:10 -0700734 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700735 """
736 Add point intents between 2 hosts:
737 - Get device ids | ports
738 - Add point intents
739 - Check intents
740 - Verify flows
741 - Ping hosts
742 - Reroute
743 - Link down
744 - Verify flows
745 - Check topology
746 - Ping hosts
747 - Link up
748 - Verify flows
749 - Check topology
750 - Ping hosts
751 - Remove intents
752 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700753 if main.initialized == main.FALSE:
754 main.log.error( "Test components did not start correctly, skipping further tests" )
755 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700756 # Assert variables - These variable's name|format must be followed
757 # if you want to use the wrapper function
758 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700759 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700760 assert main.Mininet1
761 except AssertionError:
762 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
763 main.initialized = main.FALSE
764 main.skipCase()
765 try:
766 assert main.numSwitch
767 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700768 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700769 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700770 main.initialized = main.FALSE
771 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700772
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700773 main.testName = "Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700774 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700775 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700776 main.caseExplanation = "This test case will test point to point" +\
Devin Lim142b5342017-07-20 15:22:39 -0700777 " intents using " + str( main.Cluster.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700778 " node(s) cluster;\n" +\
779 "Different type of hosts will be tested in " +\
780 "each step such as IPV4, Dual stack, VLAN etc" +\
781 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -0700782 " OVS running in Mininet and compile intents" +\
783 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700784
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700785 # No option point intents
786 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700787 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800788 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700789 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800790 ]
791 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700792 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800793 ]
Jeremy42df2e72016-02-23 16:37:46 -0800794 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700795 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700796 main,
797 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800798 senders=senders,
799 recipients=recipients )
800
801 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700802 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800803 main,
804 intentId=installResult,
805 name="NOOPTION",
806 senders=senders,
807 recipients=recipients,
808 sw1="s5",
809 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700810 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800811 else:
Devin Lim142b5342017-07-20 15:22:39 -0700812 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700813
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700814 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800815 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700816 onpass=main.assertReturnString,
817 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700818
kelvin-onlabb769f562015-07-15 17:05:10 -0700819 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700820 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800821 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700822 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800823 ]
824 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700825 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800826 ]
Jeremy42df2e72016-02-23 16:37:46 -0800827 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700828 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700829 main,
830 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800831 senders=senders,
832 recipients=recipients,
833 ethType="IPV4" )
834
835 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700836 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800837 main,
838 intentId=installResult,
839 name="IPV4",
840 senders=senders,
841 recipients=recipients,
842 sw1="s5",
843 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700844 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800845 else:
Devin Lim142b5342017-07-20 15:22:39 -0700846 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700847
848 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800849 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700850 onpass=main.assertReturnString,
851 onfail=main.assertReturnString )
alisonda157272016-12-22 01:13:21 -0800852
Jon Hall78be4962017-05-23 14:53:53 -0700853 main.step( "Protected: Add point intents between h1 and h9" )
alisonda157272016-12-22 01:13:21 -0800854 main.assertReturnString = "Assertion Result for protected point intent\n"
855 senders = [
Jon Hall78be4962017-05-23 14:53:53 -0700856 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
alisonda157272016-12-22 01:13:21 -0800857 ]
858 recipients = [
Jon Hall78be4962017-05-23 14:53:53 -0700859 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
alisonda157272016-12-22 01:13:21 -0800860 ]
861 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700862 installResult = main.intents.installPointIntent(
alisonda157272016-12-22 01:13:21 -0800863 main,
864 name="Protected",
865 senders=senders,
866 recipients=recipients,
867 protected=True )
868
869 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700870 testResult = main.intents.testPointIntent(
alisonda157272016-12-22 01:13:21 -0800871 main,
872 name="Protected",
873 intentId=installResult,
874 senders=senders,
875 recipients=recipients,
876 sw1="s5",
877 sw2="s2",
878 protected=True,
879 expectedLink=18 )
880 else:
Devin Lim142b5342017-07-20 15:22:39 -0700881 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alisonda157272016-12-22 01:13:21 -0800882
883 utilities.assert_equals( expect=main.TRUE,
884 actual=testResult,
885 onpass=main.assertReturnString,
886 onfail=main.assertReturnString )
887
kelvin-onlabb769f562015-07-15 17:05:10 -0700888 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700889 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800890 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700891 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800892 ]
893 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700894 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800895 ]
Jeremy42df2e72016-02-23 16:37:46 -0800896 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700897 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700898 main,
899 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800900 senders=senders,
901 recipients=recipients,
902 ethType="IPV4" )
903
904 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700905 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800906 main,
907 intentId=installResult,
908 name="IPV4_2",
909 senders=senders,
910 recipients=recipients,
911 sw1="s5",
912 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700913 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800914 else:
Devin Lim142b5342017-07-20 15:22:39 -0700915 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700916
917 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800918 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700919 onpass=main.assertReturnString,
920 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700921
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700922 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700923 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800924 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700925 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700926 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800927 ]
928 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700929 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700930 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800931 ]
Jeremy6f000c62016-02-25 17:02:28 -0800932 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700933 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800934 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
935 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -0800936 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700937 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800938 main,
939 name="SDNIP-ICMP",
940 senders=senders,
941 recipients=recipients,
942 ethType="IPV4",
943 ipProto=ipProto,
944 tcpSrc=tcpSrc,
945 tcpDst=tcpDst )
946
947 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700948 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800949 main,
950 intentId=installResult,
951 name="SDNIP_ICMP",
952 senders=senders,
953 recipients=recipients,
954 sw1="s5",
955 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -0700956 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700957 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -0800958 else:
Devin Lim142b5342017-07-20 15:22:39 -0700959 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -0700960
961 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800962 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700963 onpass=main.assertReturnString,
964 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700965
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700966 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700967 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700968 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
969 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700970 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
971 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700972 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
973 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
974 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
975
Jon Hall78be4962017-05-23 14:53:53 -0700976 stepResult = main.intents.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700977 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700978 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700979 host1="h1",
980 host2="h9",
981 deviceId1="of:0000000000000005/1",
982 deviceId2="of:0000000000000006/1",
983 mac1=mac1,
984 mac2=mac2,
985 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700986 ipProto=ipProto,
987 ip1=ip1,
988 ip2=ip2,
989 tcp1=tcp1,
990 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700991
992 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -0800993 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700994 onpass=main.assertReturnString,
995 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700996
acsmars5d8cc862015-09-25 09:44:50 -0700997 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
998 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800999 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001000 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001001 ]
1002 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001003 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001004 ]
Jeremy42df2e72016-02-23 16:37:46 -08001005 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001006 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001007 main,
1008 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001009 senders=senders,
1010 recipients=recipients,
1011 ethType="IPV4" )
1012
1013 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001014 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001015 main,
1016 intentId=installResult,
1017 name="DUALSTACK1",
1018 senders=senders,
1019 recipients=recipients,
1020 sw1="s5",
1021 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001022 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001023 else:
Devin Lim142b5342017-07-20 15:22:39 -07001024 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001025
1026 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001027 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001028 onpass=main.assertReturnString,
1029 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001030
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001031 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001032 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001033 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001034 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001035 ]
1036 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001037 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001038 ]
Jeremy42df2e72016-02-23 16:37:46 -08001039 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001040 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001041 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001042 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001043 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001044 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001045
1046 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001047 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001048 main,
1049 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001050 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001051 senders=senders,
1052 recipients=recipients,
1053 sw1="s5",
1054 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001055 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001056
1057 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001058 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001059 onpass=main.assertReturnString,
1060 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001061
Jeremy Songsterff553672016-05-12 17:06:23 -07001062 main.step( "VLAN: Add point intents between h5 and h21" )
1063 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1064 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001065 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001066 ]
1067 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001068 { "name": "h21", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001069 ]
1070 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001071 installResult = main.intents.installPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001072 main,
1073 name="VLAN2",
1074 senders=senders,
1075 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001076 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001077
1078 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001079 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001080 main,
1081 intentId=installResult,
1082 name="VLAN2",
1083 senders=senders,
1084 recipients=recipients,
1085 sw1="s5",
1086 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001087 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001088
1089 utilities.assert_equals( expect=main.TRUE,
1090 actual=testResult,
1091 onpass=main.assertReturnString,
1092 onfail=main.assertReturnString )
1093
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001094 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001095 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001096 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001097 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001098 ]
1099 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001100 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001101 ]
Jeremy42df2e72016-02-23 16:37:46 -08001102 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001103 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001104 main,
1105 name="1HOP IPV4",
1106 senders=senders,
1107 recipients=recipients,
1108 ethType="IPV4" )
1109
1110 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001111 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001112 main,
1113 intentId=installResult,
1114 name="1HOP IPV4",
1115 senders=senders,
1116 recipients=recipients,
1117 sw1="s5",
1118 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001119 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001120 else:
Devin Lim142b5342017-07-20 15:22:39 -07001121 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001122
1123 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001124 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001125 onpass=main.assertReturnString,
1126 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001127
Jeremy Songsterc032f162016-08-04 17:14:49 -07001128 main.step( "Add point to point intents using VLAN Encapsulation" )
1129 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1130 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001131 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001132 ]
1133 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001134 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001135 ]
1136 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001137 installResult = main.intents.installPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001138 main,
1139 name="ENCAPSULATION",
1140 senders=senders,
1141 recipients=recipients,
1142 encap="VLAN" )
1143
1144 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001145 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001146 main,
1147 intentId=installResult,
1148 name="ENCAPSULATION",
1149 senders=senders,
1150 recipients=recipients,
1151 sw1="s5",
1152 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001153 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001154 else:
Devin Lim142b5342017-07-20 15:22:39 -07001155 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001156
1157 utilities.assert_equals( expect=main.TRUE,
1158 actual=testResult,
1159 onpass=main.assertReturnString,
1160 onfail=main.assertReturnString )
1161
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001162 main.step( "BANDWIDTH ALLOCATION: Checking bandwidth allocation for point intents between h1 and h9" )
1163 main.assertReturnString = "Assertion Result for BANDWIDTH ALLOCATION for point intent\n"
1164 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001165 { "name": "h1", "device": "of:0000000000000005/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001166 ]
1167 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001168 { "name": "h9", "device": "of:0000000000000006/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001169 ]
1170 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001171 installResult = main.intents.installPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001172 main,
1173 name="NOOPTION",
1174 senders=senders,
1175 recipients=recipients,
Jon Hallf539eb92017-05-22 17:18:42 -07001176 bandwidth=100 )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001177
1178 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001179 testResult = main.intents.testPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001180 main,
1181 intentId=installResult,
1182 name="NOOPTION",
1183 senders=senders,
1184 recipients=recipients,
1185 sw1="s5",
1186 sw2="s2",
1187 expectedLink=18 )
1188 else:
Devin Lim142b5342017-07-20 15:22:39 -07001189 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001190
1191 utilities.assert_equals( expect=main.TRUE,
1192 actual=testResult,
1193 onpass=main.assertReturnString,
1194 onfail=main.assertReturnString )
1195
Jon Hall78be4962017-05-23 14:53:53 -07001196 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -07001197 # main.step( "Add point to point intents using MPLS Encapsulation" )
1198 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1199 # senders = [
1200 # { "name": "h1", "device": "of:0000000000000005/1" }
1201 # ]
1202 # recipients = [
1203 # { "name": "h9", "device": "of:0000000000000006/1" }
1204 # ]
1205 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001206 # installResult = main.intents.installPointIntent(
alison52b25892016-09-19 10:53:48 -07001207 # main,
1208 # name="ENCAPSULATION",
1209 # senders=senders,
1210 # recipients=recipients,
1211 # encap="MPLS" )
1212 #
1213 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001214 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001215 # main,
1216 # intentId=installResult,
1217 # name="ENCAPSULATION",
1218 # senders=senders,
1219 # recipients=recipients,
1220 # sw1="s5",
1221 # sw2="s2",
1222 # expectedLink=18 )
1223 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001224 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001225 #
1226 # utilities.assert_equals( expect=main.TRUE,
1227 # actual=testResult,
1228 # onpass=main.assertReturnString,
1229 # onfail=main.assertReturnString )
1230
Jon Hall78be4962017-05-23 14:53:53 -07001231 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001232
kelvin-onlabb769f562015-07-15 17:05:10 -07001233 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001234 """
1235 Add single point to multi point intents
1236 - Get device ids
1237 - Add single point to multi point intents
1238 - Check intents
1239 - Verify flows
1240 - Ping hosts
1241 - Reroute
1242 - Link down
1243 - Verify flows
1244 - Check topology
1245 - Ping hosts
1246 - Link up
1247 - Verify flows
1248 - Check topology
1249 - Ping hosts
1250 - Remove intents
1251 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001252 if main.initialized == main.FALSE:
1253 main.log.error( "Test components did not start correctly, skipping further tests" )
1254 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001255 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001256 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001257 assert main.Mininet1
1258 except AssertionError:
1259 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1260 main.initialized = main.FALSE
1261 main.skipCase()
1262 try:
1263 assert main.numSwitch
1264 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001265 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001266 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001267 main.initialized = main.FALSE
1268 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001269
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001270 main.testName = "Single to Multi Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001271 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001272 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001273 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001274 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001275 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001276 "Different type of hosts will be tested in " +\
1277 "each step such as IPV4, Dual stack, VLAN etc" +\
1278 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001279 " OVS running in Mininet and compile intents" +\
1280 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001281
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001282 main.step( "NOOPTION: Install and test single point to multi point intents" )
1283 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1284 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001285 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001286 ]
1287 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001288 { "name": "h16", "device": "of:0000000000000006/8" },
1289 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001290 ]
Jon Hall9c888672017-05-15 18:03:54 -07001291 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1292 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001293 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001294 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001295 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001296 name="NOOPTION",
1297 senders=senders,
1298 recipients=recipients,
1299 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001300 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001301
1302 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001303 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001304 main,
1305 intentId=installResult,
1306 name="NOOPTION",
1307 senders=senders,
1308 recipients=recipients,
1309 badSenders=badSenders,
1310 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001311 sw1="s5",
1312 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001313 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001314 else:
Devin Lim142b5342017-07-20 15:22:39 -07001315 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001316
1317 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001318 actual=testResult,
1319 onpass=main.assertReturnString,
1320 onfail=main.assertReturnString )
1321
1322 main.step( "IPV4: Install and test single point to multi point intents" )
1323 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1324 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001325 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001326 ]
1327 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001328 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1329 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001330 ]
Jon Hall9c888672017-05-15 18:03:54 -07001331 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1332 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001333 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001334 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001335 main,
1336 name="IPV4",
1337 senders=senders,
1338 recipients=recipients,
1339 ethType="IPV4",
1340 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001341 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001342
1343 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001344 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001345 main,
1346 intentId=installResult,
1347 name="IPV4",
1348 senders=senders,
1349 recipients=recipients,
1350 badSenders=badSenders,
1351 badRecipients=badRecipients,
1352 sw1="s5",
1353 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001354 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001355 else:
Devin Lim142b5342017-07-20 15:22:39 -07001356 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001357
1358 utilities.assert_equals( expect=main.TRUE,
1359 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001360 onpass=main.assertReturnString,
1361 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001362
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001363 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001364 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and no MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001365 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001366 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001367 ]
1368 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001369 { "name": "h16", "device": "of:0000000000000006/8" },
1370 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001371 ]
Jon Hall9c888672017-05-15 18:03:54 -07001372 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1373 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001374 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001375 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001376 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001377 name="IPV4_2",
1378 senders=senders,
1379 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001380 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001381 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001382 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001383
1384 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001385 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001386 main,
1387 intentId=installResult,
1388 name="IPV4_2",
1389 senders=senders,
1390 recipients=recipients,
1391 badSenders=badSenders,
1392 badRecipients=badRecipients,
1393 sw1="s5",
1394 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001395 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001396 else:
Devin Lim142b5342017-07-20 15:22:39 -07001397 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001398
1399 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001400 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001401 onpass=main.assertReturnString,
1402 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001403
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001404 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001405 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses in the same VLAN\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001406 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001407 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001408 ]
1409 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001410 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1411 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001412 ]
Jon Hall9c888672017-05-15 18:03:54 -07001413 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1414 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001415 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001416 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001417 main,
alison52b25892016-09-19 10:53:48 -07001418 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001419 senders=senders,
1420 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001421 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001422 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001423
1424 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001425 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001426 main,
1427 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001428 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001429 senders=senders,
1430 recipients=recipients,
1431 badSenders=badSenders,
1432 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001433 sw1="s5",
1434 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001435 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001436 else:
Devin Lim142b5342017-07-20 15:22:39 -07001437 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001438
1439 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001440 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001441 onpass=main.assertReturnString,
1442 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001443
Jeremy Songsterff553672016-05-12 17:06:23 -07001444 main.step( "VLAN: Add single point to multi point intents" )
1445 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1446 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001447 { "name": "h5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001448 ]
1449 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001450 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1451 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001452 ]
Jon Hall9c888672017-05-15 18:03:54 -07001453 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1454 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001455 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001456 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001457 main,
1458 name="VLAN2",
1459 senders=senders,
1460 recipients=recipients,
1461 sw1="s5",
1462 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001463 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001464
1465 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001466 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001467 main,
1468 intentId=installResult,
1469 name="VLAN2",
1470 senders=senders,
1471 recipients=recipients,
1472 badSenders=badSenders,
1473 badRecipients=badRecipients,
1474 sw1="s5",
1475 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001476 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001477 else:
Devin Lim142b5342017-07-20 15:22:39 -07001478 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -07001479
1480 utilities.assert_equals( expect=main.TRUE,
1481 actual=testResult,
1482 onpass=main.assertReturnString,
1483 onfail=main.assertReturnString )
1484
alison52b25892016-09-19 10:53:48 -07001485 # Does not support Single point to multi point encapsulation
1486 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1487 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1488 # senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001489 # { "name": "h8", "device": "of:0000000000000005/8" }
alison52b25892016-09-19 10:53:48 -07001490 # ]
1491 # recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001492 # { "name": "h16", "device": "of:0000000000000006/8" },
1493 # { "name": "h24", "device": "of:0000000000000007/8" }
alison52b25892016-09-19 10:53:48 -07001494 # ]
Jon Hall9c888672017-05-15 18:03:54 -07001495 # badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1496 # badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
alison52b25892016-09-19 10:53:48 -07001497 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001498 # installResult = main.intents.installSingleToMultiIntent(
alison52b25892016-09-19 10:53:48 -07001499 # main,
1500 # name="ENCAPSULATION",
1501 # senders=senders,
1502 # recipients=recipients,
1503 # sw1="s5",
1504 # sw2="s2",
1505 # encap="VLAN" )
1506 #
1507 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001508 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001509 # main,
1510 # intentId=installResult,
1511 # name="ENCAPSULATION",
1512 # senders=senders,
1513 # recipients=recipients,
1514 # badSenders=badSenders,
1515 # badRecipients=badRecipients,
1516 # sw1="s5",
1517 # sw2="s2",
1518 # expectedLink=18 )
1519 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001520 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001521 #
1522 # utilities.assert_equals( expect=main.TRUE,
1523 # actual=testResult,
1524 # onpass=main.assertReturnString,
1525 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001526
Jon Hall78be4962017-05-23 14:53:53 -07001527 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001528
kelvin-onlabb769f562015-07-15 17:05:10 -07001529 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001530 """
1531 Add multi point to single point intents
1532 - Get device ids
1533 - Add multi point to single point intents
1534 - Check intents
1535 - Verify flows
1536 - Ping hosts
1537 - Reroute
1538 - Link down
1539 - Verify flows
1540 - Check topology
1541 - Ping hosts
1542 - Link up
1543 - Verify flows
1544 - Check topology
1545 - Ping hosts
1546 - Remove intents
1547 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001548 if main.initialized == main.FALSE:
1549 main.log.error( "Test components did not start correctly, skipping further tests" )
1550 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001551 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001552 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001553 assert main.Mininet1
1554 except AssertionError:
1555 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1556 main.initialized = main.FALSE
1557 main.skipCase()
1558 try:
1559 assert main.numSwitch
1560 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001561 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001562 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001563 main.initialized = main.FALSE
1564 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001565
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001566 main.testName = "Multi To Single Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001567 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001568 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001569 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001570 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001571 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001572 "Different type of hosts will be tested in " +\
1573 "each step such as IPV4, Dual stack, VLAN etc" +\
1574 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001575 " OVS running in Mininet and compile intents" +\
1576 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001577
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001578 main.step( "NOOPTION: Add multi point to single point intents" )
1579 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1580 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001581 { "name": "h16", "device": "of:0000000000000006/8" },
1582 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001583 ]
1584 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001585 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001586 ]
Jon Hall9c888672017-05-15 18:03:54 -07001587 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1588 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001589 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001590 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001591 main,
1592 name="NOOPTION",
1593 senders=senders,
1594 recipients=recipients,
1595 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001596 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001597
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001598 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001599 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001600 main,
1601 intentId=installResult,
1602 name="NOOPTION",
1603 senders=senders,
1604 recipients=recipients,
1605 badSenders=badSenders,
1606 badRecipients=badRecipients,
1607 sw1="s5",
1608 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001609 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001610 else:
Devin Lim142b5342017-07-20 15:22:39 -07001611 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001612
1613 utilities.assert_equals( expect=main.TRUE,
1614 actual=testResult,
1615 onpass=main.assertReturnString,
1616 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001617
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001618 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001619 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001620 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001621 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1622 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001623 ]
1624 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001625 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001626 ]
Jon Hall9c888672017-05-15 18:03:54 -07001627 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1628 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001629 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001630 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001631 main,
1632 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001633 senders=senders,
1634 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001635 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001636 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001637 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001638
1639 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001640 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001641 main,
1642 intentId=installResult,
1643 name="IPV4",
1644 senders=senders,
1645 recipients=recipients,
1646 badSenders=badSenders,
1647 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001648 sw1="s5",
1649 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001650 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001651 else:
Devin Lim142b5342017-07-20 15:22:39 -07001652 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001653
1654 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001655 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001656 onpass=main.assertReturnString,
1657 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001658
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001659 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001660 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001661 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001662 { "name": "h16", "device": "of:0000000000000006/8" },
1663 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001664 ]
1665 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001666 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001667 ]
Jon Hall9c888672017-05-15 18:03:54 -07001668 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1669 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001670 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001671 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001672 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001673 name="IPV4_2",
1674 senders=senders,
1675 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001676 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001677 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001678 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001679
1680 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001681 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001682 main,
1683 intentId=installResult,
1684 name="IPV4_2",
1685 senders=senders,
1686 recipients=recipients,
1687 badSenders=badSenders,
1688 badRecipients=badRecipients,
1689 sw1="s5",
1690 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001691 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001692 else:
Devin Lim142b5342017-07-20 15:22:39 -07001693 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001694
1695 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001696 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001697 onpass=main.assertReturnString,
1698 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001699
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001700 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001701 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses in the same VLAN\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001702 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001703 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1704 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001705 ]
1706 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001707 { "name": "h5", "device": "of:0000000000000005/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001708 ]
Jon Hall9c888672017-05-15 18:03:54 -07001709 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1710 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001711 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001712 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001713 main,
1714 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001715 senders=senders,
1716 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001717 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001718 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001719
1720 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001721 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001722 main,
1723 intentId=installResult,
1724 name="VLAN",
1725 senders=senders,
1726 recipients=recipients,
1727 badSenders=badSenders,
1728 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001729 sw1="s5",
1730 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001731 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001732 else:
Devin Lim142b5342017-07-20 15:22:39 -07001733 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001734
1735 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001736 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001737 onpass=main.assertReturnString,
1738 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001739
Jeremy Songsterff553672016-05-12 17:06:23 -07001740 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1741 main.step( "VLAN: Add multi point to single point intents" )
1742 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1743 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001744 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1745 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001746 ]
1747 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001748 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001749 ]
Jon Hall9c888672017-05-15 18:03:54 -07001750 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1751 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001752 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001753 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001754 main,
1755 name="VLAN2",
1756 senders=senders,
1757 recipients=recipients,
1758 sw1="s5",
1759 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001760 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001761
1762 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001763 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001764 main,
1765 intentId=installResult,
1766 name="VLAN2",
1767 senders=senders,
1768 recipients=recipients,
1769 badSenders=badSenders,
1770 badRecipients=badRecipients,
1771 sw1="s5",
1772 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001773 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001774 else:
Devin Lim142b5342017-07-20 15:22:39 -07001775 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -07001776
1777 utilities.assert_equals( expect=main.TRUE,
1778 actual=testResult,
1779 onpass=main.assertReturnString,
1780 onfail=main.assertReturnString )
1781
Jeremy Songsterc032f162016-08-04 17:14:49 -07001782 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1783 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
1784 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001785 { "name": "h16", "device": "of:0000000000000006/8" },
1786 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001787 ]
1788 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001789 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001790 ]
Jon Hall9c888672017-05-15 18:03:54 -07001791 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1792 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songsterc032f162016-08-04 17:14:49 -07001793 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001794 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001795 main,
1796 name="ENCAPSULATION",
1797 senders=senders,
1798 recipients=recipients,
1799 sw1="s5",
1800 sw2="s2",
1801 encap="VLAN" )
1802
1803 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001804 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001805 main,
1806 intentId=installResult,
1807 name="ENCAPSULATION",
1808 senders=senders,
1809 recipients=recipients,
1810 badSenders=badSenders,
1811 badRecipients=badRecipients,
1812 sw1="s5",
1813 sw2="s2",
1814 expectedLink=18 )
1815 else:
Devin Lim142b5342017-07-20 15:22:39 -07001816 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001817
1818 utilities.assert_equals( expect=main.TRUE,
1819 actual=testResult,
1820 onpass=main.assertReturnString,
1821 onfail=main.assertReturnString )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001822 """
1823 Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
1824 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1825 main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
1826 senders = [
1827 { "name": "h16", "device": "of:0000000000000006/8" },
1828 { "name": "h24", "device": "of:0000000000000007/8" }
1829 ]
1830 recipients = [
1831 { "name": "h8", "device": "of:0000000000000005/8" }
1832 ]
1833 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1834 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
1835 testResult = main.FALSE
1836 installResult = main.intents.installMultiToSingleIntent(
1837 main,
1838 name="ENCAPSULATION",
1839 senders=senders,
1840 recipients=recipients,
1841 sw1="s5",
1842 sw2="s2",
1843 encap="MPLS" )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001844
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001845 if installResult:
1846 testResult = main.intents.testPointIntent(
1847 main,
1848 intentId=installResult,
1849 name="ENCAPSULATION",
1850 senders=senders,
1851 recipients=recipients,
1852 badSenders=badSenders,
1853 badRecipients=badRecipients,
1854 sw1="s5",
1855 sw2="s2",
1856 expectedLink=18 )
1857 else:
1858 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
1859
1860 utilities.assert_equals( expect=main.TRUE,
1861 actual=testResult,
1862 onpass=main.assertReturnString,
1863 onfail=main.assertReturnString )
1864 """
alison52b25892016-09-19 10:53:48 -07001865
Jon Hall78be4962017-05-23 14:53:53 -07001866 main.intents.report( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001867
acsmars1ff5e052015-07-23 11:27:48 -07001868 def CASE5000( self, main ):
1869 """
acsmars5d8cc862015-09-25 09:44:50 -07001870 Tests Host Mobility
1871 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001872 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001873 if main.initialized == main.FALSE:
1874 main.log.error( "Test components did not start correctly, skipping further tests" )
1875 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001876 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001877 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001878 assert main.Mininet1
1879 except AssertionError:
1880 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1881 main.initialized = main.FALSE
1882 main.skipCase()
1883 try:
1884 assert main.numSwitch
1885 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001886 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001887 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001888 main.initialized = main.FALSE
1889 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001890 main.case( "Test host mobility with host intents " + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001891 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001892 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001893
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001894 main.log.info( "Moving h1 from s5 to s6" )
Jon Hall9c888672017-05-15 18:03:54 -07001895 main.Mininet1.moveHost( "h1", "s5", "s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001896
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001897 # Send discovery ping from moved host
1898 # Moving the host brings down the default interfaces and creates a new one.
1899 # Scapy is restarted on this host to detect the new interface
1900 main.h1.stopScapy()
1901 main.h1.startScapy()
1902
1903 # Discover new host location in ONOS and populate host data.
1904 # Host 1 IP and MAC should be unchanged
Jon Hall78be4962017-05-23 14:53:53 -07001905 main.intents.sendDiscoveryArp( main, [ main.h1 ] )
1906 main.intents.populateHostData( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001907
acsmars1ff5e052015-07-23 11:27:48 -07001908 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1909
1910 utilities.assert_equals( expect="of:0000000000000006",
1911 actual=h1PostMove,
1912 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001913 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001914 " to single point intents" +
1915 " with IPV4 type and MAC addresses" +
1916 " in the same VLAN" )
1917
1918 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001919 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall9c888672017-05-15 18:03:54 -07001920 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1921 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001922 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001923 installResult = main.intents.installHostIntent( main,
1924 name="IPV4 Mobility IPV4",
1925 onosNode=0,
1926 host1=host1,
1927 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001928 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001929 testResult = main.intents.testHostIntent( main,
1930 name="Host Mobility IPV4",
1931 intentId=installResult,
1932 onosNode=0,
1933 host1=host1,
1934 host2=host2,
1935 sw1="s6",
1936 sw2="s2",
1937 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001938 else:
Devin Lim142b5342017-07-20 15:22:39 -07001939 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001940
1941 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001942 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001943 onpass=main.assertReturnString,
1944 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001945
Jon Hall78be4962017-05-23 14:53:53 -07001946 main.intents.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001947
1948 def CASE6000( self, main ):
1949 """
1950 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1951 """
Jeremy Songster9385d412016-06-02 17:57:36 -07001952 # At some later point discussion on this behavior in MPSP and SPMP intents
1953 # will be reoppened and this test case may need to be updated to reflect
1954 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07001955 if main.initialized == main.FALSE:
1956 main.log.error( "Test components did not start correctly, skipping further tests" )
1957 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001958 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001959 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001960 assert main.Mininet1
1961 except AssertionError:
1962 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1963 main.initialized = main.FALSE
1964 main.skipCase()
1965 try:
1966 assert main.numSwitch
1967 except AssertionError:
alison52b25892016-09-19 10:53:48 -07001968 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001969 main.initialized = main.FALSE
1970 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001971 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001972 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07001973 main.step( "Installing Multi to Single Point intents with no options set" )
1974 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
1975 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08001976 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001977 { "name": "h16", "device": "of:0000000000000006/8" },
1978 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08001979 ]
1980 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001981 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08001982 ]
1983 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07001984 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08001985 ]
1986 isolatedRecipients = []
1987 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001988 installResult = main.intents.installMultiToSingleIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08001989 main,
1990 name="NOOPTION",
1991 senders=senders,
1992 recipients=recipients,
1993 sw1="s5",
1994 sw2="s2" )
1995
1996 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001997 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08001998 main,
1999 intentId=installResult,
2000 name="NOOPTION",
2001 senders=senders,
2002 recipients=recipients,
2003 isolatedSenders=isolatedSenders,
2004 isolatedRecipients=isolatedRecipients,
2005 sw1="s6",
2006 sw2="s2",
2007 sw3="s4",
2008 sw4="s1",
2009 sw5="s3",
2010 expectedLink1=16,
2011 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002012 else:
Devin Lim142b5342017-07-20 15:22:39 -07002013 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002014
2015 utilities.assert_equals( expect=main.TRUE,
2016 actual=testResult,
2017 onpass=main.assertReturnString,
2018 onfail=main.assertReturnString )
2019
Jeremy Songster9385d412016-06-02 17:57:36 -07002020 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2021
2022 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2023 "with partial failures allowed\n"
2024 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002025 { "name": "h16", "device": "of:0000000000000006/8" },
2026 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002027 ]
2028 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002029 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002030 ]
2031 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07002032 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002033 ]
2034 isolatedRecipients = []
2035 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002036 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002037 main,
2038 name="NOOPTION",
2039 senders=senders,
2040 recipients=recipients,
2041 sw1="s5",
2042 sw2="s2",
2043 partial=True )
2044
2045 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002046 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002047 main,
2048 intentId=installResult,
2049 name="NOOPTION",
2050 senders=senders,
2051 recipients=recipients,
2052 isolatedSenders=isolatedSenders,
2053 isolatedRecipients=isolatedRecipients,
2054 sw1="s6",
2055 sw2="s2",
2056 sw3="s4",
2057 sw4="s1",
2058 sw5="s3",
2059 expectedLink1=16,
2060 expectedLink2=14,
2061 partial=True )
2062 else:
Devin Lim142b5342017-07-20 15:22:39 -07002063 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002064
2065 utilities.assert_equals( expect=main.TRUE,
2066 actual=testResult,
2067 onpass=main.assertReturnString,
2068 onfail=main.assertReturnString )
2069
Jeremye0cb5eb2016-01-27 17:39:09 -08002070 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002071 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2072 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002073 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002074 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002075 ]
2076 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002077 { "name": "h16", "device": "of:0000000000000006/8" },
2078 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002079 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002080 isolatedSenders = []
2081 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002082 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002083 ]
2084 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002085 installResult = main.intents.installSingleToMultiIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08002086 main,
2087 name="NOOPTION",
2088 senders=senders,
2089 recipients=recipients,
2090 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002091 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002092
2093 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002094 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08002095 main,
2096 intentId=installResult,
2097 name="NOOPTION",
2098 senders=senders,
2099 recipients=recipients,
2100 isolatedSenders=isolatedSenders,
2101 isolatedRecipients=isolatedRecipients,
2102 sw1="s6",
2103 sw2="s2",
2104 sw3="s4",
2105 sw4="s1",
2106 sw5="s3",
2107 expectedLink1=16,
2108 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002109 else:
Devin Lim142b5342017-07-20 15:22:39 -07002110 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002111
2112 utilities.assert_equals( expect=main.TRUE,
2113 actual=testResult,
2114 onpass=main.assertReturnString,
2115 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002116 # Right now this functionality doesn't work properly in SPMP intents
Jon Hall78be4962017-05-23 14:53:53 -07002117 main.step( "NOOPTION: Install and test single point to multi point " +
Jeremy Songster9385d412016-06-02 17:57:36 -07002118 "intents with partial failures allowed" )
2119 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2120 "point intent with partial failures allowed\n"
2121 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002122 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002123 ]
2124 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002125 { "name": "h16", "device": "of:0000000000000006/8" },
2126 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002127 ]
2128 isolatedSenders = []
2129 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002130 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002131 ]
2132 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002133 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002134 main,
2135 name="NOOPTION",
2136 senders=senders,
2137 recipients=recipients,
2138 sw1="s5",
2139 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002140 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002141
2142 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002143 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002144 main,
2145 intentId=installResult,
2146 name="NOOPTION",
2147 senders=senders,
2148 recipients=recipients,
2149 isolatedSenders=isolatedSenders,
2150 isolatedRecipients=isolatedRecipients,
2151 sw1="s6",
2152 sw2="s2",
2153 sw3="s4",
2154 sw4="s1",
2155 sw5="s3",
2156 expectedLink1=16,
2157 expectedLink2=14,
2158 partial=True )
2159 else:
Devin Lim142b5342017-07-20 15:22:39 -07002160 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002161
2162 utilities.assert_equals( expect=main.TRUE,
2163 actual=testResult,
2164 onpass=main.assertReturnString,
2165 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002166
Jon Hall78be4962017-05-23 14:53:53 -07002167 main.intents.report( main )