blob: cbf1feacc36002988fd05f31f5e2b2784456485e [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"
Devin Lim142b5342017-07-20 15:22:39 -0700115 main.initialized = main.testSetUp.ONOSSetUp( main.Mininet1, 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"
156 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
157 main.topology,
158 args=args )
159 stepResult = topoResult
160 utilities.assert_equals( expect=main.TRUE,
161 actual=stepResult,
162 onpass="Successfully loaded topology",
163 onfail="Failed to load topology" )
164 # Exit if topology did not load properly
165 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700166 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700167
168 def CASE11( self, main ):
169 """
170 Start Mininet topology with OF 1.3 switches
171 """
Jeremydd9bda62016-04-18 12:02:32 -0700172 if main.initialized == main.FALSE:
173 main.log.error( "Test components did not start correctly, skipping further tests" )
174 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700175 main.OFProtocol = "1.3"
176 main.log.report( "Start Mininet topology with OF 1.3 switches" )
177 main.case( "Start Mininet topology with OF 1.3 switches" )
178 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
179 "switches to test intents, exits out if " +\
180 "topology did not start correctly"
181
182 main.step( "Starting Mininet topology with OF 1.3 switches" )
183 args = "--switch ovs,protocols=OpenFlow13"
184 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
185 main.topology,
186 args=args )
187 stepResult = topoResult
188 utilities.assert_equals( expect=main.TRUE,
189 actual=stepResult,
190 onpass="Successfully loaded topology",
191 onfail="Failed to load topology" )
192 # Exit if topology did not load properly
193 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700194 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700195
196 def CASE12( self, main ):
197 """
198 Assign mastership to controllers
199 """
200 import re
201
Jeremydd9bda62016-04-18 12:02:32 -0700202 if main.initialized == main.FALSE:
203 main.log.error( "Test components did not start correctly, skipping further tests" )
204 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700205 main.case( "Assign switches to controllers" )
206 main.step( "Assigning switches to controllers" )
207 main.caseExplanation = "Assign OF " + main.OFProtocol +\
208 " switches to ONOS nodes"
209
210 assignResult = main.TRUE
211 switchList = []
212
213 # Creates a list switch name, use getSwitch() function later...
214 for i in range( 1, ( main.numSwitch + 1 ) ):
215 switchList.append( 's' + str( i ) )
216
Devin Lim142b5342017-07-20 15:22:39 -0700217 tempONOSip = main.Cluster.getIps()
kelvin-onlab44147802015-07-27 17:57:31 -0700218
219 assignResult = main.Mininet1.assignSwController( sw=switchList,
220 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800221 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700222 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700223 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
224 main.initialized = main.FALSE
225 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700226
227 for i in range( 1, ( main.numSwitch + 1 ) ):
228 response = main.Mininet1.getSwController( "s" + str( i ) )
229 print( "Response is " + str( response ) )
Devin Lim142b5342017-07-20 15:22:39 -0700230 if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ):
kelvin-onlab44147802015-07-27 17:57:31 -0700231 assignResult = assignResult and main.TRUE
232 else:
233 assignResult = main.FALSE
234 stepResult = assignResult
235 utilities.assert_equals( expect=main.TRUE,
236 actual=stepResult,
237 onpass="Successfully assigned switches" +
238 "to controller",
239 onfail="Failed to assign switches to " +
240 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700241 if not stepResult:
242 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800243
Jon Hall02758ac2017-05-24 16:20:28 -0700244 def CASE13( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800245 """
246 Create Scapy components
247 """
Jeremydd9bda62016-04-18 12:02:32 -0700248 if main.initialized == main.FALSE:
249 main.log.error( "Test components did not start correctly, skipping further tests" )
250 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800251 main.case( "Create scapy components" )
252 main.step( "Create scapy components" )
253 import json
254 scapyResult = main.TRUE
255 for hostName in main.scapyHostNames:
256 main.Scapy1.createHostComponent( hostName )
257 main.scapyHosts.append( getattr( main, hostName ) )
258
259 main.step( "Start scapy components" )
260 for host in main.scapyHosts:
261 host.startHostCli()
262 host.startScapy()
263 host.updateSelf()
264 main.log.debug( host.name )
265 main.log.debug( host.hostIp )
266 main.log.debug( host.hostMac )
267
Jeremy2f190ca2016-01-29 15:23:57 -0800268 utilities.assert_equals( expect=main.TRUE,
269 actual=scapyResult,
270 onpass="Successfully created Scapy Components",
271 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700272 if not scapyResult:
273 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800274
275 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700276 """
277 Discover all hosts and store its data to a dictionary
278 """
Jeremydd9bda62016-04-18 12:02:32 -0700279 if main.initialized == main.FALSE:
280 main.log.error( "Test components did not start correctly, skipping further tests" )
281 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700282 main.case( "Discover all hosts" )
283
284 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700285 main.step( "Discover all ipv4 host hosts " )
286 hostList = []
287 # List of host with default vlan
288 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
289 # Lists of host with unique vlan
290 vlanHosts1 = [ "h4", "h12", "h20" ]
291 vlanHosts2 = [ "h5", "h13", "h21" ]
292 vlanHosts3 = [ "h6", "h14", "h22" ]
293 vlanHosts4 = [ "h7", "h15", "h23" ]
294 hostList.append( defaultHosts )
295 hostList.append( vlanHosts1 )
296 hostList.append( vlanHosts2 )
297 hostList.append( vlanHosts3 )
298 hostList.append( vlanHosts4 )
299
300 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700301 utilities.assert_equals( expect=main.TRUE,
302 actual=stepResult,
303 onpass="Successfully discovered hosts",
304 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700305 if not stepResult:
306 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700307
Jeremy2f190ca2016-01-29 15:23:57 -0800308 def CASE15( self, main ):
Devin Lim58046fa2017-07-05 16:55:00 -0700309 """main.topo.
Jeremy2f190ca2016-01-29 15:23:57 -0800310 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700311 """
Jeremydd9bda62016-04-18 12:02:32 -0700312 if main.initialized == main.FALSE:
313 main.log.error( "Test components did not start correctly, skipping further tests" )
314 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800315 main.case( "Discover all hosts using scapy" )
316 main.step( "Send packets from each host to the first host and confirm onos discovery" )
317
318 import collections
319 if len( main.scapyHosts ) < 1:
320 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700321 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800322 main.skipCase()
323
324 # Send ARP packets from each scapy host component
325 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
326
327 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
328 retValue=main.FALSE, args=[ main ],
329 attempts=main.checkTopoAttempts, sleep=2 )
330
331 utilities.assert_equals( expect=main.TRUE,
332 actual=stepResult,
333 onpass="ONOS correctly discovered all hosts",
334 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700335 if not stepResult:
336 main.initialized = main.FALSE
337 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800338
339 main.step( "Populate hostsData" )
340 stepResult = main.intentFunction.populateHostData( main )
341 utilities.assert_equals( expect=main.TRUE,
342 actual=stepResult,
343 onpass="Successfully populated hostsData",
344 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700345 if not stepResult:
346 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800347
348 def CASE16( self, main ):
349 """
Jeremy42df2e72016-02-23 16:37:46 -0800350 Balance Masters
351 """
Jeremydd9bda62016-04-18 12:02:32 -0700352 if main.initialized == main.FALSE:
353 main.log.error( "Test components did not start correctly, skipping further tests" )
354 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800355 main.case( "Balance mastership of switches" )
356 main.step( "Balancing mastership of switches" )
357
358 balanceResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700359 balanceResult = utilities.retry( f=main.Cluster.active( 0 ).CLI.balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800360
361 utilities.assert_equals( expect=main.TRUE,
362 actual=stepResult,
363 onpass="Successfully balanced mastership of switches",
364 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700365 if not stepResult:
366 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800367
368 def CASE17( self, main ):
369 """
Jeremyeb51cb12016-03-28 17:53:35 -0700370 Use Flow Objectives
371 """
Jeremydd9bda62016-04-18 12:02:32 -0700372 if main.initialized == main.FALSE:
373 main.log.error( "Test components did not start correctly, skipping further tests" )
374 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700375 main.case( "Enable intent compilation using Flow Objectives" )
376 main.step( "Enabling Flow Objectives" )
377
378 main.flowCompiler = "Flow Objectives"
379
380 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
381
Devin Lim142b5342017-07-20 15:22:39 -0700382 stepResult = main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700383 propName="useFlowObjectives", value="true" )
Devin Lim142b5342017-07-20 15:22:39 -0700384 stepResult &= main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700385 propName="defaultFlowObjectiveCompiler",
386 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremyeb51cb12016-03-28 17:53:35 -0700387
388 utilities.assert_equals( expect=main.TRUE,
389 actual=stepResult,
390 onpass="Successfully activated Flow Objectives",
391 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700392 if not stepResult:
393 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700394
395 def CASE18( self, main ):
396 """
Jeremy2f190ca2016-01-29 15:23:57 -0800397 Stop mininet and remove scapy hosts
398 """
Devin Lim58046fa2017-07-05 16:55:00 -0700399 try:
400 from tests.dependencies.utils import Utils
401 except ImportError:
402 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700403 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700404 try:
405 main.Utils
406 except ( NameError, AttributeError ):
407 main.Utils = Utils()
Jeremy2f190ca2016-01-29 15:23:57 -0800408 main.log.report( "Stop Mininet and Scapy" )
409 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700410 main.caseExplanation = "Stopping the current mininet topology " +\
411 "to start up fresh"
412
Jeremy2f190ca2016-01-29 15:23:57 -0800413 main.step( "Stopping and Removing Scapy Host Components" )
414 scapyResult = main.TRUE
415 for host in main.scapyHosts:
416 scapyResult = scapyResult and host.stopScapy()
417 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
418
419 for host in main.scapyHosts:
420 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
421 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
422
423 main.scapyHosts = []
424 main.scapyHostIPs = []
425
426 utilities.assert_equals( expect=main.TRUE,
427 actual=scapyResult,
428 onpass="Successfully stopped scapy and removed host components",
429 onfail="Failed to stop mininet and scapy" )
430
Devin Lim58046fa2017-07-05 16:55:00 -0700431 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlab44147802015-07-27 17:57:31 -0700432 # Exit if topology did not load properly
Jon Hall02758ac2017-05-24 16:20:28 -0700433 if not ( mininetResult and scapyResult ):
Devin Lim44075962017-08-11 10:56:37 -0700434 main.cleanAndExit()
kelvin-onlab44147802015-07-27 17:57:31 -0700435
Jeremy Songster17147f22016-05-31 18:30:52 -0700436 def CASE19( self, main ):
437 """
438 Copy the karaf.log files after each testcase cycle
439 """
Devin Lim58046fa2017-07-05 16:55:00 -0700440 try:
441 from tests.dependencies.utils import Utils
442 except ImportError:
443 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700444 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700445 try:
446 main.Utils
447 except ( NameError, AttributeError ):
448 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700449 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700450
kelvin-onlab44147802015-07-27 17:57:31 -0700451 def CASE1000( self, main ):
452 """
453 Add host intents between 2 host:
454 - Discover hosts
455 - Add host intents
456 - Check intents
457 - Verify flows
458 - Ping hosts
459 - Reroute
460 - Link down
461 - Verify flows
462 - Check topology
463 - Ping hosts
464 - Link up
465 - Verify flows
466 - Check topology
467 - Ping hosts
468 - Remove intents
469 """
470 import time
471 import json
472 import re
Jeremydd9bda62016-04-18 12:02:32 -0700473 if main.initialized == main.FALSE:
474 main.log.error( "Test components did not start correctly, skipping further tests" )
475 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700476 # Assert variables - These variable's name|format must be followed
477 # if you want to use the wrapper function
478 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700479 try:
Jeremydd9bda62016-04-18 12:02:32 -0700480 assert main.Mininet1
481 except AssertionError:
482 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
483 main.initialized = main.FALSE
484 main.skipCase()
485 try:
486 assert main.numSwitch
487 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700488 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700489 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700490 main.initialized = main.FALSE
491 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700492
Jeremye1ea0602016-02-08 16:35:05 -0800493 # Save leader candidates
Devin Lim142b5342017-07-20 15:22:39 -0700494 intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800495
Devin Lim142b5342017-07-20 15:22:39 -0700496 main.case( "Host Intents Test - " + str( main.Cluster.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700497 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700498 main.caseExplanation = "This test case tests Host intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -0700499 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab44147802015-07-27 17:57:31 -0700500 "Different type of hosts will be tested in " +\
501 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700502 "etc;\nThe test will use OF " + main.OFProtocol +\
503 " OVS running in Mininet and compile intents" +\
504 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700505
Jeremy2f190ca2016-01-29 15:23:57 -0800506 main.step( "IPV4: Add and test host intents between h1 and h9" )
507 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700508 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
509 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800510 testResult = main.FALSE
511 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700512 name='IPV4',
513 onosNode='0',
514 host1=host1,
515 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800516
517 if installResult:
518 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700519 name='IPV4',
520 intentId=installResult,
521 onosNode='0',
522 host1=host1,
523 host2=host2,
524 sw1='s5',
525 sw2='s2',
526 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700527
528 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800529 actual=testResult,
530 onpass=main.assertReturnString,
531 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700532
533 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800534 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700535 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
536 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800537 testResult = main.FALSE
538 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700539 name='DUALSTACK1',
540 onosNode='0',
541 host1=host1,
542 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800543
544 if installResult:
545 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700546 name='DUALSTACK1',
547 intentId=installResult,
548 onosNode='0',
549 host1=host1,
550 host2=host2,
551 sw1='s5',
552 sw2='s2',
553 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700554
555 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800556 actual=testResult,
557 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700558 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700559
560 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800561 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700562 host1 = { "name": "h1" }
563 host2 = { "name": "h11" }
Jeremy2f190ca2016-01-29 15:23:57 -0800564 testResult = main.FALSE
565 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700566 name='DUALSTACK2',
567 onosNode='0',
568 host1=host1,
569 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800570
571 if installResult:
572 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700573 name='DUALSTACK2',
574 intentId=installResult,
575 onosNode='0',
576 host1=host1,
577 host2=host2,
578 sw1='s5',
579 sw2='s2',
580 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700581
582 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800583 actual=testResult,
584 onpass=main.assertReturnString,
585 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700586
587 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800588 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700589 host1 = { "name": "h1" }
590 host2 = { "name": "h3" }
Jeremy2f190ca2016-01-29 15:23:57 -0800591 testResult = main.FALSE
592 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700593 name='1HOP',
594 onosNode='0',
595 host1=host1,
596 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700597
Jeremy2f190ca2016-01-29 15:23:57 -0800598 if installResult:
599 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700600 name='1HOP',
601 intentId=installResult,
602 onosNode='0',
603 host1=host1,
604 host2=host2,
605 sw1='s5',
606 sw2='s2',
607 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700608
609 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800610 actual=testResult,
611 onpass=main.assertReturnString,
612 onfail=main.assertReturnString )
613
614 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
615 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700616 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" }
617 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800618 testResult = main.FALSE
619 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700620 name='VLAN1',
621 onosNode='0',
622 host1=host1,
623 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800624
625 if installResult:
626 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700627 name='VLAN1',
628 intentId=installResult,
629 onosNode='0',
630 host1=host1,
631 host2=host2,
632 sw1='s5',
633 sw2='s2',
634 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -0800635
636 utilities.assert_equals( expect=main.TRUE,
637 actual=testResult,
638 onpass=main.assertReturnString,
639 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700640
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700641 # This step isn't currently possible to perform in the REST API
642 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
643 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
644 # host1 = { "name":"h13" }
645 # host2 = { "name":"h20" }
646 # testResult = main.FALSE
647 # installResult = main.intentFunction.installHostIntent( main,
648 # name='VLAN2',
649 # onosNode='0',
650 # host1=host1,
651 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700652
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700653 # if installResult:
654 # testResult = main.intentFunction.testHostIntent( main,
655 # name='VLAN2',
Jon Hall02758ac2017-05-24 16:20:28 -0700656 # intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700657 # onosNode='0',
658 # host1=host1,
659 # host2=host2,
660 # sw1='s5',
661 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700662 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700663
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700664 # utilities.assert_equals( expect=main.TRUE,
665 # actual=testResult,
666 # onpass=main.assertReturnString,
667 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -0800668
Jeremye1ea0602016-02-08 16:35:05 -0800669 # Change the following to use the REST API when leader checking is
670 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -0800671
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700672 main.step( "Confirm that ONOS leadership is unchanged" )
Devin Lim142b5342017-07-20 15:22:39 -0700673 intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800674 main.intentFunction.checkLeaderChange( intentLeadersOld,
675 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -0800676
Jeremye1ea0602016-02-08 16:35:05 -0800677 utilities.assert_equals( expect=main.TRUE,
678 actual=testResult,
679 onpass="ONOS Leaders Unchanged",
Jon Hall02758ac2017-05-24 16:20:28 -0700680 onfail="ONOS Leader Mismatch" )
Jeremy2f190ca2016-01-29 15:23:57 -0800681
682 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -0700683
684 def CASE2000( self, main ):
685 """
686 Add point intents between 2 hosts:
687 - Get device ids | ports
688 - Add point intents
689 - Check intents
690 - Verify flows
691 - Ping hosts
692 - Reroute
693 - Link down
694 - Verify flows
695 - Check topology
696 - Ping hosts
697 - Link up
698 - Verify flows
699 - Check topology
700 - Ping hosts
701 - Remove intents
702 """
Jeremydd9bda62016-04-18 12:02:32 -0700703 if main.initialized == main.FALSE:
704 main.log.error( "Test components did not start correctly, skipping further tests" )
705 main.skipCase()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700706 # Assert variables - These variable's name|format must be followed
707 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -0700708 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700709 try:
Jeremydd9bda62016-04-18 12:02:32 -0700710 assert main.Mininet1
711 except AssertionError:
712 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
713 main.initialized = main.FALSE
714 main.skipCase()
715 try:
716 assert main.numSwitch
717 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700718 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700719 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700720 main.initialized = main.FALSE
721 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700722
Devin Lim142b5342017-07-20 15:22:39 -0700723 main.case( "Point Intents Test - " + str( main.Cluster.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -0700724 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700725 main.caseExplanation = "This test case will test point to point" + \
Devin Lim142b5342017-07-20 15:22:39 -0700726 " intents using " + str( main.Cluster.numCtrls ) + \
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700727 " node(s) cluster;\n" + \
728 "Different type of hosts will be tested in " + \
729 "each step such as IPV4, Dual stack, VLAN etc" + \
730 ";\nThe test will use OF " + main.OFProtocol + \
731 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -0700732 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700733
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700734 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -0700735 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800736 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
737 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700738 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800739 ]
740 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700741 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800742 ]
743 testResult = main.FALSE
744 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700745 main,
746 name="NOOPTION",
747 senders=senders,
748 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800749
750 if installResult:
751 testResult = main.intentFunction.testPointIntent(
752 main,
753 intentId=installResult,
754 name="NOOPTION",
755 senders=senders,
756 recipients=recipients,
757 sw1="s5",
758 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700759 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700760
761 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800762 actual=testResult,
763 onpass=main.assertReturnString,
764 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700765
kelvin-onlab44147802015-07-27 17:57:31 -0700766 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800767 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
768 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700769 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -0800770 ]
771 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700772 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -0800773 ]
774 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700775 main,
776 name="IPV4",
777 senders=senders,
778 recipients=recipients,
779 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800780
781 if installResult:
782 testResult = main.intentFunction.testPointIntent(
783 main,
784 intentId=installResult,
785 name="IPV4",
786 senders=senders,
787 recipients=recipients,
788 sw1="s5",
789 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700790 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700791
792 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800793 actual=testResult,
794 onpass=main.assertReturnString,
795 onfail=main.assertReturnString )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700796
alisonda157272016-12-22 01:13:21 -0800797 # main.step( "Protected: Add point intents between h1 and h9" )
798 # main.assertReturnString = "Assertion Result for protected point intent\n"
799 # senders = [
800 # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
801 # ]
802 # recipients = [
803 # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
804 # ]
805 # testResult = main.FALSE
806 # installResult = main.intentFunction.installPointIntent(
807 # main,
808 # name="Protected",
809 # senders=senders,
810 # recipients=recipients,
811 # protected=True )
Jon Hall02758ac2017-05-24 16:20:28 -0700812 #
alisonda157272016-12-22 01:13:21 -0800813 # if installResult:
814 # testResult = main.intentFunction.testPointIntent(
815 # main,
816 # name="Protected",
817 # intentId=installResult,
818 # senders=senders,
819 # recipients=recipients,
820 # sw1="s5",
821 # sw2="s2",
822 # protected=True,
823 # expectedLink=18 )
824 #
825 # utilities.assert_equals( expect=main.TRUE,
826 # actual=testResult,
827 # onpass=main.assertReturnString,
828 # onfail=main.assertReturnString )
829
kelvin-onlab44147802015-07-27 17:57:31 -0700830 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800831 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
832 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700833 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800834 ]
835 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700836 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800837 ]
838 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700839 main,
840 name="IPV4_2",
841 senders=senders,
842 recipients=recipients,
843 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800844
845 if installResult:
846 testResult = main.intentFunction.testPointIntent(
847 main,
848 intentId=installResult,
849 name="IPV4_2",
850 senders=senders,
851 recipients=recipients,
852 sw1="s5",
853 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700854 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700855
856 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800857 actual=testResult,
858 onpass=main.assertReturnString,
859 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700860
kelvin-onlab0e684682015-08-11 18:51:41 -0700861 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800862 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
863 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700864 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
865 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800866 ]
867 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700868 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
869 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800870 ]
Jon Hall02758ac2017-05-24 16:20:28 -0700871 # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700872 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700873 # Uneccessary, not including this in the selectors
Jon Hall02758ac2017-05-24 16:20:28 -0700874 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
875 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700876
Jeremy2f190ca2016-01-29 15:23:57 -0800877 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700878 main,
879 name="SDNIP-ICMP",
880 senders=senders,
881 recipients=recipients,
882 ethType="IPV4",
883 ipProto=ipProto,
884 tcpSrc=tcpSrc,
885 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -0800886
887 if installResult:
888 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700889 main,
890 intentId=installResult,
891 name="SDNIP_ICMP",
892 senders=senders,
893 recipients=recipients,
894 sw1="s5",
895 sw2="s2",
896 expectedLink=18,
897 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -0700898
899 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800900 actual=testResult,
901 onpass=main.assertReturnString,
902 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700903
kelvin-onlab0e684682015-08-11 18:51:41 -0700904 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800905 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700906 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
907 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
908 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
909 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
910 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
911 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
912 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700913
kelvin-onlab0e684682015-08-11 18:51:41 -0700914 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700915 main,
916 name="SDNIP-TCP",
917 host1="h1",
918 host2="h9",
919 deviceId1="of:0000000000000005/1",
920 deviceId2="of:0000000000000006/1",
921 mac1=mac1,
922 mac2=mac2,
923 ethType="IPV4",
924 ipProto=ipProto,
925 ip1=ip1,
926 ip2=ip2,
927 tcp1=tcp1,
928 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700929
930 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700931 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -0800932 onpass=main.assertReturnString,
933 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700934
Jeremy2f190ca2016-01-29 15:23:57 -0800935 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
936 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
937 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700938 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -0800939 ]
940 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700941 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -0800942 ]
943 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700944 main,
945 name="DUALSTACK1",
946 senders=senders,
947 recipients=recipients,
948 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800949
950 if installResult:
951 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700952 main,
953 intentId=installResult,
954 name="DUALSTACK1",
955 senders=senders,
956 recipients=recipients,
957 sw1="s5",
958 sw2="s2",
959 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700960
961 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800962 actual=testResult,
963 onpass=main.assertReturnString,
964 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700965
966 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -0800967 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
968 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700969 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800970 ]
971 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700972 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800973 ]
974 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700975 main,
976 name="VLAN",
977 senders=senders,
978 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800979
980 if installResult:
981 testResult = main.intentFunction.testPointIntent(
982 main,
983 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700984 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -0800985 senders=senders,
986 recipients=recipients,
987 sw1="s5",
988 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700989 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700990
991 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800992 actual=testResult,
993 onpass=main.assertReturnString,
994 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700995
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700996 # TODO: implement VLAN selector REST API intent test once supported
997
kelvin-onlab44147802015-07-27 17:57:31 -0700998 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800999 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1000 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001001 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001002 ]
1003 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001004 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001005 ]
1006 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001007 main,
1008 name="1HOP IPV4",
1009 senders=senders,
1010 recipients=recipients,
1011 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001012
1013 if installResult:
1014 testResult = main.intentFunction.testPointIntent(
1015 main,
1016 intentId=installResult,
1017 name="1HOP IPV4",
1018 senders=senders,
1019 recipients=recipients,
1020 sw1="s5",
1021 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001022 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001023
1024 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001025 actual=testResult,
1026 onpass=main.assertReturnString,
1027 onfail=main.assertReturnString )
1028
1029 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001030
1031 def CASE3000( self, main ):
1032 """
1033 Add single point to multi point intents
1034 - Get device ids
1035 - Add single point to multi point intents
1036 - Check intents
1037 - Verify flows
1038 - Ping hosts
1039 - Reroute
1040 - Link down
1041 - Verify flows
1042 - Check topology
1043 - Ping hosts
1044 - Link up
1045 - Verify flows
1046 - Check topology
1047 - Ping hosts
1048 - Remove intents
1049 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001050 if main.initialized == main.FALSE:
1051 main.log.error( "Test components did not start correctly, skipping further tests" )
1052 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001053 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001054
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001055 try:
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001056 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1057 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1058 except AssertionError:
1059 main.initialized = main.FALSE
1060 main.skipCase()
1061
1062 main.testName = "Single to Multi Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001063 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001064 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001065 main.caseExplanation = "This test case will test single point to" + \
1066 " multi point intents using " + \
Devin Lim142b5342017-07-20 15:22:39 -07001067 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" + \
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001068 "Different type of hosts will be tested in " + \
1069 "each step such as IPV4, Dual stack, VLAN etc" + \
1070 ";\nThe test will use OF " + main.OFProtocol + \
1071 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001072 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001073
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001074 main.step( "NOOPTION: Install and test single point to multi point intents" )
1075 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1076 senders = [
1077 { "name": "h8", "device": "of:0000000000000005/8" }
1078 ]
1079 recipients = [
1080 { "name": "h16", "device": "of:0000000000000006/8" },
1081 { "name": "h24", "device": "of:0000000000000007/8" }
1082 ]
1083 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1084 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1085 testResult = main.FALSE
1086 installResult = main.intentFunction.installSingleToMultiIntent(
1087 main,
1088 name="NOOPTION",
1089 senders=senders,
1090 recipients=recipients )
1091
1092 if installResult:
1093 testResult = main.intentFunction.testPointIntent(
1094 main,
1095 intentId=installResult,
1096 name="NOOPTION",
1097 senders=senders,
1098 recipients=recipients,
1099 badSenders=badSenders,
1100 badRecipients=badRecipients,
1101 sw1="s5",
1102 sw2="s2",
1103 expectedLink=18 )
1104 else:
Devin Lim142b5342017-07-20 15:22:39 -07001105 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001106
1107 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001108 actual=testResult,
1109 onpass=main.assertReturnString,
1110 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001111
Jon Hall02758ac2017-05-24 16:20:28 -07001112 main.step( "IPV4: Install and test single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001113 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1114 "with IPV4 type and MAC addresses\n"
1115 senders = [
Jon Hall02758ac2017-05-24 16:20:28 -07001116 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001117 ]
1118 recipients = [
Jon Hall02758ac2017-05-24 16:20:28 -07001119 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1120 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001121 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001122 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1123 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001124 installResult = main.intentFunction.installSingleToMultiIntent(
1125 main,
1126 name="IPV4",
1127 senders=senders,
1128 recipients=recipients,
Jon Hall02758ac2017-05-24 16:20:28 -07001129 ethType="IPV4" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001130
1131 if installResult:
1132 testResult = main.intentFunction.testPointIntent(
1133 main,
1134 intentId=installResult,
1135 name="IPV4",
1136 senders=senders,
1137 recipients=recipients,
1138 badSenders=badSenders,
1139 badRecipients=badRecipients,
1140 sw1="s5",
1141 sw2="s2",
1142 expectedLink=18 )
1143 else:
Devin Lim142b5342017-07-20 15:22:39 -07001144 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001145
1146 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001147 actual=testResult,
1148 onpass=main.assertReturnString,
1149 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001150
1151 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001152 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1153 "with IPV4 type and no MAC addresses\n"
1154 senders = [
1155 { "name": "h8", "device": "of:0000000000000005/8" }
1156 ]
1157 recipients = [
1158 { "name": "h16", "device": "of:0000000000000006/8" },
1159 { "name": "h24", "device": "of:0000000000000007/8" }
1160 ]
1161 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1162 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1163 installResult = main.intentFunction.installSingleToMultiIntent(
1164 main,
1165 name="IPV4_2",
1166 senders=senders,
1167 recipients=recipients,
1168 ethType="IPV4" )
1169
1170 if installResult:
1171 testResult = main.intentFunction.testPointIntent(
1172 main,
1173 intentId=installResult,
1174 name="IPV4_2",
1175 senders=senders,
1176 recipients=recipients,
1177 badSenders=badSenders,
1178 badRecipients=badRecipients,
1179 sw1="s5",
1180 sw2="s2",
1181 expectedLink=18 )
1182 else:
Devin Lim142b5342017-07-20 15:22:39 -07001183 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001184
1185 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001186 actual=testResult,
1187 onpass=main.assertReturnString,
1188 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001189
1190 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001191 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1192 "and MAC addresses in the same VLAN\n"
1193 senders = [
1194 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1195 ]
1196 recipients = [
1197 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1198 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1199 ]
1200 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1201 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1202 installResult = main.intentFunction.installSingleToMultiIntent(
1203 main,
1204 name="VLAN",
1205 senders=senders,
1206 recipients=recipients,
1207 sw1="s5",
1208 sw2="s2" )
1209
1210 if installResult:
1211 testResult = main.intentFunction.testPointIntent(
1212 main,
1213 intentId=installResult,
1214 name="VLAN",
1215 senders=senders,
1216 recipients=recipients,
1217 badSenders=badSenders,
1218 badRecipients=badRecipients,
1219 sw1="s5",
1220 sw2="s2",
1221 expectedLink=18 )
1222 else:
Devin Lim142b5342017-07-20 15:22:39 -07001223 main.Cluster.active( 0 ).CLI.removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001224
1225 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001226 actual=testResult,
1227 onpass=main.assertReturnString,
1228 onfail=main.assertReturnString )
1229
1230 main.step( "VLAN: Add single point to multi point intents" )
1231 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1232 senders = [
1233 { "name": "h5", "vlan": "200" }
1234 ]
1235 recipients = [
1236 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1237 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1238 ]
1239 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1240 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1241 testResult = main.FALSE
1242 installResult = main.intentFunction.installSingleToMultiIntent(
1243 main,
1244 name="VLAN2",
1245 senders=senders,
1246 recipients=recipients,
1247 sw1="s5",
1248 sw2="s2" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001249 # setVlan=100 )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001250
1251 if installResult:
1252 testResult = main.intentFunction.testPointIntent(
1253 main,
1254 intentId=installResult,
1255 name="VLAN2",
1256 senders=senders,
1257 recipients=recipients,
1258 badSenders=badSenders,
1259 badRecipients=badRecipients,
1260 sw1="s5",
1261 sw2="s2",
1262 expectedLink=18 )
1263 else:
Devin Lim142b5342017-07-20 15:22:39 -07001264 main.Cluster.active( 0 ).CLI.removeAllIntents()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001265
1266 utilities.assert_equals( expect=main.TRUE,
1267 actual=testResult,
1268 onpass=main.assertReturnString,
1269 onfail=main.assertReturnString )
1270
1271 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001272
1273 def CASE4000( self, main ):
1274 """
1275 Add multi point to single point intents
1276 - Get device ids
1277 - Add multi point to single point intents
1278 - Check intents
1279 - Verify flows
1280 - Ping hosts
1281 - Reroute
1282 - Link down
1283 - Verify flows
1284 - Check topology
1285 - Ping hosts
1286 - Link up
1287 - Verify flows
1288 - Check topology
1289 - Ping hosts
1290 - Remove intents
1291 """
1292 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001293 assert main.Mininet1, "Mininet handle should be named Mininet1"
1294 assert main.numSwitch, "Placed the total number of switch topology in \
1295 main.numSwitch"
1296
1297 main.case( "Multi To Single Point Intents Test - " +
Devin Lim142b5342017-07-20 15:22:39 -07001298 str( main.Cluster.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001299 main.caseExplanation = "This test case will test single point to" +\
1300 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001301 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab44147802015-07-27 17:57:31 -07001302 "Different type of hosts will be tested in " +\
1303 "each step such as IPV4, Dual stack, VLAN etc" +\
1304 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001305 " OVS running in Mininet and compile intents" +\
1306 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001307
1308 main.step( "NOOPTION: Add multi point to single point intents" )
1309 stepResult = main.TRUE
1310 hostNames = [ 'h8', 'h16', 'h24' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001311 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8',
kelvin-onlab44147802015-07-27 17:57:31 -07001312 'of:0000000000000007/8' ]
1313 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1314 stepResult = main.intentFunction.multiToSingleIntent(
1315 main,
1316 name="NOOPTION",
1317 hostNames=hostNames,
1318 devices=devices,
1319 sw1="s5",
1320 sw2="s2",
1321 expectedLink=18 )
1322
1323 utilities.assert_equals( expect=main.TRUE,
1324 actual=stepResult,
1325 onpass="NOOPTION: Successfully added multi "
1326 + " point to single point intents" +
1327 " with no match action",
1328 onfail="NOOPTION: Failed to add multi point" +
1329 " to single point intents" +
1330 " with no match action" )
1331
1332 main.step( "IPV4: Add multi point to single point intents" )
1333 stepResult = main.TRUE
1334 stepResult = main.intentFunction.multiToSingleIntent(
1335 main,
1336 name="IPV4",
1337 hostNames=hostNames,
1338 devices=devices,
1339 ports=None,
1340 ethType="IPV4",
1341 macs=macs,
1342 bandwidth="",
1343 lambdaAlloc=False,
1344 ipProto="",
1345 ipAddresses="",
1346 tcp="",
1347 sw1="s5",
1348 sw2="s2",
1349 expectedLink=18 )
1350
1351 utilities.assert_equals( expect=main.TRUE,
1352 actual=stepResult,
1353 onpass="IPV4: Successfully added multi point"
1354 + " to single point intents" +
1355 " with IPV4 type and MAC addresses",
1356 onfail="IPV4: Failed to add multi point" +
1357 " to single point intents" +
1358 " with IPV4 type and MAC addresses" )
1359
1360 main.step( "IPV4_2: Add multi point to single point intents" )
1361 stepResult = main.TRUE
1362 hostNames = [ 'h8', 'h16', 'h24' ]
1363 stepResult = main.intentFunction.multiToSingleIntent(
1364 main,
1365 name="IPV4",
1366 hostNames=hostNames,
1367 ethType="IPV4",
1368 lambdaAlloc=False )
1369
1370 utilities.assert_equals( expect=main.TRUE,
1371 actual=stepResult,
1372 onpass="IPV4_2: Successfully added multi point"
1373 + " to single point intents" +
1374 " with IPV4 type and no MAC addresses",
1375 onfail="IPV4_2: Failed to add multi point" +
1376 " to single point intents" +
1377 " with IPV4 type and no MAC addresses" )
1378
1379 main.step( "VLAN: Add multi point to single point intents" )
1380 stepResult = main.TRUE
1381 hostNames = [ 'h5', 'h13', 'h21' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001382 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5',
kelvin-onlab44147802015-07-27 17:57:31 -07001383 'of:0000000000000007/5' ]
1384 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1385 stepResult = main.intentFunction.multiToSingleIntent(
1386 main,
1387 name="VLAN",
1388 hostNames=hostNames,
1389 devices=devices,
1390 ports=None,
1391 ethType="IPV4",
1392 macs=macs,
1393 bandwidth="",
1394 lambdaAlloc=False,
1395 ipProto="",
1396 ipAddresses="",
1397 tcp="",
1398 sw1="s5",
1399 sw2="s2",
1400 expectedLink=18 )
1401
1402 utilities.assert_equals( expect=main.TRUE,
1403 actual=stepResult,
1404 onpass="VLAN: Successfully added multi point"
1405 + " to single point intents" +
1406 " with IPV4 type and MAC addresses" +
1407 " in the same VLAN",
1408 onfail="VLAN: Failed to add multi point" +
1409 " to single point intents" )
1410
1411 def CASE5000( self, main ):
1412 """
Jeremy2f190ca2016-01-29 15:23:57 -08001413 Tests Host Mobility
1414 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001415 """
Jeremydd9bda62016-04-18 12:02:32 -07001416 if main.initialized == main.FALSE:
1417 main.log.error( "Test components did not start correctly, skipping further tests" )
1418 main.skipCase()
1419 # Assert variables - These variable's name|format must be followed
1420 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001421 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001422 try:
Jeremydd9bda62016-04-18 12:02:32 -07001423 assert main.Mininet1
1424 except AssertionError:
1425 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1426 main.initialized = main.FALSE
1427 main.skipCase()
1428 try:
1429 assert main.numSwitch
1430 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001431 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001432 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001433 main.initialized = main.FALSE
1434 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001435 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001436 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001437 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1438
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001439 main.log.info( "Moving h1 from s5 to s6" )
1440 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001441
Jeremy2f190ca2016-01-29 15:23:57 -08001442 # Send discovery ping from moved host
1443 # Moving the host brings down the default interfaces and creates a new one.
1444 # Scapy is restarted on this host to detect the new interface
1445 main.h1.stopScapy()
1446 main.h1.startScapy()
1447
1448 # Discover new host location in ONOS and populate host data.
1449 # Host 1 IP and MAC should be unchanged
1450 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1451 main.intentFunction.populateHostData( main )
1452
kelvin-onlab44147802015-07-27 17:57:31 -07001453 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1454
1455 utilities.assert_equals( expect="of:0000000000000006",
1456 actual=h1PostMove,
1457 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001458 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001459 " to single point intents" +
1460 " with IPV4 type and MAC addresses" +
1461 " in the same VLAN" )
1462
1463 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001464 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001465 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1466 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001467
1468 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001469 name='IPV4 Mobility IPV4',
1470 onosNode='0',
1471 host1=host1,
1472 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001473 if installResult:
1474 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001475 name='Host Mobility IPV4',
1476 intentId=installResult,
1477 onosNode='0',
1478 host1=host1,
1479 host2=host2,
1480 sw1="s6",
1481 sw2="s2",
1482 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001483
1484 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001485 actual=testResult,
1486 onpass=main.assertReturnString,
1487 onfail=main.assertReturnString )
1488
Jon Hallbd60ea02016-08-23 10:03:59 -07001489 main.intentFunction.report( main )