blob: 3a716eedc49821fb5dc15b99dc37fd9938355f40 [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-onlabfa6ada82015-06-11 13:06:24 -0700226 switchList = []
227
228 # Creates a list switch name, use getSwitch() function later...
kelvin-onlab5cbf9992015-05-05 14:34:07 -0700229 for i in range( 1, ( main.numSwitch + 1 ) ):
kelvin-onlabfa6ada82015-06-11 13:06:24 -0700230 switchList.append( 's' + str( i ) )
231
232 assignResult = main.Mininet1.assignSwController( sw=switchList,
233 ip=main.ONOSip,
234 port=main.ONOSport )
235 if not assignResult:
236 main.cleanup()
237 main.exit()
238
kelvin-onlab5cbf9992015-05-05 14:34:07 -0700239 for i in range( 1, ( main.numSwitch + 1 ) ):
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700240 response = main.Mininet1.getSwController( "s" + str( i ) )
241 print( "Response is " + str( response ) )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700242 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700243 assignResult = assignResult and main.TRUE
244 else:
245 assignResult = main.FALSE
246 stepResult = assignResult
247 utilities.assert_equals( expect=main.TRUE,
248 actual=stepResult,
249 onpass="Successfully assigned switches" +
250 "to controller",
251 onfail="Failed to assign switches to " +
252 "controller" )
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700253 def CASE13( self, main ):
254 """
255 Discover all hosts and store its data to a dictionary
256 """
257 main.case( "Discover all hosts" )
258
259 stepResult = main.TRUE
kelvin-onlab132bd5b2015-05-18 18:15:26 -0700260 main.step( "Discover all hosts using pingall " )
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700261 stepResult = main.wrapper.getHostsData( main )
kelvin-onlab08900012015-05-20 14:30:44 -0700262 utilities.assert_equals( expect=main.TRUE,
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700263 actual=stepResult,
264 onpass="Successfully discovered hosts",
265 onfail="Failed to discover hosts" )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700266
kelvin-onlab2ff57022015-05-29 10:48:51 -0700267 def CASE14( self, main ):
268 """
269 Stop mininet
270 """
271 main.log.report( "Stop Mininet topology" )
272 main.log.case( "Stop Mininet topology" )
273
274 main.step( "Stopping Mininet Topology" )
275 topoResult = main.Mininet1.stopNet( )
276 stepResult = topoResult
277 utilities.assert_equals( expect=main.TRUE,
278 actual=stepResult,
279 onpass="Successfully stop mininet",
280 onfail="Failed to stop mininet" )
281 # Exit if topology did not load properly
282 if not topoResult:
283 main.cleanup()
284 main.exit()
285
kelvin-onlabf70fd542015-05-07 18:41:40 -0700286 def CASE1001( self, main ):
kelvin-onlab7c577e82015-05-07 10:45:16 -0700287 """
kelvin-onlab65782a82015-05-07 14:12:13 -0700288 Add host intents between 2 host:
289 - Discover hosts
290 - Add host intents
291 - Check intents
kelvin-onlabe5239e52015-05-13 14:46:45 -0700292 - Verify flows
kelvin-onlab65782a82015-05-07 14:12:13 -0700293 - Ping hosts
294 - Reroute
295 - Link down
kelvin-onlabe5239e52015-05-13 14:46:45 -0700296 - Verify flows
297 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700298 - Ping hosts
299 - Link up
kelvin-onlabe5239e52015-05-13 14:46:45 -0700300 - Verify flows
301 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700302 - Ping hosts
303 - Remove intents
kelvin-onlab7c577e82015-05-07 10:45:16 -0700304 """
305 import time
306 import json
kelvin-onlab65782a82015-05-07 14:12:13 -0700307 import re
kelvin-onlabe5239e52015-05-13 14:46:45 -0700308
309 # Assert variables - These variable's name|format must be followed
310 # if you want to use the wrapper function
311 assert main, "There is no main"
312 assert main.CLIs, "There is no main.CLIs"
313 assert main.Mininet1, "Mininet handle should be named Mininet1"
314 assert main.numSwitch, "Placed the total number of switch topology in \
315 main.numSwitch"
316
kelvin-onlabe5239e52015-05-13 14:46:45 -0700317 main.case( "Add host intents between 2 host" )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700318
kelvin-onlabe5239e52015-05-13 14:46:45 -0700319 stepResult = main.TRUE
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700320 main.step( "IPV4: Add host intents between h1 and h9" )
321 stepResult = main.wrapper.hostIntent( main,
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700322 onosNode='0',
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700323 name='IPV4',
324 host1='h1',
325 host2='h9',
326 host1Id='00:00:00:00:00:01/-1',
327 host2Id='00:00:00:00:00:09/-1',
328 sw1='s5',
329 sw2='s2',
330 expectedLink=18 )
kelvin-onlab7c577e82015-05-07 10:45:16 -0700331
kelvin-onlabe5239e52015-05-13 14:46:45 -0700332 utilities.assert_equals( expect=main.TRUE,
333 actual=stepResult,
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700334 onpass="IPV4: Add host intent successful",
335 onfail="IPV4: Add host intent failed" )
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700336
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700337 stepResult = main.TRUE
kelvin-onlab381b34c2015-05-21 09:21:06 -0700338 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700339 stepResult = main.wrapper.hostIntent( main,
340 name='DUALSTACK',
341 host1='h3',
342 host2='h11',
343 host1Id='00:00:00:00:00:03/-1',
kelvin-onlab132bd5b2015-05-18 18:15:26 -0700344 host2Id='00:00:00:00:00:0B/-1',
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700345 sw1='s5',
346 sw2='s2',
347 expectedLink=18 )
348
349 utilities.assert_equals( expect=main.TRUE,
350 actual=stepResult,
kelvin-onlab381b34c2015-05-21 09:21:06 -0700351 onpass="DUALSTACK1: Add host intent" +
352 " successful",
353 onfail="DUALSTACK1: Add host intent failed" )
354
355 stepResult = main.TRUE
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700356 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlab381b34c2015-05-21 09:21:06 -0700357 stepResult = main.wrapper.hostIntent( main,
358 name='DUALSTACK2',
359 host1='h1',
360 host2='h11',
361 sw1='s5',
362 sw2='s2',
363 expectedLink=18 )
364
365 utilities.assert_equals( expect=main.TRUE,
366 actual=stepResult,
367 onpass="DUALSTACK2: Add host intent" +
368 " successful",
369 onfail="DUALSTACK2: Add host intent failed" )
kelvin-onlab7c577e82015-05-07 10:45:16 -0700370
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700371 stepResult = main.TRUE
372 main.step( "1HOP: Add host intents between h1 and h3" )
373 stepResult = main.wrapper.hostIntent( main,
374 name='1HOP',
375 host1='h1',
376 host2='h3' )
377
378 utilities.assert_equals( expect=main.TRUE,
379 actual=stepResult,
380 onpass="1HOP: Add host intent" +
381 " successful",
382 onfail="1HOP: Add host intent failed" )
383
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700384 stepResult = main.TRUE
kaouthera6f37d852015-05-27 13:52:08 -0700385 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
386 stepResult = main.wrapper.hostIntent( main,
387 name='VLAN1',
388 host1='h4',
389 host2='h12',
390 host1Id='00:00:00:00:00:04/100',
391 host2Id='00:00:00:00:00:0C/100',
392 sw1='s5',
393 sw2='s2',
394 expectedLink=18 )
395
396 utilities.assert_equals( expect=main.TRUE,
397 actual=stepResult,
kelvin-onlab2ff57022015-05-29 10:48:51 -0700398 onpass="VLAN1: Add vlan host" +
399 " intent successful",
kaouthera6f37d852015-05-27 13:52:08 -0700400 onfail="VLAN1: Add vlan host intent failed" )
kelvin-onlab2ff57022015-05-29 10:48:51 -0700401
kaouthera6f37d852015-05-27 13:52:08 -0700402 stepResult = main.TRUE
403 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
404 stepResult = main.wrapper.hostIntent( main,
405 name='VLAN2',
406 host1='h13',
kelvin-onlab2ff57022015-05-29 10:48:51 -0700407 host2='h20' )
kaouthera6f37d852015-05-27 13:52:08 -0700408
409 utilities.assert_equals( expect=main.FALSE,
410 actual=stepResult,
kelvin-onlab2ff57022015-05-29 10:48:51 -0700411 onpass="VLAN2: Add inter vlan host" +
412 " intent successful",
413 onfail="VLAN2: Add inter vlan host" +
414 " intent failed" )
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700415
kelvin-onlabf70fd542015-05-07 18:41:40 -0700416 def CASE1002( self, main ):
kelvin-onlab65782a82015-05-07 14:12:13 -0700417 """
418 Add point intents between 2 hosts:
kelvin-onlabe5239e52015-05-13 14:46:45 -0700419 - Get device ids | ports
kelvin-onlab65782a82015-05-07 14:12:13 -0700420 - Add point intents
421 - Check intents
kelvin-onlabe5239e52015-05-13 14:46:45 -0700422 - Verify flows
kelvin-onlab65782a82015-05-07 14:12:13 -0700423 - Ping hosts
424 - Reroute
425 - Link down
kelvin-onlabe5239e52015-05-13 14:46:45 -0700426 - Verify flows
427 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700428 - Ping hosts
429 - Link up
kelvin-onlabe5239e52015-05-13 14:46:45 -0700430 - Verify flows
431 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700432 - Ping hosts
433 - Remove intents
434 """
kelvin-onlabe5239e52015-05-13 14:46:45 -0700435 import time
436 import json
437 import re
kelvin-onlabe5239e52015-05-13 14:46:45 -0700438
439 # Assert variables - These variable's name|format must be followed
440 # if you want to use the wrapper function
441 assert main, "There is no main"
442 assert main.CLIs, "There is no main.CLIs"
443 assert main.Mininet1, "Mininet handle should be named Mininet1"
444 assert main.numSwitch, "Placed the total number of switch topology in \
445 main.numSwitch"
446
kelvin-onlabb2235602015-05-13 17:51:06 -0700447 main.case( "Add point intents between 2 devices" )
448
449 stepResult = main.TRUE
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700450 # No option point intents
451 main.step( "NOOPTION: Add point intents between h1 and h9" )
452 stepResult = main.wrapper.pointIntent(
453 main,
454 name="NOOPTION",
455 host1="h1",
456 host2="h9",
457 deviceId1="of:0000000000000005/1",
458 deviceId2="of:0000000000000006/1",
459 sw1="s5",
460 sw2="s2",
461 expectedLink=18 )
462
463 stepResult = main.TRUE
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700464 utilities.assert_equals( expect=main.TRUE,
465 actual=stepResult,
466 onpass="NOOPTION: Add point intent successful",
467 onfail="NOOPTION: Add point intent failed" )
468
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700469 stepResult = main.TRUE
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700470 stepResult = main.wrapper.pointIntent(
471 main,
472 name="IPV4",
473 host1="h1",
474 host2="h9",
475 deviceId1="of:0000000000000005/1",
476 deviceId2="of:0000000000000006/1",
477 port1="",
478 port2="",
479 ethType="IPV4",
480 mac1="00:00:00:00:00:01",
481 mac2="00:00:00:00:00:09",
482 bandwidth="",
483 lambdaAlloc=False,
484 ipProto="",
485 ip1="",
486 ip2="",
487 tcp1="",
488 tcp2="",
489 sw1="s5",
490 sw2="s2",
491 expectedLink=18 )
492
kelvin-onlabb2235602015-05-13 17:51:06 -0700493 utilities.assert_equals( expect=main.TRUE,
494 actual=stepResult,
kelvin-onlab2ccad6e2015-05-18 10:36:54 -0700495 onpass="IPV4: Add point intent successful",
496 onfail="IPV4: Add point intent failed" )
kelvin-onlab65782a82015-05-07 14:12:13 -0700497
kelvin-onlab381b34c2015-05-21 09:21:06 -0700498 stepResult = main.TRUE
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700499 stepResult = main.wrapper.pointIntent(
500 main,
501 name="IPV4_2",
502 host1="h1",
503 host2="h9",
504 deviceId1="of:0000000000000005/1",
505 deviceId2="of:0000000000000006/1",
506 ipProto=1,
507 ip1="",
508 ip2="",
509 tcp1="",
510 tcp2="",
511 sw1="s5",
512 sw2="s2",
513 expectedLink=18 )
514
515 utilities.assert_equals( expect=main.TRUE,
516 actual=stepResult,
517 onpass="IPV4_2: Add point intent successful",
518 onfail="IPV4_2: Add point intent failed" )
519
520 stepResult = main.TRUE
kelvin-onlab381b34c2015-05-21 09:21:06 -0700521 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
522 stepResult = main.wrapper.pointIntent(
523 main,
524 name="DUALSTACK1",
525 host1="h3",
526 host2="h11",
527 deviceId1="of:0000000000000005",
528 deviceId2="of:0000000000000006",
529 port1="3",
530 port2="3",
531 ethType="IPV4",
532 mac1="00:00:00:00:00:03",
533 mac2="00:00:00:00:00:0B",
534 bandwidth="",
535 lambdaAlloc=False,
536 ipProto="",
537 ip1="",
538 ip2="",
539 tcp1="",
540 tcp2="",
541 sw1="s5",
542 sw2="s2",
543 expectedLink=18 )
544
545 utilities.assert_equals( expect=main.TRUE,
546 actual=stepResult,
547 onpass="DUALSTACK1: Add point intent" +
548 " successful",
kaouthera426d0ab2015-05-28 17:41:10 -0700549 onfail="DUALSTACK1: Add point intent failed" )
550 stepResult = main.TRUE
551 main.step( "VLAN: Add point intents between h5 and h21" )
552 stepResult = main.wrapper.pointIntent(
553 main,
554 name="VLAN",
555 host1="h5",
556 host2="h21",
557 deviceId1="of:0000000000000005/5",
558 deviceId2="of:0000000000000007/5",
559 port1="",
560 port2="",
561 ethType="IPV4",
562 mac1="00:00:00:00:00:05",
563 mac2="00:00:00:00:00:15",
564 bandwidth="",
565 lambdaAlloc=False,
566 ipProto="",
567 ip1="",
568 ip2="",
569 tcp1="",
570 tcp2="",
571 sw1="s5",
572 sw2="s2",
573 expectedLink=18 )
574
575 utilities.assert_equals( expect=main.TRUE,
576 actual=stepResult,
577 onpass="VLAN: Add point intent successful",
578 onfail="VLAN: Add point intent failed" )
kelvin-onlabc751ab42015-05-21 14:09:39 -0700579
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700580 stepResult = main.TRUE
581 main.step( "1HOP: Add point intents between h1 and h3" )
582 stepResult = main.wrapper.hostIntent( main,
583 name='1HOP',
584 host1='h1',
585 host2='h3' )
586
587 utilities.assert_equals( expect=main.TRUE,
588 actual=stepResult,
589 onpass="1HOP: Add point intent" +
590 " successful",
591 onfail="1HOP: Add point intent failed" )
592
kelvin-onlabf70fd542015-05-07 18:41:40 -0700593 def CASE1003( self, main ):
kelvin-onlab65782a82015-05-07 14:12:13 -0700594 """
595 Add single point to multi point intents
596 - Get device ids
597 - Add single point to multi point intents
598 - Check intents
kelvin-onlabe5239e52015-05-13 14:46:45 -0700599 - Verify flows
kelvin-onlab65782a82015-05-07 14:12:13 -0700600 - Ping hosts
601 - Reroute
602 - Link down
kelvin-onlabe5239e52015-05-13 14:46:45 -0700603 - Verify flows
604 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700605 - Ping hosts
606 - Link up
kelvin-onlabe5239e52015-05-13 14:46:45 -0700607 - Verify flows
608 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700609 - Ping hosts
610 - Remove intents
611 """
kelvin-onlabf0594d72015-05-19 17:25:12 -0700612 assert main, "There is no main"
613 assert main.CLIs, "There is no main.CLIs"
614 assert main.Mininet1, "Mininet handle should be named Mininet1"
615 assert main.numSwitch, "Placed the total number of switch topology in \
616 main.numSwitch"
kelvin-onlab65782a82015-05-07 14:12:13 -0700617
kelvin-onlabf0594d72015-05-19 17:25:12 -0700618 main.case( "Add single point to multi point intents between devices" )
619
620 stepResult = main.TRUE
kelvin-onlabf0594d72015-05-19 17:25:12 -0700621 hostNames = [ 'h8', 'h16', 'h24' ]
622 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
623 'of:0000000000000007/8' ]
624 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 -0700625
626 main.step( "NOOPTION: Add single point to multi point intents" )
627 stepResult = main.wrapper.singleToMultiIntent(
628 main,
629 name="NOOPTION",
630 hostNames=hostNames,
631 devices=devices,
632 sw1="s5",
633 sw2="s2",
634 expectedLink=18 )
635
636 utilities.assert_equals( expect=main.TRUE,
637 actual=stepResult,
638 onpass="NOOPTION: Successfully added single "
639 + " point to multi point intents",
640 onfail="NOOPTION: Failed to add single point" +
641 " to multi point intents" )
642
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700643 stepResult = main.TRUE
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700644 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabf0594d72015-05-19 17:25:12 -0700645 stepResult = main.wrapper.singleToMultiIntent(
646 main,
kelvin-onlab08900012015-05-20 14:30:44 -0700647 name="IPV4",
kelvin-onlabf0594d72015-05-19 17:25:12 -0700648 hostNames=hostNames,
649 devices=devices,
650 ports=None,
651 ethType="IPV4",
652 macs=macs,
653 bandwidth="",
654 lambdaAlloc=False,
655 ipProto="",
656 ipAddresses="",
657 tcp="",
kelvin-onlab08900012015-05-20 14:30:44 -0700658 sw1="s5",
659 sw2="s2",
660 expectedLink=18 )
kelvin-onlabf0594d72015-05-19 17:25:12 -0700661
662 utilities.assert_equals( expect=main.TRUE,
663 actual=stepResult,
664 onpass="IPV4: Successfully added single point"
665 + " to multi point intents",
666 onfail="IPV4: Failed to add single point" +
667 " to multi point intents" )
kelvin-onlab08900012015-05-20 14:30:44 -0700668
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700669 stepResult = main.TRUE
kelvin-onlab08900012015-05-20 14:30:44 -0700670 main.step( "IPV4_2: Add single point to multi point intents" )
671 hostNames = [ 'h8', 'h16', 'h24' ]
kelvin-onlab08900012015-05-20 14:30:44 -0700672 stepResult = main.wrapper.singleToMultiIntent(
673 main,
674 name="IPV4",
675 hostNames=hostNames,
676 ethType="IPV4",
677 lambdaAlloc=False )
678
679 utilities.assert_equals( expect=main.TRUE,
680 actual=stepResult,
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700681 onpass="IPV4_2: Successfully added single "
682 + " point to multi point intents",
kelvin-onlab08900012015-05-20 14:30:44 -0700683 onfail="IPV4_2: Failed to add single point" +
684 " to multi point intents" )
kaouthera426d0ab2015-05-28 17:41:10 -0700685 stepResult = main.TRUE
686 main.step( "VLAN: Add single point to multi point intents" )
687 hostNames = [ 'h4', 'h12', 'h20' ]
688 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
689 'of:0000000000000007/4' ]
690 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
691 stepResult = main.wrapper.singleToMultiIntent(
692 main,
693 name="VLAN",
694 hostNames=hostNames,
695 devices=devices,
696 ports=None,
697 ethType="IPV4",
698 macs=macs,
699 bandwidth="",
700 lambdaAlloc=False,
701 ipProto="",
702 ipAddresses="",
703 tcp="",
704 sw1="s5",
705 sw2="s2",
706 expectedLink=18 )
707
708 utilities.assert_equals( expect=main.TRUE,
709 actual=stepResult,
710 onpass="VLAN: Successfully added single point"
711 + " to multi point intents",
712 onfail="VLAN: Failed to add single point" +
713 " to multi point intents" )
714
kelvin-onlabf70fd542015-05-07 18:41:40 -0700715 def CASE1004( self, main ):
kelvin-onlab65782a82015-05-07 14:12:13 -0700716 """
717 Add multi point to single point intents
718 - Get device ids
719 - Add multi point to single point intents
720 - Check intents
kelvin-onlabe5239e52015-05-13 14:46:45 -0700721 - Verify flows
kelvin-onlab65782a82015-05-07 14:12:13 -0700722 - Ping hosts
723 - Reroute
724 - Link down
kelvin-onlabe5239e52015-05-13 14:46:45 -0700725 - Verify flows
726 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700727 - Ping hosts
728 - Link up
kelvin-onlabe5239e52015-05-13 14:46:45 -0700729 - Verify flows
730 - Check topology
kelvin-onlab65782a82015-05-07 14:12:13 -0700731 - Ping hosts
kaouthera426d0ab2015-05-28 17:41:10 -0700732 - Remove intents
kelvin-onlab65782a82015-05-07 14:12:13 -0700733 """
kelvin-onlabc751ab42015-05-21 14:09:39 -0700734 assert main, "There is no main"
735 assert main.CLIs, "There is no main.CLIs"
736 assert main.Mininet1, "Mininet handle should be named Mininet1"
737 assert main.numSwitch, "Placed the total number of switch topology in \
738 main.numSwitch"
739
740 main.case( "Add multi point to single point intents between devices" )
741
742 stepResult = main.TRUE
kelvin-onlabc751ab42015-05-21 14:09:39 -0700743 hostNames = [ 'h8', 'h16', 'h24' ]
744 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
745 'of:0000000000000007/8' ]
746 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 -0700747
748 main.step( "NOOPTION: Add multi point to single point intents" )
749 stepResult = main.wrapper.multiToSingleIntent(
750 main,
751 name="NOOPTION",
752 hostNames=hostNames,
753 devices=devices,
754 sw1="s5",
755 sw2="s2",
756 expectedLink=18 )
757
758 utilities.assert_equals( expect=main.TRUE,
759 actual=stepResult,
760 onpass="NOOPTION: Successfully added multi "
761 + " point to single point intents",
762 onfail="NOOPTION: Failed to add multi point" +
763 " to single point intents" )
764
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700765 stepResult = main.TRUE
kelvin-onlabf2ec6e02015-05-27 14:15:28 -0700766 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabc751ab42015-05-21 14:09:39 -0700767 stepResult = main.wrapper.multiToSingleIntent(
768 main,
769 name="IPV4",
770 hostNames=hostNames,
771 devices=devices,
772 ports=None,
773 ethType="IPV4",
774 macs=macs,
775 bandwidth="",
776 lambdaAlloc=False,
777 ipProto="",
778 ipAddresses="",
779 tcp="",
780 sw1="s5",
781 sw2="s2",
782 expectedLink=18 )
783
784 utilities.assert_equals( expect=main.TRUE,
785 actual=stepResult,
786 onpass="IPV4: Successfully added multi point"
787 + " to single point intents",
788 onfail="IPV4: Failed to add multi point" +
789 " to single point intents" )
790
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700791 stepResult = main.TRUE
kelvin-onlabc751ab42015-05-21 14:09:39 -0700792 main.step( "IPV4_2: Add multi point to single point intents" )
793 hostNames = [ 'h8', 'h16', 'h24' ]
794 stepResult = main.wrapper.multiToSingleIntent(
795 main,
796 name="IPV4",
797 hostNames=hostNames,
798 ethType="IPV4",
799 lambdaAlloc=False )
800
801 utilities.assert_equals( expect=main.TRUE,
802 actual=stepResult,
803 onpass="IPV4_2: Successfully added multi point"
804 + " to single point intents",
805 onfail="IPV4_2: Failed to add multi point" +
806 " to single point intents" )
kaouthera426d0ab2015-05-28 17:41:10 -0700807
808 stepResult = main.TRUE
809 main.step( "VLAN: Add multi point to single point intents" )
810 hostNames = [ 'h5', 'h13', 'h21' ]
811 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
812 'of:0000000000000007/5' ]
813 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
814 stepResult = main.wrapper.multiToSingleIntent(
815 main,
816 name="VLAN",
817 hostNames=hostNames,
818 devices=devices,
819 ports=None,
820 ethType="IPV4",
821 macs=macs,
822 bandwidth="",
823 lambdaAlloc=False,
824 ipProto="",
825 ipAddresses="",
826 tcp="",
827 sw1="s5",
828 sw2="s2",
829 expectedLink=18 )
830
831 utilities.assert_equals( expect=main.TRUE,
832 actual=stepResult,
833 onpass="VLAN: Successfully added multi point"
834 + " to single point intents",
835 onfail="VLAN: Failed to add multi point" +
836 " to single point intents" )