blob: 735127374f299c6d5f6d2d98d0a9145f60334e3a [file] [log] [blame]
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -08001# 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" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800145 " before initiating environment setup" )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800146
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
Jon Hall11845ed2016-02-11 11:25:31 -0800239 main.step( "Checking that ONOS is ready" )
240 for i in range( 10 ):
241 ready = True
242 for cli in main.CLIs:
243 output = cli.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
Subhash Kumar Singh5ea4d302015-11-05 14:36:52 +0530254 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
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800262 # 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,
Subhash Kumar Singh5ea4d302015-11-05 14:36:52 +0530317 port='6633' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800318 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 CASE14( self, main ):
338 """
339 Stop mininet
340 """
341 main.log.report( "Stop Mininet topology" )
342 main.case( "Stop Mininet topology" )
343 main.caseExplanation = "Stopping the current mininet topology " +\
344 "to start up fresh"
345
346 main.step( "Stopping Mininet Topology" )
347 topoResult = main.Mininet1.stopNet( )
348 stepResult = topoResult
349 utilities.assert_equals( expect=main.TRUE,
350 actual=stepResult,
351 onpass="Successfully stop mininet",
352 onfail="Failed to stop mininet" )
353 # Exit if topology did not load properly
354 if not topoResult:
355 main.cleanup()
356 main.exit()
Subhash Kumar Singh5ea4d302015-11-05 14:36:52 +0530357
358 def CASE2000( self, main ):
359 """
360 add point intents between 2 hosts:
361 - Get device ids | ports
362 - Add point intents
363 - Check intents
364 - Verify flows
365 - Ping hosts
366 - Reroute
367 - Link down
368 - Verify flows
369 - Check topology
370 - Ping hosts
371 - Link up
372 - Verify flows
373 - Check topology
374 - Ping hosts
375 - Remove intents
376 """
377 import time
378 import json
379 import re
380
381 # Assert variables - These variable's name|format must be followed
382 # if you want to use the wrapper function
383 assert main, "There is no main"
384 assert main.CLIs, "There is no main.CLIs"
385 assert main.Mininet1, "Mininet handle should be named Mininet1"
386 assert main.numSwitch, "Placed the total number of switch topology in \
387 main.numSwitch"
388
389 main.testName = "Point Intents"
390 main.case( main.testName + " Test - " + str( main.numCtrls ) +
391 " NODE(S) - OF " + main.OFProtocol )
392 main.caseExplanation = "This test case will test point to point" +\
393 " intents using " + str( main.numCtrls ) +\
394 " node(s) cluster;\n" +\
395 "Different type of hosts will be tested in " +\
396 "each step such as IPV4, Dual stack, VLAN etc" +\
397 ";\nThe test will use OF " + main.OFProtocol +\
398 " OVS running in Mininet"
399
400 # No option point intents
401 main.step( "NOOPTION: Add point intents between h1 and h9, ipv6 hosts" )
402 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
403 stepResult = main.TRUE
404 stepResult = main.intentFunction.pointIntent(
405 main,
406 name="NOOPTION",
407 host1="h1",
408 host2="h9",
409 deviceId1="of:0000000000000005/1",
410 deviceId2="of:0000000000000006/1")
411
412 utilities.assert_equals( expect=main.TRUE,
413 actual=stepResult,
414 onpass=main.assertReturnString,
415 onfail=main.assertReturnString )
416
417 stepResult = main.TRUE
418 main.step( "IPV6: Add point intents between h1 and h9" )
419 main.assertReturnString = "Assertion Result for IPV6 point intent\n"
420 stepResult = main.intentFunction.pointIntent(
421 main,
422 name="IPV6",
423 host1="h1",
424 host2="h9",
425 deviceId1="of:0000000000000005/1",
426 deviceId2="of:0000000000000006/1",
427 port1="",
428 port2="",
429 ethType="IPV6",
430 mac1="00:00:00:00:00:01",
431 mac2="00:00:00:00:00:09",
432 bandwidth="",
433 lambdaAlloc=False,
434 ipProto="",
435 ip1="",
436 ip2="",
437 tcp1="",
438 tcp2="",
439 expectedLink=18 )
440
441 utilities.assert_equals( expect=main.TRUE,
442 actual=stepResult,
443 onpass=main.assertReturnString,
444 onfail=main.assertReturnString )
445
446 main.step( "IPV6_2: Add point intents between h1 and h9" )
447 main.assertReturnString = "Assertion Result for IPV6 no mac address point intents\n"
448 stepResult = main.intentFunction.pointIntent(
449 main,
450 name="IPV6_2",
451 host1="h1",
452 host2="h9",
453 deviceId1="of:0000000000000005/1",
454 deviceId2="of:0000000000000006/1",
455 ipProto="",
456 ip1="",
457 ip2="",
458 tcp1="",
459 tcp2="",
460 expectedLink=18 )
461
462 utilities.assert_equals( expect=main.TRUE,
463 actual=stepResult,
464 onpass=main.assertReturnString,
465 onfail=main.assertReturnString )
466 """
467 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
468 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
469 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
470 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
471 try:
472 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
473 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
474 except KeyError:
475 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
476 "main.hostsData" )
477 ip1 = main.Mininet1.getIPAddress( 'h1')
478 ip2 = main.Mininet1.getIPAddress( 'h9')
479
480 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
481 # Uneccessary, not including this in the selectors
482 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
483 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
484
485 stepResult = main.intentFunction.pointIntent(
486 main,
487 name="SDNIP-ICMP",
488 host1="h1",
489 host2="h9",
490 deviceId1="of:0000000000000005/1",
491 deviceId2="of:0000000000000006/1",
492 mac1=mac1,
493 mac2=mac2,
494 ethType="IPV6",
495 ipProto=ipProto,
496 ip1=ip1,
497 ip2=ip2 )
498
499 utilities.assert_equals( expect=main.TRUE,
500 actual=stepResult,
501 onpass=main.assertReturnString,
502 onfail=main.assertReturnString )
503
504 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
505 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
506 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
507 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
508 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
509 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
510 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
511 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
512 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
513
514 stepResult = main.intentFunction.pointIntentTcp(
515 main,
516 name="SDNIP-TCP",
517 host1="h1",
518 host2="h9",
519 deviceId1="of:0000000000000005/1",
520 deviceId2="of:0000000000000006/1",
521 mac1=mac1,
522 mac2=mac2,
523 ethType="IPV4",
524 ipProto=ipProto,
525 ip1=ip1,
526 ip2=ip2,
527 tcp1=tcp1,
528 tcp2=tcp2 )
529
530 utilities.assert_equals( expect=main.TRUE,
531 actual=stepResult,
532 onpass=main.assertReturnString,
533 onfail=main.assertReturnString )
534
535 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
536 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
537 stepResult = main.intentFunction.pointIntent(
538 main,
539 name="DUALSTACK1",
540 host1="h3",
541 host2="h11",
542 deviceId1="of:0000000000000005",
543 deviceId2="of:0000000000000006",
544 port1="3",
545 port2="3",
546 ethType="IPV4",
547 mac1="00:00:00:00:00:03",
548 mac2="00:00:00:00:00:0B",
549 bandwidth="",
550 lambdaAlloc=False,
551 ipProto="",
552 ip1="",
553 ip2="",
554 tcp1="",
555 tcp2="",
556 sw1="s5",
557 sw2="s2",
558 expectedLink=18 )
559
560 utilities.assert_equals( expect=main.TRUE,
561 actual=stepResult,
562 onpass=main.assertReturnString,
563 onfail=main.assertReturnString )
564
565 main.step( "VLAN: Add point intents between h5 and h21" )
566 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
567 stepResult = main.intentFunction.pointIntent(
568 main,
569 name="VLAN",
570 host1="h5",
571 host2="h21",
572 deviceId1="of:0000000000000005/5",
573 deviceId2="of:0000000000000007/5",
574 port1="",
575 port2="",
576 ethType="IPV4",
577 mac1="00:00:00:00:00:05",
578 mac2="00:00:00:00:00:15",
579 bandwidth="",
580 lambdaAlloc=False,
581 ipProto="",
582 ip1="",
583 ip2="",
584 tcp1="",
585 tcp2="",
586 sw1="s5",
587 sw2="s2",
588 expectedLink=18 )
589
590 utilities.assert_equals( expect=main.TRUE,
591 actual=stepResult,
592 onpass=main.assertReturnString,
593 onfail=main.assertReturnString )
594
595 main.step( "1HOP: Add point intents between h1 and h3" )
596 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
597 stepResult = main.intentFunction.hostIntent( main,
598 name='1HOP',
599 host1='h1',
600 host2='h9',
601 host1Id='00:00:00:00:00:01/-1',
602 host2Id='00:00:00:00:00:09/-1')
603
604 utilities.assert_equals( expect=main.TRUE,
605 actual=stepResult,
606 onpass=main.assertReturnString,
607 onfail=main.assertReturnString )
608 """
609 main.intentFunction.report( main )