blob: 854d5f314513601830e802602117f58c4b68ba76 [file] [log] [blame]
sathishmad953462015-12-03 17:42:07 +05301# Testing the basic intent for ipv6 functionality of ONOS
2
3class FUNCipv6Intent:
4
5 def __init__( self ):
6 self.default = ''
7
8 def CASE1( self, main ):
9 import time
10 import imp
11 import re
12
13 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
22
23 main.case( "Constructing test variables and building ONOS package" )
24 main.step( "Constructing test variables" )
25 main.caseExplanation = "This test case is mainly for loading " +\
26 "from params file, and pull and build the " +\
27 " latest ONOS package"
28 stepResult = main.FALSE
29
30 # Test variables
31 try:
32 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
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 if main.ONOSbench.maxNodes:
40 main.maxNodes = int( main.ONOSbench.maxNodes )
41 else:
42 main.maxNodes = 0
43 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
44 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
45 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
46 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
47 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
48 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
49 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
50 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
51 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
52 gitPull = main.params[ 'GIT' ][ 'pull' ]
53 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
54 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
55 main.cellData = {} # for creating cell file
56 main.hostsData = {}
57 main.CLIs = []
58 main.ONOSip = []
59 main.assertReturnString = '' # Assembled assert return string
60
61 main.ONOSip = main.ONOSbench.getOnosIps()
62 print main.ONOSip
63
64 # Assigning ONOS cli handles to a list
65 for i in range( 1, main.maxNodes + 1 ):
66 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
67
68 # -- INIT SECTION, ONLY RUNS ONCE -- #
69 main.startUp = imp.load_source( wrapperFile1,
70 main.dependencyPath +
71 wrapperFile1 +
72 ".py" )
73
74 main.intentFunction = imp.load_source( wrapperFile2,
75 main.dependencyPath +
76 wrapperFile2 +
77 ".py" )
78
79 main.topo = imp.load_source( wrapperFile3,
80 main.dependencyPath +
81 wrapperFile3 +
82 ".py" )
83
84 copyResult1 = main.ONOSbench.scp( main.Mininet1,
85 main.dependencyPath +
86 main.topology,
87 main.Mininet1.home,
88 direction="to" )
89 if main.CLIs:
90 stepResult = main.TRUE
91 else:
92 main.log.error( "Did not properly created list of ONOS CLI handle" )
93 stepResult = main.FALSE
94 except Exception as e:
95 main.log.exception(e)
96 main.cleanup()
97 main.exit()
98
99 utilities.assert_equals( expect=main.TRUE,
100 actual=stepResult,
101 onpass="Successfully construct " +
102 "test variables ",
103 onfail="Failed to construct test variables" )
104
105 if gitPull == 'True':
106 main.step( "Building ONOS in " + gitBranch + " branch" )
107 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
108 stepResult = onosBuildResult
109 utilities.assert_equals( expect=main.TRUE,
110 actual=stepResult,
111 onpass="Successfully compiled " +
112 "latest ONOS",
113 onfail="Failed to compile " +
114 "latest ONOS" )
115 else:
116 main.log.warn( "Did not pull new code so skipping mvn " +
117 "clean install" )
118 main.ONOSbench.getVersion( report=True )
119
120 def CASE2( self, main ):
121 """
122 - Set up cell
123 - Create cell file
124 - Set cell file
125 - Verify cell file
126 - Kill ONOS process
127 - Uninstall ONOS cluster
128 - Verify ONOS start up
129 - Install ONOS cluster
130 - Connect to cli
131 """
132
133 # main.scale[ 0 ] determines the current number of ONOS controller
134 main.numCtrls = int( main.scale[ 0 ] )
135
136 main.case( "Starting up " + str( main.numCtrls ) +
137 " node(s) ONOS cluster" )
138 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
139 " node(s) ONOS cluster"
140
141
142
143 #kill off all onos processes
144 main.log.info( "Safety check, killing all ONOS processes" +
145 " before initiating environment setup" )
146
147 for i in range( main.maxNodes ):
148 main.ONOSbench.onosDie( main.ONOSip[ i ] )
149
150 print "NODE COUNT = ", main.numCtrls
151
152 tempOnosIp = []
153 for i in range( main.numCtrls ):
154 tempOnosIp.append( main.ONOSip[i] )
155
156 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
157 "temp", main.Mininet1.ip_address,
158 main.apps, tempOnosIp )
159
160 main.step( "Apply cell to environment" )
161 cellResult = main.ONOSbench.setCell( "temp" )
162 verifyResult = main.ONOSbench.verifyCell()
163 stepResult = cellResult and verifyResult
164 utilities.assert_equals( expect=main.TRUE,
165 actual=stepResult,
166 onpass="Successfully applied cell to " + \
167 "environment",
168 onfail="Failed to apply cell to environment " )
169
170 main.step( "Creating ONOS package" )
171 packageResult = main.ONOSbench.onosPackage()
172 stepResult = packageResult
173 utilities.assert_equals( expect=main.TRUE,
174 actual=stepResult,
175 onpass="Successfully created ONOS package",
176 onfail="Failed to create ONOS package" )
177
178 time.sleep( main.startUpSleep )
179 main.step( "Uninstalling ONOS package" )
180 onosUninstallResult = main.TRUE
181 for ip in main.ONOSip:
182 onosUninstallResult = onosUninstallResult and \
183 main.ONOSbench.onosUninstall( nodeIp=ip )
184 stepResult = onosUninstallResult
185 utilities.assert_equals( expect=main.TRUE,
186 actual=stepResult,
187 onpass="Successfully uninstalled ONOS package",
188 onfail="Failed to uninstall ONOS package" )
189
190 time.sleep( main.startUpSleep )
191 main.step( "Installing ONOS package" )
192 onosInstallResult = main.TRUE
193 for i in range( main.numCtrls ):
194 onosInstallResult = onosInstallResult and \
195 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
196 stepResult = onosInstallResult
197 utilities.assert_equals( expect=main.TRUE,
198 actual=stepResult,
199 onpass="Successfully installed ONOS package",
200 onfail="Failed to install ONOS package" )
201
202 time.sleep( main.startUpSleep )
203 main.step( "Starting ONOS service" )
204 stopResult = main.TRUE
205 startResult = main.TRUE
206 onosIsUp = main.TRUE
207
208 for i in range( main.numCtrls ):
209 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
210 if onosIsUp == main.TRUE:
211 main.log.report( "ONOS instance is up and ready" )
212 else:
213 main.log.report( "ONOS instance may not be up, stop and " +
214 "start ONOS again " )
215
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 main.step( "Start ONOS cli" )
229 cliResult = main.TRUE
230 for i in range( main.numCtrls ):
231 cliResult = cliResult and \
232 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
233 stepResult = cliResult
234 utilities.assert_equals( expect=main.TRUE,
235 actual=stepResult,
236 onpass="Successfully start ONOS cli",
237 onfail="Failed to start ONOS cli" )
238
239 main.step( "Checking that ONOS is ready" )
240 for i in range( 10 ):
241 ready = True
242 for i in range( int( main.scale[ 0 ] ) ):
243 output = main.CLIs[ i ].summary()
244 if not output:
245 ready = False
246 time.sleep( 30 )
247 utilities.assert_equals( expect=True, actual=ready,
248 onpass="ONOS summary command succeded",
249 onfail="ONOS summary command failed" )
250 if not ready:
251 main.cleanup()
252 main.exit()
253
254 main.step( "setup the ipv6NeighbourDiscovery" )
255 cfgResult1 = main.CLIs[0].setCfg( "org.onosproject.proxyarp.ProxyArp", "ipv6NeighborDiscovery", "true" )
256 cfgResult2 = main.CLIs[0].setCfg( "org.onosproject.provider.host.impl.HostLocationProvider", "ipv6NeighborDiscovery", "true" )
257 cfgResult = cfgResult1 and cfgResult2
258 utilities.assert_equals( expect=main.TRUE, actual=cfgResult,
259 onpass="ipv6NeighborDiscovery cfg is set to true",
260 onfail="Failed to cfg set ipv6NeighborDiscovery" )
261
262 # Remove the first element in main.scale list
263 main.scale.remove( main.scale[ 0 ] )
264
265 main.intentFunction.report( main )
266
267 def CASE11( self, main ):
268 """
269 Start Mininet topology with OF 1.3 switches
270 """
271 main.OFProtocol = "1.3"
272 main.log.report( "Start Mininet topology with OF 1.3 switches" )
273 main.case( "Start Mininet topology with OF 1.3 switches" )
274 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
275 "switches to test intents, exits out if " +\
276 "topology did not start correctly"
277
278 main.step( "Starting Mininet topology with OF 1.3 switches" )
279 args = "--switch ovs,protocols=OpenFlow13"
280 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
281 main.topology,
282 args=args )
283 stepResult = topoResult
284 utilities.assert_equals( expect=main.TRUE,
285 actual=stepResult,
286 onpass="Successfully loaded topology",
287 onfail="Failed to load topology" )
288 # Exit if topology did not load properly
289 if not topoResult:
290 main.cleanup()
291 main.exit()
292
293 def CASE12( self, main ):
294 """
295 Assign mastership to controllers
296 """
297 import re
298
299 main.case( "Assign switches to controllers" )
300 main.step( "Assigning switches to controllers" )
301 main.caseExplanation = "Assign OF " + main.OFProtocol +\
302 " switches to ONOS nodes"
303
304 assignResult = main.TRUE
305 switchList = []
306
307 # Creates a list switch name, use getSwitch() function later...
308 for i in range( 1, ( main.numSwitch + 1 ) ):
309 switchList.append( 's' + str( i ) )
310
311 tempONOSip = []
312 for i in range( main.numCtrls ):
313 tempONOSip.append( main.ONOSip[ i ] )
314
315 assignResult = main.Mininet1.assignSwController( sw=switchList,
316 ip=tempONOSip,
317 port='6653' )
318 if not assignResult:
319 main.cleanup()
320 main.exit()
321
322 for i in range( 1, ( main.numSwitch + 1 ) ):
323 response = main.Mininet1.getSwController( "s" + str( i ) )
324 print( "Response is " + str( response ) )
325 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
326 assignResult = assignResult and main.TRUE
327 else:
328 assignResult = main.FALSE
329 stepResult = assignResult
330 utilities.assert_equals( expect=main.TRUE,
331 actual=stepResult,
332 onpass="Successfully assigned switches" +
333 "to controller",
334 onfail="Failed to assign switches to " +
335 "controller" )
336
337 def CASE13( self, main ):
338 """
339 Discover all hosts and store its data to a dictionary
340 """
341 main.case( "Discover all hosts" )
342
343 stepResult = main.TRUE
344 main.step( "Discover all hosts using pingall " )
345 stepResult = main.intentFunction.getHostsData( main )
346 utilities.assert_equals( expect=main.TRUE,
347 actual=stepResult,
348 onpass="Successfully discovered hosts",
349 onfail="Failed to discover hosts" )
350
351 def CASE14( self, main ):
352 """
353 Stop mininet
354 """
355 main.log.report( "Stop Mininet topology" )
356 main.case( "Stop Mininet topology" )
357 main.caseExplanation = "Stopping the current mininet topology " +\
358 "to start up fresh"
359
360 main.step( "Stopping Mininet Topology" )
361 topoResult = main.Mininet1.stopNet( )
362 stepResult = topoResult
363 utilities.assert_equals( expect=main.TRUE,
364 actual=stepResult,
365 onpass="Successfully stop mininet",
366 onfail="Failed to stop mininet" )
367 # Exit if topology did not load properly
368 if not topoResult:
369 main.cleanup()
370 main.exit()
371
372 def CASE2000( self, main ):
373 """
374 add point intents between 2 hosts:
375 - Get device ids | ports
376 - Add point intents
377 - Check intents
378 - Verify flows
379 - Ping hosts
380 - Reroute
381 - Link down
382 - Verify flows
383 - Check topology
384 - Ping hosts
385 - Link up
386 - Verify flows
387 - Check topology
388 - Ping hosts
389 - Remove intents
390 """
391 import time
392 import json
393 import re
394
395 # Assert variables - These variable's name|format must be followed
396 # if you want to use the wrapper function
397 assert main, "There is no main"
398 assert main.CLIs, "There is no main.CLIs"
399 assert main.Mininet1, "Mininet handle should be named Mininet1"
400 assert main.numSwitch, "Placed the total number of switch topology in \
401 main.numSwitch"
402
403 main.testName = "Point Intents"
404 main.case( main.testName + " Test - " + str( main.numCtrls ) +
405 " NODE(S) - OF " + main.OFProtocol )
406 main.caseExplanation = "This test case will test point to point" +\
407 " intents using " + str( main.numCtrls ) +\
408 " node(s) cluster;\n" +\
409 "Different type of hosts will be tested in " +\
410 "each step such as IPV4, Dual stack, VLAN etc" +\
411 ";\nThe test will use OF " + main.OFProtocol +\
412 " OVS running in Mininet"
413
414 # No option point intents
415 main.step( "NOOPTION: Add point intents between h1 and h9, ipv6 hosts" )
416 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
417 stepResult = main.TRUE
418 stepResult = main.intentFunction.pointIntent(
419 main,
420 name="NOOPTION",
421 host1="h1",
422 host2="h9",
423 deviceId1="of:0000000000000005/1",
424 deviceId2="of:0000000000000006/1")
425
426 utilities.assert_equals( expect=main.TRUE,
427 actual=stepResult,
428 onpass=main.assertReturnString,
429 onfail=main.assertReturnString )
430
431 stepResult = main.TRUE
432 main.step( "IPV6: Add point intents between h1 and h9" )
433 main.assertReturnString = "Assertion Result for IPV6 point intent\n"
434 stepResult = main.intentFunction.pointIntent(
435 main,
436 name="IPV6",
437 host1="h1",
438 host2="h9",
439 deviceId1="of:0000000000000005/1",
440 deviceId2="of:0000000000000006/1",
441 port1="1",
442 port2="1",
443 ethType="IPV6",
444 mac1="00:00:00:00:00:01",
445 mac2="00:00:00:00:00:09",
446 bandwidth="30",
447 lambdaAlloc=False,
448 ipProto="58",
449 ip1="10:1:0::1/128",
450 ip2="10:1:0::5/128",
451 tcp1="",
452 tcp2="",
453 expectedLink=18 )
454
455 utilities.assert_equals( expect=main.TRUE,
456 actual=stepResult,
457 onpass=main.assertReturnString,
458 onfail=main.assertReturnString )
459
460 main.step( "IPV6_2: Add point intents between h1 and h9" )
461 main.assertReturnString = "Assertion Result for IPV6 no mac address point intents\n"
462 stepResult = main.intentFunction.pointIntent(
463 main,
464 name="IPV6_2",
465 host1="h1",
466 host2="h9",
467 deviceId1="of:0000000000000005/1",
468 deviceId2="of:0000000000000006/1",
469 ipProto="58",
470 ip1="10:1:0::1/128",
471 ip2="10:1:0::5/128",
472 tcp1="",
473 tcp2="",
474 expectedLink=18 )
475
476 utilities.assert_equals( expect=main.TRUE,
477 actual=stepResult,
478 onpass=main.assertReturnString,
479 onfail=main.assertReturnString )
480 """
481 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
482 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
483 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
484 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
485 main.log.debug(mac2)
486
487 # TODO : Fix is IPv6 arg format
488 # when we install the intent "add-point-intent --ethType IPV6 --ethSrc 00:00:00:00:00:01
489 # --ethDst 00:00:00:00:00:09 --ipProto 1 --ipSrc 10:1::1/128 --ipDst 10:1::5/128
490 # of:0000000000000005/1 of:0000000000000006/1" controller reports following error :
491 # Malformed IP prefix string: 10:1::1. Address must take form "x.x.x.x/y" or "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/y"
492 ip1 = main.Mininet1.getIPAddress( 'h1', proto='IPV6' )
493 ip2 = main.Mininet1.getIPAddress( 'h9', proto='IPV6')
494
495 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
496 # Uneccessary, not including this in the selectors
497 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
498 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
499
500 stepResult = main.intentFunction.pointIntent(
501 main,
502 name="SDNIP-ICMP",
503 host1="h1",
504 host2="h9",
505 deviceId1="of:0000000000000005/1",
506 deviceId2="of:0000000000000006/1",
507 mac1=mac1,
508 mac2=mac2,
509 ethType="IPV6",
510 ipProto=ipProto,
511 ip1=ip1,
512 ip2=ip2 )
513
514 utilities.assert_equals( expect=main.TRUE,
515 actual=stepResult,
516 onpass=main.assertReturnString,
517 onfail=main.assertReturnString )
518
519 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
520 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
521 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
522 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
523 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
524 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
525 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
526 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
527 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
528
529 stepResult = main.intentFunction.pointIntentTcp(
530 main,
531 name="SDNIP-TCP",
532 host1="h1",
533 host2="h9",
534 deviceId1="of:0000000000000005/1",
535 deviceId2="of:0000000000000006/1",
536 mac1=mac1,
537 mac2=mac2,
538 ethType="IPV4",
539 ipProto=ipProto,
540 ip1=ip1,
541 ip2=ip2,
542 tcp1=tcp1,
543 tcp2=tcp2 )
544
545 utilities.assert_equals( expect=main.TRUE,
546 actual=stepResult,
547 onpass=main.assertReturnString,
548 onfail=main.assertReturnString )
549
550 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
551 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
552 stepResult = main.intentFunction.pointIntent(
553 main,
554 name="DUALSTACK1",
555 host1="h3",
556 host2="h11",
557 deviceId1="of:0000000000000005",
558 deviceId2="of:0000000000000006",
559 port1="3",
560 port2="3",
561 ethType="IPV4",
562 mac1="00:00:00:00:00:03",
563 mac2="00:00:00:00:00:0B",
564 bandwidth="",
565 lambdaAlloc=False,
566 ipProto="",
567 ip1="",
568 ip2="",
569 tcp1="",
570 tcp2="",
571 sw1="s5",
572 sw2="s2",
573 expectedLink=18 )
574
575 utilities.assert_equals( expect=main.TRUE,
576 actual=stepResult,
577 onpass=main.assertReturnString,
578 onfail=main.assertReturnString )
579
580 main.step( "VLAN: Add point intents between h5 and h21" )
581 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
582 stepResult = main.intentFunction.pointIntent(
583 main,
584 name="VLAN",
585 host1="h5",
586 host2="h21",
587 deviceId1="of:0000000000000005/5",
588 deviceId2="of:0000000000000007/5",
589 port1="",
590 port2="",
591 ethType="IPV4",
592 mac1="00:00:00:00:00:05",
593 mac2="00:00:00:00:00:15",
594 bandwidth="",
595 lambdaAlloc=False,
596 ipProto="",
597 ip1="",
598 ip2="",
599 tcp1="",
600 tcp2="",
601 sw1="s5",
602 sw2="s2",
603 expectedLink=18 )
604
605 utilities.assert_equals( expect=main.TRUE,
606 actual=stepResult,
607 onpass=main.assertReturnString,
608 onfail=main.assertReturnString )
609 """
610 main.step( "1HOP: Add point intents between h1 and h9" )
611 main.assertReturnString = "Assertion Result for 1HOP IPV6 with no mac address point intents\n"
612 stepResult = main.intentFunction.hostIntent( main,
613 name='1HOP',
614 host1='h1',
615 host2='h9',
616 host1Id='00:00:00:00:00:01/-1',
617 host2Id='00:00:00:00:00:09/-1')
618
619 utilities.assert_equals( expect=main.TRUE,
620 actual=stepResult,
621 onpass=main.assertReturnString,
622 onfail=main.assertReturnString )
623
624 main.intentFunction.report( main )
625"""