blob: a2537a266480cac25a3ce3c24b0732a0410a40ef [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"""
kelvin-onlab44147802015-07-27 17:57:31 -070021
22# Testing the basic intent functionality of ONOS
Jeremy2f190ca2016-01-29 15:23:57 -080023# TODO: Replace the CLI calls with REST API equivalents as they become available.
24# - May need to write functions in the onosrestdriver.py file to do this
25# TODO: Complete implementation of case 3000, 4000, and 6000 as REST API allows
26# -Currently there is no support in the REST API for Multi to Single and Single to Multi point intents
27# As such, these cases are incomplete and should not be enabled in the .params file
kelvin-onlab44147802015-07-27 17:57:31 -070028
29import time
30import json
31
Jon Hall02758ac2017-05-24 16:20:28 -070032
kelvin-onlab44147802015-07-27 17:57:31 -070033class FUNCintentRest:
34
35 def __init__( self ):
36 self.default = ''
37
38 def CASE1( self, main ):
39 import time
kelvin-onlab44147802015-07-27 17:57:31 -070040 import imp
Jon Hallf7234882015-08-28 13:16:31 -070041 import re
kelvin-onlab44147802015-07-27 17:57:31 -070042 """
43 - Construct tests variables
44 - GIT ( optional )
45 - Checkout ONOS master branch
46 - Pull latest ONOS code
47 - Building ONOS ( optional )
48 - Install ONOS package
49 - Build ONOS package
50 """
Devin Lim58046fa2017-07-05 16:55:00 -070051 try:
52 from tests.dependencies.ONOSSetup import ONOSSetup
53 main.testSetUp = ONOSSetup()
54 except ImportError:
55 main.log.error( "ONOSSetup not found. exiting the test" )
56 main.exit()
57 main.testSetUp.envSetupDescription()
kelvin-onlab44147802015-07-27 17:57:31 -070058 stepResult = main.FALSE
59
60 # Test variables
61 try:
kelvin-onlab44147802015-07-27 17:57:31 -070062 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
kelvin-onlab44147802015-07-27 17:57:31 -070063 main.dependencyPath = main.testOnDirectory + \
64 main.params[ 'DEPENDENCY' ][ 'path' ]
65 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
66 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
kelvin-onlab44147802015-07-27 17:57:31 -070067 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
68 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
69 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
70 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080071 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
72 main.removeIntentsleeo = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070073 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
74 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
kelvin-onlab0e684682015-08-11 18:51:41 -070075 main.addIntentSleep = int( main.params[ 'SLEEP' ][ 'addIntent' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080076 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070077 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070078 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
79 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070080 main.hostsData = {}
Jeremy2f190ca2016-01-29 15:23:57 -080081 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
82 main.scapyHosts = [] # List of scapy hosts for iterating
83 main.assertReturnString = '' # Assembled assert return string
Jon Hall02758ac2017-05-24 16:20:28 -070084 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlab44147802015-07-27 17:57:31 -070085
kelvin-onlab44147802015-07-27 17:57:31 -070086 # -- INIT SECTION, ONLY RUNS ONCE -- #
kelvin-onlab44147802015-07-27 17:57:31 -070087
88 main.intentFunction = imp.load_source( wrapperFile2,
Jon Hall02758ac2017-05-24 16:20:28 -070089 main.dependencyPath +
90 wrapperFile2 +
91 ".py" )
kelvin-onlab44147802015-07-27 17:57:31 -070092
Jon Hallf7234882015-08-28 13:16:31 -070093 copyResult1 = main.ONOSbench.scp( main.Mininet1,
94 main.dependencyPath +
95 main.topology,
Jeremy2f190ca2016-01-29 15:23:57 -080096 main.Mininet1.home + "custom/",
Jon Hallf7234882015-08-28 13:16:31 -070097 direction="to" )
Devin Lim58046fa2017-07-05 16:55:00 -070098 stepResult = main.testSetUp.envSetup( True, True )
kelvin-onlab44147802015-07-27 17:57:31 -070099 except Exception as e:
Devin Lim58046fa2017-07-05 16:55:00 -0700100 main.testSetUp.envSetupException(e)
101 main.testSetUp.evnSetupConclusion( stepResult )
kelvin-onlab44147802015-07-27 17:57:31 -0700102
103 def CASE2( self, main ):
104 """
105 - Set up cell
106 - Create cell file
107 - Set cell file
108 - Verify cell file
109 - Kill ONOS process
110 - Uninstall ONOS cluster
111 - Verify ONOS start up
112 - Install ONOS cluster
113 - Connect to cli
114 """
Jeremyeb51cb12016-03-28 17:53:35 -0700115 main.flowCompiler = "Flow Rules"
Devin Lim58046fa2017-07-05 16:55:00 -0700116 main.initialized = main.testSetUp.ONOSSetUp( main.Mininet1, True )
Jeremy2f190ca2016-01-29 15:23:57 -0800117 main.intentFunction.report( main )
118
kelvin-onlab44147802015-07-27 17:57:31 -0700119 def CASE8( self, main ):
Devin Lim58046fa2017-07-05 16:55:00 -0700120 try:
121 from tests.dependencies.topology import Topology
122 except ImportError:
123 main.log.error( "Topology not found exiting the test" )
124 main.exit()
125 try:
126 main.topoRelated
127 except ( NameError, AttributeError ):
128 main.topoRelated = Topology()
129 main.topoRelated.compareTopos( main.Mininet1, main.checkTopoAttempts )
kelvin-onlab44147802015-07-27 17:57:31 -0700130
131 def CASE9( self, main ):
Jon Hall02758ac2017-05-24 16:20:28 -0700132 """
kelvin-onlab44147802015-07-27 17:57:31 -0700133 Report errors/warnings/exceptions
Jon Hall02758ac2017-05-24 16:20:28 -0700134 """
kelvin-onlab44147802015-07-27 17:57:31 -0700135 main.log.info( "Error report: \n" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700136 main.ONOSbench.logReport( globalONOSip[ 0 ],
Jon Hall02758ac2017-05-24 16:20:28 -0700137 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR", "Except" ],
138 "s" )
139 #main.ONOSbench.logReport( globalONOSip[ 1 ], [ "INFO" ], "d" )
kelvin-onlab44147802015-07-27 17:57:31 -0700140
141 def CASE10( self, main ):
142 """
143 Start Mininet topology with OF 1.0 switches
144 """
Jeremydd9bda62016-04-18 12:02:32 -0700145 if main.initialized == main.FALSE:
146 main.log.error( "Test components did not start correctly, skipping further tests" )
147 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700148 main.OFProtocol = "1.0"
149 main.log.report( "Start Mininet topology with OF 1.0 switches" )
150 main.case( "Start Mininet topology with OF 1.0 switches" )
151 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
152 "switches to test intents, exits out if " +\
153 "topology did not start correctly"
154
155 main.step( "Starting Mininet topology with OF 1.0 switches" )
156 args = "--switch ovs,protocols=OpenFlow10"
157 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
158 main.topology,
159 args=args )
160 stepResult = topoResult
161 utilities.assert_equals( expect=main.TRUE,
162 actual=stepResult,
163 onpass="Successfully loaded topology",
164 onfail="Failed to load topology" )
165 # Exit if topology did not load properly
166 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700167 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700168
169 def CASE11( self, main ):
170 """
171 Start Mininet topology with OF 1.3 switches
172 """
Jeremydd9bda62016-04-18 12:02:32 -0700173 if main.initialized == main.FALSE:
174 main.log.error( "Test components did not start correctly, skipping further tests" )
175 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700176 main.OFProtocol = "1.3"
177 main.log.report( "Start Mininet topology with OF 1.3 switches" )
178 main.case( "Start Mininet topology with OF 1.3 switches" )
179 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
180 "switches to test intents, exits out if " +\
181 "topology did not start correctly"
182
183 main.step( "Starting Mininet topology with OF 1.3 switches" )
184 args = "--switch ovs,protocols=OpenFlow13"
185 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
186 main.topology,
187 args=args )
188 stepResult = topoResult
189 utilities.assert_equals( expect=main.TRUE,
190 actual=stepResult,
191 onpass="Successfully loaded topology",
192 onfail="Failed to load topology" )
193 # Exit if topology did not load properly
194 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700195 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700196
197 def CASE12( self, main ):
198 """
199 Assign mastership to controllers
200 """
201 import re
202
Jeremydd9bda62016-04-18 12:02:32 -0700203 if main.initialized == main.FALSE:
204 main.log.error( "Test components did not start correctly, skipping further tests" )
205 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700206 main.case( "Assign switches to controllers" )
207 main.step( "Assigning switches to controllers" )
208 main.caseExplanation = "Assign OF " + main.OFProtocol +\
209 " switches to ONOS nodes"
210
211 assignResult = main.TRUE
212 switchList = []
213
214 # Creates a list switch name, use getSwitch() function later...
215 for i in range( 1, ( main.numSwitch + 1 ) ):
216 switchList.append( 's' + str( i ) )
217
218 tempONOSip = []
219 for i in range( main.numCtrls ):
220 tempONOSip.append( main.ONOSip[ i ] )
221
222 assignResult = main.Mininet1.assignSwController( sw=switchList,
223 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800224 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700225 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700226 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
227 main.initialized = main.FALSE
228 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700229
230 for i in range( 1, ( main.numSwitch + 1 ) ):
231 response = main.Mininet1.getSwController( "s" + str( i ) )
232 print( "Response is " + str( response ) )
233 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
234 assignResult = assignResult and main.TRUE
235 else:
236 assignResult = main.FALSE
237 stepResult = assignResult
238 utilities.assert_equals( expect=main.TRUE,
239 actual=stepResult,
240 onpass="Successfully assigned switches" +
241 "to controller",
242 onfail="Failed to assign switches to " +
243 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700244 if not stepResult:
245 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800246
Jon Hall02758ac2017-05-24 16:20:28 -0700247 def CASE13( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800248 """
249 Create Scapy components
250 """
Jeremydd9bda62016-04-18 12:02:32 -0700251 if main.initialized == main.FALSE:
252 main.log.error( "Test components did not start correctly, skipping further tests" )
253 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800254 main.case( "Create scapy components" )
255 main.step( "Create scapy components" )
256 import json
257 scapyResult = main.TRUE
258 for hostName in main.scapyHostNames:
259 main.Scapy1.createHostComponent( hostName )
260 main.scapyHosts.append( getattr( main, hostName ) )
261
262 main.step( "Start scapy components" )
263 for host in main.scapyHosts:
264 host.startHostCli()
265 host.startScapy()
266 host.updateSelf()
267 main.log.debug( host.name )
268 main.log.debug( host.hostIp )
269 main.log.debug( host.hostMac )
270
Jeremy2f190ca2016-01-29 15:23:57 -0800271 utilities.assert_equals( expect=main.TRUE,
272 actual=scapyResult,
273 onpass="Successfully created Scapy Components",
274 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700275 if not scapyResult:
276 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800277
278 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700279 """
280 Discover all hosts and store its data to a dictionary
281 """
Jeremydd9bda62016-04-18 12:02:32 -0700282 if main.initialized == main.FALSE:
283 main.log.error( "Test components did not start correctly, skipping further tests" )
284 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700285 main.case( "Discover all hosts" )
286
287 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700288 main.step( "Discover all ipv4 host hosts " )
289 hostList = []
290 # List of host with default vlan
291 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
292 # Lists of host with unique vlan
293 vlanHosts1 = [ "h4", "h12", "h20" ]
294 vlanHosts2 = [ "h5", "h13", "h21" ]
295 vlanHosts3 = [ "h6", "h14", "h22" ]
296 vlanHosts4 = [ "h7", "h15", "h23" ]
297 hostList.append( defaultHosts )
298 hostList.append( vlanHosts1 )
299 hostList.append( vlanHosts2 )
300 hostList.append( vlanHosts3 )
301 hostList.append( vlanHosts4 )
302
303 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700304 utilities.assert_equals( expect=main.TRUE,
305 actual=stepResult,
306 onpass="Successfully discovered hosts",
307 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700308 if not stepResult:
309 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700310
Jeremy2f190ca2016-01-29 15:23:57 -0800311 def CASE15( self, main ):
Devin Lim58046fa2017-07-05 16:55:00 -0700312 """main.topo.
Jeremy2f190ca2016-01-29 15:23:57 -0800313 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700314 """
Jeremydd9bda62016-04-18 12:02:32 -0700315 if main.initialized == main.FALSE:
316 main.log.error( "Test components did not start correctly, skipping further tests" )
317 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800318 main.case( "Discover all hosts using scapy" )
319 main.step( "Send packets from each host to the first host and confirm onos discovery" )
320
321 import collections
322 if len( main.scapyHosts ) < 1:
323 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700324 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800325 main.skipCase()
326
327 # Send ARP packets from each scapy host component
328 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
329
330 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
331 retValue=main.FALSE, args=[ main ],
332 attempts=main.checkTopoAttempts, sleep=2 )
333
334 utilities.assert_equals( expect=main.TRUE,
335 actual=stepResult,
336 onpass="ONOS correctly discovered all hosts",
337 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700338 if not stepResult:
339 main.initialized = main.FALSE
340 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800341
342 main.step( "Populate hostsData" )
343 stepResult = main.intentFunction.populateHostData( main )
344 utilities.assert_equals( expect=main.TRUE,
345 actual=stepResult,
346 onpass="Successfully populated hostsData",
347 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700348 if not stepResult:
349 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800350
351 def CASE16( self, main ):
352 """
Jeremy42df2e72016-02-23 16:37:46 -0800353 Balance Masters
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()
Jeremy42df2e72016-02-23 16:37:46 -0800358 main.case( "Balance mastership of switches" )
359 main.step( "Balancing mastership of switches" )
360
361 balanceResult = main.FALSE
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700362 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800363
364 utilities.assert_equals( expect=main.TRUE,
365 actual=stepResult,
366 onpass="Successfully balanced mastership of switches",
367 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700368 if not stepResult:
369 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800370
371 def CASE17( self, main ):
372 """
Jeremyeb51cb12016-03-28 17:53:35 -0700373 Use Flow Objectives
374 """
Jeremydd9bda62016-04-18 12:02:32 -0700375 if main.initialized == main.FALSE:
376 main.log.error( "Test components did not start correctly, skipping further tests" )
377 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700378 main.case( "Enable intent compilation using Flow Objectives" )
379 main.step( "Enabling Flow Objectives" )
380
381 main.flowCompiler = "Flow Objectives"
382
383 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
384
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700385 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
Jeremyeb51cb12016-03-28 17:53:35 -0700386 propName="useFlowObjectives", value="true" )
You Wang106d0fa2017-05-15 17:22:15 -0700387 stepResult &= main.CLIs[ 0 ].setCfg( component=cmd,
388 propName="defaultFlowObjectiveCompiler",
Jon Hall02758ac2017-05-24 16:20:28 -0700389 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremyeb51cb12016-03-28 17:53:35 -0700390
391 utilities.assert_equals( expect=main.TRUE,
392 actual=stepResult,
393 onpass="Successfully activated Flow Objectives",
394 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700395 if not stepResult:
396 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700397
398 def CASE18( self, main ):
399 """
Jeremy2f190ca2016-01-29 15:23:57 -0800400 Stop mininet and remove scapy hosts
401 """
Devin Lim58046fa2017-07-05 16:55:00 -0700402 try:
403 from tests.dependencies.utils import Utils
404 except ImportError:
405 main.log.error( "Utils not found exiting the test" )
406 main.exit()
407 try:
408 main.Utils
409 except ( NameError, AttributeError ):
410 main.Utils = Utils()
Jeremy2f190ca2016-01-29 15:23:57 -0800411 main.log.report( "Stop Mininet and Scapy" )
412 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700413 main.caseExplanation = "Stopping the current mininet topology " +\
414 "to start up fresh"
415
Jeremy2f190ca2016-01-29 15:23:57 -0800416 main.step( "Stopping and Removing Scapy Host Components" )
417 scapyResult = main.TRUE
418 for host in main.scapyHosts:
419 scapyResult = scapyResult and host.stopScapy()
420 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
421
422 for host in main.scapyHosts:
423 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
424 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
425
426 main.scapyHosts = []
427 main.scapyHostIPs = []
428
429 utilities.assert_equals( expect=main.TRUE,
430 actual=scapyResult,
431 onpass="Successfully stopped scapy and removed host components",
432 onfail="Failed to stop mininet and scapy" )
433
Devin Lim58046fa2017-07-05 16:55:00 -0700434 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlab44147802015-07-27 17:57:31 -0700435 # Exit if topology did not load properly
Jon Hall02758ac2017-05-24 16:20:28 -0700436 if not ( mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700437 main.cleanup()
438 main.exit()
439
Jeremy Songster17147f22016-05-31 18:30:52 -0700440 def CASE19( self, main ):
441 """
442 Copy the karaf.log files after each testcase cycle
443 """
Devin Lim58046fa2017-07-05 16:55:00 -0700444 try:
445 from tests.dependencies.utils import Utils
446 except ImportError:
447 main.log.error( "Utils not found exiting the test" )
448 main.exit()
449 try:
450 main.Utils
451 except ( NameError, AttributeError ):
452 main.Utils = Utils()
453 main.Utils.copyKarafLog()
kelvin-onlab44147802015-07-27 17:57:31 -0700454 def CASE1000( self, main ):
455 """
456 Add host intents between 2 host:
457 - Discover hosts
458 - Add host intents
459 - Check intents
460 - Verify flows
461 - Ping hosts
462 - Reroute
463 - Link down
464 - Verify flows
465 - Check topology
466 - Ping hosts
467 - Link up
468 - Verify flows
469 - Check topology
470 - Ping hosts
471 - Remove intents
472 """
473 import time
474 import json
475 import re
Jeremydd9bda62016-04-18 12:02:32 -0700476 if main.initialized == main.FALSE:
477 main.log.error( "Test components did not start correctly, skipping further tests" )
478 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700479 # Assert variables - These variable's name|format must be followed
480 # if you want to use the wrapper function
481 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700482 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700483 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -0700484 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700485 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -0700486 main.initialized = main.FALSE
487 main.skipCase()
488 try:
489 assert main.Mininet1
490 except AssertionError:
491 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
492 main.initialized = main.FALSE
493 main.skipCase()
494 try:
495 assert main.numSwitch
496 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700497 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700498 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700499 main.initialized = main.FALSE
500 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700501
Jeremye1ea0602016-02-08 16:35:05 -0800502 # Save leader candidates
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700503 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800504
kelvin-onlab44147802015-07-27 17:57:31 -0700505 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700506 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700507 main.caseExplanation = "This test case tests Host intents using " +\
508 str( main.numCtrls ) + " node(s) cluster;\n" +\
509 "Different type of hosts will be tested in " +\
510 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700511 "etc;\nThe test will use OF " + main.OFProtocol +\
512 " OVS running in Mininet and compile intents" +\
513 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700514
Jeremy2f190ca2016-01-29 15:23:57 -0800515 main.step( "IPV4: Add and test host intents between h1 and h9" )
516 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700517 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
518 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800519 testResult = main.FALSE
520 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700521 name='IPV4',
522 onosNode='0',
523 host1=host1,
524 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800525
526 if installResult:
527 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700528 name='IPV4',
529 intentId=installResult,
530 onosNode='0',
531 host1=host1,
532 host2=host2,
533 sw1='s5',
534 sw2='s2',
535 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700536
537 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800538 actual=testResult,
539 onpass=main.assertReturnString,
540 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700541
542 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800543 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700544 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
545 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800546 testResult = main.FALSE
547 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700548 name='DUALSTACK1',
549 onosNode='0',
550 host1=host1,
551 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800552
553 if installResult:
554 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700555 name='DUALSTACK1',
556 intentId=installResult,
557 onosNode='0',
558 host1=host1,
559 host2=host2,
560 sw1='s5',
561 sw2='s2',
562 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700563
564 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800565 actual=testResult,
566 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700567 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700568
569 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800570 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700571 host1 = { "name": "h1" }
572 host2 = { "name": "h11" }
Jeremy2f190ca2016-01-29 15:23:57 -0800573 testResult = main.FALSE
574 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700575 name='DUALSTACK2',
576 onosNode='0',
577 host1=host1,
578 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800579
580 if installResult:
581 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700582 name='DUALSTACK2',
583 intentId=installResult,
584 onosNode='0',
585 host1=host1,
586 host2=host2,
587 sw1='s5',
588 sw2='s2',
589 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700590
591 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800592 actual=testResult,
593 onpass=main.assertReturnString,
594 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700595
596 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800597 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700598 host1 = { "name": "h1" }
599 host2 = { "name": "h3" }
Jeremy2f190ca2016-01-29 15:23:57 -0800600 testResult = main.FALSE
601 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700602 name='1HOP',
603 onosNode='0',
604 host1=host1,
605 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700606
Jeremy2f190ca2016-01-29 15:23:57 -0800607 if installResult:
608 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700609 name='1HOP',
610 intentId=installResult,
611 onosNode='0',
612 host1=host1,
613 host2=host2,
614 sw1='s5',
615 sw2='s2',
616 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700617
618 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800619 actual=testResult,
620 onpass=main.assertReturnString,
621 onfail=main.assertReturnString )
622
623 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
624 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700625 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" }
626 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800627 testResult = main.FALSE
628 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700629 name='VLAN1',
630 onosNode='0',
631 host1=host1,
632 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800633
634 if installResult:
635 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700636 name='VLAN1',
637 intentId=installResult,
638 onosNode='0',
639 host1=host1,
640 host2=host2,
641 sw1='s5',
642 sw2='s2',
643 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -0800644
645 utilities.assert_equals( expect=main.TRUE,
646 actual=testResult,
647 onpass=main.assertReturnString,
648 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700649
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700650 # This step isn't currently possible to perform in the REST API
651 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
652 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
653 # host1 = { "name":"h13" }
654 # host2 = { "name":"h20" }
655 # testResult = main.FALSE
656 # installResult = main.intentFunction.installHostIntent( main,
657 # name='VLAN2',
658 # onosNode='0',
659 # host1=host1,
660 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700661
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700662 # if installResult:
663 # testResult = main.intentFunction.testHostIntent( main,
664 # name='VLAN2',
Jon Hall02758ac2017-05-24 16:20:28 -0700665 # intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700666 # onosNode='0',
667 # host1=host1,
668 # host2=host2,
669 # sw1='s5',
670 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700671 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700672
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700673 # utilities.assert_equals( expect=main.TRUE,
674 # actual=testResult,
675 # onpass=main.assertReturnString,
676 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -0800677
Jeremye1ea0602016-02-08 16:35:05 -0800678 # Change the following to use the REST API when leader checking is
679 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -0800680
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700681 main.step( "Confirm that ONOS leadership is unchanged" )
682 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800683 main.intentFunction.checkLeaderChange( intentLeadersOld,
684 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -0800685
Jeremye1ea0602016-02-08 16:35:05 -0800686 utilities.assert_equals( expect=main.TRUE,
687 actual=testResult,
688 onpass="ONOS Leaders Unchanged",
Jon Hall02758ac2017-05-24 16:20:28 -0700689 onfail="ONOS Leader Mismatch" )
Jeremy2f190ca2016-01-29 15:23:57 -0800690
691 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -0700692
693 def CASE2000( self, main ):
694 """
695 Add point intents between 2 hosts:
696 - Get device ids | ports
697 - Add point intents
698 - Check intents
699 - Verify flows
700 - Ping hosts
701 - Reroute
702 - Link down
703 - Verify flows
704 - Check topology
705 - Ping hosts
706 - Link up
707 - Verify flows
708 - Check topology
709 - Ping hosts
710 - Remove intents
711 """
Jeremydd9bda62016-04-18 12:02:32 -0700712 if main.initialized == main.FALSE:
713 main.log.error( "Test components did not start correctly, skipping further tests" )
714 main.skipCase()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700715 # Assert variables - These variable's name|format must be followed
716 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -0700717 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700718 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700719 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -0700720 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700721 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -0700722 main.initialized = main.FALSE
723 main.skipCase()
724 try:
725 assert main.Mininet1
726 except AssertionError:
727 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
728 main.initialized = main.FALSE
729 main.skipCase()
730 try:
731 assert main.numSwitch
732 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700733 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700734 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700735 main.initialized = main.FALSE
736 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700737
738 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -0700739 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700740 main.caseExplanation = "This test case will test point to point" + \
741 " intents using " + str( main.numCtrls ) + \
742 " node(s) cluster;\n" + \
743 "Different type of hosts will be tested in " + \
744 "each step such as IPV4, Dual stack, VLAN etc" + \
745 ";\nThe test will use OF " + main.OFProtocol + \
746 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -0700747 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700748
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700749 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -0700750 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800751 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
752 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700753 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800754 ]
755 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700756 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800757 ]
758 testResult = main.FALSE
759 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700760 main,
761 name="NOOPTION",
762 senders=senders,
763 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800764
765 if installResult:
766 testResult = main.intentFunction.testPointIntent(
767 main,
768 intentId=installResult,
769 name="NOOPTION",
770 senders=senders,
771 recipients=recipients,
772 sw1="s5",
773 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700774 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700775
776 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800777 actual=testResult,
778 onpass=main.assertReturnString,
779 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700780
kelvin-onlab44147802015-07-27 17:57:31 -0700781 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800782 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
783 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700784 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -0800785 ]
786 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700787 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -0800788 ]
789 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700790 main,
791 name="IPV4",
792 senders=senders,
793 recipients=recipients,
794 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800795
796 if installResult:
797 testResult = main.intentFunction.testPointIntent(
798 main,
799 intentId=installResult,
800 name="IPV4",
801 senders=senders,
802 recipients=recipients,
803 sw1="s5",
804 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700805 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700806
807 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800808 actual=testResult,
809 onpass=main.assertReturnString,
810 onfail=main.assertReturnString )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700811
alisonda157272016-12-22 01:13:21 -0800812 # main.step( "Protected: Add point intents between h1 and h9" )
813 # main.assertReturnString = "Assertion Result for protected point intent\n"
814 # senders = [
815 # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
816 # ]
817 # recipients = [
818 # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
819 # ]
820 # testResult = main.FALSE
821 # installResult = main.intentFunction.installPointIntent(
822 # main,
823 # name="Protected",
824 # senders=senders,
825 # recipients=recipients,
826 # protected=True )
Jon Hall02758ac2017-05-24 16:20:28 -0700827 #
alisonda157272016-12-22 01:13:21 -0800828 # if installResult:
829 # testResult = main.intentFunction.testPointIntent(
830 # main,
831 # name="Protected",
832 # intentId=installResult,
833 # senders=senders,
834 # recipients=recipients,
835 # sw1="s5",
836 # sw2="s2",
837 # protected=True,
838 # expectedLink=18 )
839 #
840 # utilities.assert_equals( expect=main.TRUE,
841 # actual=testResult,
842 # onpass=main.assertReturnString,
843 # onfail=main.assertReturnString )
844
kelvin-onlab44147802015-07-27 17:57:31 -0700845 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800846 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
847 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700848 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800849 ]
850 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700851 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800852 ]
853 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700854 main,
855 name="IPV4_2",
856 senders=senders,
857 recipients=recipients,
858 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800859
860 if installResult:
861 testResult = main.intentFunction.testPointIntent(
862 main,
863 intentId=installResult,
864 name="IPV4_2",
865 senders=senders,
866 recipients=recipients,
867 sw1="s5",
868 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700869 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700870
871 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800872 actual=testResult,
873 onpass=main.assertReturnString,
874 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700875
kelvin-onlab0e684682015-08-11 18:51:41 -0700876 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800877 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
878 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700879 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
880 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800881 ]
882 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700883 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
884 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800885 ]
Jon Hall02758ac2017-05-24 16:20:28 -0700886 # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700887 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700888 # Uneccessary, not including this in the selectors
Jon Hall02758ac2017-05-24 16:20:28 -0700889 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
890 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700891
Jeremy2f190ca2016-01-29 15:23:57 -0800892 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700893 main,
894 name="SDNIP-ICMP",
895 senders=senders,
896 recipients=recipients,
897 ethType="IPV4",
898 ipProto=ipProto,
899 tcpSrc=tcpSrc,
900 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -0800901
902 if installResult:
903 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700904 main,
905 intentId=installResult,
906 name="SDNIP_ICMP",
907 senders=senders,
908 recipients=recipients,
909 sw1="s5",
910 sw2="s2",
911 expectedLink=18,
912 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -0700913
914 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800915 actual=testResult,
916 onpass=main.assertReturnString,
917 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700918
kelvin-onlab0e684682015-08-11 18:51:41 -0700919 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800920 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700921 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
922 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
923 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
924 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
925 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
926 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
927 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700928
kelvin-onlab0e684682015-08-11 18:51:41 -0700929 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700930 main,
931 name="SDNIP-TCP",
932 host1="h1",
933 host2="h9",
934 deviceId1="of:0000000000000005/1",
935 deviceId2="of:0000000000000006/1",
936 mac1=mac1,
937 mac2=mac2,
938 ethType="IPV4",
939 ipProto=ipProto,
940 ip1=ip1,
941 ip2=ip2,
942 tcp1=tcp1,
943 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700944
945 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700946 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -0800947 onpass=main.assertReturnString,
948 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700949
Jeremy2f190ca2016-01-29 15:23:57 -0800950 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
951 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
952 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700953 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -0800954 ]
955 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700956 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -0800957 ]
958 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700959 main,
960 name="DUALSTACK1",
961 senders=senders,
962 recipients=recipients,
963 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800964
965 if installResult:
966 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700967 main,
968 intentId=installResult,
969 name="DUALSTACK1",
970 senders=senders,
971 recipients=recipients,
972 sw1="s5",
973 sw2="s2",
974 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700975
976 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800977 actual=testResult,
978 onpass=main.assertReturnString,
979 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700980
981 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -0800982 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
983 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700984 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800985 ]
986 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700987 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800988 ]
989 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700990 main,
991 name="VLAN",
992 senders=senders,
993 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800994
995 if installResult:
996 testResult = main.intentFunction.testPointIntent(
997 main,
998 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700999 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001000 senders=senders,
1001 recipients=recipients,
1002 sw1="s5",
1003 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001004 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001005
1006 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001007 actual=testResult,
1008 onpass=main.assertReturnString,
1009 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001010
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001011 # TODO: implement VLAN selector REST API intent test once supported
1012
kelvin-onlab44147802015-07-27 17:57:31 -07001013 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001014 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1015 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001016 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001017 ]
1018 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001019 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001020 ]
1021 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001022 main,
1023 name="1HOP IPV4",
1024 senders=senders,
1025 recipients=recipients,
1026 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001027
1028 if installResult:
1029 testResult = main.intentFunction.testPointIntent(
1030 main,
1031 intentId=installResult,
1032 name="1HOP IPV4",
1033 senders=senders,
1034 recipients=recipients,
1035 sw1="s5",
1036 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001037 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001038
1039 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001040 actual=testResult,
1041 onpass=main.assertReturnString,
1042 onfail=main.assertReturnString )
1043
1044 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001045
1046 def CASE3000( self, main ):
1047 """
1048 Add single point to multi point intents
1049 - Get device ids
1050 - Add single point to multi point intents
1051 - Check intents
1052 - Verify flows
1053 - Ping hosts
1054 - Reroute
1055 - Link down
1056 - Verify flows
1057 - Check topology
1058 - Ping hosts
1059 - Link up
1060 - Verify flows
1061 - Check topology
1062 - Ping hosts
1063 - Remove intents
1064 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001065 if main.initialized == main.FALSE:
1066 main.log.error( "Test components did not start correctly, skipping further tests" )
1067 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001068 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001069
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001070 try:
1071 assert main.CLIs, "There is no main.CLIs, skipping test cases"
1072 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1073 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1074 except AssertionError:
1075 main.initialized = main.FALSE
1076 main.skipCase()
1077
1078 main.testName = "Single to Multi Point Intents"
1079 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001080 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001081 main.caseExplanation = "This test case will test single point to" + \
1082 " multi point intents using " + \
1083 str( main.numCtrls ) + " node(s) cluster;\n" + \
1084 "Different type of hosts will be tested in " + \
1085 "each step such as IPV4, Dual stack, VLAN etc" + \
1086 ";\nThe test will use OF " + main.OFProtocol + \
1087 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001088 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001089
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001090 main.step( "NOOPTION: Install and test single point to multi point intents" )
1091 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1092 senders = [
1093 { "name": "h8", "device": "of:0000000000000005/8" }
1094 ]
1095 recipients = [
1096 { "name": "h16", "device": "of:0000000000000006/8" },
1097 { "name": "h24", "device": "of:0000000000000007/8" }
1098 ]
1099 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1100 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1101 testResult = main.FALSE
1102 installResult = main.intentFunction.installSingleToMultiIntent(
1103 main,
1104 name="NOOPTION",
1105 senders=senders,
1106 recipients=recipients )
1107
1108 if installResult:
1109 testResult = main.intentFunction.testPointIntent(
1110 main,
1111 intentId=installResult,
1112 name="NOOPTION",
1113 senders=senders,
1114 recipients=recipients,
1115 badSenders=badSenders,
1116 badRecipients=badRecipients,
1117 sw1="s5",
1118 sw2="s2",
1119 expectedLink=18 )
1120 else:
1121 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001122
1123 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001124 actual=testResult,
1125 onpass=main.assertReturnString,
1126 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001127
Jon Hall02758ac2017-05-24 16:20:28 -07001128 main.step( "IPV4: Install and test single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001129 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1130 "with IPV4 type and MAC addresses\n"
1131 senders = [
Jon Hall02758ac2017-05-24 16:20:28 -07001132 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001133 ]
1134 recipients = [
Jon Hall02758ac2017-05-24 16:20:28 -07001135 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1136 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001137 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001138 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1139 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001140 installResult = main.intentFunction.installSingleToMultiIntent(
1141 main,
1142 name="IPV4",
1143 senders=senders,
1144 recipients=recipients,
Jon Hall02758ac2017-05-24 16:20:28 -07001145 ethType="IPV4" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001146
1147 if installResult:
1148 testResult = main.intentFunction.testPointIntent(
1149 main,
1150 intentId=installResult,
1151 name="IPV4",
1152 senders=senders,
1153 recipients=recipients,
1154 badSenders=badSenders,
1155 badRecipients=badRecipients,
1156 sw1="s5",
1157 sw2="s2",
1158 expectedLink=18 )
1159 else:
1160 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001161
1162 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001163 actual=testResult,
1164 onpass=main.assertReturnString,
1165 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001166
1167 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001168 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1169 "with IPV4 type and no MAC addresses\n"
1170 senders = [
1171 { "name": "h8", "device": "of:0000000000000005/8" }
1172 ]
1173 recipients = [
1174 { "name": "h16", "device": "of:0000000000000006/8" },
1175 { "name": "h24", "device": "of:0000000000000007/8" }
1176 ]
1177 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1178 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1179 installResult = main.intentFunction.installSingleToMultiIntent(
1180 main,
1181 name="IPV4_2",
1182 senders=senders,
1183 recipients=recipients,
1184 ethType="IPV4" )
1185
1186 if installResult:
1187 testResult = main.intentFunction.testPointIntent(
1188 main,
1189 intentId=installResult,
1190 name="IPV4_2",
1191 senders=senders,
1192 recipients=recipients,
1193 badSenders=badSenders,
1194 badRecipients=badRecipients,
1195 sw1="s5",
1196 sw2="s2",
1197 expectedLink=18 )
1198 else:
1199 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001200
1201 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001202 actual=testResult,
1203 onpass=main.assertReturnString,
1204 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001205
1206 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001207 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1208 "and MAC addresses in the same VLAN\n"
1209 senders = [
1210 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1211 ]
1212 recipients = [
1213 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1214 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1215 ]
1216 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1217 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1218 installResult = main.intentFunction.installSingleToMultiIntent(
1219 main,
1220 name="VLAN",
1221 senders=senders,
1222 recipients=recipients,
1223 sw1="s5",
1224 sw2="s2" )
1225
1226 if installResult:
1227 testResult = main.intentFunction.testPointIntent(
1228 main,
1229 intentId=installResult,
1230 name="VLAN",
1231 senders=senders,
1232 recipients=recipients,
1233 badSenders=badSenders,
1234 badRecipients=badRecipients,
1235 sw1="s5",
1236 sw2="s2",
1237 expectedLink=18 )
1238 else:
1239 main.CLIs[ 0 ].removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001240
1241 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001242 actual=testResult,
1243 onpass=main.assertReturnString,
1244 onfail=main.assertReturnString )
1245
1246 main.step( "VLAN: Add single point to multi point intents" )
1247 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1248 senders = [
1249 { "name": "h5", "vlan": "200" }
1250 ]
1251 recipients = [
1252 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1253 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1254 ]
1255 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1256 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1257 testResult = main.FALSE
1258 installResult = main.intentFunction.installSingleToMultiIntent(
1259 main,
1260 name="VLAN2",
1261 senders=senders,
1262 recipients=recipients,
1263 sw1="s5",
1264 sw2="s2" )
Jon Hall02758ac2017-05-24 16:20:28 -07001265 #setVlan=100 )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001266
1267 if installResult:
1268 testResult = main.intentFunction.testPointIntent(
1269 main,
1270 intentId=installResult,
1271 name="VLAN2",
1272 senders=senders,
1273 recipients=recipients,
1274 badSenders=badSenders,
1275 badRecipients=badRecipients,
1276 sw1="s5",
1277 sw2="s2",
1278 expectedLink=18 )
1279 else:
1280 main.CLIs[ 0 ].removeAllIntents()
1281
1282 utilities.assert_equals( expect=main.TRUE,
1283 actual=testResult,
1284 onpass=main.assertReturnString,
1285 onfail=main.assertReturnString )
1286
1287 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001288
1289 def CASE4000( self, main ):
1290 """
1291 Add multi point to single point intents
1292 - Get device ids
1293 - Add multi point to single point intents
1294 - Check intents
1295 - Verify flows
1296 - Ping hosts
1297 - Reroute
1298 - Link down
1299 - Verify flows
1300 - Check topology
1301 - Ping hosts
1302 - Link up
1303 - Verify flows
1304 - Check topology
1305 - Ping hosts
1306 - Remove intents
1307 """
1308 assert main, "There is no main"
1309 assert main.CLIs, "There is no main.CLIs"
1310 assert main.Mininet1, "Mininet handle should be named Mininet1"
1311 assert main.numSwitch, "Placed the total number of switch topology in \
1312 main.numSwitch"
1313
1314 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001315 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001316 main.caseExplanation = "This test case will test single point to" +\
1317 " multi point intents using " +\
1318 str( main.numCtrls ) + " node(s) cluster;\n" +\
1319 "Different type of hosts will be tested in " +\
1320 "each step such as IPV4, Dual stack, VLAN etc" +\
1321 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001322 " OVS running in Mininet and compile intents" +\
1323 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001324
1325 main.step( "NOOPTION: Add multi point to single point intents" )
1326 stepResult = main.TRUE
1327 hostNames = [ 'h8', 'h16', 'h24' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001328 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8',
kelvin-onlab44147802015-07-27 17:57:31 -07001329 'of:0000000000000007/8' ]
1330 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1331 stepResult = main.intentFunction.multiToSingleIntent(
1332 main,
1333 name="NOOPTION",
1334 hostNames=hostNames,
1335 devices=devices,
1336 sw1="s5",
1337 sw2="s2",
1338 expectedLink=18 )
1339
1340 utilities.assert_equals( expect=main.TRUE,
1341 actual=stepResult,
1342 onpass="NOOPTION: Successfully added multi "
1343 + " point to single point intents" +
1344 " with no match action",
1345 onfail="NOOPTION: Failed to add multi point" +
1346 " to single point intents" +
1347 " with no match action" )
1348
1349 main.step( "IPV4: Add multi point to single point intents" )
1350 stepResult = main.TRUE
1351 stepResult = main.intentFunction.multiToSingleIntent(
1352 main,
1353 name="IPV4",
1354 hostNames=hostNames,
1355 devices=devices,
1356 ports=None,
1357 ethType="IPV4",
1358 macs=macs,
1359 bandwidth="",
1360 lambdaAlloc=False,
1361 ipProto="",
1362 ipAddresses="",
1363 tcp="",
1364 sw1="s5",
1365 sw2="s2",
1366 expectedLink=18 )
1367
1368 utilities.assert_equals( expect=main.TRUE,
1369 actual=stepResult,
1370 onpass="IPV4: Successfully added multi point"
1371 + " to single point intents" +
1372 " with IPV4 type and MAC addresses",
1373 onfail="IPV4: Failed to add multi point" +
1374 " to single point intents" +
1375 " with IPV4 type and MAC addresses" )
1376
1377 main.step( "IPV4_2: Add multi point to single point intents" )
1378 stepResult = main.TRUE
1379 hostNames = [ 'h8', 'h16', 'h24' ]
1380 stepResult = main.intentFunction.multiToSingleIntent(
1381 main,
1382 name="IPV4",
1383 hostNames=hostNames,
1384 ethType="IPV4",
1385 lambdaAlloc=False )
1386
1387 utilities.assert_equals( expect=main.TRUE,
1388 actual=stepResult,
1389 onpass="IPV4_2: Successfully added multi point"
1390 + " to single point intents" +
1391 " with IPV4 type and no MAC addresses",
1392 onfail="IPV4_2: Failed to add multi point" +
1393 " to single point intents" +
1394 " with IPV4 type and no MAC addresses" )
1395
1396 main.step( "VLAN: Add multi point to single point intents" )
1397 stepResult = main.TRUE
1398 hostNames = [ 'h5', 'h13', 'h21' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001399 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5',
kelvin-onlab44147802015-07-27 17:57:31 -07001400 'of:0000000000000007/5' ]
1401 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1402 stepResult = main.intentFunction.multiToSingleIntent(
1403 main,
1404 name="VLAN",
1405 hostNames=hostNames,
1406 devices=devices,
1407 ports=None,
1408 ethType="IPV4",
1409 macs=macs,
1410 bandwidth="",
1411 lambdaAlloc=False,
1412 ipProto="",
1413 ipAddresses="",
1414 tcp="",
1415 sw1="s5",
1416 sw2="s2",
1417 expectedLink=18 )
1418
1419 utilities.assert_equals( expect=main.TRUE,
1420 actual=stepResult,
1421 onpass="VLAN: Successfully added multi point"
1422 + " to single point intents" +
1423 " with IPV4 type and MAC addresses" +
1424 " in the same VLAN",
1425 onfail="VLAN: Failed to add multi point" +
1426 " to single point intents" )
1427
1428 def CASE5000( self, main ):
1429 """
Jeremy2f190ca2016-01-29 15:23:57 -08001430 Tests Host Mobility
1431 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001432 """
Jeremydd9bda62016-04-18 12:02:32 -07001433 if main.initialized == main.FALSE:
1434 main.log.error( "Test components did not start correctly, skipping further tests" )
1435 main.skipCase()
1436 # Assert variables - These variable's name|format must be followed
1437 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001438 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001439 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001440 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001441 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001442 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001443 main.initialized = main.FALSE
1444 main.skipCase()
1445 try:
1446 assert main.Mininet1
1447 except AssertionError:
1448 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1449 main.initialized = main.FALSE
1450 main.skipCase()
1451 try:
1452 assert main.numSwitch
1453 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001454 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001455 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001456 main.initialized = main.FALSE
1457 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001458 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001459 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001460 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1461
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001462 main.log.info( "Moving h1 from s5 to s6" )
1463 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001464
Jeremy2f190ca2016-01-29 15:23:57 -08001465 # Send discovery ping from moved host
1466 # Moving the host brings down the default interfaces and creates a new one.
1467 # Scapy is restarted on this host to detect the new interface
1468 main.h1.stopScapy()
1469 main.h1.startScapy()
1470
1471 # Discover new host location in ONOS and populate host data.
1472 # Host 1 IP and MAC should be unchanged
1473 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1474 main.intentFunction.populateHostData( main )
1475
kelvin-onlab44147802015-07-27 17:57:31 -07001476 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1477
1478 utilities.assert_equals( expect="of:0000000000000006",
1479 actual=h1PostMove,
1480 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001481 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001482 " to single point intents" +
1483 " with IPV4 type and MAC addresses" +
1484 " in the same VLAN" )
1485
1486 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001487 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001488 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1489 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001490
1491 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001492 name='IPV4 Mobility IPV4',
1493 onosNode='0',
1494 host1=host1,
1495 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001496 if installResult:
1497 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001498 name='Host Mobility IPV4',
1499 intentId=installResult,
1500 onosNode='0',
1501 host1=host1,
1502 host2=host2,
1503 sw1="s6",
1504 sw2="s2",
1505 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001506
1507 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001508 actual=testResult,
1509 onpass=main.assertReturnString,
1510 onfail=main.assertReturnString )
1511
Jon Hallbd60ea02016-08-23 10:03:59 -07001512 main.intentFunction.report( main )