blob: c0374f8b28ed54758c1e1c7c9c9b0872740d9632 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2015 Open Networking Foundation (ONF)
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
21
kelvin-onlabd48a68c2015-07-13 16:01:36 -070022# Testing the basic intent functionality of ONOS
23
Jon Hall78be4962017-05-23 14:53:53 -070024
kelvin-onlabd48a68c2015-07-13 16:01:36 -070025class FUNCintent:
26
27 def __init__( self ):
28 self.default = ''
29
30 def CASE1( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -070031 import imp
Jon Hallf632d202015-07-30 15:45:11 -070032 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070033 """
34 - Construct tests variables
35 - GIT ( optional )
36 - Checkout ONOS master branch
37 - Pull latest ONOS code
38 - Building ONOS ( optional )
39 - Install ONOS package
40 - Build ONOS package
41 """
Devin Lim58046fa2017-07-05 16:55:00 -070042
43 try:
44 from tests.dependencies.ONOSSetup import ONOSSetup
45 main.testSetUp = ONOSSetup()
46 except ImportError:
47 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070048 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070049 main.testSetUp.envSetupDescription()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070050 stepResult = main.FALSE
51
52 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070053 try:
Jon Halla3e02432015-07-24 15:55:42 -070054 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Jon Halla3e02432015-07-24 15:55:42 -070055 main.dependencyPath = main.testOnDirectory + \
56 main.params[ 'DEPENDENCY' ][ 'path' ]
57 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
58 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
Devin Lim58046fa2017-07-05 16:55:00 -070059
Jon Halla3e02432015-07-24 15:55:42 -070060 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
61 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
62 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
63 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
64 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070065 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070066 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
67 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
Shreyaca8990f2017-03-16 11:43:11 -070068 main.checkConnectionSleep = int( main.params[ 'SLEEP' ][ 'checkConnection' ] )
69 main.checkFlowCountSleep = int( main.params[ 'SLEEP' ][ 'checkFlowCount' ] )
70 main.checkIntentHostSleep = int( main.params[ 'SLEEP' ][ 'checkIntentHost' ] )
71 main.checkIntentPointSleep = int( main.params[ 'SLEEP' ][ 'checkIntentPoint' ] )
acsmars59a4c552015-09-10 18:11:19 -070072 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070073 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
Devin Lima4f95bc2017-08-11 11:13:03 -070074 main.generalAttemptsNum = int( main.params[ 'RETRY' ][ 'generalAttempts' ] )
75 main.middleAttemptsNum = int( main.params[ 'RETRY' ][ 'middleAttempts' ] )
76 main.minimumAttemptsNum = int( main.params[ 'RETRY' ][ 'minimumAttempts' ] )
77 main.checkConnectionAttNum = int( main.params[ 'RETRY' ][ 'checkConnectionAtt' ] )
78 main.removeIntentAttNum = int( main.params[ 'RETRY' ][ 'removeIntentAtt' ] )
Jon Halla3e02432015-07-24 15:55:42 -070079 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
80 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
Jon Halla3e02432015-07-24 15:55:42 -070081 main.hostsData = {}
Jeremy Songster1f39bf02016-01-20 17:17:25 -080082 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
83 main.scapyHosts = [] # List of scapy hosts for iterating
acsmars5d8cc862015-09-25 09:44:50 -070084 main.assertReturnString = '' # Assembled assert return string
Jon Hall78be4962017-05-23 14:53:53 -070085 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlabd48a68c2015-07-13 16:01:36 -070086
Jon Halla3e02432015-07-24 15:55:42 -070087 # -- INIT SECTION, ONLY RUNS ONCE -- #
kelvin-onlabd48a68c2015-07-13 16:01:36 -070088
Jon Hall78be4962017-05-23 14:53:53 -070089 main.intents = imp.load_source( wrapperFile2,
Jon Halla3e02432015-07-24 15:55:42 -070090 main.dependencyPath +
91 wrapperFile2 +
92 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070093
kelvin-onlabd9e23de2015-08-06 10:34:44 -070094 copyResult1 = main.ONOSbench.scp( main.Mininet1,
95 main.dependencyPath +
96 main.topology,
Jeremy Songster1f39bf02016-01-20 17:17:25 -080097 main.Mininet1.home + "custom/",
kelvin-onlabd9e23de2015-08-06 10:34:44 -070098 direction="to" )
Devin Lim58046fa2017-07-05 16:55:00 -070099
Devin Lim142b5342017-07-20 15:22:39 -0700100 stepResult = main.testSetUp.envSetup()
Jon Halla3e02432015-07-24 15:55:42 -0700101 except Exception as e:
Devin Lim58046fa2017-07-05 16:55:00 -0700102 main.testSetUp.envSetupException( e )
103 main.testSetUp.evnSetupConclusion( stepResult )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700104
105 def CASE2( self, main ):
106 """
107 - Set up cell
108 - Create cell file
109 - Set cell file
110 - Verify cell file
111 - Kill ONOS process
112 - Uninstall ONOS cluster
113 - Verify ONOS start up
114 - Install ONOS cluster
115 - Connect to cli
116 """
Jeremy Songster17147f22016-05-31 18:30:52 -0700117
Jeremycd872222016-03-29 10:08:34 -0700118 main.flowCompiler = "Flow Rules"
Devin Lim142b5342017-07-20 15:22:39 -0700119 main.initialized = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, True )
Jon Hall78be4962017-05-23 14:53:53 -0700120 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -0700121
Jon Halla3e02432015-07-24 15:55:42 -0700122 def CASE8( self, main ):
123 """
acsmars59a4c552015-09-10 18:11:19 -0700124 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700125 """
Devin Lim58046fa2017-07-05 16:55:00 -0700126 import time
127 try:
128 from tests.dependencies.topology import Topology
129 except ImportError:
130 main.log.error( "Topology not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700131 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700132 try:
133 main.topoRelated
134 except ( NameError, AttributeError ):
135 main.topoRelated = Topology()
136 main.topoRelated.compareTopos( main.Mininet1, main.checkTopoAttempts )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700137 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700138 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700139 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700140 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700141 if main.initialized == main.FALSE:
142 main.log.error( "Test components did not start correctly, skipping further tests" )
143 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700144 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700145 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700146 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700147 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700148 "switches to test intents, exits out if " +\
149 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700150
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700151 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700152 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700153 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700154 main.topology,
155 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700156 stepResult = topoResult
157 utilities.assert_equals( expect=main.TRUE,
158 actual=stepResult,
159 onpass="Successfully loaded topology",
160 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700161
162 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700163 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700164 main.initialized = main.FALSE
165 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700166
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700167 def CASE11( self, main ):
168 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700169 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700170 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700171 if main.initialized == main.FALSE:
172 main.log.error( "Test components did not start correctly, skipping further tests" )
173 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700174 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700175 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700176 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700177 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700178 "switches to test intents, exits out if " +\
179 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700180
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700181 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700182 args = "--switch ovs,protocols=OpenFlow13"
183 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
184 main.topology,
185 args=args )
186 stepResult = topoResult
187 utilities.assert_equals( expect=main.TRUE,
188 actual=stepResult,
189 onpass="Successfully loaded topology",
190 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700191 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700192 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700193 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700194
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700195 def CASE12( self, main ):
196 """
197 Assign mastership to controllers
198 """
199 import re
200
Jeremyd9e4eb12016-04-13 12:09:06 -0700201 if main.initialized == main.FALSE:
202 main.log.error( "Test components did not start correctly, skipping further tests" )
203 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700204 main.case( "Assign switches to controllers" )
205 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700206 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700207 " switches to ONOS nodes"
208
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700209 switchList = []
210
211 # Creates a list switch name, use getSwitch() function later...
212 for i in range( 1, ( main.numSwitch + 1 ) ):
213 switchList.append( 's' + str( i ) )
214
Devin Lim142b5342017-07-20 15:22:39 -0700215 tempONOSip = main.Cluster.getIps()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700216
217 assignResult = main.Mininet1.assignSwController( sw=switchList,
218 ip=tempONOSip,
alison52b25892016-09-19 10:53:48 -0700219 port="6653" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700220 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700221 main.log.error( "Problem assigning mastership of switches" )
222 main.initialized = main.FALSE
223 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700224
225 for i in range( 1, ( main.numSwitch + 1 ) ):
226 response = main.Mininet1.getSwController( "s" + str( i ) )
Jon Hall860b8152017-05-23 10:35:23 -0700227 main.log.debug( "Response is " + str( response ) )
Devin Lim142b5342017-07-20 15:22:39 -0700228 if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700229 assignResult = assignResult and main.TRUE
230 else:
231 assignResult = main.FALSE
232 stepResult = assignResult
233 utilities.assert_equals( expect=main.TRUE,
234 actual=stepResult,
235 onpass="Successfully assigned switches" +
236 "to controller",
237 onfail="Failed to assign switches to " +
238 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700239 if not stepResult:
240 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700241
Jon Hall78be4962017-05-23 14:53:53 -0700242 def CASE13( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700243 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800244 Create Scapy components
245 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700246 if main.initialized == main.FALSE:
247 main.log.error( "Test components did not start correctly, skipping further tests" )
248 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800249 main.case( "Create scapy components" )
250 main.step( "Create scapy components" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800251 scapyResult = main.TRUE
252 for hostName in main.scapyHostNames:
253 main.Scapy1.createHostComponent( hostName )
254 main.scapyHosts.append( getattr( main, hostName ) )
255
256 main.step( "Start scapy components" )
257 for host in main.scapyHosts:
258 host.startHostCli()
259 host.startScapy()
260 host.updateSelf()
261 main.log.debug( host.name )
262 main.log.debug( host.hostIp )
263 main.log.debug( host.hostMac )
264
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800265 utilities.assert_equals( expect=main.TRUE,
266 actual=scapyResult,
267 onpass="Successfully created Scapy Components",
268 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700269 if not scapyResult:
270 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800271
272 def CASE14( self, main ):
273 """
274 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700275 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700276 if main.initialized == main.FALSE:
277 main.log.error( "Test components did not start correctly, skipping further tests" )
278 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700279 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800280 main.step( "Pingall hosts and confirm ONOS discovery" )
Jon Hall78be4962017-05-23 14:53:53 -0700281 utilities.retry( f=main.intents.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700282
Jon Hall78be4962017-05-23 14:53:53 -0700283 stepResult = utilities.retry( f=main.intents.confirmHostDiscovery, retValue=main.FALSE,
284 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700285 utilities.assert_equals( expect=main.TRUE,
286 actual=stepResult,
287 onpass="Successfully discovered hosts",
288 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700289 if not stepResult:
290 main.initialized = main.FALSE
291 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700292
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800293 main.step( "Populate hostsData" )
Jon Hall78be4962017-05-23 14:53:53 -0700294 stepResult = main.intents.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700295 utilities.assert_equals( expect=main.TRUE,
296 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800297 onpass="Successfully populated hostsData",
298 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700299 if not stepResult:
300 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800301
302 def CASE15( self, main ):
303 """
304 Discover all hosts with scapy arp packets and store its data to a dictionary
305 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700306 if main.initialized == main.FALSE:
307 main.log.error( "Test components did not start correctly, skipping further tests" )
308 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800309 main.case( "Discover all hosts using scapy" )
310 main.step( "Send packets from each host to the first host and confirm onos discovery" )
311
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800312 if len( main.scapyHosts ) < 1:
313 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700314 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800315 main.skipCase()
316
317 # Send ARP packets from each scapy host component
Jon Hall78be4962017-05-23 14:53:53 -0700318 main.intents.sendDiscoveryArp( main, main.scapyHosts )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800319
Jon Hall78be4962017-05-23 14:53:53 -0700320 stepResult = utilities.retry( f=main.intents.confirmHostDiscovery,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800321 retValue=main.FALSE, args=[ main ],
322 attempts=main.checkTopoAttempts, sleep=2 )
323
324 utilities.assert_equals( expect=main.TRUE,
325 actual=stepResult,
326 onpass="ONOS correctly discovered all hosts",
327 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700328 if not stepResult:
329 main.initialized = main.FALSE
330 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800331
332 main.step( "Populate hostsData" )
Jon Hall78be4962017-05-23 14:53:53 -0700333 stepResult = main.intents.populateHostData( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800334 utilities.assert_equals( expect=main.TRUE,
335 actual=stepResult,
336 onpass="Successfully populated hostsData",
337 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700338 if not stepResult:
339 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800340
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800341 def CASE16( self, main ):
342 """
Jeremy42df2e72016-02-23 16:37:46 -0800343 Balance Masters
344 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700345 if main.initialized == main.FALSE:
346 main.log.error( "Test components did not start correctly, skipping further tests" )
347 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800348 main.case( "Balance mastership of switches" )
349 main.step( "Balancing mastership of switches" )
350
Devin Lim142b5342017-07-20 15:22:39 -0700351 balanceResult = utilities.retry( f=main.Cluster.active( 0 ).CLI.balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800352
353 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700354 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800355 onpass="Successfully balanced mastership of switches",
356 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700357 if not balanceResult:
358 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800359
360 def CASE17( self, main ):
361 """
Jeremy6e9748f2016-03-25 15:03:39 -0700362 Use Flow Objectives
363 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700364 if main.initialized == main.FALSE:
365 main.log.error( "Test components did not start correctly, skipping further tests" )
366 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700367 main.case( "Enable intent compilation using Flow Objectives" )
368 main.step( "Enabling Flow Objectives" )
369
370 main.flowCompiler = "Flow Objectives"
371
372 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
373
Devin Lim142b5342017-07-20 15:22:39 -0700374 stepResult = main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremy6e9748f2016-03-25 15:03:39 -0700375 propName="useFlowObjectives", value="true" )
Devin Lim142b5342017-07-20 15:22:39 -0700376 stepResult &= main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
You Wang106d0fa2017-05-15 17:22:15 -0700377 propName="defaultFlowObjectiveCompiler",
Jon Hall78be4962017-05-23 14:53:53 -0700378 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremy6e9748f2016-03-25 15:03:39 -0700379
380 utilities.assert_equals( expect=main.TRUE,
381 actual=stepResult,
382 onpass="Successfully activated Flow Objectives",
383 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700384 if not balanceResult:
385 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700386
387 def CASE18( self, main ):
388 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800389 Stop mininet and remove scapy host
390 """
Devin Lim58046fa2017-07-05 16:55:00 -0700391 try:
392 from tests.dependencies.utils import Utils
393 except ImportError:
394 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700395 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700396 try:
397 main.Utils
398 except ( NameError, AttributeError ):
399 main.Utils = Utils()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800400 main.log.report( "Stop Mininet and Scapy" )
401 main.case( "Stop Mininet and Scapy" )
402 main.caseExplanation = "Stopping the current mininet topology " +\
403 "to start up fresh"
404 main.step( "Stopping and Removing Scapy Host Components" )
405 scapyResult = main.TRUE
406 for host in main.scapyHosts:
407 scapyResult = scapyResult and host.stopScapy()
408 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
409
410 for host in main.scapyHosts:
411 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
412 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
413
414 main.scapyHosts = []
415 main.scapyHostIPs = []
416
417 utilities.assert_equals( expect=main.TRUE,
418 actual=scapyResult,
419 onpass="Successfully stopped scapy and removed host components",
420 onfail="Failed to stop mininet and scapy" )
421
Devin Lim58046fa2017-07-05 16:55:00 -0700422 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700423 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800424 if not ( mininetResult and scapyResult ):
Devin Lim44075962017-08-11 10:56:37 -0700425 main.cleanAndExit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700426
Jeremy Songster17147f22016-05-31 18:30:52 -0700427 def CASE19( self, main ):
428 """
429 Copy the karaf.log files after each testcase cycle
430 """
Devin Lim58046fa2017-07-05 16:55:00 -0700431 try:
432 from tests.dependencies.utils import Utils
433 except ImportError:
434 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700435 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700436 try:
437 main.Utils
438 except ( NameError, AttributeError ):
439 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700440 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
kelvin-onlabb769f562015-07-15 17:05:10 -0700441 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700442 """
443 Add host intents between 2 host:
444 - Discover hosts
445 - Add host intents
446 - Check intents
447 - Verify flows
448 - Ping hosts
449 - Reroute
450 - Link down
451 - Verify flows
452 - Check topology
453 - Ping hosts
454 - Link up
455 - Verify flows
456 - Check topology
457 - Ping hosts
458 - Remove intents
459 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700460 if main.initialized == main.FALSE:
461 main.log.error( "Test components did not start correctly, skipping further tests" )
462 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700463 # Assert variables - These variable's name|format must be followed
464 # if you want to use the wrapper function
465 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700466 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700467 assert main.Mininet1
468 except AssertionError:
469 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
470 main.initialized = main.FALSE
471 main.skipCase()
472 try:
473 assert main.numSwitch
474 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700475 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700476 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700477 main.initialized = main.FALSE
478 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700479
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800480 # Save leader candidates
Devin Lim142b5342017-07-20 15:22:39 -0700481 intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates()
acsmarse6b410f2015-07-17 14:39:34 -0700482
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700483 main.testName = "Host Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700484 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700485 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700486 main.caseExplanation = "This test case tests Host intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -0700487 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700488 "Different type of hosts will be tested in " +\
489 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700490 "etc;\nThe test will use OF " + main.OFProtocol +\
491 " OVS running in Mininet and compile intents" +\
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700492 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700493
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700494 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700495 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700496 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
497 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800498 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700499 installResult = main.intents.installHostIntent( main,
500 name="IPV4",
501 onosNode=0,
502 host1=host1,
503 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800504 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700505 testResult = main.intents.testHostIntent( main,
506 name="IPV4",
507 intentId=installResult,
508 onosNode=0,
509 host1=host1,
510 host2=host2,
511 sw1="s5",
512 sw2="s2",
513 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800514 else:
Devin Lim142b5342017-07-20 15:22:39 -0700515 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800516
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700517 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800518 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700519 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700520 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700521
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700522 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700523 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700524 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
Jon Hall78be4962017-05-23 14:53:53 -0700525 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1 " }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800526 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700527 installResult = main.intents.installHostIntent( main,
528 name="DUALSTACK",
529 onosNode=0,
530 host1=host1,
531 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800532
533 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700534 testResult = main.intents.testHostIntent( main,
535 name="DUALSTACK",
536 intentId=installResult,
537 onosNode=0,
538 host1=host1,
539 host2=host2,
540 sw1="s5",
541 sw2="s2",
542 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700543
544 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800545 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700546 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700547 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700548
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700549 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700550 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700551 host1 = { "name": "h1" }
552 host2 = { "name": "h11" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800553 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700554 installResult = main.intents.installHostIntent( main,
555 name="DUALSTACK2",
556 onosNode=0,
557 host1=host1,
558 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800559
560 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700561 testResult = main.intents.testHostIntent( main,
562 name="DUALSTACK2",
563 intentId=installResult,
564 onosNode=0,
565 host1=host1,
566 host2=host2,
567 sw1="s5",
568 sw2="s2",
569 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800570 else:
Devin Lim142b5342017-07-20 15:22:39 -0700571 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700572
573 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800574 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700575 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700576 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700577
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700578 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700579 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall9c888672017-05-15 18:03:54 -0700580 host1 = { "name": "h1" }
581 host2 = { "name": "h3" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800582 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700583 installResult = main.intents.installHostIntent( main,
584 name="1HOP",
585 onosNode=0,
586 host1=host1,
587 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800588
589 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700590 testResult = main.intents.testHostIntent( main,
591 name="1HOP",
592 intentId=installResult,
593 onosNode=0,
594 host1=host1,
595 host2=host2,
596 sw1="s5",
597 sw2="s2",
598 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800599 else:
Devin Lim142b5342017-07-20 15:22:39 -0700600 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700601
602 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800603 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700604 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700605 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700606
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700607 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700608 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700609 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlan": "100" }
610 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800611 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700612 installResult = main.intents.installHostIntent( main,
613 name="VLAN1",
614 onosNode=0,
615 host1=host1,
616 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800617 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700618 testResult = main.intents.testHostIntent( main,
619 name="VLAN1",
620 intentId=installResult,
621 onosNode=0,
622 host1=host1,
623 host2=host2,
624 sw1="s5",
625 sw2="s2",
626 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800627 else:
Devin Lim142b5342017-07-20 15:22:39 -0700628 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700629
630 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800631 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700632 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700633 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700634
Jeremy Songsterff553672016-05-12 17:06:23 -0700635 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
636 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700637 host1 = { "name": "h5", "vlan": "200" }
638 host2 = { "name": "h12", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -0700639 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700640 installResult = main.intents.installHostIntent( main,
641 name="VLAN2",
642 onosNode=0,
643 host1=host1,
644 host2=host2 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700645
646 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700647 testResult = main.intents.testHostIntent( main,
648 name="VLAN2",
649 intentId=installResult,
650 onosNode=0,
651 host1=host1,
652 host2=host2,
653 sw1="s5",
654 sw2="s2",
655 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700656 else:
Devin Lim142b5342017-07-20 15:22:39 -0700657 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -0700658
659 utilities.assert_equals( expect=main.TRUE,
660 actual=testResult,
661 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700662 onfail=main.assertReturnString )
Jeremy Songsterff553672016-05-12 17:06:23 -0700663
Jeremy Songsterc032f162016-08-04 17:14:49 -0700664 main.step( "Encapsulation: Add host intents between h1 and h9" )
665 main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700666 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
667 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -0700668 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700669 installResult = main.intents.installHostIntent( main,
670 name="ENCAPSULATION",
671 onosNode=0,
672 host1=host1,
673 host2=host2,
674 encap="VLAN" )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700675 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700676 testResult = main.intents.testHostIntent( main,
677 name="ENCAPSULATION",
678 intentId=installResult,
679 onosNode=0,
680 host1=host1,
681 host2=host2,
682 sw1="s5",
683 sw2="s2",
684 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700685 else:
Devin Lim142b5342017-07-20 15:22:39 -0700686 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700687
688 utilities.assert_equals( expect=main.TRUE,
689 actual=testResult,
690 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700691 onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700692
Jon Hall78be4962017-05-23 14:53:53 -0700693 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -0700694 # main.step( "Encapsulation: Add host intents between h1 and h9" )
695 # main.assertReturnString = "Assertion Result for MPLS Encapsulated host intent\n"
696 # host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
697 # host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
698 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700699 # installResult = main.intents.installHostIntent( main,
700 # name="ENCAPSULATION",
701 # onosNode=0,
702 # host1=host1,
703 # host2=host2,
704 # encap="MPLS" )
alison52b25892016-09-19 10:53:48 -0700705 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700706 # testResult = main.intents.testHostIntent( main,
707 # name="ENCAPSULATION",
708 # intentId=installResult,
709 # onosNode=0,
710 # host1=host1,
711 # host2=host2,
712 # sw1="s5",
713 # sw2="s2",
714 # expectedLink=18 )
alison52b25892016-09-19 10:53:48 -0700715 # else:
Devin Lim142b5342017-07-20 15:22:39 -0700716 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -0700717 #
718 # utilities.assert_equals( expect=main.TRUE,
719 # actual=testResult,
720 # onpass=main.assertReturnString,
721 # onfail=main.assertReturnString )
722
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700723 main.step( "Confirm that ONOS leadership is unchanged" )
Devin Lim142b5342017-07-20 15:22:39 -0700724 intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jon Hall78be4962017-05-23 14:53:53 -0700725 testResult = main.intents.checkLeaderChange( intentLeadersOld,
726 intentLeadersNew )
acsmarse6b410f2015-07-17 14:39:34 -0700727
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800728 utilities.assert_equals( expect=main.TRUE,
729 actual=testResult,
730 onpass="ONOS Leaders Unchanged",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700731 onfail="ONOS Leader Mismatch" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800732
Jon Hall78be4962017-05-23 14:53:53 -0700733 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -0700734
kelvin-onlabb769f562015-07-15 17:05:10 -0700735 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700736 """
737 Add point intents between 2 hosts:
738 - Get device ids | ports
739 - Add point intents
740 - Check intents
741 - Verify flows
742 - Ping hosts
743 - Reroute
744 - Link down
745 - Verify flows
746 - Check topology
747 - Ping hosts
748 - Link up
749 - Verify flows
750 - Check topology
751 - Ping hosts
752 - Remove intents
753 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700754 if main.initialized == main.FALSE:
755 main.log.error( "Test components did not start correctly, skipping further tests" )
756 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700757 # Assert variables - These variable's name|format must be followed
758 # if you want to use the wrapper function
759 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700760 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700761 assert main.Mininet1
762 except AssertionError:
763 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
764 main.initialized = main.FALSE
765 main.skipCase()
766 try:
767 assert main.numSwitch
768 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700769 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700770 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700771 main.initialized = main.FALSE
772 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700773
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700774 main.testName = "Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700775 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700776 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700777 main.caseExplanation = "This test case will test point to point" +\
Devin Lim142b5342017-07-20 15:22:39 -0700778 " intents using " + str( main.Cluster.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700779 " node(s) cluster;\n" +\
780 "Different type of hosts will be tested in " +\
781 "each step such as IPV4, Dual stack, VLAN etc" +\
782 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -0700783 " OVS running in Mininet and compile intents" +\
784 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700785
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700786 # No option point intents
787 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700788 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800789 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700790 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800791 ]
792 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700793 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800794 ]
Jeremy42df2e72016-02-23 16:37:46 -0800795 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700796 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700797 main,
798 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800799 senders=senders,
800 recipients=recipients )
801
802 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700803 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800804 main,
805 intentId=installResult,
806 name="NOOPTION",
807 senders=senders,
808 recipients=recipients,
809 sw1="s5",
810 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700811 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800812 else:
Devin Lim142b5342017-07-20 15:22:39 -0700813 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700814
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700815 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800816 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700817 onpass=main.assertReturnString,
818 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700819
kelvin-onlabb769f562015-07-15 17:05:10 -0700820 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700821 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800822 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700823 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800824 ]
825 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700826 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800827 ]
Jeremy42df2e72016-02-23 16:37:46 -0800828 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700829 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700830 main,
831 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800832 senders=senders,
833 recipients=recipients,
834 ethType="IPV4" )
835
836 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700837 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800838 main,
839 intentId=installResult,
840 name="IPV4",
841 senders=senders,
842 recipients=recipients,
843 sw1="s5",
844 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700845 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800846 else:
Devin Lim142b5342017-07-20 15:22:39 -0700847 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700848
849 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800850 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700851 onpass=main.assertReturnString,
852 onfail=main.assertReturnString )
alisonda157272016-12-22 01:13:21 -0800853
Jon Hall78be4962017-05-23 14:53:53 -0700854 main.step( "Protected: Add point intents between h1 and h9" )
alisonda157272016-12-22 01:13:21 -0800855 main.assertReturnString = "Assertion Result for protected point intent\n"
856 senders = [
Jon Hall78be4962017-05-23 14:53:53 -0700857 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
alisonda157272016-12-22 01:13:21 -0800858 ]
859 recipients = [
Jon Hall78be4962017-05-23 14:53:53 -0700860 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
alisonda157272016-12-22 01:13:21 -0800861 ]
862 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700863 installResult = main.intents.installPointIntent(
alisonda157272016-12-22 01:13:21 -0800864 main,
865 name="Protected",
866 senders=senders,
867 recipients=recipients,
868 protected=True )
869
870 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700871 testResult = main.intents.testPointIntent(
alisonda157272016-12-22 01:13:21 -0800872 main,
873 name="Protected",
874 intentId=installResult,
875 senders=senders,
876 recipients=recipients,
877 sw1="s5",
878 sw2="s2",
879 protected=True,
880 expectedLink=18 )
881 else:
Devin Lim142b5342017-07-20 15:22:39 -0700882 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alisonda157272016-12-22 01:13:21 -0800883
884 utilities.assert_equals( expect=main.TRUE,
885 actual=testResult,
886 onpass=main.assertReturnString,
887 onfail=main.assertReturnString )
888
kelvin-onlabb769f562015-07-15 17:05:10 -0700889 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700890 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800891 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700892 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800893 ]
894 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700895 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800896 ]
Jeremy42df2e72016-02-23 16:37:46 -0800897 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700898 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700899 main,
900 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800901 senders=senders,
902 recipients=recipients,
903 ethType="IPV4" )
904
905 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700906 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800907 main,
908 intentId=installResult,
909 name="IPV4_2",
910 senders=senders,
911 recipients=recipients,
912 sw1="s5",
913 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700914 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800915 else:
Devin Lim142b5342017-07-20 15:22:39 -0700916 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700917
918 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800919 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700920 onpass=main.assertReturnString,
921 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700922
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700923 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700924 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800925 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700926 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -0800927 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800928 ]
929 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700930 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -0800931 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800932 ]
Jeremy6f000c62016-02-25 17:02:28 -0800933 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700934 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800935 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
936 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -0800937 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700938 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800939 main,
940 name="SDNIP-ICMP",
941 senders=senders,
942 recipients=recipients,
943 ethType="IPV4",
944 ipProto=ipProto,
945 tcpSrc=tcpSrc,
946 tcpDst=tcpDst )
947
948 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700949 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800950 main,
951 intentId=installResult,
952 name="SDNIP_ICMP",
953 senders=senders,
954 recipients=recipients,
955 sw1="s5",
956 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -0700957 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700958 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -0800959 else:
Devin Lim142b5342017-07-20 15:22:39 -0700960 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -0700961
962 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800963 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700964 onpass=main.assertReturnString,
965 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700966
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700967 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700968 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700969 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
970 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700971 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
972 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700973 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
974 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
975 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
976
Jon Hall78be4962017-05-23 14:53:53 -0700977 stepResult = main.intents.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700978 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700979 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700980 host1="h1",
981 host2="h9",
982 deviceId1="of:0000000000000005/1",
983 deviceId2="of:0000000000000006/1",
984 mac1=mac1,
985 mac2=mac2,
986 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700987 ipProto=ipProto,
988 ip1=ip1,
989 ip2=ip2,
990 tcp1=tcp1,
991 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700992
993 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -0800994 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700995 onpass=main.assertReturnString,
996 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700997
acsmars5d8cc862015-09-25 09:44:50 -0700998 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
999 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001000 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001001 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001002 ]
1003 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001004 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001005 ]
Jeremy42df2e72016-02-23 16:37:46 -08001006 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001007 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001008 main,
1009 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001010 senders=senders,
1011 recipients=recipients,
1012 ethType="IPV4" )
1013
1014 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001015 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001016 main,
1017 intentId=installResult,
1018 name="DUALSTACK1",
1019 senders=senders,
1020 recipients=recipients,
1021 sw1="s5",
1022 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001023 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001024 else:
Devin Lim142b5342017-07-20 15:22:39 -07001025 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001026
1027 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001028 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001029 onpass=main.assertReturnString,
1030 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001031
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001032 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001033 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001034 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001035 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001036 ]
1037 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001038 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001039 ]
Jeremy42df2e72016-02-23 16:37:46 -08001040 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001041 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001042 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001043 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001044 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001045 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001046
1047 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001048 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001049 main,
1050 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001051 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001052 senders=senders,
1053 recipients=recipients,
1054 sw1="s5",
1055 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001056 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001057
1058 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001059 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001060 onpass=main.assertReturnString,
1061 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001062
Jeremy Songsterff553672016-05-12 17:06:23 -07001063 main.step( "VLAN: Add point intents between h5 and h21" )
1064 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1065 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001066 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001067 ]
1068 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001069 { "name": "h21", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001070 ]
1071 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001072 installResult = main.intents.installPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001073 main,
1074 name="VLAN2",
1075 senders=senders,
1076 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001077 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001078
1079 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001080 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001081 main,
1082 intentId=installResult,
1083 name="VLAN2",
1084 senders=senders,
1085 recipients=recipients,
1086 sw1="s5",
1087 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001088 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001089
1090 utilities.assert_equals( expect=main.TRUE,
1091 actual=testResult,
1092 onpass=main.assertReturnString,
1093 onfail=main.assertReturnString )
1094
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001095 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001096 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001097 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001098 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001099 ]
1100 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001101 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001102 ]
Jeremy42df2e72016-02-23 16:37:46 -08001103 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001104 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001105 main,
1106 name="1HOP IPV4",
1107 senders=senders,
1108 recipients=recipients,
1109 ethType="IPV4" )
1110
1111 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001112 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001113 main,
1114 intentId=installResult,
1115 name="1HOP IPV4",
1116 senders=senders,
1117 recipients=recipients,
1118 sw1="s5",
1119 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001120 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001121 else:
Devin Lim142b5342017-07-20 15:22:39 -07001122 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001123
1124 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001125 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001126 onpass=main.assertReturnString,
1127 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001128
Jeremy Songsterc032f162016-08-04 17:14:49 -07001129 main.step( "Add point to point intents using VLAN Encapsulation" )
1130 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1131 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001132 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001133 ]
1134 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001135 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001136 ]
1137 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001138 installResult = main.intents.installPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001139 main,
1140 name="ENCAPSULATION",
1141 senders=senders,
1142 recipients=recipients,
1143 encap="VLAN" )
1144
1145 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001146 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001147 main,
1148 intentId=installResult,
1149 name="ENCAPSULATION",
1150 senders=senders,
1151 recipients=recipients,
1152 sw1="s5",
1153 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001154 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001155 else:
Devin Lim142b5342017-07-20 15:22:39 -07001156 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001157
1158 utilities.assert_equals( expect=main.TRUE,
1159 actual=testResult,
1160 onpass=main.assertReturnString,
1161 onfail=main.assertReturnString )
1162
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001163 main.step( "BANDWIDTH ALLOCATION: Checking bandwidth allocation for point intents between h1 and h9" )
1164 main.assertReturnString = "Assertion Result for BANDWIDTH ALLOCATION for point intent\n"
1165 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001166 { "name": "h1", "device": "of:0000000000000005/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001167 ]
1168 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001169 { "name": "h9", "device": "of:0000000000000006/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001170 ]
1171 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001172 installResult = main.intents.installPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001173 main,
1174 name="NOOPTION",
1175 senders=senders,
1176 recipients=recipients,
Jon Hallf539eb92017-05-22 17:18:42 -07001177 bandwidth=100 )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001178
1179 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001180 testResult = main.intents.testPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001181 main,
1182 intentId=installResult,
1183 name="NOOPTION",
1184 senders=senders,
1185 recipients=recipients,
1186 sw1="s5",
1187 sw2="s2",
1188 expectedLink=18 )
1189 else:
Devin Lim142b5342017-07-20 15:22:39 -07001190 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001191
1192 utilities.assert_equals( expect=main.TRUE,
1193 actual=testResult,
1194 onpass=main.assertReturnString,
1195 onfail=main.assertReturnString )
1196
Jon Hall78be4962017-05-23 14:53:53 -07001197 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -07001198 # main.step( "Add point to point intents using MPLS Encapsulation" )
1199 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1200 # senders = [
1201 # { "name": "h1", "device": "of:0000000000000005/1" }
1202 # ]
1203 # recipients = [
1204 # { "name": "h9", "device": "of:0000000000000006/1" }
1205 # ]
1206 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001207 # installResult = main.intents.installPointIntent(
alison52b25892016-09-19 10:53:48 -07001208 # main,
1209 # name="ENCAPSULATION",
1210 # senders=senders,
1211 # recipients=recipients,
1212 # encap="MPLS" )
1213 #
1214 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001215 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001216 # main,
1217 # intentId=installResult,
1218 # name="ENCAPSULATION",
1219 # senders=senders,
1220 # recipients=recipients,
1221 # sw1="s5",
1222 # sw2="s2",
1223 # expectedLink=18 )
1224 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001225 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001226 #
1227 # utilities.assert_equals( expect=main.TRUE,
1228 # actual=testResult,
1229 # onpass=main.assertReturnString,
1230 # onfail=main.assertReturnString )
1231
Jon Hall78be4962017-05-23 14:53:53 -07001232 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001233
kelvin-onlabb769f562015-07-15 17:05:10 -07001234 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001235 """
1236 Add single point to multi point intents
1237 - Get device ids
1238 - Add single point to multi point intents
1239 - Check intents
1240 - Verify flows
1241 - Ping hosts
1242 - Reroute
1243 - Link down
1244 - Verify flows
1245 - Check topology
1246 - Ping hosts
1247 - Link up
1248 - Verify flows
1249 - Check topology
1250 - Ping hosts
1251 - Remove intents
1252 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001253 if main.initialized == main.FALSE:
1254 main.log.error( "Test components did not start correctly, skipping further tests" )
1255 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001256 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001257 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001258 assert main.Mininet1
1259 except AssertionError:
1260 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1261 main.initialized = main.FALSE
1262 main.skipCase()
1263 try:
1264 assert main.numSwitch
1265 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001266 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001267 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001268 main.initialized = main.FALSE
1269 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001270
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001271 main.testName = "Single to Multi Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001272 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001273 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001274 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001275 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001276 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001277 "Different type of hosts will be tested in " +\
1278 "each step such as IPV4, Dual stack, VLAN etc" +\
1279 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001280 " OVS running in Mininet and compile intents" +\
1281 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001282
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001283 main.step( "NOOPTION: Install and test single point to multi point intents" )
1284 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1285 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001286 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001287 ]
1288 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001289 { "name": "h16", "device": "of:0000000000000006/8" },
1290 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001291 ]
Jon Hall9c888672017-05-15 18:03:54 -07001292 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1293 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001294 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001295 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001296 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001297 name="NOOPTION",
1298 senders=senders,
1299 recipients=recipients,
1300 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001301 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001302
1303 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001304 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001305 main,
1306 intentId=installResult,
1307 name="NOOPTION",
1308 senders=senders,
1309 recipients=recipients,
1310 badSenders=badSenders,
1311 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001312 sw1="s5",
1313 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001314 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001315 else:
Devin Lim142b5342017-07-20 15:22:39 -07001316 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001317
1318 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001319 actual=testResult,
1320 onpass=main.assertReturnString,
1321 onfail=main.assertReturnString )
1322
1323 main.step( "IPV4: Install and test single point to multi point intents" )
1324 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1325 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001326 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001327 ]
1328 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001329 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1330 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001331 ]
Jon Hall9c888672017-05-15 18:03:54 -07001332 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1333 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001334 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001335 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001336 main,
1337 name="IPV4",
1338 senders=senders,
1339 recipients=recipients,
1340 ethType="IPV4",
1341 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001342 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001343
1344 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001345 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001346 main,
1347 intentId=installResult,
1348 name="IPV4",
1349 senders=senders,
1350 recipients=recipients,
1351 badSenders=badSenders,
1352 badRecipients=badRecipients,
1353 sw1="s5",
1354 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001355 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001356 else:
Devin Lim142b5342017-07-20 15:22:39 -07001357 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001358
1359 utilities.assert_equals( expect=main.TRUE,
1360 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001361 onpass=main.assertReturnString,
1362 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001363
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001364 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001365 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 -08001366 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001367 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001368 ]
1369 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001370 { "name": "h16", "device": "of:0000000000000006/8" },
1371 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001372 ]
Jon Hall9c888672017-05-15 18:03:54 -07001373 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1374 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001375 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001376 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001377 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001378 name="IPV4_2",
1379 senders=senders,
1380 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001381 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001382 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001383 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001384
1385 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001386 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001387 main,
1388 intentId=installResult,
1389 name="IPV4_2",
1390 senders=senders,
1391 recipients=recipients,
1392 badSenders=badSenders,
1393 badRecipients=badRecipients,
1394 sw1="s5",
1395 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001396 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001397 else:
Devin Lim142b5342017-07-20 15:22:39 -07001398 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001399
1400 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001401 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001402 onpass=main.assertReturnString,
1403 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001404
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001405 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001406 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 -08001407 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001408 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001409 ]
1410 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001411 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1412 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001413 ]
Jon Hall9c888672017-05-15 18:03:54 -07001414 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1415 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001416 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001417 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001418 main,
alison52b25892016-09-19 10:53:48 -07001419 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001420 senders=senders,
1421 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001422 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001423 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001424
1425 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001426 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001427 main,
1428 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001429 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001430 senders=senders,
1431 recipients=recipients,
1432 badSenders=badSenders,
1433 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001434 sw1="s5",
1435 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001436 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001437 else:
Devin Lim142b5342017-07-20 15:22:39 -07001438 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001439
1440 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001441 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001442 onpass=main.assertReturnString,
1443 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001444
Jeremy Songsterff553672016-05-12 17:06:23 -07001445 main.step( "VLAN: Add single point to multi point intents" )
1446 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1447 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001448 { "name": "h5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001449 ]
1450 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001451 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1452 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001453 ]
Jon Hall9c888672017-05-15 18:03:54 -07001454 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1455 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001456 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001457 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001458 main,
1459 name="VLAN2",
1460 senders=senders,
1461 recipients=recipients,
1462 sw1="s5",
1463 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001464 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001465
1466 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001467 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001468 main,
1469 intentId=installResult,
1470 name="VLAN2",
1471 senders=senders,
1472 recipients=recipients,
1473 badSenders=badSenders,
1474 badRecipients=badRecipients,
1475 sw1="s5",
1476 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001477 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001478 else:
Devin Lim142b5342017-07-20 15:22:39 -07001479 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -07001480
1481 utilities.assert_equals( expect=main.TRUE,
1482 actual=testResult,
1483 onpass=main.assertReturnString,
1484 onfail=main.assertReturnString )
1485
alison52b25892016-09-19 10:53:48 -07001486 # Does not support Single point to multi point encapsulation
1487 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1488 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1489 # senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001490 # { "name": "h8", "device": "of:0000000000000005/8" }
alison52b25892016-09-19 10:53:48 -07001491 # ]
1492 # recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001493 # { "name": "h16", "device": "of:0000000000000006/8" },
1494 # { "name": "h24", "device": "of:0000000000000007/8" }
alison52b25892016-09-19 10:53:48 -07001495 # ]
Jon Hall9c888672017-05-15 18:03:54 -07001496 # badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1497 # badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
alison52b25892016-09-19 10:53:48 -07001498 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001499 # installResult = main.intents.installSingleToMultiIntent(
alison52b25892016-09-19 10:53:48 -07001500 # main,
1501 # name="ENCAPSULATION",
1502 # senders=senders,
1503 # recipients=recipients,
1504 # sw1="s5",
1505 # sw2="s2",
1506 # encap="VLAN" )
1507 #
1508 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001509 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001510 # main,
1511 # intentId=installResult,
1512 # name="ENCAPSULATION",
1513 # senders=senders,
1514 # recipients=recipients,
1515 # badSenders=badSenders,
1516 # badRecipients=badRecipients,
1517 # sw1="s5",
1518 # sw2="s2",
1519 # expectedLink=18 )
1520 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001521 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001522 #
1523 # utilities.assert_equals( expect=main.TRUE,
1524 # actual=testResult,
1525 # onpass=main.assertReturnString,
1526 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001527
Jon Hall78be4962017-05-23 14:53:53 -07001528 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001529
kelvin-onlabb769f562015-07-15 17:05:10 -07001530 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001531 """
1532 Add multi point to single point intents
1533 - Get device ids
1534 - Add multi point to single point intents
1535 - Check intents
1536 - Verify flows
1537 - Ping hosts
1538 - Reroute
1539 - Link down
1540 - Verify flows
1541 - Check topology
1542 - Ping hosts
1543 - Link up
1544 - Verify flows
1545 - Check topology
1546 - Ping hosts
1547 - Remove intents
1548 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001549 if main.initialized == main.FALSE:
1550 main.log.error( "Test components did not start correctly, skipping further tests" )
1551 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001552 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001553 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001554 assert main.Mininet1
1555 except AssertionError:
1556 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1557 main.initialized = main.FALSE
1558 main.skipCase()
1559 try:
1560 assert main.numSwitch
1561 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001562 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001563 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001564 main.initialized = main.FALSE
1565 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001566
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001567 main.testName = "Multi To Single Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001568 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001569 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001570 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001571 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001572 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001573 "Different type of hosts will be tested in " +\
1574 "each step such as IPV4, Dual stack, VLAN etc" +\
1575 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001576 " OVS running in Mininet and compile intents" +\
1577 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001578
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001579 main.step( "NOOPTION: Add multi point to single point intents" )
1580 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1581 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001582 { "name": "h16", "device": "of:0000000000000006/8" },
1583 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001584 ]
1585 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001586 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001587 ]
Jon Hall9c888672017-05-15 18:03:54 -07001588 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1589 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001590 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001591 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001592 main,
1593 name="NOOPTION",
1594 senders=senders,
1595 recipients=recipients,
1596 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001597 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001598
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001599 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001600 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001601 main,
1602 intentId=installResult,
1603 name="NOOPTION",
1604 senders=senders,
1605 recipients=recipients,
1606 badSenders=badSenders,
1607 badRecipients=badRecipients,
1608 sw1="s5",
1609 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001610 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001611 else:
Devin Lim142b5342017-07-20 15:22:39 -07001612 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001613
1614 utilities.assert_equals( expect=main.TRUE,
1615 actual=testResult,
1616 onpass=main.assertReturnString,
1617 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001618
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001619 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001620 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 -08001621 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001622 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1623 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001624 ]
1625 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001626 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001627 ]
Jon Hall9c888672017-05-15 18:03:54 -07001628 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1629 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001630 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001631 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001632 main,
1633 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001634 senders=senders,
1635 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001636 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001637 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001638 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001639
1640 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001641 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001642 main,
1643 intentId=installResult,
1644 name="IPV4",
1645 senders=senders,
1646 recipients=recipients,
1647 badSenders=badSenders,
1648 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001649 sw1="s5",
1650 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001651 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001652 else:
Devin Lim142b5342017-07-20 15:22:39 -07001653 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001654
1655 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001656 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001657 onpass=main.assertReturnString,
1658 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001659
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001660 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001661 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 -08001662 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001663 { "name": "h16", "device": "of:0000000000000006/8" },
1664 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001665 ]
1666 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001667 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001668 ]
Jon Hall9c888672017-05-15 18:03:54 -07001669 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1670 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001671 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001672 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001673 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001674 name="IPV4_2",
1675 senders=senders,
1676 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001677 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001678 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001679 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001680
1681 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001682 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001683 main,
1684 intentId=installResult,
1685 name="IPV4_2",
1686 senders=senders,
1687 recipients=recipients,
1688 badSenders=badSenders,
1689 badRecipients=badRecipients,
1690 sw1="s5",
1691 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001692 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001693 else:
Devin Lim142b5342017-07-20 15:22:39 -07001694 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001695
1696 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001697 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001698 onpass=main.assertReturnString,
1699 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001700
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001701 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001702 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 -08001703 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001704 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1705 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001706 ]
1707 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001708 { "name": "h5", "device": "of:0000000000000005/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001709 ]
Jon Hall9c888672017-05-15 18:03:54 -07001710 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1711 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001712 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001713 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001714 main,
1715 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001716 senders=senders,
1717 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001718 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001719 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001720
1721 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001722 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001723 main,
1724 intentId=installResult,
1725 name="VLAN",
1726 senders=senders,
1727 recipients=recipients,
1728 badSenders=badSenders,
1729 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001730 sw1="s5",
1731 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001732 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001733 else:
Devin Lim142b5342017-07-20 15:22:39 -07001734 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001735
1736 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001737 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001738 onpass=main.assertReturnString,
1739 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001740
Jeremy Songsterff553672016-05-12 17:06:23 -07001741 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1742 main.step( "VLAN: Add multi point to single point intents" )
1743 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1744 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001745 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1746 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001747 ]
1748 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001749 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001750 ]
Jon Hall9c888672017-05-15 18:03:54 -07001751 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1752 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001753 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001754 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001755 main,
1756 name="VLAN2",
1757 senders=senders,
1758 recipients=recipients,
1759 sw1="s5",
1760 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001761 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001762
1763 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001764 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001765 main,
1766 intentId=installResult,
1767 name="VLAN2",
1768 senders=senders,
1769 recipients=recipients,
1770 badSenders=badSenders,
1771 badRecipients=badRecipients,
1772 sw1="s5",
1773 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001774 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001775 else:
Devin Lim142b5342017-07-20 15:22:39 -07001776 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -07001777
1778 utilities.assert_equals( expect=main.TRUE,
1779 actual=testResult,
1780 onpass=main.assertReturnString,
1781 onfail=main.assertReturnString )
1782
Jeremy Songsterc032f162016-08-04 17:14:49 -07001783 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1784 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
1785 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001786 { "name": "h16", "device": "of:0000000000000006/8" },
1787 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001788 ]
1789 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001790 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001791 ]
Jon Hall9c888672017-05-15 18:03:54 -07001792 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1793 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songsterc032f162016-08-04 17:14:49 -07001794 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001795 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001796 main,
1797 name="ENCAPSULATION",
1798 senders=senders,
1799 recipients=recipients,
1800 sw1="s5",
1801 sw2="s2",
1802 encap="VLAN" )
1803
1804 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001805 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001806 main,
1807 intentId=installResult,
1808 name="ENCAPSULATION",
1809 senders=senders,
1810 recipients=recipients,
1811 badSenders=badSenders,
1812 badRecipients=badRecipients,
1813 sw1="s5",
1814 sw2="s2",
1815 expectedLink=18 )
1816 else:
Devin Lim142b5342017-07-20 15:22:39 -07001817 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001818
1819 utilities.assert_equals( expect=main.TRUE,
1820 actual=testResult,
1821 onpass=main.assertReturnString,
1822 onfail=main.assertReturnString )
1823
Jon Hall78be4962017-05-23 14:53:53 -07001824 #Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
Shreyaca8990f2017-03-16 11:43:11 -07001825 #main.step( "ENCAPSULATION: Add multi point to single point intents" )
1826 #main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
1827 #senders = [
1828 # { "name": "h16", "device": "of:0000000000000006/8" },
1829 # { "name": "h24", "device": "of:0000000000000007/8" }
Jon Hall78be4962017-05-23 14:53:53 -07001830 # ]
Shreyaca8990f2017-03-16 11:43:11 -07001831 #recipients = [
1832 # { "name": "h8", "device": "of:0000000000000005/8" }
Jon Hall78be4962017-05-23 14:53:53 -07001833 # ]
Shreyaca8990f2017-03-16 11:43:11 -07001834 #badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
Jon Hall78be4962017-05-23 14:53:53 -07001835 #badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Shreyaca8990f2017-03-16 11:43:11 -07001836 #testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001837 #installResult = main.intents.installMultiToSingleIntent(
Shreyaca8990f2017-03-16 11:43:11 -07001838 # main,
1839 # name="ENCAPSULATION",
1840 # senders=senders,
1841 # recipients=recipients,
1842 # sw1="s5",
1843 # sw2="s2",
1844 # encap="MPLS" )
alison52b25892016-09-19 10:53:48 -07001845 #
Shreyaca8990f2017-03-16 11:43:11 -07001846 #if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001847 # testResult = main.intents.testPointIntent(
Shreyaca8990f2017-03-16 11:43:11 -07001848 # main,
1849 # intentId=installResult,
1850 # name="ENCAPSULATION",
1851 # senders=senders,
1852 # recipients=recipients,
1853 # badSenders=badSenders,
1854 # badRecipients=badRecipients,
1855 # sw1="s5",
1856 # sw2="s2",
1857 # expectedLink=18 )
1858 #else:
Devin Lim142b5342017-07-20 15:22:39 -07001859 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001860 #
Shreyaca8990f2017-03-16 11:43:11 -07001861 #utilities.assert_equals( expect=main.TRUE,
1862 # actual=testResult,
1863 # onpass=main.assertReturnString,
1864 # onfail=main.assertReturnString )
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 )