blob: f3c7f1ec76202750cf17f580dccd49e4e18610d5 [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
Subhash Kumar Singh5ea4d302015-11-05 14:36:52 +0530239 main.step( "setup the ipv6NeighbourDiscovery" )
240 cfgResult1 = main.CLIs[0].setCfg( "org.onosproject.proxyarp.ProxyArp", "ipv6NeighborDiscovery", "true" )
241 cfgResult2 = main.CLIs[0].setCfg( "org.onosproject.provider.host.impl.HostLocationProvider", "ipv6NeighborDiscovery", "true" )
242 cfgResult = cfgResult1 and cfgResult2
243 utilities.assert_equals( expect=main.TRUE, actual=cfgResult,
244 onpass="ipv6NeighborDiscovery cfg is set to true",
245 onfail="Failed to cfg set ipv6NeighborDiscovery" )
246
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800247 # Remove the first element in main.scale list
248 main.scale.remove( main.scale[ 0 ] )
249
250 main.intentFunction.report( main )
251
252 def CASE11( self, main ):
253 """
254 Start Mininet topology with OF 1.3 switches
255 """
256 main.OFProtocol = "1.3"
257 main.log.report( "Start Mininet topology with OF 1.3 switches" )
258 main.case( "Start Mininet topology with OF 1.3 switches" )
259 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
260 "switches to test intents, exits out if " +\
261 "topology did not start correctly"
262
263 main.step( "Starting Mininet topology with OF 1.3 switches" )
264 args = "--switch ovs,protocols=OpenFlow13"
265 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
266 main.topology,
267 args=args )
268 stepResult = topoResult
269 utilities.assert_equals( expect=main.TRUE,
270 actual=stepResult,
271 onpass="Successfully loaded topology",
272 onfail="Failed to load topology" )
273 # Exit if topology did not load properly
274 if not topoResult:
275 main.cleanup()
276 main.exit()
277
278 def CASE12( self, main ):
279 """
280 Assign mastership to controllers
281 """
282 import re
283
284 main.case( "Assign switches to controllers" )
285 main.step( "Assigning switches to controllers" )
286 main.caseExplanation = "Assign OF " + main.OFProtocol +\
287 " switches to ONOS nodes"
288
289 assignResult = main.TRUE
290 switchList = []
291
292 # Creates a list switch name, use getSwitch() function later...
293 for i in range( 1, ( main.numSwitch + 1 ) ):
294 switchList.append( 's' + str( i ) )
295
296 tempONOSip = []
297 for i in range( main.numCtrls ):
298 tempONOSip.append( main.ONOSip[ i ] )
299
300 assignResult = main.Mininet1.assignSwController( sw=switchList,
301 ip=tempONOSip,
Subhash Kumar Singh5ea4d302015-11-05 14:36:52 +0530302 port='6633' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800303 if not assignResult:
304 main.cleanup()
305 main.exit()
306
307 for i in range( 1, ( main.numSwitch + 1 ) ):
308 response = main.Mininet1.getSwController( "s" + str( i ) )
309 print( "Response is " + str( response ) )
310 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
311 assignResult = assignResult and main.TRUE
312 else:
313 assignResult = main.FALSE
314 stepResult = assignResult
315 utilities.assert_equals( expect=main.TRUE,
316 actual=stepResult,
317 onpass="Successfully assigned switches" +
318 "to controller",
319 onfail="Failed to assign switches to " +
320 "controller" )
321
322 def CASE14( self, main ):
323 """
324 Stop mininet
325 """
326 main.log.report( "Stop Mininet topology" )
327 main.case( "Stop Mininet topology" )
328 main.caseExplanation = "Stopping the current mininet topology " +\
329 "to start up fresh"
330
331 main.step( "Stopping Mininet Topology" )
332 topoResult = main.Mininet1.stopNet( )
333 stepResult = topoResult
334 utilities.assert_equals( expect=main.TRUE,
335 actual=stepResult,
336 onpass="Successfully stop mininet",
337 onfail="Failed to stop mininet" )
338 # Exit if topology did not load properly
339 if not topoResult:
340 main.cleanup()
341 main.exit()
Subhash Kumar Singh5ea4d302015-11-05 14:36:52 +0530342
343 def CASE2000( self, main ):
344 """
345 add point intents between 2 hosts:
346 - Get device ids | ports
347 - Add point intents
348 - Check intents
349 - Verify flows
350 - Ping hosts
351 - Reroute
352 - Link down
353 - Verify flows
354 - Check topology
355 - Ping hosts
356 - Link up
357 - Verify flows
358 - Check topology
359 - Ping hosts
360 - Remove intents
361 """
362 import time
363 import json
364 import re
365
366 # Assert variables - These variable's name|format must be followed
367 # if you want to use the wrapper function
368 assert main, "There is no main"
369 assert main.CLIs, "There is no main.CLIs"
370 assert main.Mininet1, "Mininet handle should be named Mininet1"
371 assert main.numSwitch, "Placed the total number of switch topology in \
372 main.numSwitch"
373
374 main.testName = "Point Intents"
375 main.case( main.testName + " Test - " + str( main.numCtrls ) +
376 " NODE(S) - OF " + main.OFProtocol )
377 main.caseExplanation = "This test case will test point to point" +\
378 " intents using " + str( main.numCtrls ) +\
379 " node(s) cluster;\n" +\
380 "Different type of hosts will be tested in " +\
381 "each step such as IPV4, Dual stack, VLAN etc" +\
382 ";\nThe test will use OF " + main.OFProtocol +\
383 " OVS running in Mininet"
384
385 # No option point intents
386 main.step( "NOOPTION: Add point intents between h1 and h9, ipv6 hosts" )
387 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
388 stepResult = main.TRUE
389 stepResult = main.intentFunction.pointIntent(
390 main,
391 name="NOOPTION",
392 host1="h1",
393 host2="h9",
394 deviceId1="of:0000000000000005/1",
395 deviceId2="of:0000000000000006/1")
396
397 utilities.assert_equals( expect=main.TRUE,
398 actual=stepResult,
399 onpass=main.assertReturnString,
400 onfail=main.assertReturnString )
401
402 stepResult = main.TRUE
403 main.step( "IPV6: Add point intents between h1 and h9" )
404 main.assertReturnString = "Assertion Result for IPV6 point intent\n"
405 stepResult = main.intentFunction.pointIntent(
406 main,
407 name="IPV6",
408 host1="h1",
409 host2="h9",
410 deviceId1="of:0000000000000005/1",
411 deviceId2="of:0000000000000006/1",
412 port1="",
413 port2="",
414 ethType="IPV6",
415 mac1="00:00:00:00:00:01",
416 mac2="00:00:00:00:00:09",
417 bandwidth="",
418 lambdaAlloc=False,
419 ipProto="",
420 ip1="",
421 ip2="",
422 tcp1="",
423 tcp2="",
424 expectedLink=18 )
425
426 utilities.assert_equals( expect=main.TRUE,
427 actual=stepResult,
428 onpass=main.assertReturnString,
429 onfail=main.assertReturnString )
430
431 main.step( "IPV6_2: Add point intents between h1 and h9" )
432 main.assertReturnString = "Assertion Result for IPV6 no mac address point intents\n"
433 stepResult = main.intentFunction.pointIntent(
434 main,
435 name="IPV6_2",
436 host1="h1",
437 host2="h9",
438 deviceId1="of:0000000000000005/1",
439 deviceId2="of:0000000000000006/1",
440 ipProto="",
441 ip1="",
442 ip2="",
443 tcp1="",
444 tcp2="",
445 expectedLink=18 )
446
447 utilities.assert_equals( expect=main.TRUE,
448 actual=stepResult,
449 onpass=main.assertReturnString,
450 onfail=main.assertReturnString )
451 """
452 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
453 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
454 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
455 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
456 try:
457 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
458 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
459 except KeyError:
460 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
461 "main.hostsData" )
462 ip1 = main.Mininet1.getIPAddress( 'h1')
463 ip2 = main.Mininet1.getIPAddress( 'h9')
464
465 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
466 # Uneccessary, not including this in the selectors
467 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
468 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
469
470 stepResult = main.intentFunction.pointIntent(
471 main,
472 name="SDNIP-ICMP",
473 host1="h1",
474 host2="h9",
475 deviceId1="of:0000000000000005/1",
476 deviceId2="of:0000000000000006/1",
477 mac1=mac1,
478 mac2=mac2,
479 ethType="IPV6",
480 ipProto=ipProto,
481 ip1=ip1,
482 ip2=ip2 )
483
484 utilities.assert_equals( expect=main.TRUE,
485 actual=stepResult,
486 onpass=main.assertReturnString,
487 onfail=main.assertReturnString )
488
489 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
490 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
491 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
492 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
493 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
494 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
495 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
496 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
497 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
498
499 stepResult = main.intentFunction.pointIntentTcp(
500 main,
501 name="SDNIP-TCP",
502 host1="h1",
503 host2="h9",
504 deviceId1="of:0000000000000005/1",
505 deviceId2="of:0000000000000006/1",
506 mac1=mac1,
507 mac2=mac2,
508 ethType="IPV4",
509 ipProto=ipProto,
510 ip1=ip1,
511 ip2=ip2,
512 tcp1=tcp1,
513 tcp2=tcp2 )
514
515 utilities.assert_equals( expect=main.TRUE,
516 actual=stepResult,
517 onpass=main.assertReturnString,
518 onfail=main.assertReturnString )
519
520 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
521 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
522 stepResult = main.intentFunction.pointIntent(
523 main,
524 name="DUALSTACK1",
525 host1="h3",
526 host2="h11",
527 deviceId1="of:0000000000000005",
528 deviceId2="of:0000000000000006",
529 port1="3",
530 port2="3",
531 ethType="IPV4",
532 mac1="00:00:00:00:00:03",
533 mac2="00:00:00:00:00:0B",
534 bandwidth="",
535 lambdaAlloc=False,
536 ipProto="",
537 ip1="",
538 ip2="",
539 tcp1="",
540 tcp2="",
541 sw1="s5",
542 sw2="s2",
543 expectedLink=18 )
544
545 utilities.assert_equals( expect=main.TRUE,
546 actual=stepResult,
547 onpass=main.assertReturnString,
548 onfail=main.assertReturnString )
549
550 main.step( "VLAN: Add point intents between h5 and h21" )
551 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
552 stepResult = main.intentFunction.pointIntent(
553 main,
554 name="VLAN",
555 host1="h5",
556 host2="h21",
557 deviceId1="of:0000000000000005/5",
558 deviceId2="of:0000000000000007/5",
559 port1="",
560 port2="",
561 ethType="IPV4",
562 mac1="00:00:00:00:00:05",
563 mac2="00:00:00:00:00:15",
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( "1HOP: Add point intents between h1 and h3" )
581 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
582 stepResult = main.intentFunction.hostIntent( main,
583 name='1HOP',
584 host1='h1',
585 host2='h9',
586 host1Id='00:00:00:00:00:01/-1',
587 host2Id='00:00:00:00:00:09/-1')
588
589 utilities.assert_equals( expect=main.TRUE,
590 actual=stepResult,
591 onpass=main.assertReturnString,
592 onfail=main.assertReturnString )
593 """
594 main.intentFunction.report( main )