blob: eb2321ca6c0beb98ca883a97d2b2199f2b3478af [file] [log] [blame]
kelvin-onlab4ff9cc12015-05-05 11:14:42 -07001
2# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
4
5import time
6import json
7
kelvin-onlab05cf7732015-05-08 14:25:46 -07008class FuncIntent:
kelvin-onlab4ff9cc12015-05-05 11:14:42 -07009
10 def __init__( self ):
11 self.default = ''
12
13 def CASE10( self, main ):
14 import time
15 import os
kelvin-onlabe5239e52015-05-13 14:46:45 -070016 import imp
kelvin-onlab4ff9cc12015-05-05 11:14:42 -070017 """
18 Startup sequence:
19 cell <name>
20 onos-verify-cell
21 onos-remove-raft-log
22 git pull
23 mvn clean install
24 onos-package
25 onos-install -f
26 onos-wait-for-start
27 """
kelvin-onlabf70fd542015-05-07 18:41:40 -070028 global init
cameron@onlab.us59d29d92015-05-11 14:31:54 -070029 global globalONOSip
kelvin-onlabf70fd542015-05-07 18:41:40 -070030 try:
31 if type(init) is not bool:
32 init = False
33 except NameError:
34 init = False
kelvin-onlab132bd5b2015-05-18 18:15:26 -070035
36 main.wrapper = imp.load_source( 'FuncIntentFunction',
37 '/home/admin/ONLabTest/TestON/tests/' +
38 'FuncIntent/Dependency/' +
39 'FuncIntentFunction.py' )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -070040 #Local variables
41 cellName = main.params[ 'ENV' ][ 'cellName' ]
kelvin-onlabf70fd542015-05-07 18:41:40 -070042 apps = main.params[ 'ENV' ][ 'cellApps' ]
kelvin-onlabf70fd542015-05-07 18:41:40 -070043 gitBranch = main.params[ 'GIT' ][ 'branch' ]
cameron@onlab.us59d29d92015-05-11 14:31:54 -070044 benchIp = os.environ[ 'OCN' ]
kelvin-onlabf70fd542015-05-07 18:41:40 -070045 benchUser = main.params[ 'BENCH' ][ 'user' ]
kelvin-onlab05cf7732015-05-08 14:25:46 -070046 topology = main.params[ 'MININET' ][ 'topo' ]
kelvin-onlab4ff9cc12015-05-05 11:14:42 -070047 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
kelvin-onlab65782a82015-05-07 14:12:13 -070048 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
kelvin-onlabf70fd542015-05-07 18:41:40 -070049 main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
kelvin-onlab132bd5b2015-05-18 18:15:26 -070050 main.ONOSport = []
51 main.hostsData = {}
kelvin-onlab4ff9cc12015-05-05 11:14:42 -070052 PULLCODE = False
53 if main.params[ 'GIT' ][ 'pull' ] == 'True':
54 PULLCODE = True
55 main.case( "Setting up test environment" )
kelvin-onlabf70fd542015-05-07 18:41:40 -070056 main.CLIs = []
57 for i in range( 1, int( main.numCtrls ) + 1 ):
58 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlab132bd5b2015-05-18 18:15:26 -070059 main.ONOSport.append( main.params[ 'CTRL' ][ 'port' + str( i ) ] )
cameron@onlab.us7fd2a522015-05-14 11:20:33 -070060
kelvin-onlabf70fd542015-05-07 18:41:40 -070061 # -- INIT SECTION, ONLY RUNS ONCE -- #
62 if init == False:
63 init = True
kelvin-onlabf70fd542015-05-07 18:41:40 -070064
kelvin-onlab05cf7732015-05-08 14:25:46 -070065 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
66 main.numCtrls = int( main.scale[ 0 ] )
kelvin-onlabf70fd542015-05-07 18:41:40 -070067
68 if PULLCODE:
69 main.step( "Git checkout and pull " + gitBranch )
70 main.ONOSbench.gitCheckout( gitBranch )
71 gitPullResult = main.ONOSbench.gitPull()
72 if gitPullResult == main.ERROR:
73 main.log.error( "Error pulling git branch" )
74 main.step( "Using mvn clean & install" )
75 cleanInstallResult = main.ONOSbench.cleanInstall()
76 stepResult = cleanInstallResult
77 utilities.assert_equals( expect=main.TRUE,
78 actual=stepResult,
79 onpass="Successfully compiled " +
80 "latest ONOS",
81 onfail="Failed to compile " +
82 "latest ONOS" )
83 else:
84 main.log.warn( "Did not pull new code so skipping mvn " +
85 "clean install" )
kelvin-onlab132bd5b2015-05-18 18:15:26 -070086
cameron@onlab.us033cc0f2015-05-15 15:27:43 -070087 globalONOSip = main.ONOSbench.getOnosIps()
kelvin-onlab0a28a742015-05-18 16:03:13 -070088
cameron@onlab.us033cc0f2015-05-15 15:27:43 -070089 maxNodes = ( len(globalONOSip) - 2 )
kelvin-onlabf70fd542015-05-07 18:41:40 -070090
kelvin-onlab05cf7732015-05-08 14:25:46 -070091 main.numCtrls = int( main.scale[ 0 ] )
92 main.scale.remove( main.scale[ 0 ] )
cameron@onlab.us59d29d92015-05-11 14:31:54 -070093
cameron@onlab.us033cc0f2015-05-15 15:27:43 -070094 main.ONOSip = []
kelvin-onlab0a28a742015-05-18 16:03:13 -070095 for i in range( maxNodes ):
cameron@onlab.us59d29d92015-05-11 14:31:54 -070096 main.ONOSip.append( globalONOSip[i] )
97
kelvin-onlabf70fd542015-05-07 18:41:40 -070098 #kill off all onos processes
99 main.log.info( "Safety check, killing all ONOS processes" +
100 " before initiating enviornment setup" )
kelvin-onlab132bd5b2015-05-18 18:15:26 -0700101 for i in range(maxNodes):
102 main.ONOSbench.onosDie( globalONOSip[ i ] )
103
kelvin-onlab05cf7732015-05-08 14:25:46 -0700104 print "NODE COUNT = ", main.numCtrls
kelvin-onlabf70fd542015-05-07 18:41:40 -0700105 main.log.info( "Creating cell file" )
106 cellIp = []
kelvin-onlab05cf7732015-05-08 14:25:46 -0700107 for i in range( main.numCtrls ):
108 cellIp.append( str( main.ONOSip[ i ] ) )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700109 print cellIp
110 main.ONOSbench.createCellFile( benchIp, cellName, "",
111 str( apps ), *cellIp )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700112
113 main.step( "Apply cell to environment" )
114 cellResult = main.ONOSbench.setCell( cellName )
115 verifyResult = main.ONOSbench.verifyCell()
116 stepResult = cellResult and verifyResult
117 utilities.assert_equals( expect=main.TRUE,
118 actual=stepResult,
119 onpass="Successfully applied cell to " + \
120 "environment",
121 onfail="Failed to apply cell to environment " )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700122
123 main.step( "Creating ONOS package" )
124 packageResult = main.ONOSbench.onosPackage()
125 stepResult = packageResult
126 utilities.assert_equals( expect=main.TRUE,
127 actual=stepResult,
128 onpass="Successfully created ONOS package",
129 onfail="Failed to create ONOS package" )
130
131 main.step( "Uninstalling ONOS package" )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700132 onosUninstallResult = main.TRUE
cameron@onlab.us033cc0f2015-05-15 15:27:43 -0700133 for i in range( main.numCtrls ):
kelvin-onlabf70fd542015-05-07 18:41:40 -0700134 onosUninstallResult = onosUninstallResult and \
kelvin-onlab05cf7732015-05-08 14:25:46 -0700135 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700136 stepResult = onosUninstallResult
137 utilities.assert_equals( expect=main.TRUE,
138 actual=stepResult,
139 onpass="Successfully uninstalled ONOS package",
140 onfail="Failed to uninstall ONOS package" )
141 time.sleep( 5 )
142 main.step( "Installing ONOS package" )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700143 onosInstallResult = main.TRUE
cameron@onlab.us033cc0f2015-05-15 15:27:43 -0700144 for i in range( main.numCtrls ):
kelvin-onlabf70fd542015-05-07 18:41:40 -0700145 onosInstallResult = onosInstallResult and \
kelvin-onlab05cf7732015-05-08 14:25:46 -0700146 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700147 stepResult = onosInstallResult
148 utilities.assert_equals( expect=main.TRUE,
149 actual=stepResult,
150 onpass="Successfully installed ONOS package",
151 onfail="Failed to install ONOS package" )
152
cameron@onlab.us59d29d92015-05-11 14:31:54 -0700153 time.sleep( 20 )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700154 main.step( "Starting ONOS service" )
155 stopResult = main.TRUE
156 startResult = main.TRUE
kelvin-onlabf70fd542015-05-07 18:41:40 -0700157 onosIsUp = main.TRUE
kelvin-onlab05cf7732015-05-08 14:25:46 -0700158 for i in range( main.numCtrls ):
159 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700160 if onosIsUp == main.TRUE:
161 main.log.report( "ONOS instance is up and ready" )
162 else:
163 main.log.report( "ONOS instance may not be up, stop and " +
164 "start ONOS again " )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700165 for i in range( main.numCtrls ):
kelvin-onlabf70fd542015-05-07 18:41:40 -0700166 stopResult = stopResult and \
kelvin-onlab05cf7732015-05-08 14:25:46 -0700167 main.ONOSbench.onosStop( main.ONOSip[ i ] )
168 for i in range( main.numCtrls ):
kelvin-onlabf70fd542015-05-07 18:41:40 -0700169 startResult = startResult and \
kelvin-onlab05cf7732015-05-08 14:25:46 -0700170 main.ONOSbench.onosStart( main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700171 stepResult = onosIsUp and stopResult and startResult
172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
174 onpass="ONOS service is ready",
175 onfail="ONOS service did not start properly" )
kelvin-onlabe5239e52015-05-13 14:46:45 -0700176
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700177 main.step( "Start ONOS cli" )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700178 cliResult = main.TRUE
kelvin-onlab05cf7732015-05-08 14:25:46 -0700179 for i in range( main.numCtrls ):
180 cliResult = cliResult and \
181 main.CLIs[i].startOnosCli( main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700182 stepResult = cliResult
183 utilities.assert_equals( expect=main.TRUE,
184 actual=stepResult,
185 onpass="Successfully start ONOS cli",
186 onfail="Failed to start ONOS cli" )
187
kelvin-onlab0a28a742015-05-18 16:03:13 -0700188 def CASE9( self, main ):
kelvin-onlab132bd5b2015-05-18 18:15:26 -0700189 '''
190 Report errors/warnings/exceptions
191 '''
192 main.log.info( "Error report: \n" )
193 main.ONOSbench.logReport( globalONOSip[0],
194 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
195 "s" )
196 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700197
198 def CASE11( self, main ):
199 """
kelvin-onlab05cf7732015-05-08 14:25:46 -0700200 Start mininet
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700201 """
kelvin-onlab05cf7732015-05-08 14:25:46 -0700202 main.log.report( "Start Mininet topology" )
kelvin-onlab132bd5b2015-05-18 18:15:26 -0700203 main.log.case( "Start Mininet topology" )
204
kelvin-onlabf70fd542015-05-07 18:41:40 -0700205 main.step( "Starting Mininet Topology" )
206 topoResult = main.Mininet1.startNet( topoFile=topology )
207 stepResult = topoResult
208 utilities.assert_equals( expect=main.TRUE,
209 actual=stepResult,
210 onpass="Successfully loaded topology",
211 onfail="Failed to load topology" )
212 # Exit if topology did not load properly
213 if not topoResult:
214 main.cleanup()
215 main.exit()
216
kelvin-onlab05cf7732015-05-08 14:25:46 -0700217 def CASE12( self, main ):
218 """
219 Assign mastership to controllers
220 """
221 import re
222
kelvin-onlabe5239e52015-05-13 14:46:45 -0700223 main.case( "Assign switches to controllers" )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700224 main.step( "Assigning switches to controllers" )
225 assignResult = main.TRUE
kelvin-onlab5cbf9992015-05-05 14:34:07 -0700226 for i in range( 1, ( main.numSwitch + 1 ) ):
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700227 main.Mininet1.assignSwController( sw=str( i ),
228 count=1,
kelvin-onlab05cf7732015-05-08 14:25:46 -0700229 ip1=main.ONOSip[ 0 ],
230 port1=main.ONOSport[ 0 ] )
kelvin-onlab5cbf9992015-05-05 14:34:07 -0700231 for i in range( 1, ( main.numSwitch + 1 ) ):
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700232 response = main.Mininet1.getSwController( "s" + str( i ) )
233 print( "Response is " + str( response ) )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700234 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700235 assignResult = assignResult and main.TRUE
236 else:
237 assignResult = main.FALSE
238 stepResult = assignResult
239 utilities.assert_equals( expect=main.TRUE,
240 actual=stepResult,
241 onpass="Successfully assigned switches" +
242 "to controller",
243 onfail="Failed to assign switches to " +
244 "controller" )
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700245 def CASE13( self, main ):
246 """
247 Discover all hosts and store its data to a dictionary
248 """
249 main.case( "Discover all hosts" )
250
251 stepResult = main.TRUE
kelvin-onlab132bd5b2015-05-18 18:15:26 -0700252 main.step( "Discover all hosts using pingall " )
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700253 stepResult = main.wrapper.getHostsData( main )
kelvin-onlab08900012015-05-20 14:30:44 -0700254 utilities.assert_equals( expect=main.TRUE,
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700255 actual=stepResult,
256 onpass="Successfully discovered hosts",
257 onfail="Failed to discover hosts" )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700258
kelvin-onlab2ff57022015-05-29 10:48:51 -0700259 def CASE14( self, main ):
260 """
261 Stop mininet
262 """
263 main.log.report( "Stop Mininet topology" )
264 main.log.case( "Stop Mininet topology" )
265
266 main.step( "Stopping Mininet Topology" )
267 topoResult = main.Mininet1.stopNet( )
268 stepResult = topoResult
269 utilities.assert_equals( expect=main.TRUE,
270 actual=stepResult,
271 onpass="Successfully stop mininet",
272 onfail="Failed to stop mininet" )
273 # Exit if topology did not load properly
274 if not topoResult:
275 main.cleanup()
276 main.exit()
277
kelvin-onlabf70fd542015-05-07 18:41:40 -0700278 def CASE1001( self, main ):
kelvin-onlab7c577e82015-05-07 10:45:16 -0700279 """
kelvin-onlab65782a82015-05-07 14:12:13 -0700280 Add host intents between 2 host:
281 - Discover hosts
282 - Add host intents
283 - Check intents
kelvin-onlabe5239e52015-05-13 14:46:45 -0700284 - Verify flows
kelvin-onlab65782a82015-05-07 14:12:13 -0700285 - Ping hosts
286 - Reroute
287 - Link down
kelvin-onlabe5239e52015-05-13 14:46:45 -0700288 - Verify flows
289 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700290 - Ping hosts
291 - Link up
kelvin-onlabe5239e52015-05-13 14:46:45 -0700292 - Verify flows
293 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700294 - Ping hosts
295 - Remove intents
kelvin-onlab7c577e82015-05-07 10:45:16 -0700296 """
297 import time
298 import json
kelvin-onlab65782a82015-05-07 14:12:13 -0700299 import re
kelvin-onlabe5239e52015-05-13 14:46:45 -0700300
301 # Assert variables - These variable's name|format must be followed
302 # if you want to use the wrapper function
303 assert main, "There is no main"
304 assert main.CLIs, "There is no main.CLIs"
305 assert main.Mininet1, "Mininet handle should be named Mininet1"
306 assert main.numSwitch, "Placed the total number of switch topology in \
307 main.numSwitch"
308
kelvin-onlabe5239e52015-05-13 14:46:45 -0700309 main.case( "Add host intents between 2 host" )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700310
kelvin-onlabe5239e52015-05-13 14:46:45 -0700311 stepResult = main.TRUE
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700312 main.step( "IPV4: Add host intents between h1 and h9" )
313 stepResult = main.wrapper.hostIntent( main,
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700314 onosNode='0',
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700315 name='IPV4',
316 host1='h1',
317 host2='h9',
318 host1Id='00:00:00:00:00:01/-1',
319 host2Id='00:00:00:00:00:09/-1',
320 sw1='s5',
321 sw2='s2',
322 expectedLink=18 )
kelvin-onlab7c577e82015-05-07 10:45:16 -0700323
kelvin-onlabe5239e52015-05-13 14:46:45 -0700324 utilities.assert_equals( expect=main.TRUE,
325 actual=stepResult,
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700326 onpass="IPV4: Add host intent successful",
327 onfail="IPV4: Add host intent failed" )
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700328
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700329 stepResult = main.TRUE
kelvin-onlab381b34c2015-05-21 09:21:06 -0700330 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700331 stepResult = main.wrapper.hostIntent( main,
332 name='DUALSTACK',
333 host1='h3',
334 host2='h11',
335 host1Id='00:00:00:00:00:03/-1',
kelvin-onlab132bd5b2015-05-18 18:15:26 -0700336 host2Id='00:00:00:00:00:0B/-1',
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700337 sw1='s5',
338 sw2='s2',
339 expectedLink=18 )
340
341 utilities.assert_equals( expect=main.TRUE,
342 actual=stepResult,
kelvin-onlab381b34c2015-05-21 09:21:06 -0700343 onpass="DUALSTACK1: Add host intent" +
344 " successful",
345 onfail="DUALSTACK1: Add host intent failed" )
346
347 stepResult = main.TRUE
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700348 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlab381b34c2015-05-21 09:21:06 -0700349 stepResult = main.wrapper.hostIntent( main,
350 name='DUALSTACK2',
351 host1='h1',
352 host2='h11',
353 sw1='s5',
354 sw2='s2',
355 expectedLink=18 )
356
357 utilities.assert_equals( expect=main.TRUE,
358 actual=stepResult,
359 onpass="DUALSTACK2: Add host intent" +
360 " successful",
361 onfail="DUALSTACK2: Add host intent failed" )
kelvin-onlab7c577e82015-05-07 10:45:16 -0700362
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700363 stepResult = main.TRUE
364 main.step( "1HOP: Add host intents between h1 and h3" )
365 stepResult = main.wrapper.hostIntent( main,
366 name='1HOP',
367 host1='h1',
368 host2='h3' )
369
370 utilities.assert_equals( expect=main.TRUE,
371 actual=stepResult,
372 onpass="1HOP: Add host intent" +
373 " successful",
374 onfail="1HOP: Add host intent failed" )
375
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700376 stepResult = main.TRUE
kaouthera6f37d852015-05-27 13:52:08 -0700377 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
378 stepResult = main.wrapper.hostIntent( main,
379 name='VLAN1',
380 host1='h4',
381 host2='h12',
382 host1Id='00:00:00:00:00:04/100',
383 host2Id='00:00:00:00:00:0C/100',
384 sw1='s5',
385 sw2='s2',
386 expectedLink=18 )
387
388 utilities.assert_equals( expect=main.TRUE,
389 actual=stepResult,
kelvin-onlab2ff57022015-05-29 10:48:51 -0700390 onpass="VLAN1: Add vlan host" +
391 " intent successful",
kaouthera6f37d852015-05-27 13:52:08 -0700392 onfail="VLAN1: Add vlan host intent failed" )
kelvin-onlab2ff57022015-05-29 10:48:51 -0700393
kaouthera6f37d852015-05-27 13:52:08 -0700394 stepResult = main.TRUE
395 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
396 stepResult = main.wrapper.hostIntent( main,
397 name='VLAN2',
398 host1='h13',
kelvin-onlab2ff57022015-05-29 10:48:51 -0700399 host2='h20' )
kaouthera6f37d852015-05-27 13:52:08 -0700400
401 utilities.assert_equals( expect=main.FALSE,
402 actual=stepResult,
kelvin-onlab2ff57022015-05-29 10:48:51 -0700403 onpass="VLAN2: Add inter vlan host" +
404 " intent successful",
405 onfail="VLAN2: Add inter vlan host" +
406 " intent failed" )
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700407
kelvin-onlabf70fd542015-05-07 18:41:40 -0700408 def CASE1002( self, main ):
kelvin-onlab65782a82015-05-07 14:12:13 -0700409 """
410 Add point intents between 2 hosts:
kelvin-onlabe5239e52015-05-13 14:46:45 -0700411 - Get device ids | ports
kelvin-onlab65782a82015-05-07 14:12:13 -0700412 - Add point intents
413 - Check intents
kelvin-onlabe5239e52015-05-13 14:46:45 -0700414 - Verify flows
kelvin-onlab65782a82015-05-07 14:12:13 -0700415 - Ping hosts
416 - Reroute
417 - Link down
kelvin-onlabe5239e52015-05-13 14:46:45 -0700418 - Verify flows
419 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700420 - Ping hosts
421 - Link up
kelvin-onlabe5239e52015-05-13 14:46:45 -0700422 - Verify flows
423 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700424 - Ping hosts
425 - Remove intents
426 """
kelvin-onlabe5239e52015-05-13 14:46:45 -0700427 import time
428 import json
429 import re
kelvin-onlabe5239e52015-05-13 14:46:45 -0700430
431 # Assert variables - These variable's name|format must be followed
432 # if you want to use the wrapper function
433 assert main, "There is no main"
434 assert main.CLIs, "There is no main.CLIs"
435 assert main.Mininet1, "Mininet handle should be named Mininet1"
436 assert main.numSwitch, "Placed the total number of switch topology in \
437 main.numSwitch"
438
kelvin-onlabb2235602015-05-13 17:51:06 -0700439 main.case( "Add point intents between 2 devices" )
440
441 stepResult = main.TRUE
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700442 # No option point intents
443 main.step( "NOOPTION: Add point intents between h1 and h9" )
444 stepResult = main.wrapper.pointIntent(
445 main,
446 name="NOOPTION",
447 host1="h1",
448 host2="h9",
449 deviceId1="of:0000000000000005/1",
450 deviceId2="of:0000000000000006/1",
451 sw1="s5",
452 sw2="s2",
453 expectedLink=18 )
454
455 stepResult = main.TRUE
456 main.step( "NOOPTION: Add point intents between h1 and h9" )
457 utilities.assert_equals( expect=main.TRUE,
458 actual=stepResult,
459 onpass="NOOPTION: Add point intent successful",
460 onfail="NOOPTION: Add point intent failed" )
461
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700462 stepResult = main.TRUE
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700463 stepResult = main.wrapper.pointIntent(
464 main,
465 name="IPV4",
466 host1="h1",
467 host2="h9",
468 deviceId1="of:0000000000000005/1",
469 deviceId2="of:0000000000000006/1",
470 port1="",
471 port2="",
472 ethType="IPV4",
473 mac1="00:00:00:00:00:01",
474 mac2="00:00:00:00:00:09",
475 bandwidth="",
476 lambdaAlloc=False,
477 ipProto="",
478 ip1="",
479 ip2="",
480 tcp1="",
481 tcp2="",
482 sw1="s5",
483 sw2="s2",
484 expectedLink=18 )
485
kelvin-onlabb2235602015-05-13 17:51:06 -0700486 utilities.assert_equals( expect=main.TRUE,
487 actual=stepResult,
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700488 onpass="IPV4: Add point intent successful",
489 onfail="IPV4: Add point intent failed" )
kelvin-onlab65782a82015-05-07 14:12:13 -0700490
kelvin-onlab381b34c2015-05-21 09:21:06 -0700491 stepResult = main.TRUE
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700492 stepResult = main.wrapper.pointIntent(
493 main,
494 name="IPV4_2",
495 host1="h1",
496 host2="h9",
497 deviceId1="of:0000000000000005/1",
498 deviceId2="of:0000000000000006/1",
499 ipProto=1,
500 ip1="",
501 ip2="",
502 tcp1="",
503 tcp2="",
504 sw1="s5",
505 sw2="s2",
506 expectedLink=18 )
507
508 utilities.assert_equals( expect=main.TRUE,
509 actual=stepResult,
510 onpass="IPV4_2: Add point intent successful",
511 onfail="IPV4_2: Add point intent failed" )
512
513 stepResult = main.TRUE
kelvin-onlab381b34c2015-05-21 09:21:06 -0700514 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
515 stepResult = main.wrapper.pointIntent(
516 main,
517 name="DUALSTACK1",
518 host1="h3",
519 host2="h11",
520 deviceId1="of:0000000000000005",
521 deviceId2="of:0000000000000006",
522 port1="3",
523 port2="3",
524 ethType="IPV4",
525 mac1="00:00:00:00:00:03",
526 mac2="00:00:00:00:00:0B",
527 bandwidth="",
528 lambdaAlloc=False,
529 ipProto="",
530 ip1="",
531 ip2="",
532 tcp1="",
533 tcp2="",
534 sw1="s5",
535 sw2="s2",
536 expectedLink=18 )
537
538 utilities.assert_equals( expect=main.TRUE,
539 actual=stepResult,
540 onpass="DUALSTACK1: Add point intent" +
541 " successful",
kaouthera426d0ab2015-05-28 17:41:10 -0700542 onfail="DUALSTACK1: Add point intent failed" )
543 stepResult = main.TRUE
544 main.step( "VLAN: Add point intents between h5 and h21" )
545 stepResult = main.wrapper.pointIntent(
546 main,
547 name="VLAN",
548 host1="h5",
549 host2="h21",
550 deviceId1="of:0000000000000005/5",
551 deviceId2="of:0000000000000007/5",
552 port1="",
553 port2="",
554 ethType="IPV4",
555 mac1="00:00:00:00:00:05",
556 mac2="00:00:00:00:00:15",
557 bandwidth="",
558 lambdaAlloc=False,
559 ipProto="",
560 ip1="",
561 ip2="",
562 tcp1="",
563 tcp2="",
564 sw1="s5",
565 sw2="s2",
566 expectedLink=18 )
567
568 utilities.assert_equals( expect=main.TRUE,
569 actual=stepResult,
570 onpass="VLAN: Add point intent successful",
571 onfail="VLAN: Add point intent failed" )
kelvin-onlabc751ab42015-05-21 14:09:39 -0700572
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700573 stepResult = main.TRUE
574 main.step( "1HOP: Add point intents between h1 and h3" )
575 stepResult = main.wrapper.hostIntent( main,
576 name='1HOP',
577 host1='h1',
578 host2='h3' )
579
580 utilities.assert_equals( expect=main.TRUE,
581 actual=stepResult,
582 onpass="1HOP: Add point intent" +
583 " successful",
584 onfail="1HOP: Add point intent failed" )
585
kelvin-onlabf70fd542015-05-07 18:41:40 -0700586 def CASE1003( self, main ):
kelvin-onlab65782a82015-05-07 14:12:13 -0700587 """
588 Add single point to multi point intents
589 - Get device ids
590 - Add single point to multi point intents
591 - Check intents
kelvin-onlabe5239e52015-05-13 14:46:45 -0700592 - Verify flows
kelvin-onlab65782a82015-05-07 14:12:13 -0700593 - Ping hosts
594 - Reroute
595 - Link down
kelvin-onlabe5239e52015-05-13 14:46:45 -0700596 - Verify flows
597 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700598 - Ping hosts
599 - Link up
kelvin-onlabe5239e52015-05-13 14:46:45 -0700600 - Verify flows
601 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700602 - Ping hosts
603 - Remove intents
604 """
kelvin-onlabf0594d72015-05-19 17:25:12 -0700605 assert main, "There is no main"
606 assert main.CLIs, "There is no main.CLIs"
607 assert main.Mininet1, "Mininet handle should be named Mininet1"
608 assert main.numSwitch, "Placed the total number of switch topology in \
609 main.numSwitch"
kelvin-onlab65782a82015-05-07 14:12:13 -0700610
kelvin-onlabf0594d72015-05-19 17:25:12 -0700611 main.case( "Add single point to multi point intents between devices" )
612
613 stepResult = main.TRUE
kelvin-onlabf0594d72015-05-19 17:25:12 -0700614 hostNames = [ 'h8', 'h16', 'h24' ]
615 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
616 'of:0000000000000007/8' ]
617 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700618
619 main.step( "NOOPTION: Add single point to multi point intents" )
620 stepResult = main.wrapper.singleToMultiIntent(
621 main,
622 name="NOOPTION",
623 hostNames=hostNames,
624 devices=devices,
625 sw1="s5",
626 sw2="s2",
627 expectedLink=18 )
628
629 utilities.assert_equals( expect=main.TRUE,
630 actual=stepResult,
631 onpass="NOOPTION: Successfully added single "
632 + " point to multi point intents",
633 onfail="NOOPTION: Failed to add single point" +
634 " to multi point intents" )
635
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700636 stepResult = main.TRUE
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700637 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabf0594d72015-05-19 17:25:12 -0700638 stepResult = main.wrapper.singleToMultiIntent(
639 main,
kelvin-onlab08900012015-05-20 14:30:44 -0700640 name="IPV4",
kelvin-onlabf0594d72015-05-19 17:25:12 -0700641 hostNames=hostNames,
642 devices=devices,
643 ports=None,
644 ethType="IPV4",
645 macs=macs,
646 bandwidth="",
647 lambdaAlloc=False,
648 ipProto="",
649 ipAddresses="",
650 tcp="",
kelvin-onlab08900012015-05-20 14:30:44 -0700651 sw1="s5",
652 sw2="s2",
653 expectedLink=18 )
kelvin-onlabf0594d72015-05-19 17:25:12 -0700654
655 utilities.assert_equals( expect=main.TRUE,
656 actual=stepResult,
657 onpass="IPV4: Successfully added single point"
658 + " to multi point intents",
659 onfail="IPV4: Failed to add single point" +
660 " to multi point intents" )
kelvin-onlab08900012015-05-20 14:30:44 -0700661
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700662 stepResult = main.TRUE
kelvin-onlab08900012015-05-20 14:30:44 -0700663 main.step( "IPV4_2: Add single point to multi point intents" )
664 hostNames = [ 'h8', 'h16', 'h24' ]
kelvin-onlab08900012015-05-20 14:30:44 -0700665 stepResult = main.wrapper.singleToMultiIntent(
666 main,
667 name="IPV4",
668 hostNames=hostNames,
669 ethType="IPV4",
670 lambdaAlloc=False )
671
672 utilities.assert_equals( expect=main.TRUE,
673 actual=stepResult,
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700674 onpass="IPV4_2: Successfully added single "
675 + " point to multi point intents",
kelvin-onlab08900012015-05-20 14:30:44 -0700676 onfail="IPV4_2: Failed to add single point" +
677 " to multi point intents" )
kaouthera426d0ab2015-05-28 17:41:10 -0700678 stepResult = main.TRUE
679 main.step( "VLAN: Add single point to multi point intents" )
680 hostNames = [ 'h4', 'h12', 'h20' ]
681 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
682 'of:0000000000000007/4' ]
683 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
684 stepResult = main.wrapper.singleToMultiIntent(
685 main,
686 name="VLAN",
687 hostNames=hostNames,
688 devices=devices,
689 ports=None,
690 ethType="IPV4",
691 macs=macs,
692 bandwidth="",
693 lambdaAlloc=False,
694 ipProto="",
695 ipAddresses="",
696 tcp="",
697 sw1="s5",
698 sw2="s2",
699 expectedLink=18 )
700
701 utilities.assert_equals( expect=main.TRUE,
702 actual=stepResult,
703 onpass="VLAN: Successfully added single point"
704 + " to multi point intents",
705 onfail="VLAN: Failed to add single point" +
706 " to multi point intents" )
707
kelvin-onlabf70fd542015-05-07 18:41:40 -0700708 def CASE1004( self, main ):
kelvin-onlab65782a82015-05-07 14:12:13 -0700709 """
710 Add multi point to single point intents
711 - Get device ids
712 - Add multi point to single point intents
713 - Check intents
kelvin-onlabe5239e52015-05-13 14:46:45 -0700714 - Verify flows
kelvin-onlab65782a82015-05-07 14:12:13 -0700715 - Ping hosts
716 - Reroute
717 - Link down
kelvin-onlabe5239e52015-05-13 14:46:45 -0700718 - Verify flows
719 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700720 - Ping hosts
721 - Link up
kelvin-onlabe5239e52015-05-13 14:46:45 -0700722 - Verify flows
723 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700724 - Ping hosts
kaouthera426d0ab2015-05-28 17:41:10 -0700725 - Remove intents
kelvin-onlab65782a82015-05-07 14:12:13 -0700726 """
kelvin-onlabc751ab42015-05-21 14:09:39 -0700727 assert main, "There is no main"
728 assert main.CLIs, "There is no main.CLIs"
729 assert main.Mininet1, "Mininet handle should be named Mininet1"
730 assert main.numSwitch, "Placed the total number of switch topology in \
731 main.numSwitch"
732
733 main.case( "Add multi point to single point intents between devices" )
734
735 stepResult = main.TRUE
kelvin-onlabc751ab42015-05-21 14:09:39 -0700736 hostNames = [ 'h8', 'h16', 'h24' ]
737 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
738 'of:0000000000000007/8' ]
739 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700740
741 main.step( "NOOPTION: Add multi point to single point intents" )
742 stepResult = main.wrapper.multiToSingleIntent(
743 main,
744 name="NOOPTION",
745 hostNames=hostNames,
746 devices=devices,
747 sw1="s5",
748 sw2="s2",
749 expectedLink=18 )
750
751 utilities.assert_equals( expect=main.TRUE,
752 actual=stepResult,
753 onpass="NOOPTION: Successfully added multi "
754 + " point to single point intents",
755 onfail="NOOPTION: Failed to add multi point" +
756 " to single point intents" )
757
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700758 stepResult = main.TRUE
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700759 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabc751ab42015-05-21 14:09:39 -0700760 stepResult = main.wrapper.multiToSingleIntent(
761 main,
762 name="IPV4",
763 hostNames=hostNames,
764 devices=devices,
765 ports=None,
766 ethType="IPV4",
767 macs=macs,
768 bandwidth="",
769 lambdaAlloc=False,
770 ipProto="",
771 ipAddresses="",
772 tcp="",
773 sw1="s5",
774 sw2="s2",
775 expectedLink=18 )
776
777 utilities.assert_equals( expect=main.TRUE,
778 actual=stepResult,
779 onpass="IPV4: Successfully added multi point"
780 + " to single point intents",
781 onfail="IPV4: Failed to add multi point" +
782 " to single point intents" )
783
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700784 stepResult = main.TRUE
kelvin-onlabc751ab42015-05-21 14:09:39 -0700785 main.step( "IPV4_2: Add multi point to single point intents" )
786 hostNames = [ 'h8', 'h16', 'h24' ]
787 stepResult = main.wrapper.multiToSingleIntent(
788 main,
789 name="IPV4",
790 hostNames=hostNames,
791 ethType="IPV4",
792 lambdaAlloc=False )
793
794 utilities.assert_equals( expect=main.TRUE,
795 actual=stepResult,
796 onpass="IPV4_2: Successfully added multi point"
797 + " to single point intents",
798 onfail="IPV4_2: Failed to add multi point" +
799 " to single point intents" )
kaouthera426d0ab2015-05-28 17:41:10 -0700800
801 stepResult = main.TRUE
802 main.step( "VLAN: Add multi point to single point intents" )
803 hostNames = [ 'h5', 'h13', 'h21' ]
804 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
805 'of:0000000000000007/5' ]
806 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
807 stepResult = main.wrapper.multiToSingleIntent(
808 main,
809 name="VLAN",
810 hostNames=hostNames,
811 devices=devices,
812 ports=None,
813 ethType="IPV4",
814 macs=macs,
815 bandwidth="",
816 lambdaAlloc=False,
817 ipProto="",
818 ipAddresses="",
819 tcp="",
820 sw1="s5",
821 sw2="s2",
822 expectedLink=18 )
823
824 utilities.assert_equals( expect=main.TRUE,
825 actual=stepResult,
826 onpass="VLAN: Successfully added multi point"
827 + " to single point intents",
828 onfail="VLAN: Failed to add multi point" +
829 " to single point intents" )