blob: 1e10db3d0bfff7206c9484afaf62d5bee5ecc1dc [file] [log] [blame]
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001
2# Testing the basic intent functionality of ONOS
3
4import time
5import json
6
7class FUNCintent:
8
9 def __init__( self ):
10 self.default = ''
11
12 def CASE1( self, main ):
13 import time
14 import os
15 import imp
16
17 """
18 - Construct tests variables
19 - GIT ( optional )
20 - Checkout ONOS master branch
21 - Pull latest ONOS code
22 - Building ONOS ( optional )
23 - Install ONOS package
24 - Build ONOS package
25 """
26
27 main.case( "Constructing test variables and building ONOS package" )
28 main.step( "Constructing test variables" )
29 stepResult = main.FALSE
30
31 # Test variables
32 main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
33 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
34 gitBranch = main.params[ 'GIT' ][ 'branch' ]
35 main.dependencyPath = main.testOnDirectory + \
36 main.params[ 'DEPENDENCY' ][ 'path' ]
37 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
38 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
39 main.maxNodes = int( main.ONOSbench.maxNodes )
40 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
41 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
42 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
43 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
44 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
45 gitPull = main.params[ 'GIT' ][ 'pull' ]
46 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
47 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
48 main.cellData = {} # for creating cell file
49 main.hostsData = {}
50 main.CLIs = []
51 main.ONOSip = []
52
53 main.ONOSip = main.ONOSbench.getOnosIps()
54 print main.ONOSip
55
56 # Assigning ONOS cli handles to a list
57 for i in range( 1, main.maxNodes + 1 ):
58 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
59
60 # -- INIT SECTION, ONLY RUNS ONCE -- #
61 main.startUp = imp.load_source( wrapperFile1,
62 main.dependencyPath +
63 wrapperFile1 +
64 ".py" )
65
66 main.intentFunction = imp.load_source( wrapperFile2,
67 main.dependencyPath +
68 wrapperFile2 +
69 ".py" )
70
71 copyResult = main.ONOSbench.copyMininetFile( main.topology,
72 main.dependencyPath,
73 main.Mininet1.user_name,
74 main.Mininet1.ip_address )
75 if main.CLIs:
76 stepResult = main.TRUE
77 else:
78 main.log.error( "Did not properly created list of ONOS CLI handle" )
79 stepResult = main.FALSE
80
81 utilities.assert_equals( expect=main.TRUE,
82 actual=stepResult,
83 onpass="Successfully construct " +
84 "test variables ",
85 onfail="Failed to construct test variables" )
86
87 if gitPull == 'True':
88 main.step( "Building ONOS in " + gitBranch + " branch" )
89 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
90 stepResult = onosBuildResult
91 utilities.assert_equals( expect=main.TRUE,
92 actual=stepResult,
93 onpass="Successfully compiled " +
94 "latest ONOS",
95 onfail="Failed to compile " +
96 "latest ONOS" )
97 else:
98 main.log.warn( "Did not pull new code so skipping mvn " +
99 "clean install" )
100
101 def CASE2( self, main ):
102 """
103 - Set up cell
104 - Create cell file
105 - Set cell file
106 - Verify cell file
107 - Kill ONOS process
108 - Uninstall ONOS cluster
109 - Verify ONOS start up
110 - Install ONOS cluster
111 - Connect to cli
112 """
113
114 # main.scale[ 0 ] determines the current number of ONOS controller
115 main.numCtrls = int( main.scale[ 0 ] )
116
117 main.case( "Starting up " + str( main.numCtrls ) +
118 " node(s) ONOS cluster" )
119
120 #kill off all onos processes
121 main.log.info( "Safety check, killing all ONOS processes" +
122 " before initiating enviornment setup" )
123
124 for i in range( main.maxNodes ):
125 main.ONOSbench.onosDie( main.ONOSip[ i ] )
126
127 print "NODE COUNT = ", main.numCtrls
128
129 tempOnosIp = []
130 for i in range( main.numCtrls ):
131 tempOnosIp.append( main.ONOSip[i] )
132
133 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, "temp", main.Mininet1.ip_address, main.apps, tempOnosIp )
134
135 main.step( "Apply cell to environment" )
136 cellResult = main.ONOSbench.setCell( "temp" )
137 verifyResult = main.ONOSbench.verifyCell()
138 stepResult = cellResult and verifyResult
139 utilities.assert_equals( expect=main.TRUE,
140 actual=stepResult,
141 onpass="Successfully applied cell to " + \
142 "environment",
143 onfail="Failed to apply cell to environment " )
144
145 main.step( "Creating ONOS package" )
146 packageResult = main.ONOSbench.onosPackage()
147 stepResult = packageResult
148 utilities.assert_equals( expect=main.TRUE,
149 actual=stepResult,
150 onpass="Successfully created ONOS package",
151 onfail="Failed to create ONOS package" )
152
153 time.sleep( main.startUpSleep )
154 main.step( "Uninstalling ONOS package" )
155 onosUninstallResult = main.TRUE
156 for i in range( main.numCtrls ):
157 onosUninstallResult = onosUninstallResult and \
158 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
159 stepResult = onosUninstallResult
160 utilities.assert_equals( expect=main.TRUE,
161 actual=stepResult,
162 onpass="Successfully uninstalled ONOS package",
163 onfail="Failed to uninstall ONOS package" )
164
165 time.sleep( main.startUpSleep )
166 main.step( "Installing ONOS package" )
167 onosInstallResult = main.TRUE
168 for i in range( main.numCtrls ):
169 onosInstallResult = onosInstallResult and \
170 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
171 stepResult = onosInstallResult
172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
174 onpass="Successfully installed ONOS package",
175 onfail="Failed to install ONOS package" )
176
177 time.sleep( main.startUpSleep )
178 main.step( "Starting ONOS service" )
179 stopResult = main.TRUE
180 startResult = main.TRUE
181 onosIsUp = main.TRUE
182
183 for i in range( main.numCtrls ):
184 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
185 if onosIsUp == main.TRUE:
186 main.log.report( "ONOS instance is up and ready" )
187 else:
188 main.log.report( "ONOS instance may not be up, stop and " +
189 "start ONOS again " )
190 for i in range( main.numCtrls ):
191 stopResult = stopResult and \
192 main.ONOSbench.onosStop( main.ONOSip[ i ] )
193 for i in range( main.numCtrls ):
194 startResult = startResult and \
195 main.ONOSbench.onosStart( main.ONOSip[ i ] )
196 stepResult = onosIsUp and stopResult and startResult
197 utilities.assert_equals( expect=main.TRUE,
198 actual=stepResult,
199 onpass="ONOS service is ready",
200 onfail="ONOS service did not start properly" )
201
202 main.step( "Start ONOS cli" )
203 cliResult = main.TRUE
204 for i in range( main.numCtrls ):
205 cliResult = cliResult and \
206 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
207 stepResult = cliResult
208 utilities.assert_equals( expect=main.TRUE,
209 actual=stepResult,
210 onpass="Successfully start ONOS cli",
211 onfail="Failed to start ONOS cli" )
212
213 # Remove the first element in main.scale list
214 main.scale.remove( main.scale[ 0 ] )
215
216 def CASE9( self, main ):
217 '''
218 Report errors/warnings/exceptions
219 '''
220 main.log.info( "Error report: \n" )
221 main.ONOSbench.logReport( globalONOSip[0],
222 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
223 "s" )
224 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
225
226 def CASE11( self, main ):
227 """
228 Start mininet
229 """
230 main.log.report( "Start Mininet topology" )
231 main.log.case( "Start Mininet topology" )
232
233 main.step( "Starting Mininet Topology" )
234 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
235 main.topology )
236 stepResult = topoResult
237 utilities.assert_equals( expect=main.TRUE,
238 actual=stepResult,
239 onpass="Successfully loaded topology",
240 onfail="Failed to load topology" )
241 # Exit if topology did not load properly
242 if not topoResult:
243 main.cleanup()
244 main.exit()
245
246 def CASE12( self, main ):
247 """
248 Assign mastership to controllers
249 """
250 import re
251
252 main.case( "Assign switches to controllers" )
253 main.step( "Assigning switches to controllers" )
254 assignResult = main.TRUE
255 switchList = []
256
257 # Creates a list switch name, use getSwitch() function later...
258 for i in range( 1, ( main.numSwitch + 1 ) ):
259 switchList.append( 's' + str( i ) )
260
261 tempONOSip = []
262 for i in range( main.numCtrls ):
263 tempONOSip.append( main.ONOSip[ i ] )
264
265 assignResult = main.Mininet1.assignSwController( sw=switchList,
266 ip=tempONOSip,
267 port='6633' )
268 if not assignResult:
269 main.cleanup()
270 main.exit()
271
272 for i in range( 1, ( main.numSwitch + 1 ) ):
273 response = main.Mininet1.getSwController( "s" + str( i ) )
274 print( "Response is " + str( response ) )
275 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
276 assignResult = assignResult and main.TRUE
277 else:
278 assignResult = main.FALSE
279 stepResult = assignResult
280 utilities.assert_equals( expect=main.TRUE,
281 actual=stepResult,
282 onpass="Successfully assigned switches" +
283 "to controller",
284 onfail="Failed to assign switches to " +
285 "controller" )
286 def CASE13( self, main ):
287 """
288 Discover all hosts and store its data to a dictionary
289 """
290 main.case( "Discover all hosts" )
291
292 stepResult = main.TRUE
293 main.step( "Discover all hosts using pingall " )
294 stepResult = main.intentFunction.getHostsData( main )
295 utilities.assert_equals( expect=main.TRUE,
296 actual=stepResult,
297 onpass="Successfully discovered hosts",
298 onfail="Failed to discover hosts" )
299
300 def CASE14( self, main ):
301 """
302 Stop mininet
303 """
304 main.log.report( "Stop Mininet topology" )
305 main.log.case( "Stop Mininet topology" )
306
307 main.step( "Stopping Mininet Topology" )
308 topoResult = main.Mininet1.stopNet( )
309 stepResult = topoResult
310 utilities.assert_equals( expect=main.TRUE,
311 actual=stepResult,
312 onpass="Successfully stop mininet",
313 onfail="Failed to stop mininet" )
314 # Exit if topology did not load properly
315 if not topoResult:
316 main.cleanup()
317 main.exit()
318
kelvin-onlabb769f562015-07-15 17:05:10 -0700319 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700320 """
321 Add host intents between 2 host:
322 - Discover hosts
323 - Add host intents
324 - Check intents
325 - Verify flows
326 - Ping hosts
327 - Reroute
328 - Link down
329 - Verify flows
330 - Check topology
331 - Ping hosts
332 - Link up
333 - Verify flows
334 - Check topology
335 - Ping hosts
336 - Remove intents
337 """
338 import time
339 import json
340 import re
341
342 # Assert variables - These variable's name|format must be followed
343 # if you want to use the wrapper function
344 assert main, "There is no main"
345 assert main.CLIs, "There is no main.CLIs"
346 assert main.Mininet1, "Mininet handle should be named Mininet1"
347 assert main.numSwitch, "Placed the total number of switch topology in \
348 main.numSwitch"
349
350 main.case( "Add host intents between 2 host" )
351
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700352 main.step( "IPV4: Add host intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700353 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700354 stepResult = main.intentFunction.hostIntent( main,
355 onosNode='0',
356 name='IPV4',
357 host1='h1',
358 host2='h9',
359 host1Id='00:00:00:00:00:01/-1',
360 host2Id='00:00:00:00:00:09/-1',
361 sw1='s5',
362 sw2='s2',
363 expectedLink=18 )
364
365 utilities.assert_equals( expect=main.TRUE,
366 actual=stepResult,
367 onpass="IPV4: Add host intent successful",
368 onfail="IPV4: Add host intent failed" )
369
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700370 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700371 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700372 stepResult = main.intentFunction.hostIntent( main,
373 name='DUALSTACK',
374 host1='h3',
375 host2='h11',
376 host1Id='00:00:00:00:00:03/-1',
377 host2Id='00:00:00:00:00:0B/-1',
378 sw1='s5',
379 sw2='s2',
380 expectedLink=18 )
381
382 utilities.assert_equals( expect=main.TRUE,
383 actual=stepResult,
384 onpass="DUALSTACK1: Add host intent" +
385 " successful",
386 onfail="DUALSTACK1: Add host intent failed" )
387
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700388 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700389 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700390 stepResult = main.intentFunction.hostIntent( main,
391 name='DUALSTACK2',
392 host1='h1',
393 host2='h11',
394 sw1='s5',
395 sw2='s2',
396 expectedLink=18 )
397
398 utilities.assert_equals( expect=main.TRUE,
399 actual=stepResult,
400 onpass="DUALSTACK2: Add host intent" +
401 " successful",
402 onfail="DUALSTACK2: Add host intent failed" )
403
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700404 main.step( "1HOP: Add host intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700405 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700406 stepResult = main.intentFunction.hostIntent( main,
407 name='1HOP',
408 host1='h1',
409 host2='h3' )
410
411 utilities.assert_equals( expect=main.TRUE,
412 actual=stepResult,
413 onpass="1HOP: Add host intent" +
414 " successful",
415 onfail="1HOP: Add host intent failed" )
416
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700417 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700418 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700419 stepResult = main.intentFunction.hostIntent( main,
420 name='VLAN1',
421 host1='h4',
422 host2='h12',
423 host1Id='00:00:00:00:00:04/100',
424 host2Id='00:00:00:00:00:0C/100',
425 sw1='s5',
426 sw2='s2',
427 expectedLink=18 )
428
429 utilities.assert_equals( expect=main.TRUE,
430 actual=stepResult,
431 onpass="VLAN1: Add vlan host" +
432 " intent successful",
433 onfail="VLAN1: Add vlan host intent failed" )
434
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700435 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700436 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700437 stepResult = main.intentFunction.hostIntent( main,
438 name='VLAN2',
439 host1='h13',
440 host2='h20' )
441
442 utilities.assert_equals( expect=main.FALSE,
443 actual=stepResult,
444 onpass="VLAN2: Add inter vlan host" +
445 " intent successful",
446 onfail="VLAN2: Add inter vlan host" +
447 " intent failed" )
448
kelvin-onlabb769f562015-07-15 17:05:10 -0700449 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700450 """
451 Add point intents between 2 hosts:
452 - Get device ids | ports
453 - Add point 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
471
472 # Assert variables - These variable's name|format must be followed
473 # if you want to use the wrapper function
474 assert main, "There is no main"
475 assert main.CLIs, "There is no main.CLIs"
476 assert main.Mininet1, "Mininet handle should be named Mininet1"
477 assert main.numSwitch, "Placed the total number of switch topology in \
478 main.numSwitch"
479
480 main.case( "Add point intents between 2 devices" )
481
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700482 # No option point intents
483 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700484 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700485 stepResult = main.intentFunction.pointIntent(
486 main,
487 name="NOOPTION",
488 host1="h1",
489 host2="h9",
490 deviceId1="of:0000000000000005/1",
491 deviceId2="of:0000000000000006/1",
492 sw1="s5",
493 sw2="s2",
494 expectedLink=18 )
495
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700496 utilities.assert_equals( expect=main.TRUE,
497 actual=stepResult,
498 onpass="NOOPTION: Add point intent successful",
499 onfail="NOOPTION: Add point intent failed" )
500
501 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700502 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700503 stepResult = main.intentFunction.pointIntent(
504 main,
505 name="IPV4",
506 host1="h1",
507 host2="h9",
508 deviceId1="of:0000000000000005/1",
509 deviceId2="of:0000000000000006/1",
510 port1="",
511 port2="",
512 ethType="IPV4",
513 mac1="00:00:00:00:00:01",
514 mac2="00:00:00:00:00:09",
515 bandwidth="",
516 lambdaAlloc=False,
517 ipProto="",
518 ip1="",
519 ip2="",
520 tcp1="",
521 tcp2="",
522 sw1="s5",
523 sw2="s2",
524 expectedLink=18 )
525
526 utilities.assert_equals( expect=main.TRUE,
527 actual=stepResult,
528 onpass="IPV4: Add point intent successful",
529 onfail="IPV4: Add point intent failed" )
530
kelvin-onlabb769f562015-07-15 17:05:10 -0700531 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700532 stepResult = main.TRUE
533 stepResult = main.intentFunction.pointIntent(
534 main,
535 name="IPV4_2",
536 host1="h1",
537 host2="h9",
538 deviceId1="of:0000000000000005/1",
539 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700540 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700541 ip1="",
542 ip2="",
543 tcp1="",
544 tcp2="",
545 sw1="s5",
546 sw2="s2",
547 expectedLink=18 )
548
549 utilities.assert_equals( expect=main.TRUE,
550 actual=stepResult,
551 onpass="IPV4_2: Add point intent successful",
552 onfail="IPV4_2: Add point intent failed" )
553
kelvin-onlabb769f562015-07-15 17:05:10 -0700554 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700555 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700556 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
557 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
558 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
559 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
560 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
561 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
562 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
563
564 stepResult = main.intentFunction.pointIntent(
565 main,
566 name="SDNIP-TCP",
567 host1="h1",
568 host2="h9",
569 deviceId1="of:0000000000000005/1",
570 deviceId2="of:0000000000000006/1",
571 mac1=mac1,
572 mac2=mac2,
573 ethType="IPV4",
574 ipProto=ipProto,
575 ip1=ip1,
576 ip2=ip2,
577 tcp1=tcp1,
578 tcp2=tcp2 )
579
580 utilities.assert_equals( expect=main.TRUE,
581 actual=stepResult,
582 onpass="SDNIP-TCP: Add point intent successful",
583 onfail="SDNIP-TCP: Add point intent failed" )
584
585 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
586 stepResult = main.TRUE
587 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
588 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
589 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
590 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
591 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
592 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
593 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
594
595 stepResult = main.intentFunction.pointIntent(
596 main,
597 name="SDNIP-ICMP",
598 host1="h1",
599 host2="h9",
600 deviceId1="of:0000000000000005/1",
601 deviceId2="of:0000000000000006/1",
602 mac1=mac1,
603 mac2=mac2,
604 ethType="IPV4",
605 ipProto=ipProto )
606
607 utilities.assert_equals( expect=main.TRUE,
608 actual=stepResult,
609 onpass="SDNIP-ICMP: Add point intent successful",
610 onfail="SDNIP-ICMP: Add point intent failed" )
611
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700612 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700613 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700614 stepResult = main.intentFunction.pointIntent(
615 main,
616 name="DUALSTACK1",
617 host1="h3",
618 host2="h11",
619 deviceId1="of:0000000000000005",
620 deviceId2="of:0000000000000006",
621 port1="3",
622 port2="3",
623 ethType="IPV4",
624 mac1="00:00:00:00:00:03",
625 mac2="00:00:00:00:00:0B",
626 bandwidth="",
627 lambdaAlloc=False,
628 ipProto="",
629 ip1="",
630 ip2="",
631 tcp1="",
632 tcp2="",
633 sw1="s5",
634 sw2="s2",
635 expectedLink=18 )
636
637 utilities.assert_equals( expect=main.TRUE,
638 actual=stepResult,
639 onpass="DUALSTACK1: Add point intent" +
640 " successful",
641 onfail="DUALSTACK1: Add point intent failed" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700642
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700643 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700644 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700645 stepResult = main.intentFunction.pointIntent(
646 main,
647 name="VLAN",
648 host1="h5",
649 host2="h21",
650 deviceId1="of:0000000000000005/5",
651 deviceId2="of:0000000000000007/5",
652 port1="",
653 port2="",
654 ethType="IPV4",
655 mac1="00:00:00:00:00:05",
656 mac2="00:00:00:00:00:15",
657 bandwidth="",
658 lambdaAlloc=False,
659 ipProto="",
660 ip1="",
661 ip2="",
662 tcp1="",
663 tcp2="",
664 sw1="s5",
665 sw2="s2",
666 expectedLink=18 )
667
668 utilities.assert_equals( expect=main.TRUE,
669 actual=stepResult,
670 onpass="VLAN: Add point intent successful",
671 onfail="VLAN: Add point intent failed" )
672
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700673 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700674 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700675 stepResult = main.intentFunction.hostIntent( main,
676 name='1HOP',
677 host1='h1',
678 host2='h3' )
679
680 utilities.assert_equals( expect=main.TRUE,
681 actual=stepResult,
682 onpass="1HOP: Add point intent" +
683 " successful",
684 onfail="1HOP: Add point intent failed" )
685
kelvin-onlabb769f562015-07-15 17:05:10 -0700686 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700687 """
688 Add single point to multi point intents
689 - Get device ids
690 - Add single point to multi point intents
691 - Check intents
692 - Verify flows
693 - Ping hosts
694 - Reroute
695 - Link down
696 - Verify flows
697 - Check topology
698 - Ping hosts
699 - Link up
700 - Verify flows
701 - Check topology
702 - Ping hosts
703 - Remove intents
704 """
705 assert main, "There is no main"
706 assert main.CLIs, "There is no main.CLIs"
707 assert main.Mininet1, "Mininet handle should be named Mininet1"
708 assert main.numSwitch, "Placed the total number of switch topology in \
709 main.numSwitch"
710
711 main.case( "Add single point to multi point intents between devices" )
712
kelvin-onlabb769f562015-07-15 17:05:10 -0700713 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700714 stepResult = main.TRUE
715 hostNames = [ 'h8', 'h16', 'h24' ]
716 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
717 'of:0000000000000007/8' ]
718 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700719 stepResult = main.intentFunction.singleToMultiIntent(
720 main,
721 name="NOOPTION",
722 hostNames=hostNames,
723 devices=devices,
724 sw1="s5",
725 sw2="s2",
726 expectedLink=18 )
727
728 utilities.assert_equals( expect=main.TRUE,
729 actual=stepResult,
730 onpass="NOOPTION: Successfully added single "
731 + " point to multi point intents",
732 onfail="NOOPTION: Failed to add single point" +
733 " to multi point intents" )
734
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700735 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700736 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700737 stepResult = main.intentFunction.singleToMultiIntent(
738 main,
739 name="IPV4",
740 hostNames=hostNames,
741 devices=devices,
742 ports=None,
743 ethType="IPV4",
744 macs=macs,
745 bandwidth="",
746 lambdaAlloc=False,
747 ipProto="",
748 ipAddresses="",
749 tcp="",
750 sw1="s5",
751 sw2="s2",
752 expectedLink=18 )
753
754 utilities.assert_equals( expect=main.TRUE,
755 actual=stepResult,
756 onpass="IPV4: Successfully added single point"
757 + " to multi point intents",
758 onfail="IPV4: Failed to add single point" +
759 " to multi point intents" )
760
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700761 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700762 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700763 hostNames = [ 'h8', 'h16', 'h24' ]
764 stepResult = main.intentFunction.singleToMultiIntent(
765 main,
766 name="IPV4",
767 hostNames=hostNames,
768 ethType="IPV4",
769 lambdaAlloc=False )
770
771 utilities.assert_equals( expect=main.TRUE,
772 actual=stepResult,
773 onpass="IPV4_2: Successfully added single "
774 + " point to multi point intents",
775 onfail="IPV4_2: Failed to add single point" +
776 " to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700777
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700778 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700779 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700780 hostNames = [ 'h4', 'h12', 'h20' ]
781 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
782 'of:0000000000000007/4' ]
783 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
784 stepResult = main.intentFunction.singleToMultiIntent(
785 main,
786 name="VLAN",
787 hostNames=hostNames,
788 devices=devices,
789 ports=None,
790 ethType="IPV4",
791 macs=macs,
792 bandwidth="",
793 lambdaAlloc=False,
794 ipProto="",
795 ipAddresses="",
796 tcp="",
797 sw1="s5",
798 sw2="s2",
799 expectedLink=18 )
800
801 utilities.assert_equals( expect=main.TRUE,
802 actual=stepResult,
803 onpass="VLAN: Successfully added single point"
804 + " to multi point intents",
805 onfail="VLAN: Failed to add single point" +
806 " to multi point intents" )
807
kelvin-onlabb769f562015-07-15 17:05:10 -0700808 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700809 """
810 Add multi point to single point intents
811 - Get device ids
812 - Add multi point to single point intents
813 - Check intents
814 - Verify flows
815 - Ping hosts
816 - Reroute
817 - Link down
818 - Verify flows
819 - Check topology
820 - Ping hosts
821 - Link up
822 - Verify flows
823 - Check topology
824 - Ping hosts
825 - Remove intents
826 """
827 assert main, "There is no main"
828 assert main.CLIs, "There is no main.CLIs"
829 assert main.Mininet1, "Mininet handle should be named Mininet1"
830 assert main.numSwitch, "Placed the total number of switch topology in \
831 main.numSwitch"
832
833 main.case( "Add multi point to single point intents between devices" )
834
kelvin-onlabb769f562015-07-15 17:05:10 -0700835 main.step( "NOOPTION: Add multi point to single point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700836 stepResult = main.TRUE
837 hostNames = [ 'h8', 'h16', 'h24' ]
838 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
839 'of:0000000000000007/8' ]
840 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700841 stepResult = main.intentFunction.multiToSingleIntent(
842 main,
843 name="NOOPTION",
844 hostNames=hostNames,
845 devices=devices,
846 sw1="s5",
847 sw2="s2",
848 expectedLink=18 )
849
850 utilities.assert_equals( expect=main.TRUE,
851 actual=stepResult,
852 onpass="NOOPTION: Successfully added multi "
853 + " point to single point intents",
854 onfail="NOOPTION: Failed to add multi point" +
855 " to single point intents" )
856
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700857 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700858 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700859 stepResult = main.intentFunction.multiToSingleIntent(
860 main,
861 name="IPV4",
862 hostNames=hostNames,
863 devices=devices,
864 ports=None,
865 ethType="IPV4",
866 macs=macs,
867 bandwidth="",
868 lambdaAlloc=False,
869 ipProto="",
870 ipAddresses="",
871 tcp="",
872 sw1="s5",
873 sw2="s2",
874 expectedLink=18 )
875
876 utilities.assert_equals( expect=main.TRUE,
877 actual=stepResult,
878 onpass="IPV4: Successfully added multi point"
879 + " to single point intents",
880 onfail="IPV4: Failed to add multi point" +
881 " to single point intents" )
882
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700883 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700884 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700885 hostNames = [ 'h8', 'h16', 'h24' ]
886 stepResult = main.intentFunction.multiToSingleIntent(
887 main,
888 name="IPV4",
889 hostNames=hostNames,
890 ethType="IPV4",
891 lambdaAlloc=False )
892
893 utilities.assert_equals( expect=main.TRUE,
894 actual=stepResult,
895 onpass="IPV4_2: Successfully added multi point"
896 + " to single point intents",
897 onfail="IPV4_2: Failed to add multi point" +
898 " to single point intents" )
899
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700900 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700901 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700902 hostNames = [ 'h5', 'h13', 'h21' ]
903 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
904 'of:0000000000000007/5' ]
905 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
906 stepResult = main.intentFunction.multiToSingleIntent(
907 main,
908 name="VLAN",
909 hostNames=hostNames,
910 devices=devices,
911 ports=None,
912 ethType="IPV4",
913 macs=macs,
914 bandwidth="",
915 lambdaAlloc=False,
916 ipProto="",
917 ipAddresses="",
918 tcp="",
919 sw1="s5",
920 sw2="s2",
921 expectedLink=18 )
922
923 utilities.assert_equals( expect=main.TRUE,
924 actual=stepResult,
925 onpass="VLAN: Successfully added multi point"
926 + " to single point intents",
927 onfail="VLAN: Failed to add multi point" +
928 " to single point intents" )