blob: 03ab601594e440df5b5259c8c7759dab406cb52a [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 Lim142b5342017-07-20 15:22:39 -070098 stepResult = main.testSetUp.envSetup()
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 Lim142b5342017-07-20 15:22:39 -0700116 main.initialized = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, 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" )
Devin Lim142b5342017-07-20 15:22:39 -0700136 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
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
Devin Lim142b5342017-07-20 15:22:39 -0700218 tempONOSip = main.Cluster.getIps()
kelvin-onlab44147802015-07-27 17:57:31 -0700219
220 assignResult = main.Mininet1.assignSwController( sw=switchList,
221 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800222 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700223 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700224 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
225 main.initialized = main.FALSE
226 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700227
228 for i in range( 1, ( main.numSwitch + 1 ) ):
229 response = main.Mininet1.getSwController( "s" + str( i ) )
230 print( "Response is " + str( response ) )
Devin Lim142b5342017-07-20 15:22:39 -0700231 if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ):
kelvin-onlab44147802015-07-27 17:57:31 -0700232 assignResult = assignResult and main.TRUE
233 else:
234 assignResult = main.FALSE
235 stepResult = assignResult
236 utilities.assert_equals( expect=main.TRUE,
237 actual=stepResult,
238 onpass="Successfully assigned switches" +
239 "to controller",
240 onfail="Failed to assign switches to " +
241 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700242 if not stepResult:
243 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800244
Jon Hall02758ac2017-05-24 16:20:28 -0700245 def CASE13( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800246 """
247 Create Scapy components
248 """
Jeremydd9bda62016-04-18 12:02:32 -0700249 if main.initialized == main.FALSE:
250 main.log.error( "Test components did not start correctly, skipping further tests" )
251 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800252 main.case( "Create scapy components" )
253 main.step( "Create scapy components" )
254 import json
255 scapyResult = main.TRUE
256 for hostName in main.scapyHostNames:
257 main.Scapy1.createHostComponent( hostName )
258 main.scapyHosts.append( getattr( main, hostName ) )
259
260 main.step( "Start scapy components" )
261 for host in main.scapyHosts:
262 host.startHostCli()
263 host.startScapy()
264 host.updateSelf()
265 main.log.debug( host.name )
266 main.log.debug( host.hostIp )
267 main.log.debug( host.hostMac )
268
Jeremy2f190ca2016-01-29 15:23:57 -0800269 utilities.assert_equals( expect=main.TRUE,
270 actual=scapyResult,
271 onpass="Successfully created Scapy Components",
272 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700273 if not scapyResult:
274 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800275
276 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700277 """
278 Discover all hosts and store its data to a dictionary
279 """
Jeremydd9bda62016-04-18 12:02:32 -0700280 if main.initialized == main.FALSE:
281 main.log.error( "Test components did not start correctly, skipping further tests" )
282 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700283 main.case( "Discover all hosts" )
284
285 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700286 main.step( "Discover all ipv4 host hosts " )
287 hostList = []
288 # List of host with default vlan
289 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
290 # Lists of host with unique vlan
291 vlanHosts1 = [ "h4", "h12", "h20" ]
292 vlanHosts2 = [ "h5", "h13", "h21" ]
293 vlanHosts3 = [ "h6", "h14", "h22" ]
294 vlanHosts4 = [ "h7", "h15", "h23" ]
295 hostList.append( defaultHosts )
296 hostList.append( vlanHosts1 )
297 hostList.append( vlanHosts2 )
298 hostList.append( vlanHosts3 )
299 hostList.append( vlanHosts4 )
300
301 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700302 utilities.assert_equals( expect=main.TRUE,
303 actual=stepResult,
304 onpass="Successfully discovered hosts",
305 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700306 if not stepResult:
307 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700308
Jeremy2f190ca2016-01-29 15:23:57 -0800309 def CASE15( self, main ):
Devin Lim58046fa2017-07-05 16:55:00 -0700310 """main.topo.
Jeremy2f190ca2016-01-29 15:23:57 -0800311 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700312 """
Jeremydd9bda62016-04-18 12:02:32 -0700313 if main.initialized == main.FALSE:
314 main.log.error( "Test components did not start correctly, skipping further tests" )
315 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800316 main.case( "Discover all hosts using scapy" )
317 main.step( "Send packets from each host to the first host and confirm onos discovery" )
318
319 import collections
320 if len( main.scapyHosts ) < 1:
321 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700322 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800323 main.skipCase()
324
325 # Send ARP packets from each scapy host component
326 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
327
328 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
329 retValue=main.FALSE, args=[ main ],
330 attempts=main.checkTopoAttempts, sleep=2 )
331
332 utilities.assert_equals( expect=main.TRUE,
333 actual=stepResult,
334 onpass="ONOS correctly discovered all hosts",
335 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700336 if not stepResult:
337 main.initialized = main.FALSE
338 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800339
340 main.step( "Populate hostsData" )
341 stepResult = main.intentFunction.populateHostData( main )
342 utilities.assert_equals( expect=main.TRUE,
343 actual=stepResult,
344 onpass="Successfully populated hostsData",
345 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700346 if not stepResult:
347 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800348
349 def CASE16( self, main ):
350 """
Jeremy42df2e72016-02-23 16:37:46 -0800351 Balance Masters
352 """
Jeremydd9bda62016-04-18 12:02:32 -0700353 if main.initialized == main.FALSE:
354 main.log.error( "Test components did not start correctly, skipping further tests" )
355 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800356 main.case( "Balance mastership of switches" )
357 main.step( "Balancing mastership of switches" )
358
359 balanceResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700360 balanceResult = utilities.retry( f=main.Cluster.active( 0 ).CLI.balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800361
362 utilities.assert_equals( expect=main.TRUE,
363 actual=stepResult,
364 onpass="Successfully balanced mastership of switches",
365 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700366 if not stepResult:
367 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800368
369 def CASE17( self, main ):
370 """
Jeremyeb51cb12016-03-28 17:53:35 -0700371 Use Flow Objectives
372 """
Jeremydd9bda62016-04-18 12:02:32 -0700373 if main.initialized == main.FALSE:
374 main.log.error( "Test components did not start correctly, skipping further tests" )
375 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700376 main.case( "Enable intent compilation using Flow Objectives" )
377 main.step( "Enabling Flow Objectives" )
378
379 main.flowCompiler = "Flow Objectives"
380
381 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
382
Devin Lim142b5342017-07-20 15:22:39 -0700383 stepResult = main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremyeb51cb12016-03-28 17:53:35 -0700384 propName="useFlowObjectives", value="true" )
Devin Lim142b5342017-07-20 15:22:39 -0700385 stepResult &= main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
You Wang106d0fa2017-05-15 17:22:15 -0700386 propName="defaultFlowObjectiveCompiler",
Jon Hall02758ac2017-05-24 16:20:28 -0700387 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremyeb51cb12016-03-28 17:53:35 -0700388
389 utilities.assert_equals( expect=main.TRUE,
390 actual=stepResult,
391 onpass="Successfully activated Flow Objectives",
392 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700393 if not stepResult:
394 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700395
396 def CASE18( self, main ):
397 """
Jeremy2f190ca2016-01-29 15:23:57 -0800398 Stop mininet and remove scapy hosts
399 """
Devin Lim58046fa2017-07-05 16:55:00 -0700400 try:
401 from tests.dependencies.utils import Utils
402 except ImportError:
403 main.log.error( "Utils not found exiting the test" )
404 main.exit()
405 try:
406 main.Utils
407 except ( NameError, AttributeError ):
408 main.Utils = Utils()
Jeremy2f190ca2016-01-29 15:23:57 -0800409 main.log.report( "Stop Mininet and Scapy" )
410 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700411 main.caseExplanation = "Stopping the current mininet topology " +\
412 "to start up fresh"
413
Jeremy2f190ca2016-01-29 15:23:57 -0800414 main.step( "Stopping and Removing Scapy Host Components" )
415 scapyResult = main.TRUE
416 for host in main.scapyHosts:
417 scapyResult = scapyResult and host.stopScapy()
418 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
419
420 for host in main.scapyHosts:
421 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
422 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
423
424 main.scapyHosts = []
425 main.scapyHostIPs = []
426
427 utilities.assert_equals( expect=main.TRUE,
428 actual=scapyResult,
429 onpass="Successfully stopped scapy and removed host components",
430 onfail="Failed to stop mininet and scapy" )
431
Devin Lim58046fa2017-07-05 16:55:00 -0700432 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlab44147802015-07-27 17:57:31 -0700433 # Exit if topology did not load properly
Jon Hall02758ac2017-05-24 16:20:28 -0700434 if not ( mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700435 main.cleanup()
436 main.exit()
437
Jeremy Songster17147f22016-05-31 18:30:52 -0700438 def CASE19( self, main ):
439 """
440 Copy the karaf.log files after each testcase cycle
441 """
Devin Lim58046fa2017-07-05 16:55:00 -0700442 try:
443 from tests.dependencies.utils import Utils
444 except ImportError:
445 main.log.error( "Utils not found exiting the test" )
446 main.exit()
447 try:
448 main.Utils
449 except ( NameError, AttributeError ):
450 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700451 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
kelvin-onlab44147802015-07-27 17:57:31 -0700452 def CASE1000( self, main ):
453 """
454 Add host intents between 2 host:
455 - Discover hosts
456 - Add host intents
457 - Check intents
458 - Verify flows
459 - Ping hosts
460 - Reroute
461 - Link down
462 - Verify flows
463 - Check topology
464 - Ping hosts
465 - Link up
466 - Verify flows
467 - Check topology
468 - Ping hosts
469 - Remove intents
470 """
471 import time
472 import json
473 import re
Jeremydd9bda62016-04-18 12:02:32 -0700474 if main.initialized == main.FALSE:
475 main.log.error( "Test components did not start correctly, skipping further tests" )
476 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700477 # Assert variables - These variable's name|format must be followed
478 # if you want to use the wrapper function
479 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700480 try:
Jeremydd9bda62016-04-18 12:02:32 -0700481 assert main.Mininet1
482 except AssertionError:
483 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
484 main.initialized = main.FALSE
485 main.skipCase()
486 try:
487 assert main.numSwitch
488 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700489 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700490 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700491 main.initialized = main.FALSE
492 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700493
Jeremye1ea0602016-02-08 16:35:05 -0800494 # Save leader candidates
Devin Lim142b5342017-07-20 15:22:39 -0700495 intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800496
Devin Lim142b5342017-07-20 15:22:39 -0700497 main.case( "Host Intents Test - " + str( main.Cluster.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700498 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700499 main.caseExplanation = "This test case tests Host intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -0700500 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab44147802015-07-27 17:57:31 -0700501 "Different type of hosts will be tested in " +\
502 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700503 "etc;\nThe test will use OF " + main.OFProtocol +\
504 " OVS running in Mininet and compile intents" +\
505 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700506
Jeremy2f190ca2016-01-29 15:23:57 -0800507 main.step( "IPV4: Add and test host intents between h1 and h9" )
508 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700509 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
510 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800511 testResult = main.FALSE
512 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700513 name='IPV4',
514 onosNode='0',
515 host1=host1,
516 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800517
518 if installResult:
519 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700520 name='IPV4',
521 intentId=installResult,
522 onosNode='0',
523 host1=host1,
524 host2=host2,
525 sw1='s5',
526 sw2='s2',
527 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700528
529 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800530 actual=testResult,
531 onpass=main.assertReturnString,
532 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700533
534 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800535 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700536 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
537 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800538 testResult = main.FALSE
539 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700540 name='DUALSTACK1',
541 onosNode='0',
542 host1=host1,
543 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800544
545 if installResult:
546 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700547 name='DUALSTACK1',
548 intentId=installResult,
549 onosNode='0',
550 host1=host1,
551 host2=host2,
552 sw1='s5',
553 sw2='s2',
554 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700555
556 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800557 actual=testResult,
558 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700559 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700560
561 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800562 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700563 host1 = { "name": "h1" }
564 host2 = { "name": "h11" }
Jeremy2f190ca2016-01-29 15:23:57 -0800565 testResult = main.FALSE
566 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700567 name='DUALSTACK2',
568 onosNode='0',
569 host1=host1,
570 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800571
572 if installResult:
573 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700574 name='DUALSTACK2',
575 intentId=installResult,
576 onosNode='0',
577 host1=host1,
578 host2=host2,
579 sw1='s5',
580 sw2='s2',
581 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700582
583 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800584 actual=testResult,
585 onpass=main.assertReturnString,
586 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700587
588 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800589 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700590 host1 = { "name": "h1" }
591 host2 = { "name": "h3" }
Jeremy2f190ca2016-01-29 15:23:57 -0800592 testResult = main.FALSE
593 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700594 name='1HOP',
595 onosNode='0',
596 host1=host1,
597 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700598
Jeremy2f190ca2016-01-29 15:23:57 -0800599 if installResult:
600 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700601 name='1HOP',
602 intentId=installResult,
603 onosNode='0',
604 host1=host1,
605 host2=host2,
606 sw1='s5',
607 sw2='s2',
608 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700609
610 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800611 actual=testResult,
612 onpass=main.assertReturnString,
613 onfail=main.assertReturnString )
614
615 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
616 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700617 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" }
618 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800619 testResult = main.FALSE
620 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700621 name='VLAN1',
622 onosNode='0',
623 host1=host1,
624 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800625
626 if installResult:
627 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700628 name='VLAN1',
629 intentId=installResult,
630 onosNode='0',
631 host1=host1,
632 host2=host2,
633 sw1='s5',
634 sw2='s2',
635 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -0800636
637 utilities.assert_equals( expect=main.TRUE,
638 actual=testResult,
639 onpass=main.assertReturnString,
640 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700641
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700642 # This step isn't currently possible to perform in the REST API
643 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
644 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
645 # host1 = { "name":"h13" }
646 # host2 = { "name":"h20" }
647 # testResult = main.FALSE
648 # installResult = main.intentFunction.installHostIntent( main,
649 # name='VLAN2',
650 # onosNode='0',
651 # host1=host1,
652 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700653
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700654 # if installResult:
655 # testResult = main.intentFunction.testHostIntent( main,
656 # name='VLAN2',
Jon Hall02758ac2017-05-24 16:20:28 -0700657 # intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700658 # onosNode='0',
659 # host1=host1,
660 # host2=host2,
661 # sw1='s5',
662 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700663 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700664
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700665 # utilities.assert_equals( expect=main.TRUE,
666 # actual=testResult,
667 # onpass=main.assertReturnString,
668 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -0800669
Jeremye1ea0602016-02-08 16:35:05 -0800670 # Change the following to use the REST API when leader checking is
671 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -0800672
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700673 main.step( "Confirm that ONOS leadership is unchanged" )
Devin Lim142b5342017-07-20 15:22:39 -0700674 intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800675 main.intentFunction.checkLeaderChange( intentLeadersOld,
676 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -0800677
Jeremye1ea0602016-02-08 16:35:05 -0800678 utilities.assert_equals( expect=main.TRUE,
679 actual=testResult,
680 onpass="ONOS Leaders Unchanged",
Jon Hall02758ac2017-05-24 16:20:28 -0700681 onfail="ONOS Leader Mismatch" )
Jeremy2f190ca2016-01-29 15:23:57 -0800682
683 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -0700684
685 def CASE2000( self, main ):
686 """
687 Add point intents between 2 hosts:
688 - Get device ids | ports
689 - Add point intents
690 - Check intents
691 - Verify flows
692 - Ping hosts
693 - Reroute
694 - Link down
695 - Verify flows
696 - Check topology
697 - Ping hosts
698 - Link up
699 - Verify flows
700 - Check topology
701 - Ping hosts
702 - Remove intents
703 """
Jeremydd9bda62016-04-18 12:02:32 -0700704 if main.initialized == main.FALSE:
705 main.log.error( "Test components did not start correctly, skipping further tests" )
706 main.skipCase()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700707 # Assert variables - These variable's name|format must be followed
708 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -0700709 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700710 try:
Jeremydd9bda62016-04-18 12:02:32 -0700711 assert main.Mininet1
712 except AssertionError:
713 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
714 main.initialized = main.FALSE
715 main.skipCase()
716 try:
717 assert main.numSwitch
718 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700719 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700720 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700721 main.initialized = main.FALSE
722 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700723
Devin Lim142b5342017-07-20 15:22:39 -0700724 main.case( "Point Intents Test - " + str( main.Cluster.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -0700725 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700726 main.caseExplanation = "This test case will test point to point" + \
Devin Lim142b5342017-07-20 15:22:39 -0700727 " intents using " + str( main.Cluster.numCtrls ) + \
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700728 " node(s) cluster;\n" + \
729 "Different type of hosts will be tested in " + \
730 "each step such as IPV4, Dual stack, VLAN etc" + \
731 ";\nThe test will use OF " + main.OFProtocol + \
732 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -0700733 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700734
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700735 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -0700736 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800737 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
738 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700739 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800740 ]
741 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700742 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800743 ]
744 testResult = main.FALSE
745 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700746 main,
747 name="NOOPTION",
748 senders=senders,
749 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800750
751 if installResult:
752 testResult = main.intentFunction.testPointIntent(
753 main,
754 intentId=installResult,
755 name="NOOPTION",
756 senders=senders,
757 recipients=recipients,
758 sw1="s5",
759 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700760 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700761
762 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800763 actual=testResult,
764 onpass=main.assertReturnString,
765 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700766
kelvin-onlab44147802015-07-27 17:57:31 -0700767 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800768 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
769 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700770 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -0800771 ]
772 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700773 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -0800774 ]
775 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700776 main,
777 name="IPV4",
778 senders=senders,
779 recipients=recipients,
780 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800781
782 if installResult:
783 testResult = main.intentFunction.testPointIntent(
784 main,
785 intentId=installResult,
786 name="IPV4",
787 senders=senders,
788 recipients=recipients,
789 sw1="s5",
790 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700791 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700792
793 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800794 actual=testResult,
795 onpass=main.assertReturnString,
796 onfail=main.assertReturnString )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700797
alisonda157272016-12-22 01:13:21 -0800798 # main.step( "Protected: Add point intents between h1 and h9" )
799 # main.assertReturnString = "Assertion Result for protected point intent\n"
800 # senders = [
801 # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
802 # ]
803 # recipients = [
804 # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
805 # ]
806 # testResult = main.FALSE
807 # installResult = main.intentFunction.installPointIntent(
808 # main,
809 # name="Protected",
810 # senders=senders,
811 # recipients=recipients,
812 # protected=True )
Jon Hall02758ac2017-05-24 16:20:28 -0700813 #
alisonda157272016-12-22 01:13:21 -0800814 # if installResult:
815 # testResult = main.intentFunction.testPointIntent(
816 # main,
817 # name="Protected",
818 # intentId=installResult,
819 # senders=senders,
820 # recipients=recipients,
821 # sw1="s5",
822 # sw2="s2",
823 # protected=True,
824 # expectedLink=18 )
825 #
826 # utilities.assert_equals( expect=main.TRUE,
827 # actual=testResult,
828 # onpass=main.assertReturnString,
829 # onfail=main.assertReturnString )
830
kelvin-onlab44147802015-07-27 17:57:31 -0700831 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800832 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
833 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700834 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800835 ]
836 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700837 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800838 ]
839 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700840 main,
841 name="IPV4_2",
842 senders=senders,
843 recipients=recipients,
844 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800845
846 if installResult:
847 testResult = main.intentFunction.testPointIntent(
848 main,
849 intentId=installResult,
850 name="IPV4_2",
851 senders=senders,
852 recipients=recipients,
853 sw1="s5",
854 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700855 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700856
857 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800858 actual=testResult,
859 onpass=main.assertReturnString,
860 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700861
kelvin-onlab0e684682015-08-11 18:51:41 -0700862 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800863 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
864 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700865 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
866 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800867 ]
868 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700869 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
870 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800871 ]
Jon Hall02758ac2017-05-24 16:20:28 -0700872 # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700873 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700874 # Uneccessary, not including this in the selectors
Jon Hall02758ac2017-05-24 16:20:28 -0700875 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
876 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700877
Jeremy2f190ca2016-01-29 15:23:57 -0800878 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700879 main,
880 name="SDNIP-ICMP",
881 senders=senders,
882 recipients=recipients,
883 ethType="IPV4",
884 ipProto=ipProto,
885 tcpSrc=tcpSrc,
886 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -0800887
888 if installResult:
889 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700890 main,
891 intentId=installResult,
892 name="SDNIP_ICMP",
893 senders=senders,
894 recipients=recipients,
895 sw1="s5",
896 sw2="s2",
897 expectedLink=18,
898 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -0700899
900 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800901 actual=testResult,
902 onpass=main.assertReturnString,
903 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700904
kelvin-onlab0e684682015-08-11 18:51:41 -0700905 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800906 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700907 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
908 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
909 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
910 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
911 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
912 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
913 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700914
kelvin-onlab0e684682015-08-11 18:51:41 -0700915 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700916 main,
917 name="SDNIP-TCP",
918 host1="h1",
919 host2="h9",
920 deviceId1="of:0000000000000005/1",
921 deviceId2="of:0000000000000006/1",
922 mac1=mac1,
923 mac2=mac2,
924 ethType="IPV4",
925 ipProto=ipProto,
926 ip1=ip1,
927 ip2=ip2,
928 tcp1=tcp1,
929 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700930
931 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700932 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -0800933 onpass=main.assertReturnString,
934 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700935
Jeremy2f190ca2016-01-29 15:23:57 -0800936 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
937 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
938 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700939 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -0800940 ]
941 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700942 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -0800943 ]
944 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700945 main,
946 name="DUALSTACK1",
947 senders=senders,
948 recipients=recipients,
949 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800950
951 if installResult:
952 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700953 main,
954 intentId=installResult,
955 name="DUALSTACK1",
956 senders=senders,
957 recipients=recipients,
958 sw1="s5",
959 sw2="s2",
960 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700961
962 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800963 actual=testResult,
964 onpass=main.assertReturnString,
965 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700966
967 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -0800968 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
969 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700970 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800971 ]
972 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700973 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800974 ]
975 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700976 main,
977 name="VLAN",
978 senders=senders,
979 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800980
981 if installResult:
982 testResult = main.intentFunction.testPointIntent(
983 main,
984 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700985 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -0800986 senders=senders,
987 recipients=recipients,
988 sw1="s5",
989 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700990 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700991
992 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800993 actual=testResult,
994 onpass=main.assertReturnString,
995 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700996
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700997 # TODO: implement VLAN selector REST API intent test once supported
998
kelvin-onlab44147802015-07-27 17:57:31 -0700999 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001000 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1001 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001002 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001003 ]
1004 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001005 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001006 ]
1007 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001008 main,
1009 name="1HOP IPV4",
1010 senders=senders,
1011 recipients=recipients,
1012 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001013
1014 if installResult:
1015 testResult = main.intentFunction.testPointIntent(
1016 main,
1017 intentId=installResult,
1018 name="1HOP IPV4",
1019 senders=senders,
1020 recipients=recipients,
1021 sw1="s5",
1022 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001023 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001024
1025 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001026 actual=testResult,
1027 onpass=main.assertReturnString,
1028 onfail=main.assertReturnString )
1029
1030 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001031
1032 def CASE3000( self, main ):
1033 """
1034 Add single point to multi point intents
1035 - Get device ids
1036 - Add single point to multi point intents
1037 - Check intents
1038 - Verify flows
1039 - Ping hosts
1040 - Reroute
1041 - Link down
1042 - Verify flows
1043 - Check topology
1044 - Ping hosts
1045 - Link up
1046 - Verify flows
1047 - Check topology
1048 - Ping hosts
1049 - Remove intents
1050 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001051 if main.initialized == main.FALSE:
1052 main.log.error( "Test components did not start correctly, skipping further tests" )
1053 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001054 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001055
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001056 try:
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001057 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1058 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1059 except AssertionError:
1060 main.initialized = main.FALSE
1061 main.skipCase()
1062
1063 main.testName = "Single to Multi Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001064 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001065 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001066 main.caseExplanation = "This test case will test single point to" + \
1067 " multi point intents using " + \
Devin Lim142b5342017-07-20 15:22:39 -07001068 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" + \
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001069 "Different type of hosts will be tested in " + \
1070 "each step such as IPV4, Dual stack, VLAN etc" + \
1071 ";\nThe test will use OF " + main.OFProtocol + \
1072 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001073 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001074
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001075 main.step( "NOOPTION: Install and test single point to multi point intents" )
1076 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1077 senders = [
1078 { "name": "h8", "device": "of:0000000000000005/8" }
1079 ]
1080 recipients = [
1081 { "name": "h16", "device": "of:0000000000000006/8" },
1082 { "name": "h24", "device": "of:0000000000000007/8" }
1083 ]
1084 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1085 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1086 testResult = main.FALSE
1087 installResult = main.intentFunction.installSingleToMultiIntent(
1088 main,
1089 name="NOOPTION",
1090 senders=senders,
1091 recipients=recipients )
1092
1093 if installResult:
1094 testResult = main.intentFunction.testPointIntent(
1095 main,
1096 intentId=installResult,
1097 name="NOOPTION",
1098 senders=senders,
1099 recipients=recipients,
1100 badSenders=badSenders,
1101 badRecipients=badRecipients,
1102 sw1="s5",
1103 sw2="s2",
1104 expectedLink=18 )
1105 else:
Devin Lim142b5342017-07-20 15:22:39 -07001106 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001107
1108 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001109 actual=testResult,
1110 onpass=main.assertReturnString,
1111 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001112
Jon Hall02758ac2017-05-24 16:20:28 -07001113 main.step( "IPV4: Install and test single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001114 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1115 "with IPV4 type and MAC addresses\n"
1116 senders = [
Jon Hall02758ac2017-05-24 16:20:28 -07001117 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001118 ]
1119 recipients = [
Jon Hall02758ac2017-05-24 16:20:28 -07001120 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1121 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001122 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001123 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1124 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001125 installResult = main.intentFunction.installSingleToMultiIntent(
1126 main,
1127 name="IPV4",
1128 senders=senders,
1129 recipients=recipients,
Jon Hall02758ac2017-05-24 16:20:28 -07001130 ethType="IPV4" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001131
1132 if installResult:
1133 testResult = main.intentFunction.testPointIntent(
1134 main,
1135 intentId=installResult,
1136 name="IPV4",
1137 senders=senders,
1138 recipients=recipients,
1139 badSenders=badSenders,
1140 badRecipients=badRecipients,
1141 sw1="s5",
1142 sw2="s2",
1143 expectedLink=18 )
1144 else:
Devin Lim142b5342017-07-20 15:22:39 -07001145 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001146
1147 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001148 actual=testResult,
1149 onpass=main.assertReturnString,
1150 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001151
1152 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001153 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1154 "with IPV4 type and no MAC addresses\n"
1155 senders = [
1156 { "name": "h8", "device": "of:0000000000000005/8" }
1157 ]
1158 recipients = [
1159 { "name": "h16", "device": "of:0000000000000006/8" },
1160 { "name": "h24", "device": "of:0000000000000007/8" }
1161 ]
1162 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1163 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1164 installResult = main.intentFunction.installSingleToMultiIntent(
1165 main,
1166 name="IPV4_2",
1167 senders=senders,
1168 recipients=recipients,
1169 ethType="IPV4" )
1170
1171 if installResult:
1172 testResult = main.intentFunction.testPointIntent(
1173 main,
1174 intentId=installResult,
1175 name="IPV4_2",
1176 senders=senders,
1177 recipients=recipients,
1178 badSenders=badSenders,
1179 badRecipients=badRecipients,
1180 sw1="s5",
1181 sw2="s2",
1182 expectedLink=18 )
1183 else:
Devin Lim142b5342017-07-20 15:22:39 -07001184 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001185
1186 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001187 actual=testResult,
1188 onpass=main.assertReturnString,
1189 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001190
1191 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001192 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1193 "and MAC addresses in the same VLAN\n"
1194 senders = [
1195 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1196 ]
1197 recipients = [
1198 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1199 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1200 ]
1201 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1202 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1203 installResult = main.intentFunction.installSingleToMultiIntent(
1204 main,
1205 name="VLAN",
1206 senders=senders,
1207 recipients=recipients,
1208 sw1="s5",
1209 sw2="s2" )
1210
1211 if installResult:
1212 testResult = main.intentFunction.testPointIntent(
1213 main,
1214 intentId=installResult,
1215 name="VLAN",
1216 senders=senders,
1217 recipients=recipients,
1218 badSenders=badSenders,
1219 badRecipients=badRecipients,
1220 sw1="s5",
1221 sw2="s2",
1222 expectedLink=18 )
1223 else:
Devin Lim142b5342017-07-20 15:22:39 -07001224 main.Cluster.active( 0 ).CLI.removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001225
1226 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001227 actual=testResult,
1228 onpass=main.assertReturnString,
1229 onfail=main.assertReturnString )
1230
1231 main.step( "VLAN: Add single point to multi point intents" )
1232 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1233 senders = [
1234 { "name": "h5", "vlan": "200" }
1235 ]
1236 recipients = [
1237 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1238 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1239 ]
1240 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1241 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1242 testResult = main.FALSE
1243 installResult = main.intentFunction.installSingleToMultiIntent(
1244 main,
1245 name="VLAN2",
1246 senders=senders,
1247 recipients=recipients,
1248 sw1="s5",
1249 sw2="s2" )
Jon Hall02758ac2017-05-24 16:20:28 -07001250 #setVlan=100 )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001251
1252 if installResult:
1253 testResult = main.intentFunction.testPointIntent(
1254 main,
1255 intentId=installResult,
1256 name="VLAN2",
1257 senders=senders,
1258 recipients=recipients,
1259 badSenders=badSenders,
1260 badRecipients=badRecipients,
1261 sw1="s5",
1262 sw2="s2",
1263 expectedLink=18 )
1264 else:
Devin Lim142b5342017-07-20 15:22:39 -07001265 main.Cluster.active( 0 ).CLI.removeAllIntents()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001266
1267 utilities.assert_equals( expect=main.TRUE,
1268 actual=testResult,
1269 onpass=main.assertReturnString,
1270 onfail=main.assertReturnString )
1271
1272 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001273
1274 def CASE4000( self, main ):
1275 """
1276 Add multi point to single point intents
1277 - Get device ids
1278 - Add multi point to single point intents
1279 - Check intents
1280 - Verify flows
1281 - Ping hosts
1282 - Reroute
1283 - Link down
1284 - Verify flows
1285 - Check topology
1286 - Ping hosts
1287 - Link up
1288 - Verify flows
1289 - Check topology
1290 - Ping hosts
1291 - Remove intents
1292 """
1293 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001294 assert main.Mininet1, "Mininet handle should be named Mininet1"
1295 assert main.numSwitch, "Placed the total number of switch topology in \
1296 main.numSwitch"
1297
1298 main.case( "Multi To Single Point Intents Test - " +
Devin Lim142b5342017-07-20 15:22:39 -07001299 str( main.Cluster.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001300 main.caseExplanation = "This test case will test single point to" +\
1301 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001302 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab44147802015-07-27 17:57:31 -07001303 "Different type of hosts will be tested in " +\
1304 "each step such as IPV4, Dual stack, VLAN etc" +\
1305 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001306 " OVS running in Mininet and compile intents" +\
1307 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001308
1309 main.step( "NOOPTION: Add multi point to single point intents" )
1310 stepResult = main.TRUE
1311 hostNames = [ 'h8', 'h16', 'h24' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001312 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8',
kelvin-onlab44147802015-07-27 17:57:31 -07001313 'of:0000000000000007/8' ]
1314 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1315 stepResult = main.intentFunction.multiToSingleIntent(
1316 main,
1317 name="NOOPTION",
1318 hostNames=hostNames,
1319 devices=devices,
1320 sw1="s5",
1321 sw2="s2",
1322 expectedLink=18 )
1323
1324 utilities.assert_equals( expect=main.TRUE,
1325 actual=stepResult,
1326 onpass="NOOPTION: Successfully added multi "
1327 + " point to single point intents" +
1328 " with no match action",
1329 onfail="NOOPTION: Failed to add multi point" +
1330 " to single point intents" +
1331 " with no match action" )
1332
1333 main.step( "IPV4: Add multi point to single point intents" )
1334 stepResult = main.TRUE
1335 stepResult = main.intentFunction.multiToSingleIntent(
1336 main,
1337 name="IPV4",
1338 hostNames=hostNames,
1339 devices=devices,
1340 ports=None,
1341 ethType="IPV4",
1342 macs=macs,
1343 bandwidth="",
1344 lambdaAlloc=False,
1345 ipProto="",
1346 ipAddresses="",
1347 tcp="",
1348 sw1="s5",
1349 sw2="s2",
1350 expectedLink=18 )
1351
1352 utilities.assert_equals( expect=main.TRUE,
1353 actual=stepResult,
1354 onpass="IPV4: Successfully added multi point"
1355 + " to single point intents" +
1356 " with IPV4 type and MAC addresses",
1357 onfail="IPV4: Failed to add multi point" +
1358 " to single point intents" +
1359 " with IPV4 type and MAC addresses" )
1360
1361 main.step( "IPV4_2: Add multi point to single point intents" )
1362 stepResult = main.TRUE
1363 hostNames = [ 'h8', 'h16', 'h24' ]
1364 stepResult = main.intentFunction.multiToSingleIntent(
1365 main,
1366 name="IPV4",
1367 hostNames=hostNames,
1368 ethType="IPV4",
1369 lambdaAlloc=False )
1370
1371 utilities.assert_equals( expect=main.TRUE,
1372 actual=stepResult,
1373 onpass="IPV4_2: Successfully added multi point"
1374 + " to single point intents" +
1375 " with IPV4 type and no MAC addresses",
1376 onfail="IPV4_2: Failed to add multi point" +
1377 " to single point intents" +
1378 " with IPV4 type and no MAC addresses" )
1379
1380 main.step( "VLAN: Add multi point to single point intents" )
1381 stepResult = main.TRUE
1382 hostNames = [ 'h5', 'h13', 'h21' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001383 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5',
kelvin-onlab44147802015-07-27 17:57:31 -07001384 'of:0000000000000007/5' ]
1385 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1386 stepResult = main.intentFunction.multiToSingleIntent(
1387 main,
1388 name="VLAN",
1389 hostNames=hostNames,
1390 devices=devices,
1391 ports=None,
1392 ethType="IPV4",
1393 macs=macs,
1394 bandwidth="",
1395 lambdaAlloc=False,
1396 ipProto="",
1397 ipAddresses="",
1398 tcp="",
1399 sw1="s5",
1400 sw2="s2",
1401 expectedLink=18 )
1402
1403 utilities.assert_equals( expect=main.TRUE,
1404 actual=stepResult,
1405 onpass="VLAN: Successfully added multi point"
1406 + " to single point intents" +
1407 " with IPV4 type and MAC addresses" +
1408 " in the same VLAN",
1409 onfail="VLAN: Failed to add multi point" +
1410 " to single point intents" )
1411
1412 def CASE5000( self, main ):
1413 """
Jeremy2f190ca2016-01-29 15:23:57 -08001414 Tests Host Mobility
1415 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001416 """
Jeremydd9bda62016-04-18 12:02:32 -07001417 if main.initialized == main.FALSE:
1418 main.log.error( "Test components did not start correctly, skipping further tests" )
1419 main.skipCase()
1420 # Assert variables - These variable's name|format must be followed
1421 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001422 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001423 try:
Jeremydd9bda62016-04-18 12:02:32 -07001424 assert main.Mininet1
1425 except AssertionError:
1426 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1427 main.initialized = main.FALSE
1428 main.skipCase()
1429 try:
1430 assert main.numSwitch
1431 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001432 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001433 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001434 main.initialized = main.FALSE
1435 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001436 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001437 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001438 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1439
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001440 main.log.info( "Moving h1 from s5 to s6" )
1441 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001442
Jeremy2f190ca2016-01-29 15:23:57 -08001443 # Send discovery ping from moved host
1444 # Moving the host brings down the default interfaces and creates a new one.
1445 # Scapy is restarted on this host to detect the new interface
1446 main.h1.stopScapy()
1447 main.h1.startScapy()
1448
1449 # Discover new host location in ONOS and populate host data.
1450 # Host 1 IP and MAC should be unchanged
1451 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1452 main.intentFunction.populateHostData( main )
1453
kelvin-onlab44147802015-07-27 17:57:31 -07001454 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1455
1456 utilities.assert_equals( expect="of:0000000000000006",
1457 actual=h1PostMove,
1458 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001459 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001460 " to single point intents" +
1461 " with IPV4 type and MAC addresses" +
1462 " in the same VLAN" )
1463
1464 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001465 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001466 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1467 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001468
1469 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001470 name='IPV4 Mobility IPV4',
1471 onosNode='0',
1472 host1=host1,
1473 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001474 if installResult:
1475 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001476 name='Host Mobility IPV4',
1477 intentId=installResult,
1478 onosNode='0',
1479 host1=host1,
1480 host2=host2,
1481 sw1="s6",
1482 sw2="s2",
1483 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001484
1485 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001486 actual=testResult,
1487 onpass=main.assertReturnString,
1488 onfail=main.assertReturnString )
1489
Jon Hallbd60ea02016-08-23 10:03:59 -07001490 main.intentFunction.report( main )