blob: ef204e91b6f4168a0e894d721ae8c8c8cc95e131 [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' ] )
55 main.hostIntentSleep = int( main.params[ 'SLEEP' ][ 'hostintent' ] )
56 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
414 main.step( "Discover all hosts using pingall " )
415 stepResult = main.intentFunction.getHostsData( main )
416 utilities.assert_equals( expect=main.TRUE,
417 actual=stepResult,
418 onpass="Successfully discovered hosts",
419 onfail="Failed to discover hosts" )
420
421 def CASE14( self, main ):
422 """
423 Stop mininet
424 """
425 main.log.report( "Stop Mininet topology" )
426 main.case( "Stop Mininet topology" )
427 main.caseExplanation = "Stopping the current mininet topology " +\
428 "to start up fresh"
429
430 main.step( "Stopping Mininet Topology" )
431 topoResult = main.Mininet1.stopNet( )
432 stepResult = topoResult
433 utilities.assert_equals( expect=main.TRUE,
434 actual=stepResult,
435 onpass="Successfully stop mininet",
436 onfail="Failed to stop mininet" )
437 # Exit if topology did not load properly
438 if not topoResult:
439 main.cleanup()
440 main.exit()
441
442 def CASE1000( self, main ):
443 """
444 Add host intents between 2 host:
445 - Discover hosts
446 - Add host intents
447 - Check intents
448 - Verify flows
449 - Ping hosts
450 - Reroute
451 - Link down
452 - Verify flows
453 - Check topology
454 - Ping hosts
455 - Link up
456 - Verify flows
457 - Check topology
458 - Ping hosts
459 - Remove intents
460 """
461 import time
462 import json
463 import re
464
465 # Assert variables - These variable's name|format must be followed
466 # if you want to use the wrapper function
467 assert main, "There is no main"
468 assert main.CLIs, "There is no main.CLIs"
469 assert main.Mininet1, "Mininet handle should be named Mininet1"
470 assert main.numSwitch, "Placed the total number of switch topology in \
471 main.numSwitch"
472
473 main.case( "Host Intents Test - " + str( main.numCtrls ) +
474 " NODE(S) - OF " + main.OFProtocol )
475 main.caseExplanation = "This test case tests Host intents using " +\
476 str( main.numCtrls ) + " node(s) cluster;\n" +\
477 "Different type of hosts will be tested in " +\
478 "each step such as IPV4, Dual stack, VLAN " +\
479 "etc;\nThe test will use OF " + main.OFProtocol\
480 + " OVS running in Mininet"
481
482 main.step( "IPV4: Add host intents between h1 and h9" )
483 stepResult = main.TRUE
484 stepResult = main.intentFunction.hostIntent( main,
485 onosNode='0',
486 name='IPV4',
487 host1='h1',
488 host2='h9',
489 host1Id='00:00:00:00:00:01/-1',
490 host2Id='00:00:00:00:00:09/-1',
491 sw1='s5',
492 sw2='s2',
493 expectedLink=18 )
494
495 utilities.assert_equals( expect=main.TRUE,
496 actual=stepResult,
497 onpass="IPV4: Host intent test successful " +
498 "between two IPV4 hosts",
499 onfail="IPV4: Host intent test failed " +
500 "between two IPV4 hosts")
501
502 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
503 stepResult = main.TRUE
504 stepResult = main.intentFunction.hostIntent( main,
505 name='DUALSTACK',
506 host1='h3',
507 host2='h11',
508 host1Id='00:00:00:00:00:03/-1',
509 host2Id='00:00:00:00:00:0B/-1',
510 sw1='s5',
511 sw2='s2',
512 expectedLink=18 )
513
514 utilities.assert_equals( expect=main.TRUE,
515 actual=stepResult,
516 onpass="DUALSTACK: Host intent test " +
517 "successful between two " +
518 "dual stack host using IPV4",
519 onfail="DUALSTACK: Host intent test " +
520 "failed between two" +
521 "dual stack host using IPV4" )
522
523
524 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
525 stepResult = main.TRUE
526 stepResult = main.intentFunction.hostIntent( main,
527 name='DUALSTACK2',
528 host1='h1',
529 host2='h11',
530 sw1='s5',
531 sw2='s2',
532 expectedLink=18 )
533
534 utilities.assert_equals( expect=main.TRUE,
535 actual=stepResult,
536 onpass="DUALSTACK2: Host intent test " +
537 "successful between two " +
538 "dual stack host using IPV4",
539 onfail="DUALSTACK2: Host intent test " +
540 "failed between two" +
541 "dual stack host using IPV4" )
542
543 main.step( "1HOP: Add host intents between h1 and h3" )
544 stepResult = main.TRUE
545 stepResult = main.intentFunction.hostIntent( main,
546 name='1HOP',
547 host1='h1',
548 host2='h3' )
549
550 utilities.assert_equals( expect=main.TRUE,
551 actual=stepResult,
552 onpass="1HOP: Host intent test " +
553 "successful between two " +
554 "host using IPV4 in the same switch",
555 onfail="1HOP: Host intent test " +
556 "failed between two" +
557 "host using IPV4 in the same switch" )
558
559 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
560 stepResult = main.TRUE
561 stepResult = main.intentFunction.hostIntent( main,
562 name='VLAN1',
563 host1='h4',
564 host2='h12',
565 host1Id='00:00:00:00:00:04/100',
566 host2Id='00:00:00:00:00:0C/100',
567 sw1='s5',
568 sw2='s2',
569 expectedLink=18 )
570
571 utilities.assert_equals( expect=main.TRUE,
572 actual=stepResult,
573 onpass="VLAN1: Host intent test " +
574 "successful between two " +
575 "host using IPV4 in the same VLAN",
576 onfail="VLAN1: Host intent test " +
577 "failed between two" +
578 "host using IPV4 in the same VLAN" )
579
580 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
581 stepResult = main.TRUE
582 stepResult = main.intentFunction.hostIntent( main,
583 name='VLAN2',
584 host1='h13',
585 host2='h20' )
586
587 utilities.assert_equals( expect=main.FALSE,
588 actual=stepResult,
589 onpass="VLAN2: Host intent negative test " +
590 "successful between two " +
591 "host using IPV4 in different VLAN",
592 onfail="VLAN2: Host intent negative test " +
593 "failed between two" +
594 "host using IPV4 in different VLAN" )
595
596
597 def CASE2000( self, main ):
598 """
599 Add point intents between 2 hosts:
600 - Get device ids | ports
601 - Add point intents
602 - Check intents
603 - Verify flows
604 - Ping hosts
605 - Reroute
606 - Link down
607 - Verify flows
608 - Check topology
609 - Ping hosts
610 - Link up
611 - Verify flows
612 - Check topology
613 - Ping hosts
614 - Remove intents
615 """
616 import time
617 import json
618 import re
619
620 # Assert variables - These variable's name|format must be followed
621 # if you want to use the wrapper function
622 assert main, "There is no main"
623 assert main.CLIs, "There is no main.CLIs"
624 assert main.Mininet1, "Mininet handle should be named Mininet1"
625 assert main.numSwitch, "Placed the total number of switch topology in \
626 main.numSwitch"
627
628 main.case( "Point Intents Test - " + str( main.numCtrls ) +
629 " NODE(S) - OF " + main.OFProtocol )
630 main.caseExplanation = "This test case will test point to point" +\
631 " intents using " + str( main.numCtrls ) +\
632 " node(s) cluster;\n" +\
633 "Different type of hosts will be tested in " +\
634 "each step such as IPV4, Dual stack, VLAN etc" +\
635 ";\nThe test will use OF " + main.OFProtocol +\
636 " OVS running in Mininet"
637
638 # No option point intents
639 main.step( "NOOPTION: Add point intents between h1 and h9" )
640 stepResult = main.TRUE
641 stepResult = main.intentFunction.pointIntent(
642 main,
643 name="NOOPTION",
644 host1="h1",
645 host2="h9",
646 deviceId1="of:0000000000000005/1",
647 deviceId2="of:0000000000000006/1",
648 sw1="s5",
649 sw2="s2",
650 expectedLink=18 )
651
652 utilities.assert_equals( expect=main.TRUE,
653 actual=stepResult,
654 onpass="NOOPTION: Point intent test " +
655 "successful using no match action",
656 onfail="NOOPTION: Point intent test " +
657 "failed using no match action" )
658
659 stepResult = main.TRUE
660 main.step( "IPV4: Add point intents between h1 and h9" )
661 stepResult = main.intentFunction.pointIntent(
662 main,
663 name="IPV4",
664 host1="h1",
665 host2="h9",
666 deviceId1="of:0000000000000005/1",
667 deviceId2="of:0000000000000006/1",
668 port1="",
669 port2="",
670 ethType="IPV4",
671 mac1="00:00:00:00:00:01",
672 mac2="00:00:00:00:00:09",
673 bandwidth="",
674 lambdaAlloc=False,
675 ipProto="",
676 ip1="",
677 ip2="",
678 tcp1="",
679 tcp2="",
680 sw1="s5",
681 sw2="s2",
682 expectedLink=18 )
683
684 utilities.assert_equals( expect=main.TRUE,
685 actual=stepResult,
686 onpass="IPV4: Point intent test " +
687 "successful using IPV4 type with " +
688 "MAC addresses",
689 onfail="IPV4: Point intent test " +
690 "failed using IPV4 type with " +
691 "MAC addresses" )
692 main.step( "IPV4_2: Add point intents between h1 and h9" )
693 stepResult = main.TRUE
694 stepResult = main.intentFunction.pointIntent(
695 main,
696 name="IPV4_2",
697 host1="h1",
698 host2="h9",
699 deviceId1="of:0000000000000005/1",
700 deviceId2="of:0000000000000006/1",
701 ipProto="",
702 ip1="",
703 ip2="",
704 tcp1="",
705 tcp2="",
706 sw1="s5",
707 sw2="s2",
708 expectedLink=18 )
709
710 utilities.assert_equals( expect=main.TRUE,
711 actual=stepResult,
712 onpass="IPV4_2: Point intent test " +
713 "successful using IPV4 type with " +
714 "no MAC addresses",
715 onfail="IPV4_2: Point intent test " +
716 "failed using IPV4 type with " +
717 "no MAC addresses" )
718
719 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
720 stepResult = main.TRUE
721 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
722 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
723 try:
724 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
725 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
726 except KeyError:
727 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
728 "main.hostsData" )
729 ip1 = main.Mininet1.getIPAddress( 'h1')
730 ip2 = main.Mininet1.getIPAddress( 'h9')
731
732 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
733 # Uneccessary, not including this in the selectors
734 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
735 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
736
737 stepResult = main.intentFunction.pointIntent(
738 main,
739 name="SDNIP-TCP",
740 host1="h1",
741 host2="h9",
742 deviceId1="of:0000000000000005/1",
743 deviceId2="of:0000000000000006/1",
744 mac1=mac1,
745 mac2=mac2,
746 ethType="IPV4",
747 ipProto=ipProto,
748 ip1=ip1,
749 ip2=ip2 )
750
751 utilities.assert_equals( expect=main.TRUE,
752 actual=stepResult,
753 onpass="SDNIP-TCP: Point intent test " +
754 "successful using IPV4 type with " +
755 "IP protocol TCP enabled",
756 onfail="SDNIP-TCP: Point intent test " +
757 "failed using IPV4 type with " +
758 "IP protocol TCP enabled" )
759
760 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
761 stepResult = main.TRUE
762 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
763 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
764 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
765 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
766 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
767 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
768 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
769
770 stepResult = main.intentFunction.pointIntent(
771 main,
772 name="SDNIP-ICMP",
773 host1="h1",
774 host2="h9",
775 deviceId1="of:0000000000000005/1",
776 deviceId2="of:0000000000000006/1",
777 mac1=mac1,
778 mac2=mac2,
779 ethType="IPV4",
780 ipProto=ipProto )
781
782 utilities.assert_equals( expect=main.TRUE,
783 actual=stepResult,
784 onpass="SDNIP-ICMP: Point intent test " +
785 "successful using IPV4 type with " +
786 "IP protocol ICMP enabled",
787 onfail="SDNIP-ICMP: Point intent test " +
788 "failed using IPV4 type with " +
789 "IP protocol ICMP enabled" )
790
791 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
792 stepResult = main.TRUE
793 stepResult = main.intentFunction.pointIntent(
794 main,
795 name="DUALSTACK1",
796 host1="h3",
797 host2="h11",
798 deviceId1="of:0000000000000005",
799 deviceId2="of:0000000000000006",
800 port1="3",
801 port2="3",
802 ethType="IPV4",
803 mac1="00:00:00:00:00:03",
804 mac2="00:00:00:00:00:0B",
805 bandwidth="",
806 lambdaAlloc=False,
807 ipProto="",
808 ip1="",
809 ip2="",
810 tcp1="",
811 tcp2="",
812 sw1="s5",
813 sw2="s2",
814 expectedLink=18 )
815
816 utilities.assert_equals( expect=main.TRUE,
817 actual=stepResult,
818 onpass="DUALSTACK1: Point intent test " +
819 "successful using IPV4 type with " +
820 "MAC addresses",
821 onfail="DUALSTACK1: Point intent test " +
822 "failed using IPV4 type with " +
823 "MAC addresses" )
824
825 main.step( "VLAN: Add point intents between h5 and h21" )
826 stepResult = main.TRUE
827 stepResult = main.intentFunction.pointIntent(
828 main,
829 name="VLAN",
830 host1="h5",
831 host2="h21",
832 deviceId1="of:0000000000000005/5",
833 deviceId2="of:0000000000000007/5",
834 port1="",
835 port2="",
836 ethType="IPV4",
837 mac1="00:00:00:00:00:05",
838 mac2="00:00:00:00:00:15",
839 bandwidth="",
840 lambdaAlloc=False,
841 ipProto="",
842 ip1="",
843 ip2="",
844 tcp1="",
845 tcp2="",
846 sw1="s5",
847 sw2="s2",
848 expectedLink=18 )
849
850 utilities.assert_equals( expect=main.TRUE,
851 actual=stepResult,
852 onpass="VLAN1: Point intent test " +
853 "successful using IPV4 type with " +
854 "MAC addresses",
855 onfail="VLAN1: Point intent test " +
856 "failed using IPV4 type with " +
857 "MAC addresses" )
858
859 main.step( "1HOP: Add point intents between h1 and h3" )
860 stepResult = main.TRUE
861 stepResult = main.intentFunction.hostIntent( main,
862 name='1HOP',
863 host1='h1',
864 host2='h3' )
865
866 utilities.assert_equals( expect=main.TRUE,
867 actual=stepResult,
868 onpass="1HOP: Point intent test " +
869 "successful using IPV4 type with " +
870 "no MAC addresses",
871 onfail="1HOP: Point intent test " +
872 "failed using IPV4 type with " +
873 "no MAC addresses" )
874
875 def CASE3000( self, main ):
876 """
877 Add single point to multi point intents
878 - Get device ids
879 - Add single point to multi point intents
880 - Check intents
881 - Verify flows
882 - Ping hosts
883 - Reroute
884 - Link down
885 - Verify flows
886 - Check topology
887 - Ping hosts
888 - Link up
889 - Verify flows
890 - Check topology
891 - Ping hosts
892 - Remove intents
893 """
894 assert main, "There is no main"
895 assert main.CLIs, "There is no main.CLIs"
896 assert main.Mininet1, "Mininet handle should be named Mininet1"
897 assert main.numSwitch, "Placed the total number of switch topology in \
898 main.numSwitch"
899
900 main.case( "Single To Multi Point Intents Test - " +
901 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
902 main.caseExplanation = "This test case will test single point to" +\
903 " multi point intents using " +\
904 str( main.numCtrls ) + " node(s) cluster;\n" +\
905 "Different type of hosts will be tested in " +\
906 "each step such as IPV4, Dual stack, VLAN etc" +\
907 ";\nThe test will use OF " + main.OFProtocol +\
908 " OVS running in Mininet"
909
910 main.step( "NOOPTION: Add single point to multi point intents" )
911 stepResult = main.TRUE
912 hostNames = [ 'h8', 'h16', 'h24' ]
913 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
914 'of:0000000000000007/8' ]
915 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
916 stepResult = main.intentFunction.singleToMultiIntent(
917 main,
918 name="NOOPTION",
919 hostNames=hostNames,
920 devices=devices,
921 sw1="s5",
922 sw2="s2",
923 expectedLink=18 )
924
925 utilities.assert_equals( expect=main.TRUE,
926 actual=stepResult,
927 onpass="NOOPTION: Successfully added single "
928 + " point to multi point intents" +
929 " with no match action",
930 onfail="NOOPTION: Failed to add single point"
931 + " point to multi point intents" +
932 " with no match action" )
933
934 main.step( "IPV4: Add single point to multi point intents" )
935 stepResult = main.TRUE
936 stepResult = main.intentFunction.singleToMultiIntent(
937 main,
938 name="IPV4",
939 hostNames=hostNames,
940 devices=devices,
941 ports=None,
942 ethType="IPV4",
943 macs=macs,
944 bandwidth="",
945 lambdaAlloc=False,
946 ipProto="",
947 ipAddresses="",
948 tcp="",
949 sw1="s5",
950 sw2="s2",
951 expectedLink=18 )
952
953 utilities.assert_equals( expect=main.TRUE,
954 actual=stepResult,
955 onpass="IPV4: Successfully added single "
956 + " point to multi point intents" +
957 " with IPV4 type and MAC addresses",
958 onfail="IPV4: Failed to add single point"
959 + " point to multi point intents" +
960 " with IPV4 type and MAC addresses" )
961
962 main.step( "IPV4_2: Add single point to multi point intents" )
963 stepResult = main.TRUE
964 hostNames = [ 'h8', 'h16', 'h24' ]
965 stepResult = main.intentFunction.singleToMultiIntent(
966 main,
967 name="IPV4",
968 hostNames=hostNames,
969 ethType="IPV4",
970 lambdaAlloc=False )
971
972 utilities.assert_equals( expect=main.TRUE,
973 actual=stepResult,
974 onpass="IPV4_2: Successfully added single "
975 + " point to multi point intents" +
976 " with IPV4 type and no MAC addresses",
977 onfail="IPV4_2: Failed to add single point"
978 + " point to multi point intents" +
979 " with IPV4 type and no MAC addresses" )
980
981 main.step( "VLAN: Add single point to multi point intents" )
982 stepResult = main.TRUE
983 hostNames = [ 'h4', 'h12', 'h20' ]
984 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
985 'of:0000000000000007/4' ]
986 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
987 stepResult = main.intentFunction.singleToMultiIntent(
988 main,
989 name="VLAN",
990 hostNames=hostNames,
991 devices=devices,
992 ports=None,
993 ethType="IPV4",
994 macs=macs,
995 bandwidth="",
996 lambdaAlloc=False,
997 ipProto="",
998 ipAddresses="",
999 tcp="",
1000 sw1="s5",
1001 sw2="s2",
1002 expectedLink=18 )
1003
1004 utilities.assert_equals( expect=main.TRUE,
1005 actual=stepResult,
1006 onpass="VLAN: Successfully added single "
1007 + " point to multi point intents" +
1008 " with IPV4 type and MAC addresses" +
1009 " in the same VLAN",
1010 onfail="VLAN: Failed to add single point"
1011 + " point to multi point intents" +
1012 " with IPV4 type and MAC addresses" +
1013 " in the same VLAN")
1014
1015 def CASE4000( self, main ):
1016 """
1017 Add multi point to single point intents
1018 - Get device ids
1019 - Add multi point to single point intents
1020 - Check intents
1021 - Verify flows
1022 - Ping hosts
1023 - Reroute
1024 - Link down
1025 - Verify flows
1026 - Check topology
1027 - Ping hosts
1028 - Link up
1029 - Verify flows
1030 - Check topology
1031 - Ping hosts
1032 - Remove intents
1033 """
1034 assert main, "There is no main"
1035 assert main.CLIs, "There is no main.CLIs"
1036 assert main.Mininet1, "Mininet handle should be named Mininet1"
1037 assert main.numSwitch, "Placed the total number of switch topology in \
1038 main.numSwitch"
1039
1040 main.case( "Multi To Single Point Intents Test - " +
1041 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
1042 main.caseExplanation = "This test case will test single point to" +\
1043 " multi point intents using " +\
1044 str( main.numCtrls ) + " node(s) cluster;\n" +\
1045 "Different type of hosts will be tested in " +\
1046 "each step such as IPV4, Dual stack, VLAN etc" +\
1047 ";\nThe test will use OF " + main.OFProtocol +\
1048 " OVS running in Mininet"
1049
1050 main.step( "NOOPTION: Add multi point to single point intents" )
1051 stepResult = main.TRUE
1052 hostNames = [ 'h8', 'h16', 'h24' ]
1053 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1054 'of:0000000000000007/8' ]
1055 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1056 stepResult = main.intentFunction.multiToSingleIntent(
1057 main,
1058 name="NOOPTION",
1059 hostNames=hostNames,
1060 devices=devices,
1061 sw1="s5",
1062 sw2="s2",
1063 expectedLink=18 )
1064
1065 utilities.assert_equals( expect=main.TRUE,
1066 actual=stepResult,
1067 onpass="NOOPTION: Successfully added multi "
1068 + " point to single point intents" +
1069 " with no match action",
1070 onfail="NOOPTION: Failed to add multi point" +
1071 " to single point intents" +
1072 " with no match action" )
1073
1074 main.step( "IPV4: Add multi point to single point intents" )
1075 stepResult = main.TRUE
1076 stepResult = main.intentFunction.multiToSingleIntent(
1077 main,
1078 name="IPV4",
1079 hostNames=hostNames,
1080 devices=devices,
1081 ports=None,
1082 ethType="IPV4",
1083 macs=macs,
1084 bandwidth="",
1085 lambdaAlloc=False,
1086 ipProto="",
1087 ipAddresses="",
1088 tcp="",
1089 sw1="s5",
1090 sw2="s2",
1091 expectedLink=18 )
1092
1093 utilities.assert_equals( expect=main.TRUE,
1094 actual=stepResult,
1095 onpass="IPV4: Successfully added multi point"
1096 + " to single point intents" +
1097 " with IPV4 type and MAC addresses",
1098 onfail="IPV4: Failed to add multi point" +
1099 " to single point intents" +
1100 " with IPV4 type and MAC addresses" )
1101
1102 main.step( "IPV4_2: Add multi point to single point intents" )
1103 stepResult = main.TRUE
1104 hostNames = [ 'h8', 'h16', 'h24' ]
1105 stepResult = main.intentFunction.multiToSingleIntent(
1106 main,
1107 name="IPV4",
1108 hostNames=hostNames,
1109 ethType="IPV4",
1110 lambdaAlloc=False )
1111
1112 utilities.assert_equals( expect=main.TRUE,
1113 actual=stepResult,
1114 onpass="IPV4_2: Successfully added multi point"
1115 + " to single point intents" +
1116 " with IPV4 type and no MAC addresses",
1117 onfail="IPV4_2: Failed to add multi point" +
1118 " to single point intents" +
1119 " with IPV4 type and no MAC addresses" )
1120
1121 main.step( "VLAN: Add multi point to single point intents" )
1122 stepResult = main.TRUE
1123 hostNames = [ 'h5', 'h13', 'h21' ]
1124 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1125 'of:0000000000000007/5' ]
1126 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1127 stepResult = main.intentFunction.multiToSingleIntent(
1128 main,
1129 name="VLAN",
1130 hostNames=hostNames,
1131 devices=devices,
1132 ports=None,
1133 ethType="IPV4",
1134 macs=macs,
1135 bandwidth="",
1136 lambdaAlloc=False,
1137 ipProto="",
1138 ipAddresses="",
1139 tcp="",
1140 sw1="s5",
1141 sw2="s2",
1142 expectedLink=18 )
1143
1144 utilities.assert_equals( expect=main.TRUE,
1145 actual=stepResult,
1146 onpass="VLAN: Successfully added multi point"
1147 + " to single point intents" +
1148 " with IPV4 type and MAC addresses" +
1149 " in the same VLAN",
1150 onfail="VLAN: Failed to add multi point" +
1151 " to single point intents" )
1152
1153 def CASE5000( self, main ):
1154 """
1155 Will add description in next patch set
1156 """
1157 assert main, "There is no main"
1158 assert main.CLIs, "There is no main.CLIs"
1159 assert main.Mininet1, "Mininet handle should be named Mininet1"
1160 assert main.numSwitch, "Placed the total number of switch topology in \
1161 main.numSwitch"
1162 main.case( "Test host mobility with host intents " )
1163 main.step( " Testing host mobility by moving h1 from s5 to s6" )
1164 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1165
1166 main.log.info( "Moving h1 from s5 to s6")
1167
1168 main.Mininet1.moveHost( "h1","s5","s6" )
1169
1170 main.intentFunction.getHostsData( main )
1171 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1172
1173 utilities.assert_equals( expect="of:0000000000000006",
1174 actual=h1PostMove,
1175 onpass="Mobility: Successfully moved h1 to s6",
1176 onfail="Mobility: Failed to moved h1 to s6" +
1177 " to single point intents" +
1178 " with IPV4 type and MAC addresses" +
1179 " in the same VLAN" )
1180
1181 main.step( "IPV4: Add host intents between h1 and h9" )
1182 stepResult = main.TRUE
1183 stepResult = main.intentFunction.hostIntent( main,
1184 onosNode='0',
1185 name='IPV4',
1186 host1='h1',
1187 host2='h9',
1188 host1Id='00:00:00:00:00:01/-1',
1189 host2Id='00:00:00:00:00:09/-1' )
1190
1191 utilities.assert_equals( expect=main.TRUE,
1192 actual=stepResult,
1193 onpass="IPV4: Host intent test successful " +
1194 "between two IPV4 hosts",
1195 onfail="IPV4: Host intent test failed " +
1196 "between two IPV4 hosts")