blob: 0bc5c3ccdc6dc50f83808f9f7b4440d086eafcad [file] [log] [blame]
kelvin-onlab44147802015-07-27 17:57:31 -07001
2# Testing the basic intent functionality of ONOS
3
4import time
5import json
6
7class FUNCintentRest:
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 main.caseExplanation = "This test case is mainly for loading " +\
30 "from params file, and pull and build the " +\
31 " latest ONOS package"
32 stepResult = main.FALSE
33
34 # Test variables
35 try:
36 main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
37 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
38 gitBranch = main.params[ 'GIT' ][ 'branch' ]
39 main.dependencyPath = main.testOnDirectory + \
40 main.params[ 'DEPENDENCY' ][ 'path' ]
41 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
42 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
43 if main.ONOSbench.maxNodes:
44 main.maxNodes = int( main.ONOSbench.maxNodes )
45 else:
46 main.maxNodes = 0
47 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
48 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
49 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
50 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
51 main.checkIntentSleep = int( main.params[ 'SLEEP' ]\
52 [ 'checkintent' ] )
53 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
54 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
kelvin-onlab0e684682015-08-11 18:51:41 -070055 main.addIntentSleep = int( main.params[ 'SLEEP' ][ 'addIntent' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070056 gitPull = main.params[ 'GIT' ][ 'pull' ]
57 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
58 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
59 main.cellData = {} # for creating cell file
60 main.hostsData = {}
61 main.CLIs = []
62 main.ONOSip = []
63
64 main.ONOSip = main.ONOSbench.getOnosIps()
65
66 # Assigning ONOS cli handles to a list
67 for i in range( 1, main.maxNodes + 1 ):
68 main.CLIs.append( getattr( main, 'ONOSrest' + str( i ) ) )
69
70 # -- INIT SECTION, ONLY RUNS ONCE -- #
71 main.startUp = imp.load_source( wrapperFile1,
72 main.dependencyPath +
73 wrapperFile1 +
74 ".py" )
75
76 main.intentFunction = imp.load_source( wrapperFile2,
77 main.dependencyPath +
78 wrapperFile2 +
79 ".py" )
80
81 main.topo = imp.load_source( wrapperFile3,
82 main.dependencyPath +
83 wrapperFile3 +
84 ".py" )
85
86 copyResult = main.ONOSbench.copyMininetFile( main.topology,
87 main.dependencyPath,
88 main.Mininet1.user_name,
89 main.Mininet1.ip_address )
90 if main.CLIs:
91 stepResult = main.TRUE
92 else:
93 main.log.error( "Did not properly created list of ONOS CLI handle" )
94 stepResult = main.FALSE
95 except Exception as e:
96 main.log.exception(e)
97 main.cleanup()
98 main.exit()
99
100 utilities.assert_equals( expect=main.TRUE,
101 actual=stepResult,
102 onpass="Successfully construct " +
103 "test variables ",
104 onfail="Failed to construct test variables" )
105
106 if gitPull == 'True':
107 main.step( "Building ONOS in " + gitBranch + " branch" )
108 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
109 stepResult = onosBuildResult
110 utilities.assert_equals( expect=main.TRUE,
111 actual=stepResult,
112 onpass="Successfully compiled " +
113 "latest ONOS",
114 onfail="Failed to compile " +
115 "latest ONOS" )
116 else:
117 main.log.warn( "Did not pull new code so skipping mvn " +
118 "clean install" )
119 main.ONOSbench.getVersion( report=True )
120
121 def CASE2( self, main ):
122 """
123 - Set up cell
124 - Create cell file
125 - Set cell file
126 - Verify cell file
127 - Kill ONOS process
128 - Uninstall ONOS cluster
129 - Verify ONOS start up
130 - Install ONOS cluster
131 - Connect to cli
132 """
133
134 # main.scale[ 0 ] determines the current number of ONOS controller
135 main.numCtrls = int( main.scale[ 0 ] )
136
137 main.case( "Starting up " + str( main.numCtrls ) +
138 " node(s) ONOS cluster" )
139 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
140 " node(s) ONOS cluster"
141
142
143
144 #kill off all onos processes
145 main.log.info( "Safety check, killing all ONOS processes" +
146 " before initiating enviornment setup" )
147
148 for i in range( main.maxNodes ):
149 main.ONOSbench.onosDie( main.ONOSip[ i ] )
150
151 print "NODE COUNT = ", main.numCtrls
152
153 tempOnosIp = []
154 for i in range( main.numCtrls ):
155 tempOnosIp.append( main.ONOSip[i] )
156
157 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
158 "temp", main.Mininet1.ip_address,
159 main.apps, tempOnosIp )
160
161 main.step( "Apply cell to environment" )
162 cellResult = main.ONOSbench.setCell( "temp" )
163 verifyResult = main.ONOSbench.verifyCell()
164 stepResult = cellResult and verifyResult
165 utilities.assert_equals( expect=main.TRUE,
166 actual=stepResult,
167 onpass="Successfully applied cell to " + \
168 "environment",
169 onfail="Failed to apply cell to environment " )
170
171 main.step( "Creating ONOS package" )
172 packageResult = main.ONOSbench.onosPackage()
173 stepResult = packageResult
174 utilities.assert_equals( expect=main.TRUE,
175 actual=stepResult,
176 onpass="Successfully created ONOS package",
177 onfail="Failed to create ONOS package" )
178
179 time.sleep( main.startUpSleep )
180 main.step( "Uninstalling ONOS package" )
181 onosUninstallResult = main.TRUE
182 for i in range( main.numCtrls ):
183 onosUninstallResult = onosUninstallResult and \
184 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
185 stepResult = onosUninstallResult
186 utilities.assert_equals( expect=main.TRUE,
187 actual=stepResult,
188 onpass="Successfully uninstalled ONOS package",
189 onfail="Failed to uninstall ONOS package" )
190
191 time.sleep( main.startUpSleep )
192 main.step( "Installing ONOS package" )
193 onosInstallResult = main.TRUE
194 for i in range( main.numCtrls ):
195 onosInstallResult = onosInstallResult and \
196 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
197 stepResult = onosInstallResult
198 utilities.assert_equals( expect=main.TRUE,
199 actual=stepResult,
200 onpass="Successfully installed ONOS package",
201 onfail="Failed to install ONOS package" )
202
203 time.sleep( main.startUpSleep )
204 main.step( "Starting ONOS service" )
205 stopResult = main.TRUE
206 startResult = main.TRUE
207 onosIsUp = main.TRUE
208
209 for i in range( main.numCtrls ):
210 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
211 if onosIsUp == main.TRUE:
212 main.log.report( "ONOS instance is up and ready" )
213 else:
214 main.log.report( "ONOS instance may not be up, stop and " +
215 "start ONOS again " )
216 for i in range( main.numCtrls ):
217 stopResult = stopResult and \
218 main.ONOSbench.onosStop( main.ONOSip[ i ] )
219 for i in range( main.numCtrls ):
220 startResult = startResult and \
221 main.ONOSbench.onosStart( main.ONOSip[ i ] )
222 stepResult = onosIsUp and stopResult and startResult
223 utilities.assert_equals( expect=main.TRUE,
224 actual=stepResult,
225 onpass="ONOS service is ready",
226 onfail="ONOS service did not start properly" )
227
228 # Remove the first element in main.scale list
229 main.scale.remove( main.scale[ 0 ] )
230
231 def CASE8( self, main ):
232 """
233 Compare Topo
234 """
235 import json
236
237 main.case( "Compare ONOS Topology view to Mininet topology" )
238 main.caseExplanation = "Compare topology elements between Mininet" +\
239 " and ONOS"
240
241 main.step( "Gathering topology information" )
242 # TODO: add a paramaterized sleep here
243 devicesResults = main.TRUE
244 linksResults = main.TRUE
245 hostsResults = main.TRUE
246 devices = main.topo.getAllDevices( main )
247 hosts = main.topo.getAllHosts( main )
248 ports = main.topo.getAllPorts( main )
249 links = main.topo.getAllLinks( main )
250 clusters = main.topo.getAllClusters( main )
251
252 mnSwitches = main.Mininet1.getSwitches()
253 mnLinks = main.Mininet1.getLinks()
254 mnHosts = main.Mininet1.getHosts()
255
256 main.step( "Conmparing MN topology to ONOS topology" )
257 for controller in range( main.numCtrls ):
258 controllerStr = str( controller + 1 )
259 if devices[ controller ] and ports[ controller ] and\
260 "Error" not in devices[ controller ] and\
261 "Error" not in ports[ controller ]:
262
263 currentDevicesResult = main.Mininet1.compareSwitches(
264 mnSwitches,
265 json.loads( devices[ controller ] ),
266 json.loads( ports[ controller ] ) )
267 else:
268 currentDevicesResult = main.FALSE
269 utilities.assert_equals( expect=main.TRUE,
270 actual=currentDevicesResult,
271 onpass="ONOS" + controllerStr +
272 " Switches view is correct",
273 onfail="ONOS" + controllerStr +
274 " Switches view is incorrect" )
275
276 if links[ controller ] and "Error" not in links[ controller ]:
277 currentLinksResult = main.Mininet1.compareLinks(
278 mnSwitches, mnLinks,
279 json.loads( links[ controller ] ) )
280 else:
281 currentLinksResult = main.FALSE
282 utilities.assert_equals( expect=main.TRUE,
283 actual=currentLinksResult,
284 onpass="ONOS" + controllerStr +
285 " links view is correct",
286 onfail="ONOS" + controllerStr +
287 " links view is incorrect" )
288
289 if hosts[ controller ] or "Error" not in hosts[ controller ]:
290 currentHostsResult = main.Mininet1.compareHosts(
291 mnHosts,
292 json.loads( hosts[ controller ] ) )
293 else:
294 currentHostsResult = main.FALSE
295 utilities.assert_equals( expect=main.TRUE,
296 actual=currentHostsResult,
297 onpass="ONOS" + controllerStr +
298 " hosts exist in Mininet",
299 onfail="ONOS" + controllerStr +
300 " hosts don't match Mininet" )
301
302 def CASE9( self, main ):
303 '''
304 Report errors/warnings/exceptions
305 '''
306 main.log.info( "Error report: \n" )
307 main.ONOSbench.logReport( globalONOSip[0],
308 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
309 "s" )
310 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
311
312 def CASE10( self, main ):
313 """
314 Start Mininet topology with OF 1.0 switches
315 """
316 main.OFProtocol = "1.0"
317 main.log.report( "Start Mininet topology with OF 1.0 switches" )
318 main.case( "Start Mininet topology with OF 1.0 switches" )
319 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
320 "switches to test intents, exits out if " +\
321 "topology did not start correctly"
322
323 main.step( "Starting Mininet topology with OF 1.0 switches" )
324 args = "--switch ovs,protocols=OpenFlow10"
325 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
326 main.topology,
327 args=args )
328 stepResult = topoResult
329 utilities.assert_equals( expect=main.TRUE,
330 actual=stepResult,
331 onpass="Successfully loaded topology",
332 onfail="Failed to load topology" )
333 # Exit if topology did not load properly
334 if not topoResult:
335 main.cleanup()
336 main.exit()
337
338 def CASE11( self, main ):
339 """
340 Start Mininet topology with OF 1.3 switches
341 """
342 main.OFProtocol = "1.3"
343 main.log.report( "Start Mininet topology with OF 1.3 switches" )
344 main.case( "Start Mininet topology with OF 1.3 switches" )
345 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
346 "switches to test intents, exits out if " +\
347 "topology did not start correctly"
348
349 main.step( "Starting Mininet topology with OF 1.3 switches" )
350 args = "--switch ovs,protocols=OpenFlow13"
351 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
352 main.topology,
353 args=args )
354 stepResult = topoResult
355 utilities.assert_equals( expect=main.TRUE,
356 actual=stepResult,
357 onpass="Successfully loaded topology",
358 onfail="Failed to load topology" )
359 # Exit if topology did not load properly
360 if not topoResult:
361 main.cleanup()
362 main.exit()
363
364 def CASE12( self, main ):
365 """
366 Assign mastership to controllers
367 """
368 import re
369
370 main.case( "Assign switches to controllers" )
371 main.step( "Assigning switches to controllers" )
372 main.caseExplanation = "Assign OF " + main.OFProtocol +\
373 " switches to ONOS nodes"
374
375 assignResult = main.TRUE
376 switchList = []
377
378 # Creates a list switch name, use getSwitch() function later...
379 for i in range( 1, ( main.numSwitch + 1 ) ):
380 switchList.append( 's' + str( i ) )
381
382 tempONOSip = []
383 for i in range( main.numCtrls ):
384 tempONOSip.append( main.ONOSip[ i ] )
385
386 assignResult = main.Mininet1.assignSwController( sw=switchList,
387 ip=tempONOSip,
388 port='6633' )
389 if not assignResult:
390 main.cleanup()
391 main.exit()
392
393 for i in range( 1, ( main.numSwitch + 1 ) ):
394 response = main.Mininet1.getSwController( "s" + str( i ) )
395 print( "Response is " + str( response ) )
396 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
397 assignResult = assignResult and main.TRUE
398 else:
399 assignResult = main.FALSE
400 stepResult = assignResult
401 utilities.assert_equals( expect=main.TRUE,
402 actual=stepResult,
403 onpass="Successfully assigned switches" +
404 "to controller",
405 onfail="Failed to assign switches to " +
406 "controller" )
407 def CASE13( self, main ):
408 """
409 Discover all hosts and store its data to a dictionary
410 """
411 main.case( "Discover all hosts" )
412
413 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700414 main.step( "Discover all ipv4 host hosts " )
415 hostList = []
416 # List of host with default vlan
417 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
418 # Lists of host with unique vlan
419 vlanHosts1 = [ "h4", "h12", "h20" ]
420 vlanHosts2 = [ "h5", "h13", "h21" ]
421 vlanHosts3 = [ "h6", "h14", "h22" ]
422 vlanHosts4 = [ "h7", "h15", "h23" ]
423 hostList.append( defaultHosts )
424 hostList.append( vlanHosts1 )
425 hostList.append( vlanHosts2 )
426 hostList.append( vlanHosts3 )
427 hostList.append( vlanHosts4 )
428
429 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700430 utilities.assert_equals( expect=main.TRUE,
431 actual=stepResult,
432 onpass="Successfully discovered hosts",
433 onfail="Failed to discover hosts" )
434
435 def CASE14( self, main ):
436 """
437 Stop mininet
438 """
439 main.log.report( "Stop Mininet topology" )
440 main.case( "Stop Mininet topology" )
441 main.caseExplanation = "Stopping the current mininet topology " +\
442 "to start up fresh"
443
444 main.step( "Stopping Mininet Topology" )
445 topoResult = main.Mininet1.stopNet( )
446 stepResult = topoResult
447 utilities.assert_equals( expect=main.TRUE,
448 actual=stepResult,
449 onpass="Successfully stop mininet",
450 onfail="Failed to stop mininet" )
451 # Exit if topology did not load properly
452 if not topoResult:
453 main.cleanup()
454 main.exit()
455
456 def CASE1000( self, main ):
457 """
458 Add host intents between 2 host:
459 - Discover hosts
460 - Add host intents
461 - Check intents
462 - Verify flows
463 - Ping hosts
464 - Reroute
465 - Link down
466 - Verify flows
467 - Check topology
468 - Ping hosts
469 - Link up
470 - Verify flows
471 - Check topology
472 - Ping hosts
473 - Remove intents
474 """
475 import time
476 import json
477 import re
478
479 # Assert variables - These variable's name|format must be followed
480 # if you want to use the wrapper function
481 assert main, "There is no main"
482 assert main.CLIs, "There is no main.CLIs"
483 assert main.Mininet1, "Mininet handle should be named Mininet1"
484 assert main.numSwitch, "Placed the total number of switch topology in \
485 main.numSwitch"
486
487 main.case( "Host Intents Test - " + str( main.numCtrls ) +
488 " NODE(S) - OF " + main.OFProtocol )
489 main.caseExplanation = "This test case tests Host intents using " +\
490 str( main.numCtrls ) + " node(s) cluster;\n" +\
491 "Different type of hosts will be tested in " +\
492 "each step such as IPV4, Dual stack, VLAN " +\
493 "etc;\nThe test will use OF " + main.OFProtocol\
494 + " OVS running in Mininet"
495
496 main.step( "IPV4: Add host intents between h1 and h9" )
497 stepResult = main.TRUE
498 stepResult = main.intentFunction.hostIntent( main,
499 onosNode='0',
500 name='IPV4',
501 host1='h1',
502 host2='h9',
503 host1Id='00:00:00:00:00:01/-1',
504 host2Id='00:00:00:00:00:09/-1',
505 sw1='s5',
506 sw2='s2',
507 expectedLink=18 )
508
509 utilities.assert_equals( expect=main.TRUE,
510 actual=stepResult,
511 onpass="IPV4: Host intent test successful " +
512 "between two IPV4 hosts",
513 onfail="IPV4: Host intent test failed " +
514 "between two IPV4 hosts")
515
516 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
517 stepResult = main.TRUE
518 stepResult = main.intentFunction.hostIntent( main,
519 name='DUALSTACK',
520 host1='h3',
521 host2='h11',
522 host1Id='00:00:00:00:00:03/-1',
523 host2Id='00:00:00:00:00:0B/-1',
524 sw1='s5',
525 sw2='s2',
526 expectedLink=18 )
527
528 utilities.assert_equals( expect=main.TRUE,
529 actual=stepResult,
530 onpass="DUALSTACK: Host intent test " +
531 "successful between two " +
532 "dual stack host using IPV4",
533 onfail="DUALSTACK: Host intent test " +
534 "failed between two" +
535 "dual stack host using IPV4" )
536
537
538 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
539 stepResult = main.TRUE
540 stepResult = main.intentFunction.hostIntent( main,
541 name='DUALSTACK2',
542 host1='h1',
543 host2='h11',
544 sw1='s5',
545 sw2='s2',
546 expectedLink=18 )
547
548 utilities.assert_equals( expect=main.TRUE,
549 actual=stepResult,
550 onpass="DUALSTACK2: Host intent test " +
551 "successful between two " +
552 "dual stack host using IPV4",
553 onfail="DUALSTACK2: Host intent test " +
554 "failed between two" +
555 "dual stack host using IPV4" )
556
557 main.step( "1HOP: Add host intents between h1 and h3" )
558 stepResult = main.TRUE
559 stepResult = main.intentFunction.hostIntent( main,
560 name='1HOP',
561 host1='h1',
562 host2='h3' )
563
564 utilities.assert_equals( expect=main.TRUE,
565 actual=stepResult,
566 onpass="1HOP: Host intent test " +
567 "successful between two " +
568 "host using IPV4 in the same switch",
569 onfail="1HOP: Host intent test " +
570 "failed between two" +
571 "host using IPV4 in the same switch" )
572
573 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
574 stepResult = main.TRUE
575 stepResult = main.intentFunction.hostIntent( main,
576 name='VLAN1',
577 host1='h4',
578 host2='h12',
579 host1Id='00:00:00:00:00:04/100',
580 host2Id='00:00:00:00:00:0C/100',
581 sw1='s5',
582 sw2='s2',
583 expectedLink=18 )
584
585 utilities.assert_equals( expect=main.TRUE,
586 actual=stepResult,
587 onpass="VLAN1: Host intent test " +
588 "successful between two " +
589 "host using IPV4 in the same VLAN",
590 onfail="VLAN1: Host intent test " +
591 "failed between two" +
592 "host using IPV4 in the same VLAN" )
593
594 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
595 stepResult = main.TRUE
596 stepResult = main.intentFunction.hostIntent( main,
597 name='VLAN2',
598 host1='h13',
599 host2='h20' )
600
601 utilities.assert_equals( expect=main.FALSE,
602 actual=stepResult,
603 onpass="VLAN2: Host intent negative test " +
604 "successful between two " +
605 "host using IPV4 in different VLAN",
606 onfail="VLAN2: Host intent negative test " +
607 "failed between two" +
608 "host using IPV4 in different VLAN" )
609
610
611 def CASE2000( self, main ):
612 """
613 Add point intents between 2 hosts:
614 - Get device ids | ports
615 - Add point intents
616 - Check intents
617 - Verify flows
618 - Ping hosts
619 - Reroute
620 - Link down
621 - Verify flows
622 - Check topology
623 - Ping hosts
624 - Link up
625 - Verify flows
626 - Check topology
627 - Ping hosts
628 - Remove intents
629 """
630 import time
631 import json
632 import re
633
634 # Assert variables - These variable's name|format must be followed
635 # if you want to use the wrapper function
636 assert main, "There is no main"
637 assert main.CLIs, "There is no main.CLIs"
638 assert main.Mininet1, "Mininet handle should be named Mininet1"
639 assert main.numSwitch, "Placed the total number of switch topology in \
640 main.numSwitch"
641
642 main.case( "Point Intents Test - " + str( main.numCtrls ) +
643 " NODE(S) - OF " + main.OFProtocol )
644 main.caseExplanation = "This test case will test point to point" +\
645 " intents using " + str( main.numCtrls ) +\
646 " node(s) cluster;\n" +\
647 "Different type of hosts will be tested in " +\
648 "each step such as IPV4, Dual stack, VLAN etc" +\
649 ";\nThe test will use OF " + main.OFProtocol +\
650 " OVS running in Mininet"
651
652 # No option point intents
653 main.step( "NOOPTION: Add point intents between h1 and h9" )
654 stepResult = main.TRUE
655 stepResult = main.intentFunction.pointIntent(
656 main,
657 name="NOOPTION",
658 host1="h1",
659 host2="h9",
660 deviceId1="of:0000000000000005/1",
661 deviceId2="of:0000000000000006/1",
662 sw1="s5",
663 sw2="s2",
664 expectedLink=18 )
665
666 utilities.assert_equals( expect=main.TRUE,
667 actual=stepResult,
668 onpass="NOOPTION: Point intent test " +
669 "successful using no match action",
670 onfail="NOOPTION: Point intent test " +
671 "failed using no match action" )
672
673 stepResult = main.TRUE
674 main.step( "IPV4: Add point intents between h1 and h9" )
675 stepResult = main.intentFunction.pointIntent(
676 main,
677 name="IPV4",
678 host1="h1",
679 host2="h9",
680 deviceId1="of:0000000000000005/1",
681 deviceId2="of:0000000000000006/1",
682 port1="",
683 port2="",
684 ethType="IPV4",
685 mac1="00:00:00:00:00:01",
686 mac2="00:00:00:00:00:09",
687 bandwidth="",
688 lambdaAlloc=False,
689 ipProto="",
690 ip1="",
691 ip2="",
692 tcp1="",
693 tcp2="",
694 sw1="s5",
695 sw2="s2",
696 expectedLink=18 )
697
698 utilities.assert_equals( expect=main.TRUE,
699 actual=stepResult,
700 onpass="IPV4: Point intent test " +
701 "successful using IPV4 type with " +
702 "MAC addresses",
703 onfail="IPV4: Point intent test " +
704 "failed using IPV4 type with " +
705 "MAC addresses" )
706 main.step( "IPV4_2: Add point intents between h1 and h9" )
707 stepResult = main.TRUE
708 stepResult = main.intentFunction.pointIntent(
709 main,
710 name="IPV4_2",
711 host1="h1",
712 host2="h9",
713 deviceId1="of:0000000000000005/1",
714 deviceId2="of:0000000000000006/1",
715 ipProto="",
716 ip1="",
717 ip2="",
718 tcp1="",
719 tcp2="",
720 sw1="s5",
721 sw2="s2",
722 expectedLink=18 )
723
724 utilities.assert_equals( expect=main.TRUE,
725 actual=stepResult,
726 onpass="IPV4_2: Point intent test " +
727 "successful using IPV4 type with " +
728 "no MAC addresses",
729 onfail="IPV4_2: Point intent test " +
730 "failed using IPV4 type with " +
731 "no MAC addresses" )
732
kelvin-onlab0e684682015-08-11 18:51:41 -0700733 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
kelvin-onlab44147802015-07-27 17:57:31 -0700734 stepResult = main.TRUE
735 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
736 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
737 try:
kelvin-onlab0e684682015-08-11 18:51:41 -0700738 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
739 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlab44147802015-07-27 17:57:31 -0700740 except KeyError:
741 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
742 "main.hostsData" )
743 ip1 = main.Mininet1.getIPAddress( 'h1')
744 ip2 = main.Mininet1.getIPAddress( 'h9')
745
746 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
747 # Uneccessary, not including this in the selectors
748 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
749 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
750
751 stepResult = main.intentFunction.pointIntent(
752 main,
kelvin-onlab0e684682015-08-11 18:51:41 -0700753 name="SDNIP-ICMP",
kelvin-onlab44147802015-07-27 17:57:31 -0700754 host1="h1",
755 host2="h9",
756 deviceId1="of:0000000000000005/1",
757 deviceId2="of:0000000000000006/1",
758 mac1=mac1,
759 mac2=mac2,
760 ethType="IPV4",
761 ipProto=ipProto,
762 ip1=ip1,
763 ip2=ip2 )
764
765 utilities.assert_equals( expect=main.TRUE,
766 actual=stepResult,
kelvin-onlab0e684682015-08-11 18:51:41 -0700767 onpass="SDNIP-ICMP: Point intent test " +
kelvin-onlab44147802015-07-27 17:57:31 -0700768 "successful using IPV4 type with " +
769 "IP protocol TCP enabled",
kelvin-onlab0e684682015-08-11 18:51:41 -0700770 onfail="SDNIP-ICMP: Point intent test " +
kelvin-onlab44147802015-07-27 17:57:31 -0700771 "failed using IPV4 type with " +
772 "IP protocol TCP enabled" )
773
kelvin-onlab0e684682015-08-11 18:51:41 -0700774 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlab44147802015-07-27 17:57:31 -0700775 stepResult = main.TRUE
776 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
777 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0e684682015-08-11 18:51:41 -0700778 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
779 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlab44147802015-07-27 17:57:31 -0700780 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
781 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
782 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
783
kelvin-onlab0e684682015-08-11 18:51:41 -0700784 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlab44147802015-07-27 17:57:31 -0700785 main,
kelvin-onlab0e684682015-08-11 18:51:41 -0700786 name="SDNIP-TCP",
kelvin-onlab44147802015-07-27 17:57:31 -0700787 host1="h1",
788 host2="h9",
789 deviceId1="of:0000000000000005/1",
790 deviceId2="of:0000000000000006/1",
791 mac1=mac1,
792 mac2=mac2,
793 ethType="IPV4",
kelvin-onlab0e684682015-08-11 18:51:41 -0700794 ipProto=ipProto,
795 ip1=ip1,
796 ip2=ip2,
797 tcp1=tcp1,
798 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700799
800 utilities.assert_equals( expect=main.TRUE,
801 actual=stepResult,
kelvin-onlab0e684682015-08-11 18:51:41 -0700802 onpass="SDNIP-TCP: Point intent test " +
kelvin-onlab44147802015-07-27 17:57:31 -0700803 "successful using IPV4 type with " +
kelvin-onlab0e684682015-08-11 18:51:41 -0700804 "IP protocol TCP enabled",
805 onfail="SDNIP-TCP: Point intent test " +
kelvin-onlab44147802015-07-27 17:57:31 -0700806 "failed using IPV4 type with " +
kelvin-onlab0e684682015-08-11 18:51:41 -0700807 "IP protocol TCP enabled" )
kelvin-onlab44147802015-07-27 17:57:31 -0700808
809 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
810 stepResult = main.TRUE
811 stepResult = main.intentFunction.pointIntent(
812 main,
813 name="DUALSTACK1",
814 host1="h3",
815 host2="h11",
816 deviceId1="of:0000000000000005",
817 deviceId2="of:0000000000000006",
818 port1="3",
819 port2="3",
820 ethType="IPV4",
821 mac1="00:00:00:00:00:03",
822 mac2="00:00:00:00:00:0B",
823 bandwidth="",
824 lambdaAlloc=False,
825 ipProto="",
826 ip1="",
827 ip2="",
828 tcp1="",
829 tcp2="",
830 sw1="s5",
831 sw2="s2",
832 expectedLink=18 )
833
834 utilities.assert_equals( expect=main.TRUE,
835 actual=stepResult,
836 onpass="DUALSTACK1: Point intent test " +
837 "successful using IPV4 type with " +
838 "MAC addresses",
839 onfail="DUALSTACK1: Point intent test " +
840 "failed using IPV4 type with " +
841 "MAC addresses" )
842
843 main.step( "VLAN: Add point intents between h5 and h21" )
844 stepResult = main.TRUE
845 stepResult = main.intentFunction.pointIntent(
846 main,
847 name="VLAN",
848 host1="h5",
849 host2="h21",
850 deviceId1="of:0000000000000005/5",
851 deviceId2="of:0000000000000007/5",
852 port1="",
853 port2="",
854 ethType="IPV4",
855 mac1="00:00:00:00:00:05",
856 mac2="00:00:00:00:00:15",
857 bandwidth="",
858 lambdaAlloc=False,
859 ipProto="",
860 ip1="",
861 ip2="",
862 tcp1="",
863 tcp2="",
864 sw1="s5",
865 sw2="s2",
866 expectedLink=18 )
867
868 utilities.assert_equals( expect=main.TRUE,
869 actual=stepResult,
870 onpass="VLAN1: Point intent test " +
871 "successful using IPV4 type with " +
872 "MAC addresses",
873 onfail="VLAN1: Point intent test " +
874 "failed using IPV4 type with " +
875 "MAC addresses" )
876
877 main.step( "1HOP: Add point intents between h1 and h3" )
878 stepResult = main.TRUE
879 stepResult = main.intentFunction.hostIntent( main,
880 name='1HOP',
881 host1='h1',
882 host2='h3' )
883
884 utilities.assert_equals( expect=main.TRUE,
885 actual=stepResult,
886 onpass="1HOP: Point intent test " +
887 "successful using IPV4 type with " +
888 "no MAC addresses",
889 onfail="1HOP: Point intent test " +
890 "failed using IPV4 type with " +
891 "no MAC addresses" )
892
893 def CASE3000( self, main ):
894 """
895 Add single point to multi point intents
896 - Get device ids
897 - Add single point to multi point intents
898 - Check intents
899 - Verify flows
900 - Ping hosts
901 - Reroute
902 - Link down
903 - Verify flows
904 - Check topology
905 - Ping hosts
906 - Link up
907 - Verify flows
908 - Check topology
909 - Ping hosts
910 - Remove intents
911 """
912 assert main, "There is no main"
913 assert main.CLIs, "There is no main.CLIs"
914 assert main.Mininet1, "Mininet handle should be named Mininet1"
915 assert main.numSwitch, "Placed the total number of switch topology in \
916 main.numSwitch"
917
918 main.case( "Single To Multi Point Intents Test - " +
919 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
920 main.caseExplanation = "This test case will test single point to" +\
921 " multi point intents using " +\
922 str( main.numCtrls ) + " node(s) cluster;\n" +\
923 "Different type of hosts will be tested in " +\
924 "each step such as IPV4, Dual stack, VLAN etc" +\
925 ";\nThe test will use OF " + main.OFProtocol +\
926 " OVS running in Mininet"
927
928 main.step( "NOOPTION: Add single point to multi point intents" )
929 stepResult = main.TRUE
930 hostNames = [ 'h8', 'h16', 'h24' ]
931 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
932 'of:0000000000000007/8' ]
933 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
934 stepResult = main.intentFunction.singleToMultiIntent(
935 main,
936 name="NOOPTION",
937 hostNames=hostNames,
938 devices=devices,
939 sw1="s5",
940 sw2="s2",
941 expectedLink=18 )
942
943 utilities.assert_equals( expect=main.TRUE,
944 actual=stepResult,
945 onpass="NOOPTION: Successfully added single "
946 + " point to multi point intents" +
947 " with no match action",
948 onfail="NOOPTION: Failed to add single point"
949 + " point to multi point intents" +
950 " with no match action" )
951
952 main.step( "IPV4: Add single point to multi point intents" )
953 stepResult = main.TRUE
954 stepResult = main.intentFunction.singleToMultiIntent(
955 main,
956 name="IPV4",
957 hostNames=hostNames,
958 devices=devices,
959 ports=None,
960 ethType="IPV4",
961 macs=macs,
962 bandwidth="",
963 lambdaAlloc=False,
964 ipProto="",
965 ipAddresses="",
966 tcp="",
967 sw1="s5",
968 sw2="s2",
969 expectedLink=18 )
970
971 utilities.assert_equals( expect=main.TRUE,
972 actual=stepResult,
973 onpass="IPV4: Successfully added single "
974 + " point to multi point intents" +
975 " with IPV4 type and MAC addresses",
976 onfail="IPV4: Failed to add single point"
977 + " point to multi point intents" +
978 " with IPV4 type and MAC addresses" )
979
980 main.step( "IPV4_2: Add single point to multi point intents" )
981 stepResult = main.TRUE
982 hostNames = [ 'h8', 'h16', 'h24' ]
983 stepResult = main.intentFunction.singleToMultiIntent(
984 main,
985 name="IPV4",
986 hostNames=hostNames,
987 ethType="IPV4",
988 lambdaAlloc=False )
989
990 utilities.assert_equals( expect=main.TRUE,
991 actual=stepResult,
992 onpass="IPV4_2: Successfully added single "
993 + " point to multi point intents" +
994 " with IPV4 type and no MAC addresses",
995 onfail="IPV4_2: Failed to add single point"
996 + " point to multi point intents" +
997 " with IPV4 type and no MAC addresses" )
998
999 main.step( "VLAN: Add single point to multi point intents" )
1000 stepResult = main.TRUE
1001 hostNames = [ 'h4', 'h12', 'h20' ]
1002 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1003 'of:0000000000000007/4' ]
1004 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1005 stepResult = main.intentFunction.singleToMultiIntent(
1006 main,
1007 name="VLAN",
1008 hostNames=hostNames,
1009 devices=devices,
1010 ports=None,
1011 ethType="IPV4",
1012 macs=macs,
1013 bandwidth="",
1014 lambdaAlloc=False,
1015 ipProto="",
1016 ipAddresses="",
1017 tcp="",
1018 sw1="s5",
1019 sw2="s2",
1020 expectedLink=18 )
1021
1022 utilities.assert_equals( expect=main.TRUE,
1023 actual=stepResult,
1024 onpass="VLAN: Successfully added single "
1025 + " point to multi point intents" +
1026 " with IPV4 type and MAC addresses" +
1027 " in the same VLAN",
1028 onfail="VLAN: Failed to add single point"
1029 + " point to multi point intents" +
1030 " with IPV4 type and MAC addresses" +
1031 " in the same VLAN")
1032
1033 def CASE4000( self, main ):
1034 """
1035 Add multi point to single point intents
1036 - Get device ids
1037 - Add multi point to single point intents
1038 - Check intents
1039 - Verify flows
1040 - Ping hosts
1041 - Reroute
1042 - Link down
1043 - Verify flows
1044 - Check topology
1045 - Ping hosts
1046 - Link up
1047 - Verify flows
1048 - Check topology
1049 - Ping hosts
1050 - Remove intents
1051 """
1052 assert main, "There is no main"
1053 assert main.CLIs, "There is no main.CLIs"
1054 assert main.Mininet1, "Mininet handle should be named Mininet1"
1055 assert main.numSwitch, "Placed the total number of switch topology in \
1056 main.numSwitch"
1057
1058 main.case( "Multi To Single Point Intents Test - " +
1059 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
1060 main.caseExplanation = "This test case will test single point to" +\
1061 " multi point intents using " +\
1062 str( main.numCtrls ) + " node(s) cluster;\n" +\
1063 "Different type of hosts will be tested in " +\
1064 "each step such as IPV4, Dual stack, VLAN etc" +\
1065 ";\nThe test will use OF " + main.OFProtocol +\
1066 " OVS running in Mininet"
1067
1068 main.step( "NOOPTION: Add multi point to single point intents" )
1069 stepResult = main.TRUE
1070 hostNames = [ 'h8', 'h16', 'h24' ]
1071 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1072 'of:0000000000000007/8' ]
1073 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1074 stepResult = main.intentFunction.multiToSingleIntent(
1075 main,
1076 name="NOOPTION",
1077 hostNames=hostNames,
1078 devices=devices,
1079 sw1="s5",
1080 sw2="s2",
1081 expectedLink=18 )
1082
1083 utilities.assert_equals( expect=main.TRUE,
1084 actual=stepResult,
1085 onpass="NOOPTION: Successfully added multi "
1086 + " point to single point intents" +
1087 " with no match action",
1088 onfail="NOOPTION: Failed to add multi point" +
1089 " to single point intents" +
1090 " with no match action" )
1091
1092 main.step( "IPV4: Add multi point to single point intents" )
1093 stepResult = main.TRUE
1094 stepResult = main.intentFunction.multiToSingleIntent(
1095 main,
1096 name="IPV4",
1097 hostNames=hostNames,
1098 devices=devices,
1099 ports=None,
1100 ethType="IPV4",
1101 macs=macs,
1102 bandwidth="",
1103 lambdaAlloc=False,
1104 ipProto="",
1105 ipAddresses="",
1106 tcp="",
1107 sw1="s5",
1108 sw2="s2",
1109 expectedLink=18 )
1110
1111 utilities.assert_equals( expect=main.TRUE,
1112 actual=stepResult,
1113 onpass="IPV4: Successfully added multi point"
1114 + " to single point intents" +
1115 " with IPV4 type and MAC addresses",
1116 onfail="IPV4: Failed to add multi point" +
1117 " to single point intents" +
1118 " with IPV4 type and MAC addresses" )
1119
1120 main.step( "IPV4_2: Add multi point to single point intents" )
1121 stepResult = main.TRUE
1122 hostNames = [ 'h8', 'h16', 'h24' ]
1123 stepResult = main.intentFunction.multiToSingleIntent(
1124 main,
1125 name="IPV4",
1126 hostNames=hostNames,
1127 ethType="IPV4",
1128 lambdaAlloc=False )
1129
1130 utilities.assert_equals( expect=main.TRUE,
1131 actual=stepResult,
1132 onpass="IPV4_2: Successfully added multi point"
1133 + " to single point intents" +
1134 " with IPV4 type and no MAC addresses",
1135 onfail="IPV4_2: Failed to add multi point" +
1136 " to single point intents" +
1137 " with IPV4 type and no MAC addresses" )
1138
1139 main.step( "VLAN: Add multi point to single point intents" )
1140 stepResult = main.TRUE
1141 hostNames = [ 'h5', 'h13', 'h21' ]
1142 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1143 'of:0000000000000007/5' ]
1144 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1145 stepResult = main.intentFunction.multiToSingleIntent(
1146 main,
1147 name="VLAN",
1148 hostNames=hostNames,
1149 devices=devices,
1150 ports=None,
1151 ethType="IPV4",
1152 macs=macs,
1153 bandwidth="",
1154 lambdaAlloc=False,
1155 ipProto="",
1156 ipAddresses="",
1157 tcp="",
1158 sw1="s5",
1159 sw2="s2",
1160 expectedLink=18 )
1161
1162 utilities.assert_equals( expect=main.TRUE,
1163 actual=stepResult,
1164 onpass="VLAN: Successfully added multi point"
1165 + " to single point intents" +
1166 " with IPV4 type and MAC addresses" +
1167 " in the same VLAN",
1168 onfail="VLAN: Failed to add multi point" +
1169 " to single point intents" )
1170
1171 def CASE5000( self, main ):
1172 """
1173 Will add description in next patch set
1174 """
1175 assert main, "There is no main"
1176 assert main.CLIs, "There is no main.CLIs"
1177 assert main.Mininet1, "Mininet handle should be named Mininet1"
1178 assert main.numSwitch, "Placed the total number of switch topology in \
1179 main.numSwitch"
1180 main.case( "Test host mobility with host intents " )
1181 main.step( " Testing host mobility by moving h1 from s5 to s6" )
1182 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1183
1184 main.log.info( "Moving h1 from s5 to s6")
1185
1186 main.Mininet1.moveHost( "h1","s5","s6" )
1187
1188 main.intentFunction.getHostsData( main )
1189 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1190
1191 utilities.assert_equals( expect="of:0000000000000006",
1192 actual=h1PostMove,
1193 onpass="Mobility: Successfully moved h1 to s6",
1194 onfail="Mobility: Failed to moved h1 to s6" +
1195 " to single point intents" +
1196 " with IPV4 type and MAC addresses" +
1197 " in the same VLAN" )
1198
1199 main.step( "IPV4: Add host intents between h1 and h9" )
1200 stepResult = main.TRUE
1201 stepResult = main.intentFunction.hostIntent( main,
1202 onosNode='0',
1203 name='IPV4',
1204 host1='h1',
1205 host2='h9',
1206 host1Id='00:00:00:00:00:01/-1',
1207 host2Id='00:00:00:00:00:09/-1' )
1208
1209 utilities.assert_equals( expect=main.TRUE,
1210 actual=stepResult,
1211 onpass="IPV4: Host intent test successful " +
1212 "between two IPV4 hosts",
1213 onfail="IPV4: Host intent test failed " +
1214 "between two IPV4 hosts")