blob: dda829e85e09fc87cc6a073a459e3bc0c6ad6858 [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" )
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="defaultFlowObjectiveCompiler",
384 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremyeb51cb12016-03-28 17:53:35 -0700385
386 utilities.assert_equals( expect=main.TRUE,
387 actual=stepResult,
388 onpass="Successfully activated Flow Objectives",
389 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700390 if not stepResult:
391 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700392
393 def CASE18( self, main ):
394 """
Jeremy2f190ca2016-01-29 15:23:57 -0800395 Stop mininet and remove scapy hosts
396 """
Devin Lim58046fa2017-07-05 16:55:00 -0700397 try:
398 from tests.dependencies.utils import Utils
399 except ImportError:
400 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700401 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700402 try:
403 main.Utils
404 except ( NameError, AttributeError ):
405 main.Utils = Utils()
Jeremy2f190ca2016-01-29 15:23:57 -0800406 main.log.report( "Stop Mininet and Scapy" )
407 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700408 main.caseExplanation = "Stopping the current mininet topology " +\
409 "to start up fresh"
410
Jeremy2f190ca2016-01-29 15:23:57 -0800411 main.step( "Stopping and Removing Scapy Host Components" )
412 scapyResult = main.TRUE
413 for host in main.scapyHosts:
414 scapyResult = scapyResult and host.stopScapy()
415 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
416
417 for host in main.scapyHosts:
418 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
419 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
420
421 main.scapyHosts = []
422 main.scapyHostIPs = []
423
424 utilities.assert_equals( expect=main.TRUE,
425 actual=scapyResult,
426 onpass="Successfully stopped scapy and removed host components",
427 onfail="Failed to stop mininet and scapy" )
428
Devin Lim58046fa2017-07-05 16:55:00 -0700429 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlab44147802015-07-27 17:57:31 -0700430 # Exit if topology did not load properly
Jon Hall02758ac2017-05-24 16:20:28 -0700431 if not ( mininetResult and scapyResult ):
Devin Lim44075962017-08-11 10:56:37 -0700432 main.cleanAndExit()
kelvin-onlab44147802015-07-27 17:57:31 -0700433
Jeremy Songster17147f22016-05-31 18:30:52 -0700434 def CASE19( self, main ):
435 """
436 Copy the karaf.log files after each testcase cycle
437 """
Devin Lim58046fa2017-07-05 16:55:00 -0700438 try:
439 from tests.dependencies.utils import Utils
440 except ImportError:
441 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700442 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700443 try:
444 main.Utils
445 except ( NameError, AttributeError ):
446 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700447 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700448
kelvin-onlab44147802015-07-27 17:57:31 -0700449 def CASE1000( self, main ):
450 """
451 Add host intents between 2 host:
452 - Discover hosts
453 - Add host intents
454 - Check intents
455 - Verify flows
456 - Ping hosts
457 - Reroute
458 - Link down
459 - Verify flows
460 - Check topology
461 - Ping hosts
462 - Link up
463 - Verify flows
464 - Check topology
465 - Ping hosts
466 - Remove intents
467 """
468 import time
469 import json
470 import re
Jeremydd9bda62016-04-18 12:02:32 -0700471 if main.initialized == main.FALSE:
472 main.log.error( "Test components did not start correctly, skipping further tests" )
473 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700474 # Assert variables - These variable's name|format must be followed
475 # if you want to use the wrapper function
476 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700477 try:
Jeremydd9bda62016-04-18 12:02:32 -0700478 assert main.Mininet1
479 except AssertionError:
480 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
481 main.initialized = main.FALSE
482 main.skipCase()
483 try:
484 assert main.numSwitch
485 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700486 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700487 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700488 main.initialized = main.FALSE
489 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700490
Jeremye1ea0602016-02-08 16:35:05 -0800491 # Save leader candidates
Devin Lim142b5342017-07-20 15:22:39 -0700492 intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800493
Devin Lim142b5342017-07-20 15:22:39 -0700494 main.case( "Host Intents Test - " + str( main.Cluster.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700495 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700496 main.caseExplanation = "This test case tests Host intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -0700497 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab44147802015-07-27 17:57:31 -0700498 "Different type of hosts will be tested in " +\
499 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700500 "etc;\nThe test will use OF " + main.OFProtocol +\
501 " OVS running in Mininet and compile intents" +\
502 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700503
Jeremy2f190ca2016-01-29 15:23:57 -0800504 main.step( "IPV4: Add and test host intents between h1 and h9" )
505 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700506 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
507 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800508 testResult = main.FALSE
509 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700510 name='IPV4',
511 onosNode='0',
512 host1=host1,
513 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800514
515 if installResult:
516 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700517 name='IPV4',
518 intentId=installResult,
519 onosNode='0',
520 host1=host1,
521 host2=host2,
522 sw1='s5',
523 sw2='s2',
524 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700525
526 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800527 actual=testResult,
528 onpass=main.assertReturnString,
529 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700530
531 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800532 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700533 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
534 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800535 testResult = main.FALSE
536 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700537 name='DUALSTACK1',
538 onosNode='0',
539 host1=host1,
540 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800541
542 if installResult:
543 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700544 name='DUALSTACK1',
545 intentId=installResult,
546 onosNode='0',
547 host1=host1,
548 host2=host2,
549 sw1='s5',
550 sw2='s2',
551 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700552
553 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800554 actual=testResult,
555 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700556 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700557
558 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800559 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700560 host1 = { "name": "h1" }
561 host2 = { "name": "h11" }
Jeremy2f190ca2016-01-29 15:23:57 -0800562 testResult = main.FALSE
563 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700564 name='DUALSTACK2',
565 onosNode='0',
566 host1=host1,
567 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800568
569 if installResult:
570 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700571 name='DUALSTACK2',
572 intentId=installResult,
573 onosNode='0',
574 host1=host1,
575 host2=host2,
576 sw1='s5',
577 sw2='s2',
578 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700579
580 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800581 actual=testResult,
582 onpass=main.assertReturnString,
583 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700584
585 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800586 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700587 host1 = { "name": "h1" }
588 host2 = { "name": "h3" }
Jeremy2f190ca2016-01-29 15:23:57 -0800589 testResult = main.FALSE
590 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700591 name='1HOP',
592 onosNode='0',
593 host1=host1,
594 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700595
Jeremy2f190ca2016-01-29 15:23:57 -0800596 if installResult:
597 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700598 name='1HOP',
599 intentId=installResult,
600 onosNode='0',
601 host1=host1,
602 host2=host2,
603 sw1='s5',
604 sw2='s2',
605 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700606
607 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800608 actual=testResult,
609 onpass=main.assertReturnString,
610 onfail=main.assertReturnString )
611
612 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
613 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700614 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" }
615 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800616 testResult = main.FALSE
617 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700618 name='VLAN1',
619 onosNode='0',
620 host1=host1,
621 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800622
623 if installResult:
624 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700625 name='VLAN1',
626 intentId=installResult,
627 onosNode='0',
628 host1=host1,
629 host2=host2,
630 sw1='s5',
631 sw2='s2',
632 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -0800633
634 utilities.assert_equals( expect=main.TRUE,
635 actual=testResult,
636 onpass=main.assertReturnString,
637 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700638
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700639 # This step isn't currently possible to perform in the REST API
640 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
641 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
642 # host1 = { "name":"h13" }
643 # host2 = { "name":"h20" }
644 # testResult = main.FALSE
645 # installResult = main.intentFunction.installHostIntent( main,
646 # name='VLAN2',
647 # onosNode='0',
648 # host1=host1,
649 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700650
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700651 # if installResult:
652 # testResult = main.intentFunction.testHostIntent( main,
653 # name='VLAN2',
Jon Hall02758ac2017-05-24 16:20:28 -0700654 # intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700655 # onosNode='0',
656 # host1=host1,
657 # host2=host2,
658 # sw1='s5',
659 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700660 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700661
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700662 # utilities.assert_equals( expect=main.TRUE,
663 # actual=testResult,
664 # onpass=main.assertReturnString,
665 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -0800666
Jeremye1ea0602016-02-08 16:35:05 -0800667 # Change the following to use the REST API when leader checking is
668 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -0800669
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700670 main.step( "Confirm that ONOS leadership is unchanged" )
Devin Lim142b5342017-07-20 15:22:39 -0700671 intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800672 main.intentFunction.checkLeaderChange( intentLeadersOld,
673 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -0800674
Jeremye1ea0602016-02-08 16:35:05 -0800675 utilities.assert_equals( expect=main.TRUE,
676 actual=testResult,
677 onpass="ONOS Leaders Unchanged",
Jon Hall02758ac2017-05-24 16:20:28 -0700678 onfail="ONOS Leader Mismatch" )
Jeremy2f190ca2016-01-29 15:23:57 -0800679
680 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -0700681
682 def CASE2000( self, main ):
683 """
684 Add point intents between 2 hosts:
685 - Get device ids | ports
686 - Add point intents
687 - Check intents
688 - Verify flows
689 - Ping hosts
690 - Reroute
691 - Link down
692 - Verify flows
693 - Check topology
694 - Ping hosts
695 - Link up
696 - Verify flows
697 - Check topology
698 - Ping hosts
699 - Remove intents
700 """
Jeremydd9bda62016-04-18 12:02:32 -0700701 if main.initialized == main.FALSE:
702 main.log.error( "Test components did not start correctly, skipping further tests" )
703 main.skipCase()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700704 # Assert variables - These variable's name|format must be followed
705 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -0700706 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700707 try:
Jeremydd9bda62016-04-18 12:02:32 -0700708 assert main.Mininet1
709 except AssertionError:
710 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
711 main.initialized = main.FALSE
712 main.skipCase()
713 try:
714 assert main.numSwitch
715 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700716 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700717 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700718 main.initialized = main.FALSE
719 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700720
Devin Lim142b5342017-07-20 15:22:39 -0700721 main.case( "Point Intents Test - " + str( main.Cluster.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -0700722 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700723 main.caseExplanation = "This test case will test point to point" + \
Devin Lim142b5342017-07-20 15:22:39 -0700724 " intents using " + str( main.Cluster.numCtrls ) + \
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700725 " node(s) cluster;\n" + \
726 "Different type of hosts will be tested in " + \
727 "each step such as IPV4, Dual stack, VLAN etc" + \
728 ";\nThe test will use OF " + main.OFProtocol + \
729 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -0700730 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700731
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700732 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -0700733 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800734 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
735 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700736 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800737 ]
738 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700739 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800740 ]
741 testResult = main.FALSE
742 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700743 main,
744 name="NOOPTION",
745 senders=senders,
746 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800747
748 if installResult:
749 testResult = main.intentFunction.testPointIntent(
750 main,
751 intentId=installResult,
752 name="NOOPTION",
753 senders=senders,
754 recipients=recipients,
755 sw1="s5",
756 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700757 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700758
759 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800760 actual=testResult,
761 onpass=main.assertReturnString,
762 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700763
kelvin-onlab44147802015-07-27 17:57:31 -0700764 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800765 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
766 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700767 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -0800768 ]
769 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700770 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -0800771 ]
772 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700773 main,
774 name="IPV4",
775 senders=senders,
776 recipients=recipients,
777 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800778
779 if installResult:
780 testResult = main.intentFunction.testPointIntent(
781 main,
782 intentId=installResult,
783 name="IPV4",
784 senders=senders,
785 recipients=recipients,
786 sw1="s5",
787 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700788 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700789
790 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800791 actual=testResult,
792 onpass=main.assertReturnString,
793 onfail=main.assertReturnString )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700794
alisonda157272016-12-22 01:13:21 -0800795 # main.step( "Protected: Add point intents between h1 and h9" )
796 # main.assertReturnString = "Assertion Result for protected point intent\n"
797 # senders = [
798 # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
799 # ]
800 # recipients = [
801 # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
802 # ]
803 # testResult = main.FALSE
804 # installResult = main.intentFunction.installPointIntent(
805 # main,
806 # name="Protected",
807 # senders=senders,
808 # recipients=recipients,
809 # protected=True )
Jon Hall02758ac2017-05-24 16:20:28 -0700810 #
alisonda157272016-12-22 01:13:21 -0800811 # if installResult:
812 # testResult = main.intentFunction.testPointIntent(
813 # main,
814 # name="Protected",
815 # intentId=installResult,
816 # senders=senders,
817 # recipients=recipients,
818 # sw1="s5",
819 # sw2="s2",
820 # protected=True,
821 # expectedLink=18 )
822 #
823 # utilities.assert_equals( expect=main.TRUE,
824 # actual=testResult,
825 # onpass=main.assertReturnString,
826 # onfail=main.assertReturnString )
827
kelvin-onlab44147802015-07-27 17:57:31 -0700828 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800829 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
830 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700831 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800832 ]
833 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700834 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800835 ]
836 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700837 main,
838 name="IPV4_2",
839 senders=senders,
840 recipients=recipients,
841 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800842
843 if installResult:
844 testResult = main.intentFunction.testPointIntent(
845 main,
846 intentId=installResult,
847 name="IPV4_2",
848 senders=senders,
849 recipients=recipients,
850 sw1="s5",
851 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700852 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700853
854 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800855 actual=testResult,
856 onpass=main.assertReturnString,
857 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700858
kelvin-onlab0e684682015-08-11 18:51:41 -0700859 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800860 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
861 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700862 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
863 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800864 ]
865 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700866 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
867 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -0800868 ]
Jon Hall02758ac2017-05-24 16:20:28 -0700869 # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700870 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700871 # Uneccessary, not including this in the selectors
Jon Hall02758ac2017-05-24 16:20:28 -0700872 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
873 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700874
Jeremy2f190ca2016-01-29 15:23:57 -0800875 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700876 main,
877 name="SDNIP-ICMP",
878 senders=senders,
879 recipients=recipients,
880 ethType="IPV4",
881 ipProto=ipProto,
882 tcpSrc=tcpSrc,
883 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -0800884
885 if installResult:
886 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700887 main,
888 intentId=installResult,
889 name="SDNIP_ICMP",
890 senders=senders,
891 recipients=recipients,
892 sw1="s5",
893 sw2="s2",
894 expectedLink=18,
895 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -0700896
897 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800898 actual=testResult,
899 onpass=main.assertReturnString,
900 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700901
kelvin-onlab0e684682015-08-11 18:51:41 -0700902 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800903 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700904 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
905 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
906 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
907 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
908 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
909 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
910 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -0700911
kelvin-onlab0e684682015-08-11 18:51:41 -0700912 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700913 main,
914 name="SDNIP-TCP",
915 host1="h1",
916 host2="h9",
917 deviceId1="of:0000000000000005/1",
918 deviceId2="of:0000000000000006/1",
919 mac1=mac1,
920 mac2=mac2,
921 ethType="IPV4",
922 ipProto=ipProto,
923 ip1=ip1,
924 ip2=ip2,
925 tcp1=tcp1,
926 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700927
928 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700929 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -0800930 onpass=main.assertReturnString,
931 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700932
Jeremy2f190ca2016-01-29 15:23:57 -0800933 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
934 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
935 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700936 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -0800937 ]
938 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700939 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -0800940 ]
941 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700942 main,
943 name="DUALSTACK1",
944 senders=senders,
945 recipients=recipients,
946 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -0800947
948 if installResult:
949 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700950 main,
951 intentId=installResult,
952 name="DUALSTACK1",
953 senders=senders,
954 recipients=recipients,
955 sw1="s5",
956 sw2="s2",
957 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700958
959 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800960 actual=testResult,
961 onpass=main.assertReturnString,
962 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700963
964 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -0800965 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
966 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700967 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800968 ]
969 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700970 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -0800971 ]
972 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700973 main,
974 name="VLAN",
975 senders=senders,
976 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -0800977
978 if installResult:
979 testResult = main.intentFunction.testPointIntent(
980 main,
981 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700982 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -0800983 senders=senders,
984 recipients=recipients,
985 sw1="s5",
986 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700987 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700988
989 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800990 actual=testResult,
991 onpass=main.assertReturnString,
992 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700993
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700994 # TODO: implement VLAN selector REST API intent test once supported
995
kelvin-onlab44147802015-07-27 17:57:31 -0700996 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800997 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
998 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700999 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001000 ]
1001 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001002 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001003 ]
1004 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001005 main,
1006 name="1HOP IPV4",
1007 senders=senders,
1008 recipients=recipients,
1009 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001010
1011 if installResult:
1012 testResult = main.intentFunction.testPointIntent(
1013 main,
1014 intentId=installResult,
1015 name="1HOP IPV4",
1016 senders=senders,
1017 recipients=recipients,
1018 sw1="s5",
1019 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001020 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001021
1022 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001023 actual=testResult,
1024 onpass=main.assertReturnString,
1025 onfail=main.assertReturnString )
1026
1027 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001028
1029 def CASE3000( self, main ):
1030 """
1031 Add single point to multi point intents
1032 - Get device ids
1033 - Add single point to multi point intents
1034 - Check intents
1035 - Verify flows
1036 - Ping hosts
1037 - Reroute
1038 - Link down
1039 - Verify flows
1040 - Check topology
1041 - Ping hosts
1042 - Link up
1043 - Verify flows
1044 - Check topology
1045 - Ping hosts
1046 - Remove intents
1047 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001048 if main.initialized == main.FALSE:
1049 main.log.error( "Test components did not start correctly, skipping further tests" )
1050 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001051 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001052
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001053 try:
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001054 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1055 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1056 except AssertionError:
1057 main.initialized = main.FALSE
1058 main.skipCase()
1059
1060 main.testName = "Single to Multi Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001061 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001062 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001063 main.caseExplanation = "This test case will test single point to" + \
1064 " multi point intents using " + \
Devin Lim142b5342017-07-20 15:22:39 -07001065 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" + \
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001066 "Different type of hosts will be tested in " + \
1067 "each step such as IPV4, Dual stack, VLAN etc" + \
1068 ";\nThe test will use OF " + main.OFProtocol + \
1069 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001070 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001071
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001072 main.step( "NOOPTION: Install and test single point to multi point intents" )
1073 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1074 senders = [
1075 { "name": "h8", "device": "of:0000000000000005/8" }
1076 ]
1077 recipients = [
1078 { "name": "h16", "device": "of:0000000000000006/8" },
1079 { "name": "h24", "device": "of:0000000000000007/8" }
1080 ]
1081 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1082 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1083 testResult = main.FALSE
1084 installResult = main.intentFunction.installSingleToMultiIntent(
1085 main,
1086 name="NOOPTION",
1087 senders=senders,
1088 recipients=recipients )
1089
1090 if installResult:
1091 testResult = main.intentFunction.testPointIntent(
1092 main,
1093 intentId=installResult,
1094 name="NOOPTION",
1095 senders=senders,
1096 recipients=recipients,
1097 badSenders=badSenders,
1098 badRecipients=badRecipients,
1099 sw1="s5",
1100 sw2="s2",
1101 expectedLink=18 )
1102 else:
Devin Lim142b5342017-07-20 15:22:39 -07001103 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001104
1105 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001106 actual=testResult,
1107 onpass=main.assertReturnString,
1108 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001109
Jon Hall02758ac2017-05-24 16:20:28 -07001110 main.step( "IPV4: Install and test single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001111 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1112 "with IPV4 type and MAC addresses\n"
1113 senders = [
Jon Hall02758ac2017-05-24 16:20:28 -07001114 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001115 ]
1116 recipients = [
Jon Hall02758ac2017-05-24 16:20:28 -07001117 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1118 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001119 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001120 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1121 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001122 installResult = main.intentFunction.installSingleToMultiIntent(
1123 main,
1124 name="IPV4",
1125 senders=senders,
1126 recipients=recipients,
Jon Hall02758ac2017-05-24 16:20:28 -07001127 ethType="IPV4" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001128
1129 if installResult:
1130 testResult = main.intentFunction.testPointIntent(
1131 main,
1132 intentId=installResult,
1133 name="IPV4",
1134 senders=senders,
1135 recipients=recipients,
1136 badSenders=badSenders,
1137 badRecipients=badRecipients,
1138 sw1="s5",
1139 sw2="s2",
1140 expectedLink=18 )
1141 else:
Devin Lim142b5342017-07-20 15:22:39 -07001142 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001143
1144 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001145 actual=testResult,
1146 onpass=main.assertReturnString,
1147 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001148
1149 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001150 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1151 "with IPV4 type and no MAC addresses\n"
1152 senders = [
1153 { "name": "h8", "device": "of:0000000000000005/8" }
1154 ]
1155 recipients = [
1156 { "name": "h16", "device": "of:0000000000000006/8" },
1157 { "name": "h24", "device": "of:0000000000000007/8" }
1158 ]
1159 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1160 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1161 installResult = main.intentFunction.installSingleToMultiIntent(
1162 main,
1163 name="IPV4_2",
1164 senders=senders,
1165 recipients=recipients,
1166 ethType="IPV4" )
1167
1168 if installResult:
1169 testResult = main.intentFunction.testPointIntent(
1170 main,
1171 intentId=installResult,
1172 name="IPV4_2",
1173 senders=senders,
1174 recipients=recipients,
1175 badSenders=badSenders,
1176 badRecipients=badRecipients,
1177 sw1="s5",
1178 sw2="s2",
1179 expectedLink=18 )
1180 else:
Devin Lim142b5342017-07-20 15:22:39 -07001181 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001182
1183 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001184 actual=testResult,
1185 onpass=main.assertReturnString,
1186 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001187
1188 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001189 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1190 "and MAC addresses in the same VLAN\n"
1191 senders = [
1192 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1193 ]
1194 recipients = [
1195 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1196 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1197 ]
1198 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1199 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1200 installResult = main.intentFunction.installSingleToMultiIntent(
1201 main,
1202 name="VLAN",
1203 senders=senders,
1204 recipients=recipients,
1205 sw1="s5",
1206 sw2="s2" )
1207
1208 if installResult:
1209 testResult = main.intentFunction.testPointIntent(
1210 main,
1211 intentId=installResult,
1212 name="VLAN",
1213 senders=senders,
1214 recipients=recipients,
1215 badSenders=badSenders,
1216 badRecipients=badRecipients,
1217 sw1="s5",
1218 sw2="s2",
1219 expectedLink=18 )
1220 else:
Devin Lim142b5342017-07-20 15:22:39 -07001221 main.Cluster.active( 0 ).CLI.removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001222
1223 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001224 actual=testResult,
1225 onpass=main.assertReturnString,
1226 onfail=main.assertReturnString )
1227
1228 main.step( "VLAN: Add single point to multi point intents" )
1229 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1230 senders = [
1231 { "name": "h5", "vlan": "200" }
1232 ]
1233 recipients = [
1234 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1235 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1236 ]
1237 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1238 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1239 testResult = main.FALSE
1240 installResult = main.intentFunction.installSingleToMultiIntent(
1241 main,
1242 name="VLAN2",
1243 senders=senders,
1244 recipients=recipients,
1245 sw1="s5",
1246 sw2="s2" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001247 # setVlan=100 )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001248
1249 if installResult:
1250 testResult = main.intentFunction.testPointIntent(
1251 main,
1252 intentId=installResult,
1253 name="VLAN2",
1254 senders=senders,
1255 recipients=recipients,
1256 badSenders=badSenders,
1257 badRecipients=badRecipients,
1258 sw1="s5",
1259 sw2="s2",
1260 expectedLink=18 )
1261 else:
Devin Lim142b5342017-07-20 15:22:39 -07001262 main.Cluster.active( 0 ).CLI.removeAllIntents()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001263
1264 utilities.assert_equals( expect=main.TRUE,
1265 actual=testResult,
1266 onpass=main.assertReturnString,
1267 onfail=main.assertReturnString )
1268
1269 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001270
1271 def CASE4000( self, main ):
1272 """
1273 Add multi point to single point intents
1274 - Get device ids
1275 - Add multi point to single point intents
1276 - Check intents
1277 - Verify flows
1278 - Ping hosts
1279 - Reroute
1280 - Link down
1281 - Verify flows
1282 - Check topology
1283 - Ping hosts
1284 - Link up
1285 - Verify flows
1286 - Check topology
1287 - Ping hosts
1288 - Remove intents
1289 """
1290 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001291 assert main.Mininet1, "Mininet handle should be named Mininet1"
1292 assert main.numSwitch, "Placed the total number of switch topology in \
1293 main.numSwitch"
1294
1295 main.case( "Multi To Single Point Intents Test - " +
Devin Lim142b5342017-07-20 15:22:39 -07001296 str( main.Cluster.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001297 main.caseExplanation = "This test case will test single point to" +\
1298 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001299 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab44147802015-07-27 17:57:31 -07001300 "Different type of hosts will be tested in " +\
1301 "each step such as IPV4, Dual stack, VLAN etc" +\
1302 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001303 " OVS running in Mininet and compile intents" +\
1304 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001305
1306 main.step( "NOOPTION: Add multi point to single point intents" )
1307 stepResult = main.TRUE
1308 hostNames = [ 'h8', 'h16', 'h24' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001309 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8',
kelvin-onlab44147802015-07-27 17:57:31 -07001310 'of:0000000000000007/8' ]
1311 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1312 stepResult = main.intentFunction.multiToSingleIntent(
1313 main,
1314 name="NOOPTION",
1315 hostNames=hostNames,
1316 devices=devices,
1317 sw1="s5",
1318 sw2="s2",
1319 expectedLink=18 )
1320
1321 utilities.assert_equals( expect=main.TRUE,
1322 actual=stepResult,
1323 onpass="NOOPTION: Successfully added multi "
1324 + " point to single point intents" +
1325 " with no match action",
1326 onfail="NOOPTION: Failed to add multi point" +
1327 " to single point intents" +
1328 " with no match action" )
1329
1330 main.step( "IPV4: Add multi point to single point intents" )
1331 stepResult = main.TRUE
1332 stepResult = main.intentFunction.multiToSingleIntent(
1333 main,
1334 name="IPV4",
1335 hostNames=hostNames,
1336 devices=devices,
1337 ports=None,
1338 ethType="IPV4",
1339 macs=macs,
1340 bandwidth="",
1341 lambdaAlloc=False,
1342 ipProto="",
1343 ipAddresses="",
1344 tcp="",
1345 sw1="s5",
1346 sw2="s2",
1347 expectedLink=18 )
1348
1349 utilities.assert_equals( expect=main.TRUE,
1350 actual=stepResult,
1351 onpass="IPV4: Successfully added multi point"
1352 + " to single point intents" +
1353 " with IPV4 type and MAC addresses",
1354 onfail="IPV4: Failed to add multi point" +
1355 " to single point intents" +
1356 " with IPV4 type and MAC addresses" )
1357
1358 main.step( "IPV4_2: Add multi point to single point intents" )
1359 stepResult = main.TRUE
1360 hostNames = [ 'h8', 'h16', 'h24' ]
1361 stepResult = main.intentFunction.multiToSingleIntent(
1362 main,
1363 name="IPV4",
1364 hostNames=hostNames,
1365 ethType="IPV4",
1366 lambdaAlloc=False )
1367
1368 utilities.assert_equals( expect=main.TRUE,
1369 actual=stepResult,
1370 onpass="IPV4_2: Successfully added multi point"
1371 + " to single point intents" +
1372 " with IPV4 type and no MAC addresses",
1373 onfail="IPV4_2: Failed to add multi point" +
1374 " to single point intents" +
1375 " with IPV4 type and no MAC addresses" )
1376
1377 main.step( "VLAN: Add multi point to single point intents" )
1378 stepResult = main.TRUE
1379 hostNames = [ 'h5', 'h13', 'h21' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001380 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5',
kelvin-onlab44147802015-07-27 17:57:31 -07001381 'of:0000000000000007/5' ]
1382 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1383 stepResult = main.intentFunction.multiToSingleIntent(
1384 main,
1385 name="VLAN",
1386 hostNames=hostNames,
1387 devices=devices,
1388 ports=None,
1389 ethType="IPV4",
1390 macs=macs,
1391 bandwidth="",
1392 lambdaAlloc=False,
1393 ipProto="",
1394 ipAddresses="",
1395 tcp="",
1396 sw1="s5",
1397 sw2="s2",
1398 expectedLink=18 )
1399
1400 utilities.assert_equals( expect=main.TRUE,
1401 actual=stepResult,
1402 onpass="VLAN: Successfully added multi point"
1403 + " to single point intents" +
1404 " with IPV4 type and MAC addresses" +
1405 " in the same VLAN",
1406 onfail="VLAN: Failed to add multi point" +
1407 " to single point intents" )
1408
1409 def CASE5000( self, main ):
1410 """
Jeremy2f190ca2016-01-29 15:23:57 -08001411 Tests Host Mobility
1412 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001413 """
Jeremydd9bda62016-04-18 12:02:32 -07001414 if main.initialized == main.FALSE:
1415 main.log.error( "Test components did not start correctly, skipping further tests" )
1416 main.skipCase()
1417 # Assert variables - These variable's name|format must be followed
1418 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001419 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001420 try:
Jeremydd9bda62016-04-18 12:02:32 -07001421 assert main.Mininet1
1422 except AssertionError:
1423 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1424 main.initialized = main.FALSE
1425 main.skipCase()
1426 try:
1427 assert main.numSwitch
1428 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001429 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001430 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001431 main.initialized = main.FALSE
1432 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001433 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001434 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001435 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1436
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001437 main.log.info( "Moving h1 from s5 to s6" )
1438 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001439
Jeremy2f190ca2016-01-29 15:23:57 -08001440 # Send discovery ping from moved host
1441 # Moving the host brings down the default interfaces and creates a new one.
1442 # Scapy is restarted on this host to detect the new interface
1443 main.h1.stopScapy()
1444 main.h1.startScapy()
1445
1446 # Discover new host location in ONOS and populate host data.
1447 # Host 1 IP and MAC should be unchanged
1448 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1449 main.intentFunction.populateHostData( main )
1450
kelvin-onlab44147802015-07-27 17:57:31 -07001451 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1452
1453 utilities.assert_equals( expect="of:0000000000000006",
1454 actual=h1PostMove,
1455 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001456 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001457 " to single point intents" +
1458 " with IPV4 type and MAC addresses" +
1459 " in the same VLAN" )
1460
1461 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001462 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001463 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1464 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001465
1466 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001467 name='IPV4 Mobility IPV4',
1468 onosNode='0',
1469 host1=host1,
1470 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001471 if installResult:
1472 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001473 name='Host Mobility IPV4',
1474 intentId=installResult,
1475 onosNode='0',
1476 host1=host1,
1477 host2=host2,
1478 sw1="s6",
1479 sw2="s2",
1480 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001481
1482 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001483 actual=testResult,
1484 onpass=main.assertReturnString,
1485 onfail=main.assertReturnString )
1486
Jon Hallbd60ea02016-08-23 10:03:59 -07001487 main.intentFunction.report( main )