blob: 0e96d695c86cf1b42944c4bbdfed28d69aa6e345 [file] [log] [blame]
kelvin-onlab44147802015-07-27 17:57:31 -07001
2# Testing the basic intent functionality of ONOS
Jeremy2f190ca2016-01-29 15:23:57 -08003# TODO: Replace the CLI calls with REST API equivalents as they become available.
4# - May need to write functions in the onosrestdriver.py file to do this
5# TODO: Complete implementation of case 3000, 4000, and 6000 as REST API allows
6# -Currently there is no support in the REST API for Multi to Single and Single to Multi point intents
7# As such, these cases are incomplete and should not be enabled in the .params file
kelvin-onlab44147802015-07-27 17:57:31 -07008
9import time
10import json
11
Jon Hall02758ac2017-05-24 16:20:28 -070012
kelvin-onlab44147802015-07-27 17:57:31 -070013class FUNCintentRest:
14
15 def __init__( self ):
16 self.default = ''
17
18 def CASE1( self, main ):
19 import time
kelvin-onlab44147802015-07-27 17:57:31 -070020 import imp
Jon Hallf7234882015-08-28 13:16:31 -070021 import re
kelvin-onlab44147802015-07-27 17:57:31 -070022 """
23 - Construct tests variables
24 - GIT ( optional )
25 - Checkout ONOS master branch
26 - Pull latest ONOS code
27 - Building ONOS ( optional )
28 - Install ONOS package
29 - Build ONOS package
30 """
Devin Lim58046fa2017-07-05 16:55:00 -070031 try:
32 from tests.dependencies.ONOSSetup import ONOSSetup
33 main.testSetUp = ONOSSetup()
34 except ImportError:
35 main.log.error( "ONOSSetup not found. exiting the test" )
36 main.exit()
37 main.testSetUp.envSetupDescription()
kelvin-onlab44147802015-07-27 17:57:31 -070038 stepResult = main.FALSE
39
40 # Test variables
41 try:
kelvin-onlab44147802015-07-27 17:57:31 -070042 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
kelvin-onlab44147802015-07-27 17:57:31 -070043 main.dependencyPath = main.testOnDirectory + \
44 main.params[ 'DEPENDENCY' ][ 'path' ]
45 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
46 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
kelvin-onlab44147802015-07-27 17:57:31 -070047 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
48 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
49 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
50 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080051 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
52 main.removeIntentsleeo = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070053 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
54 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
kelvin-onlab0e684682015-08-11 18:51:41 -070055 main.addIntentSleep = int( main.params[ 'SLEEP' ][ 'addIntent' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080056 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070057 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070058 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
59 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070060 main.hostsData = {}
Jeremy2f190ca2016-01-29 15:23:57 -080061 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
62 main.scapyHosts = [] # List of scapy hosts for iterating
63 main.assertReturnString = '' # Assembled assert return string
Jon Hall02758ac2017-05-24 16:20:28 -070064 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlab44147802015-07-27 17:57:31 -070065
kelvin-onlab44147802015-07-27 17:57:31 -070066 # -- INIT SECTION, ONLY RUNS ONCE -- #
kelvin-onlab44147802015-07-27 17:57:31 -070067
68 main.intentFunction = imp.load_source( wrapperFile2,
Jon Hall02758ac2017-05-24 16:20:28 -070069 main.dependencyPath +
70 wrapperFile2 +
71 ".py" )
kelvin-onlab44147802015-07-27 17:57:31 -070072
Jon Hallf7234882015-08-28 13:16:31 -070073 copyResult1 = main.ONOSbench.scp( main.Mininet1,
74 main.dependencyPath +
75 main.topology,
Jeremy2f190ca2016-01-29 15:23:57 -080076 main.Mininet1.home + "custom/",
Jon Hallf7234882015-08-28 13:16:31 -070077 direction="to" )
Devin Lim58046fa2017-07-05 16:55:00 -070078 stepResult = main.testSetUp.envSetup( True, True )
kelvin-onlab44147802015-07-27 17:57:31 -070079 except Exception as e:
Devin Lim58046fa2017-07-05 16:55:00 -070080 main.testSetUp.envSetupException(e)
81 main.testSetUp.evnSetupConclusion( stepResult )
kelvin-onlab44147802015-07-27 17:57:31 -070082
83 def CASE2( self, main ):
84 """
85 - Set up cell
86 - Create cell file
87 - Set cell file
88 - Verify cell file
89 - Kill ONOS process
90 - Uninstall ONOS cluster
91 - Verify ONOS start up
92 - Install ONOS cluster
93 - Connect to cli
94 """
Jeremyeb51cb12016-03-28 17:53:35 -070095 main.flowCompiler = "Flow Rules"
Devin Lim58046fa2017-07-05 16:55:00 -070096 main.initialized = main.testSetUp.ONOSSetUp( main.Mininet1, True )
Jeremy2f190ca2016-01-29 15:23:57 -080097 main.intentFunction.report( main )
98
kelvin-onlab44147802015-07-27 17:57:31 -070099 def CASE8( self, main ):
Devin Lim58046fa2017-07-05 16:55:00 -0700100 try:
101 from tests.dependencies.topology import Topology
102 except ImportError:
103 main.log.error( "Topology not found exiting the test" )
104 main.exit()
105 try:
106 main.topoRelated
107 except ( NameError, AttributeError ):
108 main.topoRelated = Topology()
109 main.topoRelated.compareTopos( main.Mininet1, main.checkTopoAttempts )
kelvin-onlab44147802015-07-27 17:57:31 -0700110
111 def CASE9( self, main ):
Jon Hall02758ac2017-05-24 16:20:28 -0700112 """
kelvin-onlab44147802015-07-27 17:57:31 -0700113 Report errors/warnings/exceptions
Jon Hall02758ac2017-05-24 16:20:28 -0700114 """
kelvin-onlab44147802015-07-27 17:57:31 -0700115 main.log.info( "Error report: \n" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700116 main.ONOSbench.logReport( globalONOSip[ 0 ],
Jon Hall02758ac2017-05-24 16:20:28 -0700117 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR", "Except" ],
118 "s" )
119 #main.ONOSbench.logReport( globalONOSip[ 1 ], [ "INFO" ], "d" )
kelvin-onlab44147802015-07-27 17:57:31 -0700120
121 def CASE10( self, main ):
122 """
123 Start Mininet topology with OF 1.0 switches
124 """
Jeremydd9bda62016-04-18 12:02:32 -0700125 if main.initialized == main.FALSE:
126 main.log.error( "Test components did not start correctly, skipping further tests" )
127 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700128 main.OFProtocol = "1.0"
129 main.log.report( "Start Mininet topology with OF 1.0 switches" )
130 main.case( "Start Mininet topology with OF 1.0 switches" )
131 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
132 "switches to test intents, exits out if " +\
133 "topology did not start correctly"
134
135 main.step( "Starting Mininet topology with OF 1.0 switches" )
136 args = "--switch ovs,protocols=OpenFlow10"
137 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
138 main.topology,
139 args=args )
140 stepResult = topoResult
141 utilities.assert_equals( expect=main.TRUE,
142 actual=stepResult,
143 onpass="Successfully loaded topology",
144 onfail="Failed to load topology" )
145 # Exit if topology did not load properly
146 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700147 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700148
149 def CASE11( self, main ):
150 """
151 Start Mininet topology with OF 1.3 switches
152 """
Jeremydd9bda62016-04-18 12:02:32 -0700153 if main.initialized == main.FALSE:
154 main.log.error( "Test components did not start correctly, skipping further tests" )
155 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700156 main.OFProtocol = "1.3"
157 main.log.report( "Start Mininet topology with OF 1.3 switches" )
158 main.case( "Start Mininet topology with OF 1.3 switches" )
159 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
160 "switches to test intents, exits out if " +\
161 "topology did not start correctly"
162
163 main.step( "Starting Mininet topology with OF 1.3 switches" )
164 args = "--switch ovs,protocols=OpenFlow13"
165 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
166 main.topology,
167 args=args )
168 stepResult = topoResult
169 utilities.assert_equals( expect=main.TRUE,
170 actual=stepResult,
171 onpass="Successfully loaded topology",
172 onfail="Failed to load topology" )
173 # Exit if topology did not load properly
174 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700175 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700176
177 def CASE12( self, main ):
178 """
179 Assign mastership to controllers
180 """
181 import re
182
Jeremydd9bda62016-04-18 12:02:32 -0700183 if main.initialized == main.FALSE:
184 main.log.error( "Test components did not start correctly, skipping further tests" )
185 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700186 main.case( "Assign switches to controllers" )
187 main.step( "Assigning switches to controllers" )
188 main.caseExplanation = "Assign OF " + main.OFProtocol +\
189 " switches to ONOS nodes"
190
191 assignResult = main.TRUE
192 switchList = []
193
194 # Creates a list switch name, use getSwitch() function later...
195 for i in range( 1, ( main.numSwitch + 1 ) ):
196 switchList.append( 's' + str( i ) )
197
198 tempONOSip = []
199 for i in range( main.numCtrls ):
200 tempONOSip.append( main.ONOSip[ i ] )
201
202 assignResult = main.Mininet1.assignSwController( sw=switchList,
203 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800204 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700205 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700206 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
207 main.initialized = main.FALSE
208 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700209
210 for i in range( 1, ( main.numSwitch + 1 ) ):
211 response = main.Mininet1.getSwController( "s" + str( i ) )
212 print( "Response is " + str( response ) )
213 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
214 assignResult = assignResult and main.TRUE
215 else:
216 assignResult = main.FALSE
217 stepResult = assignResult
218 utilities.assert_equals( expect=main.TRUE,
219 actual=stepResult,
220 onpass="Successfully assigned switches" +
221 "to controller",
222 onfail="Failed to assign switches to " +
223 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700224 if not stepResult:
225 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800226
Jon Hall02758ac2017-05-24 16:20:28 -0700227 def CASE13( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800228 """
229 Create Scapy components
230 """
Jeremydd9bda62016-04-18 12:02:32 -0700231 if main.initialized == main.FALSE:
232 main.log.error( "Test components did not start correctly, skipping further tests" )
233 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800234 main.case( "Create scapy components" )
235 main.step( "Create scapy components" )
236 import json
237 scapyResult = main.TRUE
238 for hostName in main.scapyHostNames:
239 main.Scapy1.createHostComponent( hostName )
240 main.scapyHosts.append( getattr( main, hostName ) )
241
242 main.step( "Start scapy components" )
243 for host in main.scapyHosts:
244 host.startHostCli()
245 host.startScapy()
246 host.updateSelf()
247 main.log.debug( host.name )
248 main.log.debug( host.hostIp )
249 main.log.debug( host.hostMac )
250
Jeremy2f190ca2016-01-29 15:23:57 -0800251 utilities.assert_equals( expect=main.TRUE,
252 actual=scapyResult,
253 onpass="Successfully created Scapy Components",
254 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700255 if not scapyResult:
256 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800257
258 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700259 """
260 Discover all hosts and store its data to a dictionary
261 """
Jeremydd9bda62016-04-18 12:02:32 -0700262 if main.initialized == main.FALSE:
263 main.log.error( "Test components did not start correctly, skipping further tests" )
264 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700265 main.case( "Discover all hosts" )
266
267 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700268 main.step( "Discover all ipv4 host hosts " )
269 hostList = []
270 # List of host with default vlan
271 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
272 # Lists of host with unique vlan
273 vlanHosts1 = [ "h4", "h12", "h20" ]
274 vlanHosts2 = [ "h5", "h13", "h21" ]
275 vlanHosts3 = [ "h6", "h14", "h22" ]
276 vlanHosts4 = [ "h7", "h15", "h23" ]
277 hostList.append( defaultHosts )
278 hostList.append( vlanHosts1 )
279 hostList.append( vlanHosts2 )
280 hostList.append( vlanHosts3 )
281 hostList.append( vlanHosts4 )
282
283 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700284 utilities.assert_equals( expect=main.TRUE,
285 actual=stepResult,
286 onpass="Successfully discovered hosts",
287 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700288 if not stepResult:
289 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700290
Jeremy2f190ca2016-01-29 15:23:57 -0800291 def CASE15( self, main ):
Devin Lim58046fa2017-07-05 16:55:00 -0700292 """main.topo.
Jeremy2f190ca2016-01-29 15:23:57 -0800293 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700294 """
Jeremydd9bda62016-04-18 12:02:32 -0700295 if main.initialized == main.FALSE:
296 main.log.error( "Test components did not start correctly, skipping further tests" )
297 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800298 main.case( "Discover all hosts using scapy" )
299 main.step( "Send packets from each host to the first host and confirm onos discovery" )
300
301 import collections
302 if len( main.scapyHosts ) < 1:
303 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700304 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800305 main.skipCase()
306
307 # Send ARP packets from each scapy host component
308 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
309
310 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
311 retValue=main.FALSE, args=[ main ],
312 attempts=main.checkTopoAttempts, sleep=2 )
313
314 utilities.assert_equals( expect=main.TRUE,
315 actual=stepResult,
316 onpass="ONOS correctly discovered all hosts",
317 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700318 if not stepResult:
319 main.initialized = main.FALSE
320 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800321
322 main.step( "Populate hostsData" )
323 stepResult = main.intentFunction.populateHostData( main )
324 utilities.assert_equals( expect=main.TRUE,
325 actual=stepResult,
326 onpass="Successfully populated hostsData",
327 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700328 if not stepResult:
329 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800330
331 def CASE16( self, main ):
332 """
Jeremy42df2e72016-02-23 16:37:46 -0800333 Balance Masters
334 """
Jeremydd9bda62016-04-18 12:02:32 -0700335 if main.initialized == main.FALSE:
336 main.log.error( "Test components did not start correctly, skipping further tests" )
337 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800338 main.case( "Balance mastership of switches" )
339 main.step( "Balancing mastership of switches" )
340
341 balanceResult = main.FALSE
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700342 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800343
344 utilities.assert_equals( expect=main.TRUE,
345 actual=stepResult,
346 onpass="Successfully balanced mastership of switches",
347 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700348 if not stepResult:
349 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800350
351 def CASE17( self, main ):
352 """
Jeremyeb51cb12016-03-28 17:53:35 -0700353 Use Flow Objectives
354 """
Jeremydd9bda62016-04-18 12:02:32 -0700355 if main.initialized == main.FALSE:
356 main.log.error( "Test components did not start correctly, skipping further tests" )
357 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700358 main.case( "Enable intent compilation using Flow Objectives" )
359 main.step( "Enabling Flow Objectives" )
360
361 main.flowCompiler = "Flow Objectives"
362
363 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
364
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700365 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
Jeremyeb51cb12016-03-28 17:53:35 -0700366 propName="useFlowObjectives", value="true" )
You Wang106d0fa2017-05-15 17:22:15 -0700367 stepResult &= main.CLIs[ 0 ].setCfg( component=cmd,
368 propName="defaultFlowObjectiveCompiler",
Jon Hall02758ac2017-05-24 16:20:28 -0700369 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremyeb51cb12016-03-28 17:53:35 -0700370
371 utilities.assert_equals( expect=main.TRUE,
372 actual=stepResult,
373 onpass="Successfully activated Flow Objectives",
374 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700375 if not stepResult:
376 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700377
378 def CASE18( self, main ):
379 """
Jeremy2f190ca2016-01-29 15:23:57 -0800380 Stop mininet and remove scapy hosts
381 """
Devin Lim58046fa2017-07-05 16:55:00 -0700382 try:
383 from tests.dependencies.utils import Utils
384 except ImportError:
385 main.log.error( "Utils not found exiting the test" )
386 main.exit()
387 try:
388 main.Utils
389 except ( NameError, AttributeError ):
390 main.Utils = Utils()
Jeremy2f190ca2016-01-29 15:23:57 -0800391 main.log.report( "Stop Mininet and Scapy" )
392 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700393 main.caseExplanation = "Stopping the current mininet topology " +\
394 "to start up fresh"
395
Jeremy2f190ca2016-01-29 15:23:57 -0800396 main.step( "Stopping and Removing Scapy Host Components" )
397 scapyResult = main.TRUE
398 for host in main.scapyHosts:
399 scapyResult = scapyResult and host.stopScapy()
400 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
401
402 for host in main.scapyHosts:
403 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
404 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
405
406 main.scapyHosts = []
407 main.scapyHostIPs = []
408
409 utilities.assert_equals( expect=main.TRUE,
410 actual=scapyResult,
411 onpass="Successfully stopped scapy and removed host components",
412 onfail="Failed to stop mininet and scapy" )
413
Devin Lim58046fa2017-07-05 16:55:00 -0700414 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlab44147802015-07-27 17:57:31 -0700415 # Exit if topology did not load properly
Jon Hall02758ac2017-05-24 16:20:28 -0700416 if not ( mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700417 main.cleanup()
418 main.exit()
419
Jeremy Songster17147f22016-05-31 18:30:52 -0700420 def CASE19( self, main ):
421 """
422 Copy the karaf.log files after each testcase cycle
423 """
Devin Lim58046fa2017-07-05 16:55:00 -0700424 try:
425 from tests.dependencies.utils import Utils
426 except ImportError:
427 main.log.error( "Utils not found exiting the test" )
428 main.exit()
429 try:
430 main.Utils
431 except ( NameError, AttributeError ):
432 main.Utils = Utils()
433 main.Utils.copyKarafLog()
kelvin-onlab44147802015-07-27 17:57:31 -0700434 def CASE1000( self, main ):
435 """
436 Add host intents between 2 host:
437 - Discover hosts
438 - Add host intents
439 - Check intents
440 - Verify flows
441 - Ping hosts
442 - Reroute
443 - Link down
444 - Verify flows
445 - Check topology
446 - Ping hosts
447 - Link up
448 - Verify flows
449 - Check topology
450 - Ping hosts
451 - Remove intents
452 """
453 import time
454 import json
455 import re
Jeremydd9bda62016-04-18 12:02:32 -0700456 if main.initialized == main.FALSE:
457 main.log.error( "Test components did not start correctly, skipping further tests" )
458 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700459 # Assert variables - These variable's name|format must be followed
460 # if you want to use the wrapper function
461 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700462 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700463 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -0700464 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700465 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -0700466 main.initialized = main.FALSE
467 main.skipCase()
468 try:
469 assert main.Mininet1
470 except AssertionError:
471 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
472 main.initialized = main.FALSE
473 main.skipCase()
474 try:
475 assert main.numSwitch
476 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700477 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700478 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700479 main.initialized = main.FALSE
480 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700481
Jeremye1ea0602016-02-08 16:35:05 -0800482 # Save leader candidates
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700483 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800484
kelvin-onlab44147802015-07-27 17:57:31 -0700485 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700486 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700487 main.caseExplanation = "This test case tests Host intents using " +\
488 str( main.numCtrls ) + " node(s) cluster;\n" +\
489 "Different type of hosts will be tested in " +\
490 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700491 "etc;\nThe test will use OF " + main.OFProtocol +\
492 " OVS running in Mininet and compile intents" +\
493 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700494
Jeremy2f190ca2016-01-29 15:23:57 -0800495 main.step( "IPV4: Add and test host intents between h1 and h9" )
496 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700497 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
498 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800499 testResult = main.FALSE
500 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700501 name='IPV4',
502 onosNode='0',
503 host1=host1,
504 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800505
506 if installResult:
507 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700508 name='IPV4',
509 intentId=installResult,
510 onosNode='0',
511 host1=host1,
512 host2=host2,
513 sw1='s5',
514 sw2='s2',
515 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700516
517 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800518 actual=testResult,
519 onpass=main.assertReturnString,
520 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700521
522 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800523 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700524 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
525 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800526 testResult = main.FALSE
527 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700528 name='DUALSTACK1',
529 onosNode='0',
530 host1=host1,
531 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800532
533 if installResult:
534 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700535 name='DUALSTACK1',
536 intentId=installResult,
537 onosNode='0',
538 host1=host1,
539 host2=host2,
540 sw1='s5',
541 sw2='s2',
542 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700543
544 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800545 actual=testResult,
546 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700547 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700548
549 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800550 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700551 host1 = { "name": "h1" }
552 host2 = { "name": "h11" }
Jeremy2f190ca2016-01-29 15:23:57 -0800553 testResult = main.FALSE
554 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700555 name='DUALSTACK2',
556 onosNode='0',
557 host1=host1,
558 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800559
560 if installResult:
561 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700562 name='DUALSTACK2',
563 intentId=installResult,
564 onosNode='0',
565 host1=host1,
566 host2=host2,
567 sw1='s5',
568 sw2='s2',
569 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700570
571 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800572 actual=testResult,
573 onpass=main.assertReturnString,
574 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700575
576 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800577 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700578 host1 = { "name": "h1" }
579 host2 = { "name": "h3" }
Jeremy2f190ca2016-01-29 15:23:57 -0800580 testResult = main.FALSE
581 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700582 name='1HOP',
583 onosNode='0',
584 host1=host1,
585 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700586
Jeremy2f190ca2016-01-29 15:23:57 -0800587 if installResult:
588 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700589 name='1HOP',
590 intentId=installResult,
591 onosNode='0',
592 host1=host1,
593 host2=host2,
594 sw1='s5',
595 sw2='s2',
596 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700597
598 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800599 actual=testResult,
600 onpass=main.assertReturnString,
601 onfail=main.assertReturnString )
602
603 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
604 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700605 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" }
606 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800607 testResult = main.FALSE
608 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700609 name='VLAN1',
610 onosNode='0',
611 host1=host1,
612 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800613
614 if installResult:
615 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700616 name='VLAN1',
617 intentId=installResult,
618 onosNode='0',
619 host1=host1,
620 host2=host2,
621 sw1='s5',
622 sw2='s2',
623 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -0800624
625 utilities.assert_equals( expect=main.TRUE,
626 actual=testResult,
627 onpass=main.assertReturnString,
628 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700629
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700630 # This step isn't currently possible to perform in the REST API
631 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
632 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
633 # host1 = { "name":"h13" }
634 # host2 = { "name":"h20" }
635 # testResult = main.FALSE
636 # installResult = main.intentFunction.installHostIntent( main,
637 # name='VLAN2',
638 # onosNode='0',
639 # host1=host1,
640 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700641
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700642 # if installResult:
643 # testResult = main.intentFunction.testHostIntent( main,
644 # name='VLAN2',
Jon Hall02758ac2017-05-24 16:20:28 -0700645 # intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700646 # onosNode='0',
647 # host1=host1,
648 # host2=host2,
649 # sw1='s5',
650 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700651 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700652
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700653 # utilities.assert_equals( expect=main.TRUE,
654 # actual=testResult,
655 # onpass=main.assertReturnString,
656 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -0800657
Jeremye1ea0602016-02-08 16:35:05 -0800658 # Change the following to use the REST API when leader checking is
659 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -0800660
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700661 main.step( "Confirm that ONOS leadership is unchanged" )
662 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800663 main.intentFunction.checkLeaderChange( intentLeadersOld,
664 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -0800665
Jeremye1ea0602016-02-08 16:35:05 -0800666 utilities.assert_equals( expect=main.TRUE,
667 actual=testResult,
668 onpass="ONOS Leaders Unchanged",
Jon Hall02758ac2017-05-24 16:20:28 -0700669 onfail="ONOS Leader Mismatch" )
Jeremy2f190ca2016-01-29 15:23:57 -0800670
671 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -0700672
673 def CASE2000( self, main ):
674 """
675 Add point intents between 2 hosts:
676 - Get device ids | ports
677 - Add point intents
678 - Check intents
679 - Verify flows
680 - Ping hosts
681 - Reroute
682 - Link down
683 - Verify flows
684 - Check topology
685 - Ping hosts
686 - Link up
687 - Verify flows
688 - Check topology
689 - Ping hosts
690 - Remove intents
691 """
Jeremydd9bda62016-04-18 12:02:32 -0700692 if main.initialized == main.FALSE:
693 main.log.error( "Test components did not start correctly, skipping further tests" )
694 main.skipCase()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700695 # Assert variables - These variable's name|format must be followed
696 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -0700697 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700698 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700699 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -0700700 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700701 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -0700702 main.initialized = main.FALSE
703 main.skipCase()
704 try:
705 assert main.Mininet1
706 except AssertionError:
707 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
708 main.initialized = main.FALSE
709 main.skipCase()
710 try:
711 assert main.numSwitch
712 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700713 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700714 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700715 main.initialized = main.FALSE
716 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700717
718 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -0700719 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700720 main.caseExplanation = "This test case will test point to point" + \
721 " intents using " + str( main.numCtrls ) + \
722 " node(s) cluster;\n" + \
723 "Different type of hosts will be tested in " + \
724 "each step such as IPV4, Dual stack, VLAN etc" + \
725 ";\nThe test will use OF " + main.OFProtocol + \
726 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -0700727 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700728
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700729 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -0700730 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800731 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
732 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700733 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800734 ]
735 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700736 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800737 ]
738 testResult = main.FALSE
739 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700740 main,
741 name="NOOPTION",
742 senders=senders,
743 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800744
745 if installResult:
746 testResult = main.intentFunction.testPointIntent(
747 main,
748 intentId=installResult,
749 name="NOOPTION",
750 senders=senders,
751 recipients=recipients,
752 sw1="s5",
753 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700754 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700755
756 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800757 actual=testResult,
758 onpass=main.assertReturnString,
759 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700760
kelvin-onlab44147802015-07-27 17:57:31 -0700761 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800762 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
763 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700764 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -0800765 ]
766 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700767 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -0800768 ]
769 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700770 main,
771 name="IPV4",
772 senders=senders,
773 recipients=recipients,
774 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800775
776 if installResult:
777 testResult = main.intentFunction.testPointIntent(
778 main,
779 intentId=installResult,
780 name="IPV4",
781 senders=senders,
782 recipients=recipients,
783 sw1="s5",
784 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700785 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700786
787 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800788 actual=testResult,
789 onpass=main.assertReturnString,
790 onfail=main.assertReturnString )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700791
alisonda157272016-12-22 01:13:21 -0800792 # main.step( "Protected: Add point intents between h1 and h9" )
793 # main.assertReturnString = "Assertion Result for protected point intent\n"
794 # senders = [
795 # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
796 # ]
797 # recipients = [
798 # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
799 # ]
800 # testResult = main.FALSE
801 # installResult = main.intentFunction.installPointIntent(
802 # main,
803 # name="Protected",
804 # senders=senders,
805 # recipients=recipients,
806 # protected=True )
Jon Hall02758ac2017-05-24 16:20:28 -0700807 #
alisonda157272016-12-22 01:13:21 -0800808 # if installResult:
809 # testResult = main.intentFunction.testPointIntent(
810 # main,
811 # name="Protected",
812 # intentId=installResult,
813 # senders=senders,
814 # recipients=recipients,
815 # sw1="s5",
816 # sw2="s2",
817 # protected=True,
818 # expectedLink=18 )
819 #
820 # utilities.assert_equals( expect=main.TRUE,
821 # actual=testResult,
822 # onpass=main.assertReturnString,
823 # onfail=main.assertReturnString )
824
kelvin-onlab44147802015-07-27 17:57:31 -0700825 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800826 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
827 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700828 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800829 ]
830 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700831 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800832 ]
833 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700834 main,
835 name="IPV4_2",
836 senders=senders,
837 recipients=recipients,
838 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800839
840 if installResult:
841 testResult = main.intentFunction.testPointIntent(
842 main,
843 intentId=installResult,
844 name="IPV4_2",
845 senders=senders,
846 recipients=recipients,
847 sw1="s5",
848 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700849 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700850
851 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800852 actual=testResult,
853 onpass=main.assertReturnString,
854 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700855
kelvin-onlab0e684682015-08-11 18:51:41 -0700856 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800857 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
858 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700859 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
860 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800861 ]
862 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700863 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
864 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800865 ]
Jon Hall02758ac2017-05-24 16:20:28 -0700866 # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700867 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700868 # Uneccessary, not including this in the selectors
Jon Hall02758ac2017-05-24 16:20:28 -0700869 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
870 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700871
Jeremy2f190ca2016-01-29 15:23:57 -0800872 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700873 main,
874 name="SDNIP-ICMP",
875 senders=senders,
876 recipients=recipients,
877 ethType="IPV4",
878 ipProto=ipProto,
879 tcpSrc=tcpSrc,
880 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -0800881
882 if installResult:
883 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700884 main,
885 intentId=installResult,
886 name="SDNIP_ICMP",
887 senders=senders,
888 recipients=recipients,
889 sw1="s5",
890 sw2="s2",
891 expectedLink=18,
892 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -0700893
894 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800895 actual=testResult,
896 onpass=main.assertReturnString,
897 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700898
kelvin-onlab0e684682015-08-11 18:51:41 -0700899 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800900 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700901 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
902 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
903 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
904 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
905 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
906 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
907 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700908
kelvin-onlab0e684682015-08-11 18:51:41 -0700909 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700910 main,
911 name="SDNIP-TCP",
912 host1="h1",
913 host2="h9",
914 deviceId1="of:0000000000000005/1",
915 deviceId2="of:0000000000000006/1",
916 mac1=mac1,
917 mac2=mac2,
918 ethType="IPV4",
919 ipProto=ipProto,
920 ip1=ip1,
921 ip2=ip2,
922 tcp1=tcp1,
923 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700924
925 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700926 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -0800927 onpass=main.assertReturnString,
928 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700929
Jeremy2f190ca2016-01-29 15:23:57 -0800930 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
931 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
932 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700933 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -0800934 ]
935 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700936 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -0800937 ]
938 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700939 main,
940 name="DUALSTACK1",
941 senders=senders,
942 recipients=recipients,
943 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800944
945 if installResult:
946 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700947 main,
948 intentId=installResult,
949 name="DUALSTACK1",
950 senders=senders,
951 recipients=recipients,
952 sw1="s5",
953 sw2="s2",
954 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700955
956 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800957 actual=testResult,
958 onpass=main.assertReturnString,
959 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700960
961 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -0800962 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
963 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700964 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800965 ]
966 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700967 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800968 ]
969 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700970 main,
971 name="VLAN",
972 senders=senders,
973 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800974
975 if installResult:
976 testResult = main.intentFunction.testPointIntent(
977 main,
978 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700979 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -0800980 senders=senders,
981 recipients=recipients,
982 sw1="s5",
983 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700984 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700985
986 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800987 actual=testResult,
988 onpass=main.assertReturnString,
989 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700990
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700991 # TODO: implement VLAN selector REST API intent test once supported
992
kelvin-onlab44147802015-07-27 17:57:31 -0700993 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800994 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
995 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700996 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -0800997 ]
998 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700999 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001000 ]
1001 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001002 main,
1003 name="1HOP IPV4",
1004 senders=senders,
1005 recipients=recipients,
1006 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001007
1008 if installResult:
1009 testResult = main.intentFunction.testPointIntent(
1010 main,
1011 intentId=installResult,
1012 name="1HOP IPV4",
1013 senders=senders,
1014 recipients=recipients,
1015 sw1="s5",
1016 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001017 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001018
1019 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001020 actual=testResult,
1021 onpass=main.assertReturnString,
1022 onfail=main.assertReturnString )
1023
1024 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001025
1026 def CASE3000( self, main ):
1027 """
1028 Add single point to multi point intents
1029 - Get device ids
1030 - Add single point to multi point intents
1031 - Check intents
1032 - Verify flows
1033 - Ping hosts
1034 - Reroute
1035 - Link down
1036 - Verify flows
1037 - Check topology
1038 - Ping hosts
1039 - Link up
1040 - Verify flows
1041 - Check topology
1042 - Ping hosts
1043 - Remove intents
1044 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001045 if main.initialized == main.FALSE:
1046 main.log.error( "Test components did not start correctly, skipping further tests" )
1047 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001048 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001049
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001050 try:
1051 assert main.CLIs, "There is no main.CLIs, skipping test cases"
1052 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1053 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1054 except AssertionError:
1055 main.initialized = main.FALSE
1056 main.skipCase()
1057
1058 main.testName = "Single to Multi Point Intents"
1059 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001060 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001061 main.caseExplanation = "This test case will test single point to" + \
1062 " multi point intents using " + \
1063 str( main.numCtrls ) + " node(s) cluster;\n" + \
1064 "Different type of hosts will be tested in " + \
1065 "each step such as IPV4, Dual stack, VLAN etc" + \
1066 ";\nThe test will use OF " + main.OFProtocol + \
1067 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001068 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001069
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001070 main.step( "NOOPTION: Install and test single point to multi point intents" )
1071 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1072 senders = [
1073 { "name": "h8", "device": "of:0000000000000005/8" }
1074 ]
1075 recipients = [
1076 { "name": "h16", "device": "of:0000000000000006/8" },
1077 { "name": "h24", "device": "of:0000000000000007/8" }
1078 ]
1079 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1080 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1081 testResult = main.FALSE
1082 installResult = main.intentFunction.installSingleToMultiIntent(
1083 main,
1084 name="NOOPTION",
1085 senders=senders,
1086 recipients=recipients )
1087
1088 if installResult:
1089 testResult = main.intentFunction.testPointIntent(
1090 main,
1091 intentId=installResult,
1092 name="NOOPTION",
1093 senders=senders,
1094 recipients=recipients,
1095 badSenders=badSenders,
1096 badRecipients=badRecipients,
1097 sw1="s5",
1098 sw2="s2",
1099 expectedLink=18 )
1100 else:
1101 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001102
1103 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001104 actual=testResult,
1105 onpass=main.assertReturnString,
1106 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001107
Jon Hall02758ac2017-05-24 16:20:28 -07001108 main.step( "IPV4: Install and test single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001109 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1110 "with IPV4 type and MAC addresses\n"
1111 senders = [
Jon Hall02758ac2017-05-24 16:20:28 -07001112 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001113 ]
1114 recipients = [
Jon Hall02758ac2017-05-24 16:20:28 -07001115 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1116 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001117 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001118 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1119 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001120 installResult = main.intentFunction.installSingleToMultiIntent(
1121 main,
1122 name="IPV4",
1123 senders=senders,
1124 recipients=recipients,
Jon Hall02758ac2017-05-24 16:20:28 -07001125 ethType="IPV4" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001126
1127 if installResult:
1128 testResult = main.intentFunction.testPointIntent(
1129 main,
1130 intentId=installResult,
1131 name="IPV4",
1132 senders=senders,
1133 recipients=recipients,
1134 badSenders=badSenders,
1135 badRecipients=badRecipients,
1136 sw1="s5",
1137 sw2="s2",
1138 expectedLink=18 )
1139 else:
1140 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001141
1142 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001143 actual=testResult,
1144 onpass=main.assertReturnString,
1145 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001146
1147 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001148 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1149 "with IPV4 type and no MAC addresses\n"
1150 senders = [
1151 { "name": "h8", "device": "of:0000000000000005/8" }
1152 ]
1153 recipients = [
1154 { "name": "h16", "device": "of:0000000000000006/8" },
1155 { "name": "h24", "device": "of:0000000000000007/8" }
1156 ]
1157 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1158 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1159 installResult = main.intentFunction.installSingleToMultiIntent(
1160 main,
1161 name="IPV4_2",
1162 senders=senders,
1163 recipients=recipients,
1164 ethType="IPV4" )
1165
1166 if installResult:
1167 testResult = main.intentFunction.testPointIntent(
1168 main,
1169 intentId=installResult,
1170 name="IPV4_2",
1171 senders=senders,
1172 recipients=recipients,
1173 badSenders=badSenders,
1174 badRecipients=badRecipients,
1175 sw1="s5",
1176 sw2="s2",
1177 expectedLink=18 )
1178 else:
1179 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001180
1181 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001182 actual=testResult,
1183 onpass=main.assertReturnString,
1184 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001185
1186 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001187 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1188 "and MAC addresses in the same VLAN\n"
1189 senders = [
1190 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1191 ]
1192 recipients = [
1193 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1194 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1195 ]
1196 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1197 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1198 installResult = main.intentFunction.installSingleToMultiIntent(
1199 main,
1200 name="VLAN",
1201 senders=senders,
1202 recipients=recipients,
1203 sw1="s5",
1204 sw2="s2" )
1205
1206 if installResult:
1207 testResult = main.intentFunction.testPointIntent(
1208 main,
1209 intentId=installResult,
1210 name="VLAN",
1211 senders=senders,
1212 recipients=recipients,
1213 badSenders=badSenders,
1214 badRecipients=badRecipients,
1215 sw1="s5",
1216 sw2="s2",
1217 expectedLink=18 )
1218 else:
1219 main.CLIs[ 0 ].removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001220
1221 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001222 actual=testResult,
1223 onpass=main.assertReturnString,
1224 onfail=main.assertReturnString )
1225
1226 main.step( "VLAN: Add single point to multi point intents" )
1227 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1228 senders = [
1229 { "name": "h5", "vlan": "200" }
1230 ]
1231 recipients = [
1232 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1233 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1234 ]
1235 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1236 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1237 testResult = main.FALSE
1238 installResult = main.intentFunction.installSingleToMultiIntent(
1239 main,
1240 name="VLAN2",
1241 senders=senders,
1242 recipients=recipients,
1243 sw1="s5",
1244 sw2="s2" )
Jon Hall02758ac2017-05-24 16:20:28 -07001245 #setVlan=100 )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001246
1247 if installResult:
1248 testResult = main.intentFunction.testPointIntent(
1249 main,
1250 intentId=installResult,
1251 name="VLAN2",
1252 senders=senders,
1253 recipients=recipients,
1254 badSenders=badSenders,
1255 badRecipients=badRecipients,
1256 sw1="s5",
1257 sw2="s2",
1258 expectedLink=18 )
1259 else:
1260 main.CLIs[ 0 ].removeAllIntents()
1261
1262 utilities.assert_equals( expect=main.TRUE,
1263 actual=testResult,
1264 onpass=main.assertReturnString,
1265 onfail=main.assertReturnString )
1266
1267 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001268
1269 def CASE4000( self, main ):
1270 """
1271 Add multi point to single point intents
1272 - Get device ids
1273 - Add multi point to single point intents
1274 - Check intents
1275 - Verify flows
1276 - Ping hosts
1277 - Reroute
1278 - Link down
1279 - Verify flows
1280 - Check topology
1281 - Ping hosts
1282 - Link up
1283 - Verify flows
1284 - Check topology
1285 - Ping hosts
1286 - Remove intents
1287 """
1288 assert main, "There is no main"
1289 assert main.CLIs, "There is no main.CLIs"
1290 assert main.Mininet1, "Mininet handle should be named Mininet1"
1291 assert main.numSwitch, "Placed the total number of switch topology in \
1292 main.numSwitch"
1293
1294 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001295 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001296 main.caseExplanation = "This test case will test single point to" +\
1297 " multi point intents using " +\
1298 str( main.numCtrls ) + " node(s) cluster;\n" +\
1299 "Different type of hosts will be tested in " +\
1300 "each step such as IPV4, Dual stack, VLAN etc" +\
1301 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001302 " OVS running in Mininet and compile intents" +\
1303 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001304
1305 main.step( "NOOPTION: Add multi point to single point intents" )
1306 stepResult = main.TRUE
1307 hostNames = [ 'h8', 'h16', 'h24' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001308 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8',
kelvin-onlab44147802015-07-27 17:57:31 -07001309 'of:0000000000000007/8' ]
1310 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1311 stepResult = main.intentFunction.multiToSingleIntent(
1312 main,
1313 name="NOOPTION",
1314 hostNames=hostNames,
1315 devices=devices,
1316 sw1="s5",
1317 sw2="s2",
1318 expectedLink=18 )
1319
1320 utilities.assert_equals( expect=main.TRUE,
1321 actual=stepResult,
1322 onpass="NOOPTION: Successfully added multi "
1323 + " point to single point intents" +
1324 " with no match action",
1325 onfail="NOOPTION: Failed to add multi point" +
1326 " to single point intents" +
1327 " with no match action" )
1328
1329 main.step( "IPV4: Add multi point to single point intents" )
1330 stepResult = main.TRUE
1331 stepResult = main.intentFunction.multiToSingleIntent(
1332 main,
1333 name="IPV4",
1334 hostNames=hostNames,
1335 devices=devices,
1336 ports=None,
1337 ethType="IPV4",
1338 macs=macs,
1339 bandwidth="",
1340 lambdaAlloc=False,
1341 ipProto="",
1342 ipAddresses="",
1343 tcp="",
1344 sw1="s5",
1345 sw2="s2",
1346 expectedLink=18 )
1347
1348 utilities.assert_equals( expect=main.TRUE,
1349 actual=stepResult,
1350 onpass="IPV4: Successfully added multi point"
1351 + " to single point intents" +
1352 " with IPV4 type and MAC addresses",
1353 onfail="IPV4: Failed to add multi point" +
1354 " to single point intents" +
1355 " with IPV4 type and MAC addresses" )
1356
1357 main.step( "IPV4_2: Add multi point to single point intents" )
1358 stepResult = main.TRUE
1359 hostNames = [ 'h8', 'h16', 'h24' ]
1360 stepResult = main.intentFunction.multiToSingleIntent(
1361 main,
1362 name="IPV4",
1363 hostNames=hostNames,
1364 ethType="IPV4",
1365 lambdaAlloc=False )
1366
1367 utilities.assert_equals( expect=main.TRUE,
1368 actual=stepResult,
1369 onpass="IPV4_2: Successfully added multi point"
1370 + " to single point intents" +
1371 " with IPV4 type and no MAC addresses",
1372 onfail="IPV4_2: Failed to add multi point" +
1373 " to single point intents" +
1374 " with IPV4 type and no MAC addresses" )
1375
1376 main.step( "VLAN: Add multi point to single point intents" )
1377 stepResult = main.TRUE
1378 hostNames = [ 'h5', 'h13', 'h21' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001379 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5',
kelvin-onlab44147802015-07-27 17:57:31 -07001380 'of:0000000000000007/5' ]
1381 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1382 stepResult = main.intentFunction.multiToSingleIntent(
1383 main,
1384 name="VLAN",
1385 hostNames=hostNames,
1386 devices=devices,
1387 ports=None,
1388 ethType="IPV4",
1389 macs=macs,
1390 bandwidth="",
1391 lambdaAlloc=False,
1392 ipProto="",
1393 ipAddresses="",
1394 tcp="",
1395 sw1="s5",
1396 sw2="s2",
1397 expectedLink=18 )
1398
1399 utilities.assert_equals( expect=main.TRUE,
1400 actual=stepResult,
1401 onpass="VLAN: Successfully added multi point"
1402 + " to single point intents" +
1403 " with IPV4 type and MAC addresses" +
1404 " in the same VLAN",
1405 onfail="VLAN: Failed to add multi point" +
1406 " to single point intents" )
1407
1408 def CASE5000( self, main ):
1409 """
Jeremy2f190ca2016-01-29 15:23:57 -08001410 Tests Host Mobility
1411 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001412 """
Jeremydd9bda62016-04-18 12:02:32 -07001413 if main.initialized == main.FALSE:
1414 main.log.error( "Test components did not start correctly, skipping further tests" )
1415 main.skipCase()
1416 # Assert variables - These variable's name|format must be followed
1417 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001418 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001419 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001420 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001421 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001422 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001423 main.initialized = main.FALSE
1424 main.skipCase()
1425 try:
1426 assert main.Mininet1
1427 except AssertionError:
1428 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1429 main.initialized = main.FALSE
1430 main.skipCase()
1431 try:
1432 assert main.numSwitch
1433 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001434 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001435 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001436 main.initialized = main.FALSE
1437 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001438 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001439 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001440 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1441
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001442 main.log.info( "Moving h1 from s5 to s6" )
1443 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001444
Jeremy2f190ca2016-01-29 15:23:57 -08001445 # Send discovery ping from moved host
1446 # Moving the host brings down the default interfaces and creates a new one.
1447 # Scapy is restarted on this host to detect the new interface
1448 main.h1.stopScapy()
1449 main.h1.startScapy()
1450
1451 # Discover new host location in ONOS and populate host data.
1452 # Host 1 IP and MAC should be unchanged
1453 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1454 main.intentFunction.populateHostData( main )
1455
kelvin-onlab44147802015-07-27 17:57:31 -07001456 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1457
1458 utilities.assert_equals( expect="of:0000000000000006",
1459 actual=h1PostMove,
1460 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001461 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001462 " to single point intents" +
1463 " with IPV4 type and MAC addresses" +
1464 " in the same VLAN" )
1465
1466 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001467 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001468 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1469 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001470
1471 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001472 name='IPV4 Mobility IPV4',
1473 onosNode='0',
1474 host1=host1,
1475 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001476 if installResult:
1477 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001478 name='Host Mobility IPV4',
1479 intentId=installResult,
1480 onosNode='0',
1481 host1=host1,
1482 host2=host2,
1483 sw1="s6",
1484 sw2="s2",
1485 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001486
1487 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001488 actual=testResult,
1489 onpass=main.assertReturnString,
1490 onfail=main.assertReturnString )
1491
Jon Hallbd60ea02016-08-23 10:03:59 -07001492 main.intentFunction.report( main )