blob: 2ee7260b00384358175c3d0252867c49106be696 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
kelvin-onlab44147802015-07-27 17:57:31 -070021# Testing the basic intent functionality of ONOS
Jeremy2f190ca2016-01-29 15:23:57 -080022# TODO: Replace the CLI calls with REST API equivalents as they become available.
23# - May need to write functions in the onosrestdriver.py file to do this
24# TODO: Complete implementation of case 3000, 4000, and 6000 as REST API allows
25# -Currently there is no support in the REST API for Multi to Single and Single to Multi point intents
26# As such, these cases are incomplete and should not be enabled in the .params file
kelvin-onlab44147802015-07-27 17:57:31 -070027
28import time
29import json
30
Jon Hall02758ac2017-05-24 16:20:28 -070031
kelvin-onlab44147802015-07-27 17:57:31 -070032class FUNCintentRest:
33
34 def __init__( self ):
35 self.default = ''
36
37 def CASE1( self, main ):
38 import time
kelvin-onlab44147802015-07-27 17:57:31 -070039 import imp
Jon Hallf7234882015-08-28 13:16:31 -070040 import re
kelvin-onlab44147802015-07-27 17:57:31 -070041 """
42 - Construct tests variables
43 - GIT ( optional )
44 - Checkout ONOS master branch
45 - Pull latest ONOS code
46 - Building ONOS ( optional )
47 - Install ONOS package
48 - Build ONOS package
49 """
Devin Lim58046fa2017-07-05 16:55:00 -070050 try:
51 from tests.dependencies.ONOSSetup import ONOSSetup
52 main.testSetUp = ONOSSetup()
53 except ImportError:
54 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070055 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070056 main.testSetUp.envSetupDescription()
kelvin-onlab44147802015-07-27 17:57:31 -070057 stepResult = main.FALSE
58
59 # Test variables
60 try:
kelvin-onlab44147802015-07-27 17:57:31 -070061 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
kelvin-onlab44147802015-07-27 17:57:31 -070062 main.dependencyPath = main.testOnDirectory + \
63 main.params[ 'DEPENDENCY' ][ 'path' ]
64 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
65 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
kelvin-onlab44147802015-07-27 17:57:31 -070066 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
67 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
68 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
69 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080070 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
71 main.removeIntentsleeo = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070072 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
73 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
kelvin-onlab0e684682015-08-11 18:51:41 -070074 main.addIntentSleep = int( main.params[ 'SLEEP' ][ 'addIntent' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080075 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070076 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070077 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
78 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070079 main.hostsData = {}
Jeremy2f190ca2016-01-29 15:23:57 -080080 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
81 main.scapyHosts = [] # List of scapy hosts for iterating
82 main.assertReturnString = '' # Assembled assert return string
Jon Hall02758ac2017-05-24 16:20:28 -070083 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlab44147802015-07-27 17:57:31 -070084
kelvin-onlab44147802015-07-27 17:57:31 -070085 # -- INIT SECTION, ONLY RUNS ONCE -- #
kelvin-onlab44147802015-07-27 17:57:31 -070086
87 main.intentFunction = imp.load_source( wrapperFile2,
Jon Hall02758ac2017-05-24 16:20:28 -070088 main.dependencyPath +
89 wrapperFile2 +
90 ".py" )
kelvin-onlab44147802015-07-27 17:57:31 -070091
Jon Hallf7234882015-08-28 13:16:31 -070092 copyResult1 = main.ONOSbench.scp( main.Mininet1,
93 main.dependencyPath +
94 main.topology,
Jeremy2f190ca2016-01-29 15:23:57 -080095 main.Mininet1.home + "custom/",
Jon Hallf7234882015-08-28 13:16:31 -070096 direction="to" )
Devin Lim142b5342017-07-20 15:22:39 -070097 stepResult = main.testSetUp.envSetup()
kelvin-onlab44147802015-07-27 17:57:31 -070098 except Exception as e:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070099 main.testSetUp.envSetupException( e )
Devin Lim58046fa2017-07-05 16:55:00 -0700100 main.testSetUp.evnSetupConclusion( stepResult )
kelvin-onlab44147802015-07-27 17:57:31 -0700101
102 def CASE2( self, main ):
103 """
104 - Set up cell
105 - Create cell file
106 - Set cell file
107 - Verify cell file
108 - Kill ONOS process
109 - Uninstall ONOS cluster
110 - Verify ONOS start up
111 - Install ONOS cluster
112 - Connect to cli
113 """
Jeremyeb51cb12016-03-28 17:53:35 -0700114 main.flowCompiler = "Flow Rules"
You Wanga0f6ff62018-01-11 15:46:30 -0800115 main.initialized = main.testSetUp.ONOSSetUp( main.Cluster, True )
Jeremy2f190ca2016-01-29 15:23:57 -0800116 main.intentFunction.report( main )
117
kelvin-onlab44147802015-07-27 17:57:31 -0700118 def CASE8( self, main ):
Devin Lim58046fa2017-07-05 16:55:00 -0700119 try:
120 from tests.dependencies.topology import Topology
121 except ImportError:
122 main.log.error( "Topology not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700123 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700124 try:
125 main.topoRelated
126 except ( NameError, AttributeError ):
127 main.topoRelated = Topology()
128 main.topoRelated.compareTopos( main.Mininet1, main.checkTopoAttempts )
kelvin-onlab44147802015-07-27 17:57:31 -0700129
130 def CASE9( self, main ):
Jon Hall02758ac2017-05-24 16:20:28 -0700131 """
kelvin-onlab44147802015-07-27 17:57:31 -0700132 Report errors/warnings/exceptions
Jon Hall02758ac2017-05-24 16:20:28 -0700133 """
kelvin-onlab44147802015-07-27 17:57:31 -0700134 main.log.info( "Error report: \n" )
Devin Lim142b5342017-07-20 15:22:39 -0700135 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall02758ac2017-05-24 16:20:28 -0700136 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR", "Except" ],
137 "s" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700138 # main.ONOSbench.logReport( globalONOSip[ 1 ], [ "INFO" ], "d" )
kelvin-onlab44147802015-07-27 17:57:31 -0700139
140 def CASE10( self, main ):
141 """
142 Start Mininet topology with OF 1.0 switches
143 """
Jeremydd9bda62016-04-18 12:02:32 -0700144 if main.initialized == main.FALSE:
145 main.log.error( "Test components did not start correctly, skipping further tests" )
146 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700147 main.OFProtocol = "1.0"
148 main.log.report( "Start Mininet topology with OF 1.0 switches" )
149 main.case( "Start Mininet topology with OF 1.0 switches" )
150 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
151 "switches to test intents, exits out if " +\
152 "topology did not start correctly"
153
154 main.step( "Starting Mininet topology with OF 1.0 switches" )
155 args = "--switch ovs,protocols=OpenFlow10"
Devin Lim29a9e3d2018-01-30 14:09:47 -0800156 topoResult = main.Mininet1.startNet( topoFile=main.Mininet1.home + "/custom/" + main.topology,
kelvin-onlab44147802015-07-27 17:57:31 -0700157 args=args )
158 stepResult = topoResult
159 utilities.assert_equals( expect=main.TRUE,
160 actual=stepResult,
161 onpass="Successfully loaded topology",
162 onfail="Failed to load topology" )
163 # Exit if topology did not load properly
164 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700165 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700166
167 def CASE11( self, main ):
168 """
169 Start Mininet topology with OF 1.3 switches
170 """
Jeremydd9bda62016-04-18 12:02:32 -0700171 if main.initialized == main.FALSE:
172 main.log.error( "Test components did not start correctly, skipping further tests" )
173 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700174 main.OFProtocol = "1.3"
175 main.log.report( "Start Mininet topology with OF 1.3 switches" )
176 main.case( "Start Mininet topology with OF 1.3 switches" )
177 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
178 "switches to test intents, exits out if " +\
179 "topology did not start correctly"
180
181 main.step( "Starting Mininet topology with OF 1.3 switches" )
182 args = "--switch ovs,protocols=OpenFlow13"
Devin Lim29a9e3d2018-01-30 14:09:47 -0800183 topoResult = main.Mininet1.startNet( topoFile=main.Mininet1.home + "/custom/" + main.topology,
kelvin-onlab44147802015-07-27 17:57:31 -0700184 args=args )
185 stepResult = topoResult
186 utilities.assert_equals( expect=main.TRUE,
187 actual=stepResult,
188 onpass="Successfully loaded topology",
189 onfail="Failed to load topology" )
190 # Exit if topology did not load properly
191 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700192 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700193
194 def CASE12( self, main ):
195 """
196 Assign mastership to controllers
197 """
198 import re
199
Jeremydd9bda62016-04-18 12:02:32 -0700200 if main.initialized == main.FALSE:
201 main.log.error( "Test components did not start correctly, skipping further tests" )
202 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700203 main.case( "Assign switches to controllers" )
204 main.step( "Assigning switches to controllers" )
205 main.caseExplanation = "Assign OF " + main.OFProtocol +\
206 " switches to ONOS nodes"
207
208 assignResult = main.TRUE
209 switchList = []
210
211 # Creates a list switch name, use getSwitch() function later...
212 for i in range( 1, ( main.numSwitch + 1 ) ):
213 switchList.append( 's' + str( i ) )
214
Devin Lim142b5342017-07-20 15:22:39 -0700215 tempONOSip = main.Cluster.getIps()
kelvin-onlab44147802015-07-27 17:57:31 -0700216
217 assignResult = main.Mininet1.assignSwController( sw=switchList,
218 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800219 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700220 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700221 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
222 main.initialized = main.FALSE
223 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700224
225 for i in range( 1, ( main.numSwitch + 1 ) ):
226 response = main.Mininet1.getSwController( "s" + str( i ) )
227 print( "Response is " + str( response ) )
Devin Lim142b5342017-07-20 15:22:39 -0700228 if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ):
kelvin-onlab44147802015-07-27 17:57:31 -0700229 assignResult = assignResult and main.TRUE
230 else:
231 assignResult = main.FALSE
232 stepResult = assignResult
233 utilities.assert_equals( expect=main.TRUE,
234 actual=stepResult,
235 onpass="Successfully assigned switches" +
236 "to controller",
237 onfail="Failed to assign switches to " +
238 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700239 if not stepResult:
240 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800241
Jon Hall02758ac2017-05-24 16:20:28 -0700242 def CASE13( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800243 """
244 Create Scapy components
245 """
Jeremydd9bda62016-04-18 12:02:32 -0700246 if main.initialized == main.FALSE:
247 main.log.error( "Test components did not start correctly, skipping further tests" )
248 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800249 main.case( "Create scapy components" )
250 main.step( "Create scapy components" )
251 import json
252 scapyResult = main.TRUE
253 for hostName in main.scapyHostNames:
254 main.Scapy1.createHostComponent( hostName )
255 main.scapyHosts.append( getattr( main, hostName ) )
256
257 main.step( "Start scapy components" )
258 for host in main.scapyHosts:
259 host.startHostCli()
260 host.startScapy()
261 host.updateSelf()
262 main.log.debug( host.name )
263 main.log.debug( host.hostIp )
264 main.log.debug( host.hostMac )
265
Jeremy2f190ca2016-01-29 15:23:57 -0800266 utilities.assert_equals( expect=main.TRUE,
267 actual=scapyResult,
268 onpass="Successfully created Scapy Components",
269 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700270 if not scapyResult:
271 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800272
273 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700274 """
275 Discover all hosts and store its data to a dictionary
276 """
Jeremydd9bda62016-04-18 12:02:32 -0700277 if main.initialized == main.FALSE:
278 main.log.error( "Test components did not start correctly, skipping further tests" )
279 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700280 main.case( "Discover all hosts" )
281
282 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700283 main.step( "Discover all ipv4 host hosts " )
284 hostList = []
285 # List of host with default vlan
286 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
287 # Lists of host with unique vlan
288 vlanHosts1 = [ "h4", "h12", "h20" ]
289 vlanHosts2 = [ "h5", "h13", "h21" ]
290 vlanHosts3 = [ "h6", "h14", "h22" ]
291 vlanHosts4 = [ "h7", "h15", "h23" ]
292 hostList.append( defaultHosts )
293 hostList.append( vlanHosts1 )
294 hostList.append( vlanHosts2 )
295 hostList.append( vlanHosts3 )
296 hostList.append( vlanHosts4 )
297
298 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700299 utilities.assert_equals( expect=main.TRUE,
300 actual=stepResult,
301 onpass="Successfully discovered hosts",
302 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700303 if not stepResult:
304 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700305
Jeremy2f190ca2016-01-29 15:23:57 -0800306 def CASE15( self, main ):
Devin Lim58046fa2017-07-05 16:55:00 -0700307 """main.topo.
Jeremy2f190ca2016-01-29 15:23:57 -0800308 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700309 """
Jeremydd9bda62016-04-18 12:02:32 -0700310 if main.initialized == main.FALSE:
311 main.log.error( "Test components did not start correctly, skipping further tests" )
312 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800313 main.case( "Discover all hosts using scapy" )
314 main.step( "Send packets from each host to the first host and confirm onos discovery" )
315
316 import collections
317 if len( main.scapyHosts ) < 1:
318 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700319 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800320 main.skipCase()
321
322 # Send ARP packets from each scapy host component
323 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
324
325 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
326 retValue=main.FALSE, args=[ main ],
327 attempts=main.checkTopoAttempts, sleep=2 )
328
329 utilities.assert_equals( expect=main.TRUE,
330 actual=stepResult,
331 onpass="ONOS correctly discovered all hosts",
332 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700333 if not stepResult:
334 main.initialized = main.FALSE
335 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800336
337 main.step( "Populate hostsData" )
338 stepResult = main.intentFunction.populateHostData( main )
339 utilities.assert_equals( expect=main.TRUE,
340 actual=stepResult,
341 onpass="Successfully populated hostsData",
342 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700343 if not stepResult:
344 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800345
346 def CASE16( self, main ):
347 """
Jeremy42df2e72016-02-23 16:37:46 -0800348 Balance Masters
349 """
Jeremydd9bda62016-04-18 12:02:32 -0700350 if main.initialized == main.FALSE:
351 main.log.error( "Test components did not start correctly, skipping further tests" )
352 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800353 main.case( "Balance mastership of switches" )
354 main.step( "Balancing mastership of switches" )
355
356 balanceResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700357 balanceResult = utilities.retry( f=main.Cluster.active( 0 ).CLI.balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800358
359 utilities.assert_equals( expect=main.TRUE,
360 actual=stepResult,
361 onpass="Successfully balanced mastership of switches",
362 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700363 if not stepResult:
364 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800365
366 def CASE17( self, main ):
367 """
Jeremyeb51cb12016-03-28 17:53:35 -0700368 Use Flow Objectives
369 """
Jeremydd9bda62016-04-18 12:02:32 -0700370 if main.initialized == main.FALSE:
371 main.log.error( "Test components did not start correctly, skipping further tests" )
372 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700373 main.case( "Enable intent compilation using Flow Objectives" )
374 main.step( "Enabling Flow Objectives" )
375
376 main.flowCompiler = "Flow Objectives"
377
378 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
379
Devin Lim142b5342017-07-20 15:22:39 -0700380 stepResult = main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700381 propName="useFlowObjectives", value="true" )
Jeremyeb51cb12016-03-28 17:53:35 -0700382 utilities.assert_equals( expect=main.TRUE,
383 actual=stepResult,
384 onpass="Successfully activated Flow Objectives",
385 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700386 if not stepResult:
387 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700388
389 def CASE18( self, main ):
390 """
Jeremy2f190ca2016-01-29 15:23:57 -0800391 Stop mininet and remove scapy hosts
392 """
Devin Lim58046fa2017-07-05 16:55:00 -0700393 try:
394 from tests.dependencies.utils import Utils
395 except ImportError:
396 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700397 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700398 try:
399 main.Utils
400 except ( NameError, AttributeError ):
401 main.Utils = Utils()
Jeremy2f190ca2016-01-29 15:23:57 -0800402 main.log.report( "Stop Mininet and Scapy" )
403 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700404 main.caseExplanation = "Stopping the current mininet topology " +\
405 "to start up fresh"
406
Jeremy2f190ca2016-01-29 15:23:57 -0800407 main.step( "Stopping and Removing Scapy Host Components" )
408 scapyResult = main.TRUE
409 for host in main.scapyHosts:
410 scapyResult = scapyResult and host.stopScapy()
411 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
412
413 for host in main.scapyHosts:
414 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
415 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
416
417 main.scapyHosts = []
418 main.scapyHostIPs = []
419
420 utilities.assert_equals( expect=main.TRUE,
421 actual=scapyResult,
422 onpass="Successfully stopped scapy and removed host components",
423 onfail="Failed to stop mininet and scapy" )
424
Devin Lim58046fa2017-07-05 16:55:00 -0700425 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlab44147802015-07-27 17:57:31 -0700426 # Exit if topology did not load properly
Jon Hall02758ac2017-05-24 16:20:28 -0700427 if not ( mininetResult and scapyResult ):
Devin Lim44075962017-08-11 10:56:37 -0700428 main.cleanAndExit()
kelvin-onlab44147802015-07-27 17:57:31 -0700429
Jeremy Songster17147f22016-05-31 18:30:52 -0700430 def CASE19( self, main ):
431 """
432 Copy the karaf.log files after each testcase cycle
433 """
Devin Lim58046fa2017-07-05 16:55:00 -0700434 try:
435 from tests.dependencies.utils import Utils
436 except ImportError:
437 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700438 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700439 try:
440 main.Utils
441 except ( NameError, AttributeError ):
442 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700443 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700444
kelvin-onlab44147802015-07-27 17:57:31 -0700445 def CASE1000( self, main ):
446 """
447 Add host intents between 2 host:
448 - Discover hosts
449 - Add host intents
450 - Check intents
451 - Verify flows
452 - Ping hosts
453 - Reroute
454 - Link down
455 - Verify flows
456 - Check topology
457 - Ping hosts
458 - Link up
459 - Verify flows
460 - Check topology
461 - Ping hosts
462 - Remove intents
463 """
464 import time
465 import json
466 import re
Jeremydd9bda62016-04-18 12:02:32 -0700467 if main.initialized == main.FALSE:
468 main.log.error( "Test components did not start correctly, skipping further tests" )
469 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700470 # Assert variables - These variable's name|format must be followed
471 # if you want to use the wrapper function
472 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700473 try:
Jeremydd9bda62016-04-18 12:02:32 -0700474 assert main.Mininet1
475 except AssertionError:
476 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
477 main.initialized = main.FALSE
478 main.skipCase()
479 try:
480 assert main.numSwitch
481 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700482 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700483 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700484 main.initialized = main.FALSE
485 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700486
Jeremye1ea0602016-02-08 16:35:05 -0800487 # Save leader candidates
Devin Lim142b5342017-07-20 15:22:39 -0700488 intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800489
Devin Lim142b5342017-07-20 15:22:39 -0700490 main.case( "Host Intents Test - " + str( main.Cluster.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700491 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700492 main.caseExplanation = "This test case tests Host intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -0700493 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab44147802015-07-27 17:57:31 -0700494 "Different type of hosts will be tested in " +\
495 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700496 "etc;\nThe test will use OF " + main.OFProtocol +\
497 " OVS running in Mininet and compile intents" +\
498 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700499
Jeremy2f190ca2016-01-29 15:23:57 -0800500 main.step( "IPV4: Add and test host intents between h1 and h9" )
501 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700502 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
503 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800504 testResult = main.FALSE
505 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700506 name='IPV4',
507 onosNode='0',
508 host1=host1,
509 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800510
511 if installResult:
512 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700513 name='IPV4',
514 intentId=installResult,
515 onosNode='0',
516 host1=host1,
517 host2=host2,
518 sw1='s5',
519 sw2='s2',
520 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700521
522 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800523 actual=testResult,
524 onpass=main.assertReturnString,
525 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700526
527 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800528 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700529 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
530 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800531 testResult = main.FALSE
532 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700533 name='DUALSTACK1',
534 onosNode='0',
535 host1=host1,
536 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800537
538 if installResult:
539 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700540 name='DUALSTACK1',
541 intentId=installResult,
542 onosNode='0',
543 host1=host1,
544 host2=host2,
545 sw1='s5',
546 sw2='s2',
547 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700548
549 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800550 actual=testResult,
551 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700552 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700553
554 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800555 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700556 host1 = { "name": "h1" }
557 host2 = { "name": "h11" }
Jeremy2f190ca2016-01-29 15:23:57 -0800558 testResult = main.FALSE
559 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700560 name='DUALSTACK2',
561 onosNode='0',
562 host1=host1,
563 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800564
565 if installResult:
566 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700567 name='DUALSTACK2',
568 intentId=installResult,
569 onosNode='0',
570 host1=host1,
571 host2=host2,
572 sw1='s5',
573 sw2='s2',
574 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700575
576 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800577 actual=testResult,
578 onpass=main.assertReturnString,
579 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700580
581 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800582 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700583 host1 = { "name": "h1" }
584 host2 = { "name": "h3" }
Jeremy2f190ca2016-01-29 15:23:57 -0800585 testResult = main.FALSE
586 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700587 name='1HOP',
588 onosNode='0',
589 host1=host1,
590 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700591
Jeremy2f190ca2016-01-29 15:23:57 -0800592 if installResult:
593 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700594 name='1HOP',
595 intentId=installResult,
596 onosNode='0',
597 host1=host1,
598 host2=host2,
599 sw1='s5',
600 sw2='s2',
601 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700602
603 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800604 actual=testResult,
605 onpass=main.assertReturnString,
606 onfail=main.assertReturnString )
607
608 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
609 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700610 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" }
611 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800612 testResult = main.FALSE
613 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700614 name='VLAN1',
615 onosNode='0',
616 host1=host1,
617 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800618
619 if installResult:
620 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700621 name='VLAN1',
622 intentId=installResult,
623 onosNode='0',
624 host1=host1,
625 host2=host2,
626 sw1='s5',
627 sw2='s2',
628 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -0800629
630 utilities.assert_equals( expect=main.TRUE,
631 actual=testResult,
632 onpass=main.assertReturnString,
633 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700634
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700635 # This step isn't currently possible to perform in the REST API
636 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
637 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
638 # host1 = { "name":"h13" }
639 # host2 = { "name":"h20" }
640 # testResult = main.FALSE
641 # installResult = main.intentFunction.installHostIntent( main,
642 # name='VLAN2',
643 # onosNode='0',
644 # host1=host1,
645 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700646
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700647 # if installResult:
648 # testResult = main.intentFunction.testHostIntent( main,
649 # name='VLAN2',
Jon Hall02758ac2017-05-24 16:20:28 -0700650 # intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700651 # onosNode='0',
652 # host1=host1,
653 # host2=host2,
654 # sw1='s5',
655 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700656 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700657
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700658 # utilities.assert_equals( expect=main.TRUE,
659 # actual=testResult,
660 # onpass=main.assertReturnString,
661 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -0800662
Jeremye1ea0602016-02-08 16:35:05 -0800663 # Change the following to use the REST API when leader checking is
664 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -0800665
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700666 main.step( "Confirm that ONOS leadership is unchanged" )
Devin Lim142b5342017-07-20 15:22:39 -0700667 intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800668 main.intentFunction.checkLeaderChange( intentLeadersOld,
669 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -0800670
Jeremye1ea0602016-02-08 16:35:05 -0800671 utilities.assert_equals( expect=main.TRUE,
672 actual=testResult,
673 onpass="ONOS Leaders Unchanged",
Jon Hall02758ac2017-05-24 16:20:28 -0700674 onfail="ONOS Leader Mismatch" )
Jeremy2f190ca2016-01-29 15:23:57 -0800675
676 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -0700677
678 def CASE2000( self, main ):
679 """
680 Add point intents between 2 hosts:
681 - Get device ids | ports
682 - Add point intents
683 - Check intents
684 - Verify flows
685 - Ping hosts
686 - Reroute
687 - Link down
688 - Verify flows
689 - Check topology
690 - Ping hosts
691 - Link up
692 - Verify flows
693 - Check topology
694 - Ping hosts
695 - Remove intents
696 """
Jeremydd9bda62016-04-18 12:02:32 -0700697 if main.initialized == main.FALSE:
698 main.log.error( "Test components did not start correctly, skipping further tests" )
699 main.skipCase()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700700 # Assert variables - These variable's name|format must be followed
701 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -0700702 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700703 try:
Jeremydd9bda62016-04-18 12:02:32 -0700704 assert main.Mininet1
705 except AssertionError:
706 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
707 main.initialized = main.FALSE
708 main.skipCase()
709 try:
710 assert main.numSwitch
711 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700712 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700713 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700714 main.initialized = main.FALSE
715 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700716
Devin Lim142b5342017-07-20 15:22:39 -0700717 main.case( "Point Intents Test - " + str( main.Cluster.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -0700718 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700719 main.caseExplanation = "This test case will test point to point" + \
Devin Lim142b5342017-07-20 15:22:39 -0700720 " intents using " + str( main.Cluster.numCtrls ) + \
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700721 " node(s) cluster;\n" + \
722 "Different type of hosts will be tested in " + \
723 "each step such as IPV4, Dual stack, VLAN etc" + \
724 ";\nThe test will use OF " + main.OFProtocol + \
725 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -0700726 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700727
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700728 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -0700729 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800730 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
731 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700732 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800733 ]
734 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700735 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800736 ]
737 testResult = main.FALSE
738 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700739 main,
740 name="NOOPTION",
741 senders=senders,
742 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800743
744 if installResult:
745 testResult = main.intentFunction.testPointIntent(
746 main,
747 intentId=installResult,
748 name="NOOPTION",
749 senders=senders,
750 recipients=recipients,
751 sw1="s5",
752 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700753 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700754
755 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800756 actual=testResult,
757 onpass=main.assertReturnString,
758 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700759
kelvin-onlab44147802015-07-27 17:57:31 -0700760 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800761 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
762 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700763 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -0800764 ]
765 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700766 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -0800767 ]
768 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700769 main,
770 name="IPV4",
771 senders=senders,
772 recipients=recipients,
773 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800774
775 if installResult:
776 testResult = main.intentFunction.testPointIntent(
777 main,
778 intentId=installResult,
779 name="IPV4",
780 senders=senders,
781 recipients=recipients,
782 sw1="s5",
783 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700784 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700785
786 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800787 actual=testResult,
788 onpass=main.assertReturnString,
789 onfail=main.assertReturnString )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700790
alisonda157272016-12-22 01:13:21 -0800791 # main.step( "Protected: Add point intents between h1 and h9" )
792 # main.assertReturnString = "Assertion Result for protected point intent\n"
793 # senders = [
794 # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
795 # ]
796 # recipients = [
797 # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
798 # ]
799 # testResult = main.FALSE
800 # installResult = main.intentFunction.installPointIntent(
801 # main,
802 # name="Protected",
803 # senders=senders,
804 # recipients=recipients,
805 # protected=True )
Jon Hall02758ac2017-05-24 16:20:28 -0700806 #
alisonda157272016-12-22 01:13:21 -0800807 # if installResult:
808 # testResult = main.intentFunction.testPointIntent(
809 # main,
810 # name="Protected",
811 # intentId=installResult,
812 # senders=senders,
813 # recipients=recipients,
814 # sw1="s5",
815 # sw2="s2",
816 # protected=True,
817 # expectedLink=18 )
818 #
819 # utilities.assert_equals( expect=main.TRUE,
820 # actual=testResult,
821 # onpass=main.assertReturnString,
822 # onfail=main.assertReturnString )
823
kelvin-onlab44147802015-07-27 17:57:31 -0700824 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800825 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
826 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700827 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800828 ]
829 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700830 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800831 ]
832 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700833 main,
834 name="IPV4_2",
835 senders=senders,
836 recipients=recipients,
837 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800838
839 if installResult:
840 testResult = main.intentFunction.testPointIntent(
841 main,
842 intentId=installResult,
843 name="IPV4_2",
844 senders=senders,
845 recipients=recipients,
846 sw1="s5",
847 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700848 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700849
850 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800851 actual=testResult,
852 onpass=main.assertReturnString,
853 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700854
kelvin-onlab0e684682015-08-11 18:51:41 -0700855 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800856 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
857 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700858 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
859 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800860 ]
861 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700862 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
863 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800864 ]
Jon Hall02758ac2017-05-24 16:20:28 -0700865 # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700866 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700867 # Uneccessary, not including this in the selectors
Jon Hall02758ac2017-05-24 16:20:28 -0700868 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
869 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700870
Jeremy2f190ca2016-01-29 15:23:57 -0800871 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700872 main,
873 name="SDNIP-ICMP",
874 senders=senders,
875 recipients=recipients,
876 ethType="IPV4",
877 ipProto=ipProto,
878 tcpSrc=tcpSrc,
879 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -0800880
881 if installResult:
882 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700883 main,
884 intentId=installResult,
885 name="SDNIP_ICMP",
886 senders=senders,
887 recipients=recipients,
888 sw1="s5",
889 sw2="s2",
890 expectedLink=18,
891 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -0700892
893 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800894 actual=testResult,
895 onpass=main.assertReturnString,
896 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700897
kelvin-onlab0e684682015-08-11 18:51:41 -0700898 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800899 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700900 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
901 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
902 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
903 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
904 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
905 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
906 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700907
kelvin-onlab0e684682015-08-11 18:51:41 -0700908 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700909 main,
910 name="SDNIP-TCP",
911 host1="h1",
912 host2="h9",
913 deviceId1="of:0000000000000005/1",
914 deviceId2="of:0000000000000006/1",
915 mac1=mac1,
916 mac2=mac2,
917 ethType="IPV4",
918 ipProto=ipProto,
919 ip1=ip1,
920 ip2=ip2,
921 tcp1=tcp1,
922 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700923
924 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700925 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -0800926 onpass=main.assertReturnString,
927 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700928
Jeremy2f190ca2016-01-29 15:23:57 -0800929 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
930 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
931 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700932 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -0800933 ]
934 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700935 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -0800936 ]
937 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700938 main,
939 name="DUALSTACK1",
940 senders=senders,
941 recipients=recipients,
942 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800943
944 if installResult:
945 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700946 main,
947 intentId=installResult,
948 name="DUALSTACK1",
949 senders=senders,
950 recipients=recipients,
951 sw1="s5",
952 sw2="s2",
953 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700954
955 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800956 actual=testResult,
957 onpass=main.assertReturnString,
958 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700959
960 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -0800961 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
962 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700963 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800964 ]
965 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700966 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800967 ]
968 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700969 main,
970 name="VLAN",
971 senders=senders,
972 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800973
974 if installResult:
975 testResult = main.intentFunction.testPointIntent(
976 main,
977 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700978 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -0800979 senders=senders,
980 recipients=recipients,
981 sw1="s5",
982 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700983 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700984
985 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800986 actual=testResult,
987 onpass=main.assertReturnString,
988 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700989
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700990 # TODO: implement VLAN selector REST API intent test once supported
991
kelvin-onlab44147802015-07-27 17:57:31 -0700992 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800993 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
994 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700995 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -0800996 ]
997 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700998 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -0800999 ]
1000 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001001 main,
1002 name="1HOP IPV4",
1003 senders=senders,
1004 recipients=recipients,
1005 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001006
1007 if installResult:
1008 testResult = main.intentFunction.testPointIntent(
1009 main,
1010 intentId=installResult,
1011 name="1HOP IPV4",
1012 senders=senders,
1013 recipients=recipients,
1014 sw1="s5",
1015 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001016 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001017
1018 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001019 actual=testResult,
1020 onpass=main.assertReturnString,
1021 onfail=main.assertReturnString )
1022
1023 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001024
1025 def CASE3000( self, main ):
1026 """
1027 Add single point to multi point intents
1028 - Get device ids
1029 - Add single point to multi point intents
1030 - Check intents
1031 - Verify flows
1032 - Ping hosts
1033 - Reroute
1034 - Link down
1035 - Verify flows
1036 - Check topology
1037 - Ping hosts
1038 - Link up
1039 - Verify flows
1040 - Check topology
1041 - Ping hosts
1042 - Remove intents
1043 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001044 if main.initialized == main.FALSE:
1045 main.log.error( "Test components did not start correctly, skipping further tests" )
1046 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001047 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001048
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001049 try:
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001050 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1051 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1052 except AssertionError:
1053 main.initialized = main.FALSE
1054 main.skipCase()
1055
1056 main.testName = "Single to Multi Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001057 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001058 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001059 main.caseExplanation = "This test case will test single point to" + \
1060 " multi point intents using " + \
Devin Lim142b5342017-07-20 15:22:39 -07001061 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" + \
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001062 "Different type of hosts will be tested in " + \
1063 "each step such as IPV4, Dual stack, VLAN etc" + \
1064 ";\nThe test will use OF " + main.OFProtocol + \
1065 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001066 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001067
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001068 main.step( "NOOPTION: Install and test single point to multi point intents" )
1069 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1070 senders = [
1071 { "name": "h8", "device": "of:0000000000000005/8" }
1072 ]
1073 recipients = [
1074 { "name": "h16", "device": "of:0000000000000006/8" },
1075 { "name": "h24", "device": "of:0000000000000007/8" }
1076 ]
1077 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1078 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1079 testResult = main.FALSE
1080 installResult = main.intentFunction.installSingleToMultiIntent(
1081 main,
1082 name="NOOPTION",
1083 senders=senders,
1084 recipients=recipients )
1085
1086 if installResult:
1087 testResult = main.intentFunction.testPointIntent(
1088 main,
1089 intentId=installResult,
1090 name="NOOPTION",
1091 senders=senders,
1092 recipients=recipients,
1093 badSenders=badSenders,
1094 badRecipients=badRecipients,
1095 sw1="s5",
1096 sw2="s2",
1097 expectedLink=18 )
1098 else:
Devin Lim142b5342017-07-20 15:22:39 -07001099 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001100
1101 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001102 actual=testResult,
1103 onpass=main.assertReturnString,
1104 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001105
Jon Hall02758ac2017-05-24 16:20:28 -07001106 main.step( "IPV4: Install and test single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001107 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1108 "with IPV4 type and MAC addresses\n"
1109 senders = [
Jon Hall02758ac2017-05-24 16:20:28 -07001110 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001111 ]
1112 recipients = [
Jon Hall02758ac2017-05-24 16:20:28 -07001113 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1114 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001115 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001116 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1117 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001118 installResult = main.intentFunction.installSingleToMultiIntent(
1119 main,
1120 name="IPV4",
1121 senders=senders,
1122 recipients=recipients,
Jon Hall02758ac2017-05-24 16:20:28 -07001123 ethType="IPV4" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001124
1125 if installResult:
1126 testResult = main.intentFunction.testPointIntent(
1127 main,
1128 intentId=installResult,
1129 name="IPV4",
1130 senders=senders,
1131 recipients=recipients,
1132 badSenders=badSenders,
1133 badRecipients=badRecipients,
1134 sw1="s5",
1135 sw2="s2",
1136 expectedLink=18 )
1137 else:
Devin Lim142b5342017-07-20 15:22:39 -07001138 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001139
1140 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001141 actual=testResult,
1142 onpass=main.assertReturnString,
1143 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001144
1145 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001146 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1147 "with IPV4 type and no MAC addresses\n"
1148 senders = [
1149 { "name": "h8", "device": "of:0000000000000005/8" }
1150 ]
1151 recipients = [
1152 { "name": "h16", "device": "of:0000000000000006/8" },
1153 { "name": "h24", "device": "of:0000000000000007/8" }
1154 ]
1155 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1156 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1157 installResult = main.intentFunction.installSingleToMultiIntent(
1158 main,
1159 name="IPV4_2",
1160 senders=senders,
1161 recipients=recipients,
1162 ethType="IPV4" )
1163
1164 if installResult:
1165 testResult = main.intentFunction.testPointIntent(
1166 main,
1167 intentId=installResult,
1168 name="IPV4_2",
1169 senders=senders,
1170 recipients=recipients,
1171 badSenders=badSenders,
1172 badRecipients=badRecipients,
1173 sw1="s5",
1174 sw2="s2",
1175 expectedLink=18 )
1176 else:
Devin Lim142b5342017-07-20 15:22:39 -07001177 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001178
1179 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001180 actual=testResult,
1181 onpass=main.assertReturnString,
1182 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001183
1184 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001185 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1186 "and MAC addresses in the same VLAN\n"
1187 senders = [
1188 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1189 ]
1190 recipients = [
1191 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1192 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1193 ]
1194 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1195 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1196 installResult = main.intentFunction.installSingleToMultiIntent(
1197 main,
1198 name="VLAN",
1199 senders=senders,
1200 recipients=recipients,
1201 sw1="s5",
1202 sw2="s2" )
1203
1204 if installResult:
1205 testResult = main.intentFunction.testPointIntent(
1206 main,
1207 intentId=installResult,
1208 name="VLAN",
1209 senders=senders,
1210 recipients=recipients,
1211 badSenders=badSenders,
1212 badRecipients=badRecipients,
1213 sw1="s5",
1214 sw2="s2",
1215 expectedLink=18 )
1216 else:
Devin Lim142b5342017-07-20 15:22:39 -07001217 main.Cluster.active( 0 ).CLI.removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001218
1219 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001220 actual=testResult,
1221 onpass=main.assertReturnString,
1222 onfail=main.assertReturnString )
1223
1224 main.step( "VLAN: Add single point to multi point intents" )
1225 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1226 senders = [
1227 { "name": "h5", "vlan": "200" }
1228 ]
1229 recipients = [
1230 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1231 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1232 ]
1233 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1234 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1235 testResult = main.FALSE
1236 installResult = main.intentFunction.installSingleToMultiIntent(
1237 main,
1238 name="VLAN2",
1239 senders=senders,
1240 recipients=recipients,
1241 sw1="s5",
1242 sw2="s2" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001243 # setVlan=100 )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001244
1245 if installResult:
1246 testResult = main.intentFunction.testPointIntent(
1247 main,
1248 intentId=installResult,
1249 name="VLAN2",
1250 senders=senders,
1251 recipients=recipients,
1252 badSenders=badSenders,
1253 badRecipients=badRecipients,
1254 sw1="s5",
1255 sw2="s2",
1256 expectedLink=18 )
1257 else:
Devin Lim142b5342017-07-20 15:22:39 -07001258 main.Cluster.active( 0 ).CLI.removeAllIntents()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001259
1260 utilities.assert_equals( expect=main.TRUE,
1261 actual=testResult,
1262 onpass=main.assertReturnString,
1263 onfail=main.assertReturnString )
1264
1265 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001266
1267 def CASE4000( self, main ):
1268 """
1269 Add multi point to single point intents
1270 - Get device ids
1271 - Add multi point to single point intents
1272 - Check intents
1273 - Verify flows
1274 - Ping hosts
1275 - Reroute
1276 - Link down
1277 - Verify flows
1278 - Check topology
1279 - Ping hosts
1280 - Link up
1281 - Verify flows
1282 - Check topology
1283 - Ping hosts
1284 - Remove intents
1285 """
1286 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001287 assert main.Mininet1, "Mininet handle should be named Mininet1"
1288 assert main.numSwitch, "Placed the total number of switch topology in \
1289 main.numSwitch"
1290
1291 main.case( "Multi To Single Point Intents Test - " +
Devin Lim142b5342017-07-20 15:22:39 -07001292 str( main.Cluster.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001293 main.caseExplanation = "This test case will test single point to" +\
1294 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001295 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab44147802015-07-27 17:57:31 -07001296 "Different type of hosts will be tested in " +\
1297 "each step such as IPV4, Dual stack, VLAN etc" +\
1298 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001299 " OVS running in Mininet and compile intents" +\
1300 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001301
1302 main.step( "NOOPTION: Add multi point to single point intents" )
1303 stepResult = main.TRUE
1304 hostNames = [ 'h8', 'h16', 'h24' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001305 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8',
kelvin-onlab44147802015-07-27 17:57:31 -07001306 'of:0000000000000007/8' ]
1307 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1308 stepResult = main.intentFunction.multiToSingleIntent(
1309 main,
1310 name="NOOPTION",
1311 hostNames=hostNames,
1312 devices=devices,
1313 sw1="s5",
1314 sw2="s2",
1315 expectedLink=18 )
1316
1317 utilities.assert_equals( expect=main.TRUE,
1318 actual=stepResult,
1319 onpass="NOOPTION: Successfully added multi "
1320 + " point to single point intents" +
1321 " with no match action",
1322 onfail="NOOPTION: Failed to add multi point" +
1323 " to single point intents" +
1324 " with no match action" )
1325
1326 main.step( "IPV4: Add multi point to single point intents" )
1327 stepResult = main.TRUE
1328 stepResult = main.intentFunction.multiToSingleIntent(
1329 main,
1330 name="IPV4",
1331 hostNames=hostNames,
1332 devices=devices,
1333 ports=None,
1334 ethType="IPV4",
1335 macs=macs,
1336 bandwidth="",
1337 lambdaAlloc=False,
1338 ipProto="",
1339 ipAddresses="",
1340 tcp="",
1341 sw1="s5",
1342 sw2="s2",
1343 expectedLink=18 )
1344
1345 utilities.assert_equals( expect=main.TRUE,
1346 actual=stepResult,
1347 onpass="IPV4: Successfully added multi point"
1348 + " to single point intents" +
1349 " with IPV4 type and MAC addresses",
1350 onfail="IPV4: Failed to add multi point" +
1351 " to single point intents" +
1352 " with IPV4 type and MAC addresses" )
1353
1354 main.step( "IPV4_2: Add multi point to single point intents" )
1355 stepResult = main.TRUE
1356 hostNames = [ 'h8', 'h16', 'h24' ]
1357 stepResult = main.intentFunction.multiToSingleIntent(
1358 main,
1359 name="IPV4",
1360 hostNames=hostNames,
1361 ethType="IPV4",
1362 lambdaAlloc=False )
1363
1364 utilities.assert_equals( expect=main.TRUE,
1365 actual=stepResult,
1366 onpass="IPV4_2: Successfully added multi point"
1367 + " to single point intents" +
1368 " with IPV4 type and no MAC addresses",
1369 onfail="IPV4_2: Failed to add multi point" +
1370 " to single point intents" +
1371 " with IPV4 type and no MAC addresses" )
1372
1373 main.step( "VLAN: Add multi point to single point intents" )
1374 stepResult = main.TRUE
1375 hostNames = [ 'h5', 'h13', 'h21' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001376 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5',
kelvin-onlab44147802015-07-27 17:57:31 -07001377 'of:0000000000000007/5' ]
1378 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1379 stepResult = main.intentFunction.multiToSingleIntent(
1380 main,
1381 name="VLAN",
1382 hostNames=hostNames,
1383 devices=devices,
1384 ports=None,
1385 ethType="IPV4",
1386 macs=macs,
1387 bandwidth="",
1388 lambdaAlloc=False,
1389 ipProto="",
1390 ipAddresses="",
1391 tcp="",
1392 sw1="s5",
1393 sw2="s2",
1394 expectedLink=18 )
1395
1396 utilities.assert_equals( expect=main.TRUE,
1397 actual=stepResult,
1398 onpass="VLAN: Successfully added multi point"
1399 + " to single point intents" +
1400 " with IPV4 type and MAC addresses" +
1401 " in the same VLAN",
1402 onfail="VLAN: Failed to add multi point" +
1403 " to single point intents" )
1404
1405 def CASE5000( self, main ):
1406 """
Jeremy2f190ca2016-01-29 15:23:57 -08001407 Tests Host Mobility
1408 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001409 """
Jeremydd9bda62016-04-18 12:02:32 -07001410 if main.initialized == main.FALSE:
1411 main.log.error( "Test components did not start correctly, skipping further tests" )
1412 main.skipCase()
1413 # Assert variables - These variable's name|format must be followed
1414 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001415 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001416 try:
Jeremydd9bda62016-04-18 12:02:32 -07001417 assert main.Mininet1
1418 except AssertionError:
1419 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1420 main.initialized = main.FALSE
1421 main.skipCase()
1422 try:
1423 assert main.numSwitch
1424 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001425 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001426 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001427 main.initialized = main.FALSE
1428 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001429 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001430 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001431 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1432
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001433 main.log.info( "Moving h1 from s5 to s6" )
1434 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001435
Jeremy2f190ca2016-01-29 15:23:57 -08001436 # Send discovery ping from moved host
1437 # Moving the host brings down the default interfaces and creates a new one.
1438 # Scapy is restarted on this host to detect the new interface
1439 main.h1.stopScapy()
1440 main.h1.startScapy()
1441
1442 # Discover new host location in ONOS and populate host data.
1443 # Host 1 IP and MAC should be unchanged
1444 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1445 main.intentFunction.populateHostData( main )
1446
kelvin-onlab44147802015-07-27 17:57:31 -07001447 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1448
1449 utilities.assert_equals( expect="of:0000000000000006",
1450 actual=h1PostMove,
1451 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001452 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001453 " to single point intents" +
1454 " with IPV4 type and MAC addresses" +
1455 " in the same VLAN" )
1456
1457 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001458 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001459 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1460 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001461
1462 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001463 name='IPV4 Mobility IPV4',
1464 onosNode='0',
1465 host1=host1,
1466 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001467 if installResult:
1468 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001469 name='Host Mobility IPV4',
1470 intentId=installResult,
1471 onosNode='0',
1472 host1=host1,
1473 host2=host2,
1474 sw1="s6",
1475 sw2="s2",
1476 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001477
1478 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001479 actual=testResult,
1480 onpass=main.assertReturnString,
1481 onfail=main.assertReturnString )
1482
Jon Hallbd60ea02016-08-23 10:03:59 -07001483 main.intentFunction.report( main )