blob: 95e90fde49d23ce9ea0e8a6d9b42495b0b11392d [file] [log] [blame]
zhanghaoyu451c1392015-08-07 19:21:16 +08001"""
2Description: This test is to check onos set configuration and flows with ovsdb connection.
3
4List of test cases:
5CASE1: Compile ONOS and push it to the test machines
6CASE2: Test ovsdb connection and tearDown
7CASE3: Test default br-int configuration and vxlan port
8CASE4: Test default openflow configuration
9CASE5: Test default flows
zhanghaoyu7474d8c62015-08-26 14:53:28 +080010CASE6: Configure Network Subnet Port
zhanghaoyu451c1392015-08-07 19:21:16 +080011CASE7: Test host go online and ping each other
zhanghaoyu7474d8c62015-08-26 14:53:28 +080012CASE8: Clear ovs configuration and host configuration
zhanghaoyu451c1392015-08-07 19:21:16 +080013zhanghaoyu7@huawei.com
14"""
15import os
16
17class FUNCovsdbtest:
18
19 def __init__( self ):
20 self.default = ''
21
22 def CASE1( self, main ):
23 """
24 CASE1 is to compile ONOS and push it to the test machines
25
26 Startup sequence:
27 cell <name>
28 onos-verify-cell
29 NOTE: temporary - onos-remove-raft-logs
30 onos-uninstall
31 start mininet
32 git pull
33 mvn clean install
34 onos-package
35 onos-install -f
36 onos-wait-for-start
37 start cli sessions
38 start ovsdb
39 start vtn apps
40 """
41 import os
42 main.log.info( "ONOS Single node start " +
43 "ovsdb test - initialization" )
44 main.case( "Setting up test environment" )
45 main.caseExplanation = "Setup the test environment including " +\
46 "installing ONOS, start ONOS."
47
48 # load some variables from the params file
49 PULLCODE = False
50 if main.params[ 'GIT' ][ 'pull' ] == 'True':
51 PULLCODE = True
52 gitBranch = main.params[ 'GIT' ][ 'branch' ]
53 cellName = main.params[ 'ENV' ][ 'cellName' ]
54 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
55 OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
56 OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
57
58 main.step( "Create cell file" )
59 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
60 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
61 main.OVSDB1.ip_address,
62 cellAppString, ipList )
63
64 main.step( "Applying cell variable to environment" )
65 cellResult = main.ONOSbench.setCell( cellName )
66 verifyResult = main.ONOSbench.verifyCell()
67
68 main.log.info( "Removing raft logs" )
69 main.ONOSbench.onosRemoveRaftLogs()
70
71 main.CLIs = []
72 main.nodes = []
73 main.numCtrls= 1
74
75 for i in range( 1, main.numCtrls + 1 ):
76 try:
77 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
78 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
79 ipList.append( main.nodes[ -1 ].ip_address )
80 except AttributeError:
81 break
82
83 main.log.info( "Uninstalling ONOS" )
84 for node in main.nodes:
85 main.ONOSbench.onosUninstall( node.ip_address )
86
87 # Make sure ONOS process is not running
88 main.log.info( "Killing any ONOS processes" )
89 killResults = main.TRUE
90 for node in main.nodes:
91 killed = main.ONOSbench.onosKill( node.ip_address )
92 killResults = killResults and killed
93
94 cleanInstallResult = main.TRUE
95 gitPullResult = main.TRUE
96 main.step( "Git checkout and pull" + gitBranch )
97 if PULLCODE:
98 main.ONOSbench.gitCheckout( gitBranch )
99 gitPullResult = main.ONOSbench.gitPull()
100 # values of 1 or 3 are good
101 utilities.assert_lesser( expect=0, actual=gitPullResult,
102 onpass="Git pull successful",
103 onfail="Git pull failed" )
104
105 main.ONOSbench.getVersion( report=True )
106
107 main.step( "Using mvn clean install" )
108 cleanInstallResult = main.TRUE
109 if PULLCODE and gitPullResult == main.TRUE:
110 cleanInstallResult = main.ONOSbench.cleanInstall()
111 else:
112 main.log.warn( "Did not pull new code so skipping mvn" +
113 "clean install" )
114 utilities.assert_equals( expect=main.TRUE,
115 actual=cleanInstallResult,
116 onpass="MCI successful",
117 onfail="MCI failed" )
118
119 main.step( "Creating ONOS package" )
120 packageResult = main.ONOSbench.onosPackage()
121 utilities.assert_equals( expect=main.TRUE,
122 actual=packageResult,
123 onpass="Successfully created ONOS package",
124 onfail="Failed to create ONOS package" )
125
126 main.step( "Installing ONOS package" )
127 onosInstallResult = main.ONOSbench.onosInstall(
128 options="-f", node=main.nodes[0].ip_address )
129 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
130 onpass="ONOS install successful",
131 onfail="ONOS install failed" )
132
133 main.step( "Checking if ONOS is up yet" )
134 print main.nodes[0].ip_address
135 for i in range( 2 ):
136 onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
137 if onos1Isup:
138 break
139 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
140 onpass="ONOS startup successful",
141 onfail="ONOS startup failed" )
142 main.log.step( "Starting ONOS CLI sessions" )
143 print main.nodes[0].ip_address
144 cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
145 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
146 onpass="ONOS cli startup successful",
147 onfail="ONOS cli startup failed" )
148
149 main.step( "App Ids check" )
150 appCheck = main.ONOScli1.appToIDCheck()
151
152 if appCheck !=main.TRUE:
153 main.log.warn( main.CLIs[0].apps() )
154 main.log.warn( main.CLIs[0].appIDs() )
155 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
156 onpass="App Ids seem to be correct",
157 onfail="Something is wrong with app Ids" )
158 if cliResults == main.FALSE:
159 main.log.error( "Failed to start ONOS,stopping test" )
160 main.cleanup()
161 main.exit()
162
163 main.step( "Install onos-ovsdatabase" )
164 installResults = main.ONOScli1.activateApp( "org.onosproject.ovsdb" )
165 utilities.assert_equals( expect=main.TRUE, actual=installResults,
166 onpass="Install onos-ovsdatabase successful",
167 onfail="Install onos-ovsdatabase failed" )
168
169 main.step( "Install onos-app-vtnrsc" )
170 installResults = main.ONOScli1.activateApp( "org.onosproject.vtnrsc" )
171 utilities.assert_equals( expect=main.TRUE, actual=installResults,
172 onpass="Install onos-app-vtnrsc successful",
173 onfail="Install onos-app-vtnrsc failed" )
174
175 main.step( "Install onos-app-vtn" )
176 installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" )
177 utilities.assert_equals( expect=main.TRUE, actual=installResults,
178 onpass="Install onos-app-vtn successful",
179 onfail="Install onos-app-vtn failed" )
180
181 main.step( "Install onos-app-vtnweb" )
182 installResults = main.ONOScli1.activateApp( "org.onosproject.vtnweb" )
183 utilities.assert_equals( expect=main.TRUE, actual=installResults,
184 onpass="Install onos-app-vtnweb successful",
185 onfail="Install onos-app-vtnweb failed" )
186
187 def CASE2( self, main ):
188
189 """
190 Test ovsdb connection and teardown
191 """
192 import os,sys
193 import re
194 import time
195
196 main.case( "Test ovsdb connection and teardown" )
197 main.caseExplanation = "Test ovsdb connection create and delete" +\
198 " over ovsdb node and onos node "
199
200 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
201 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
202 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
203
204 main.step( "Set ovsdb node manager" )
205 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
206 stepResult = assignResult
207 utilities.assert_equals( expect=main.TRUE,
208 actual=stepResult,
209 onpass="Set ovsdb node manager sucess",
210 onfail="Set ovsdb node manager failed" )
211
212 main.step( "Check ovsdb node manager is " + str( ctrlip ) )
213 response = main.OVSDB1.getManager()
214 if re.search( ctrlip, response ):
215 stepResult = main.TRUE
216 else:
217 stepResult = main.FALSE
218 utilities.assert_equals( expect=main.TRUE,
219 actual=stepResult,
220 onpass="Check ovsdb node manager is " + str( response ) ,
221 onfail="Check ovsdb node manager failed" )
222
223 main.step( "Delete ovsdb node manager" )
224 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
225 stepResult = deleteResult
226 utilities.assert_equals( expect=main.TRUE,
227 actual=stepResult,
228 onpass="ovsdb node delete manager sucess",
229 onfail="ovsdb node delete manager failed" )
230
231 main.step( "Check ovsdb node delete manager " + str( ctrlip ) )
232 response = main.OVSDB1.getManager()
233 if not re.search( ctrlip, response ):
234 stepResult = main.TRUE
235 else:
236 stepResult = main.FALSE
237 utilities.assert_equals( expect=main.TRUE,
238 actual=stepResult,
239 onpass="Check ovsdb node delete manager sucess",
240 onfail="Check ovsdb node delete manager failed" )
241
242 def CASE3( self, main ):
243
244 """
245 Test default br-int configuration and vxlan port
246 """
247 import re
248 import time
249 import os,sys
250
251 main.case( "Test default br-int configuration and vxlan port" )
252 main.caseExplanation = "onos create default br-int bridge and" +\
253 " vxlan port on the ovsdb node"
254
255 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
256 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
257 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
258
259 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
260 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
261 stepResult = assignResult
262 utilities.assert_equals( expect=main.TRUE,
263 actual=stepResult,
264 onpass="ovsdb node 1 set ovs manager to to " +\
265 str( ctrlip ) + " sucess",
266 onfail="ovsdb node 1 set ovs manager to to " +\
267 str( ctrlip ) + " failed" )
268
269 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
270 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
271 stepResult = assignResult
272 utilities.assert_equals( expect=main.TRUE,
273 actual=stepResult,
274 onpass="ovsdb node 2 set ovs manager to to " +\
275 str( ctrlip ) + " sucess",
276 onfail="ovsdb node 2 set ovs manager to to " +\
277 str( ctrlip ) + " failed" )
278
279 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
280 response = main.OVSDB1.getManager()
281 if re.search( ctrlip, response ):
282 stepResult = main.TRUE
283 else:
284 stepResult = main.FALSE
285 utilities.assert_equals( expect=main.TRUE,
286 actual=stepResult,
287 onpass="ovsdb node 1 manager is " + str( response ) ,
288 onfail="ovsdb node 1 manager check failed" )
289
290 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
291 response = main.OVSDB2.getManager()
292 if re.search( ctrlip, response ):
293 stepResult = main.TRUE
294 else:
295 stepResult = main.FALSE
296 utilities.assert_equals( expect=main.TRUE,
297 actual=stepResult,
298 onpass="ovsdb node 2 manager is " + str( response ) ,
299 onfail="ovsdb node 2 manager check failed" )
300
301 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) )
302 response = main.OVSDB1.listBr()
303 if re.search( "br-int", response ):
304 stepResult = main.TRUE
305 else:
306 stepResult = main.FALSE
307 utilities.assert_equals( expect=main.TRUE,
308 actual=stepResult,
309 onpass="onos add default bridge on the node 1 sucess",
310 onfail="onos add default bridge on the node 1 failed" )
311
312 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB2Ip ) )
313 response = main.OVSDB2.listBr()
314 if re.search( "br-int", response ):
315 stepResult = main.TRUE
316 else:
317 stepResult = main.FALSE
318 utilities.assert_equals( expect=main.TRUE,
319 actual=stepResult,
320 onpass="onos add default bridge on the node 2 sucess",
321 onfail="onos add default bridge on the node 2 failed" )
322
323 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB1Ip ) )
324 response = main.OVSDB1.listPorts( "br-int" )
325 if re.search( "vxlan", response ) and re.search( str( OVSDB2Ip ), response ):
326 stepResult = main.TRUE
327 else:
328 stepResult = main.FALSE
329 utilities.assert_equals( expect=main.TRUE,
330 actual=stepResult,
331 onpass="onos add default vxlan port on the node 1 sucess",
332 onfail="onos add default vxlan port on the node 1 failed" )
333
334 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB2Ip ) )
335 response = main.OVSDB2.listPorts( "br-int" )
336 if re.search( "vxlan", response ) and re.search( str( OVSDB1Ip ), response ):
337 stepResult = main.TRUE
338 else:
339 stepResult = main.FALSE
340 utilities.assert_equals( expect=main.TRUE,
341 actual=stepResult,
342 onpass="onos add default vxlan port on the node 2 sucess",
343 onfail="onos add default vxlan port on the node 2 failed" )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800344
345 def CASE4( self, main ):
346
347 """
348 Test default openflow configuration
349 """
350 import re
351 import time
352 import os,sys
353
354 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
355 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
356 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
357
358 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
359 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
360 stepResult = assignResult
361 utilities.assert_equals( expect=main.TRUE,
362 actual=stepResult,
363 onpass="ovsdb node 1 set ovs manager to to " +\
364 str( ctrlip ) + " sucess",
365 onfail="ovsdb node 1 set ovs manager to to " +\
366 str( ctrlip ) + " failed" )
367
368 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
369 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
370 stepResult = assignResult
371 utilities.assert_equals( expect=main.TRUE,
372 actual=stepResult,
373 onpass="ovsdb node 2 set ovs manager to to " +\
374 str( ctrlip ) + " sucess",
375 onfail="ovsdb node 2 set ovs manager to to " +\
376 str( ctrlip ) + " failed" )
377
378 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
379 response = main.OVSDB1.getManager()
380 if re.search( ctrlip, response ):
381 stepResult = main.TRUE
382 else:
383 stepResult = main.FALSE
384 utilities.assert_equals( expect=main.TRUE,
385 actual=stepResult,
386 onpass="ovsdb node 1 manager is " + str( response ) ,
387 onfail="ovsdb node 1 manager check failed" )
388
389 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
390 response = main.OVSDB2.getManager()
391 if re.search( ctrlip, response ):
392 stepResult = main.TRUE
393 else:
394 stepResult = main.FALSE
395 utilities.assert_equals( expect=main.TRUE,
396 actual=stepResult,
397 onpass="ovsdb node 2 manager is " + str( response ) ,
398 onfail="ovsdb node 2 manager check failed" )
399
400 main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) )
401 response = main.OVSDB1.getController( "br-int" )
402 if re.search( ctrlip, response ):
403 stepResult = main.TRUE
404 else:
405 stepResult = main.FALSE
406 utilities.assert_equals( expect=main.TRUE,
407 actual=stepResult,
408 onpass="Check ovsdb node 1 bridge br-int controller set to " +\
409 str( ctrlip ) + " sucess",
410 onfail="Check ovsdb node 1 bridge br-int controller set to " +\
411 str( ctrlip ) + " failed" )
412
413 main.step( "Check ovsdb node 2 bridge br-int controller set to " + str( ctrlip ) )
414 response = main.OVSDB2.getController( "br-int" )
415 if re.search( ctrlip, response ):
416 stepResult = main.TRUE
417 else:
418 stepResult = main.FALSE
419 utilities.assert_equals( expect=main.TRUE,
420 actual=stepResult,
421 onpass="Check ovsdb node 2 bridge br-int controller set to " +\
422 str( ctrlip ) + " sucess",
423 onfail="Check ovsdb node 2 bridge br-int controller set to " +\
424 str( ctrlip ) + " failed" )
425
426 main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) )
427 response = main.ONOScli1.devices()
428 if re.search( OVSDB1Ip, response ) and not re.search( "false", response ):
429 stepResult = main.TRUE
430 else:
431 stepResult = main.FALSE
432 utilities.assert_equals( expect=main.TRUE,
433 actual=stepResult,
434 onpass="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " sucess",
435 onfail="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " failed" )
436
437 main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
438 response = main.ONOScli1.devices()
439 if re.search( OVSDB2Ip, response ) and not re.search( "false", response ):
440 stepResult = main.TRUE
441 else:
442 stepResult = main.FALSE
443 utilities.assert_equals( expect=main.TRUE,
444 actual=stepResult,
445 onpass="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " sucess",
446 onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" )
447
448 def CASE5( self, main ):
449
450 """
451 Test default flows
452 """
453 import re
454 import time
455 import os,sys
456
457 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
458 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
459 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
460
461 main.step( "ovsdb node 1 set ovs manager to onos" )
462 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
463 stepResult = assignResult
464 utilities.assert_equals( expect=main.TRUE,
465 actual=stepResult,
466 onpass="ovsdb node 1 set ovs manager to to " +\
467 str( ctrlip ) + " sucess",
468 onfail="ovsdb node 1 set ovs manager to to " +\
469 str( ctrlip ) + " failed" )
470
471 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
472 response = main.OVSDB1.getManager()
473 if re.search( ctrlip, response ):
474 stepResult = main.TRUE
475 else:
476 stepResult = main.FALSE
477 utilities.assert_equals( expect=main.TRUE,
478 actual=stepResult,
479 onpass="ovsdb node 1 manager is " + str( response ) ,
480 onfail="ovsdb node 1 manager check failed" )
481
482 main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) )
483 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
484 if re.search( "actions=CONTROLLER", response ):
485 stepResult = main.TRUE
486 else:
487 stepResult = main.FALSE
488 utilities.assert_equals( expect=main.TRUE,
489 actual=stepResult,
490 onpass="Successfully set default flows " + str( ctrlip ) ,
491 onfail="Failed to set default flows " + str( ctrlip ) )
492
493 def CASE6( self, main ):
494 """
495 Configure Network Subnet Port
496 """
497 import os
498
499 try:
500 from tests.FUNCovsdbtest.dependencies.Nbdata import NetworkData
501 from tests.FUNCovsdbtest.dependencies.Nbdata import SubnetData
502 from tests.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData
503 except ImportError:
504 main.log.exception( "Something wrong with import file or code error." )
505 main.log.info( "Import Error, please check!" )
506 main.cleanup()
507 main.exit()
508
509 main.log.info( "Configure Network Subnet Port Start" )
510 main.case( "Configure Network Subnet Port" )
511 main.caseExplanation = "Configure Network Subnet Port " +\
512 "Verify post is OK"
513
514 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
515 httpport = main.params['HTTP']['port']
516 path = main.params['HTTP']['path']
517
518 main.step( "Generate Post Data" )
519 network = NetworkData()
520 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
521 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
522 subnet = SubnetData()
523 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
524 subnet.tenant_id = network.tenant_id
525 subnet.network_id = network.id
526 subnet.start = "10.0.0.1"
527 subnet.end = "10.0.0.254"
528 subnet.cidr = "10.0.0.0/24"
529 port1 = VirtualPortData()
530 port1.id = "00000000-0000-0000-0000-000000000001"
531 port1.subnet_id = subnet.id
532 port1.tenant_id = network.tenant_id
533 port1.network_id = network.id
534 port1.macAddress = "00:00:00:00:00:01"
535 port1.ip_address = "10.0.0.1"
536 port2 = VirtualPortData()
537 port2.id = "00000000-0000-0000-0000-000000000002"
538 port2.subnet_id = subnet.id
539 port2.tenant_id = network.tenant_id
540 port2.network_id = network.id
541 port2.macAddress = "00:00:00:00:00:02"
542 port2.ip_address = "10.0.0.2"
543
544 networkpostdata = network.DictoJson()
545 subnetpostdata = subnet.DictoJson()
546 port1postdata = port1.DictoJson()
547 port2postdata = port2.DictoJson()
548
549 main.step( "Post Network Data via HTTP(Post port need post network)" )
550 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
551 'POST', None, networkpostdata )
552 utilities.assert_equals(
553 expect='200',
554 actual=Poststatus,
555 onpass="Post Network Success",
556 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
557
558 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
559 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
560 'POST', None, subnetpostdata )
561 utilities.assert_equals(
562 expect='202',
563 actual=Poststatus,
564 onpass="Post Subnet Success",
565 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
566
567 main.step( "Post Port1 Data via HTTP" )
568 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
569 'POST', None, port1postdata )
570 utilities.assert_equals(
571 expect='200',
572 actual=Poststatus,
573 onpass="Post Port Success",
574 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
575
576 main.step( "Post Port2 Data via HTTP" )
577 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
578 'POST', None, port2postdata )
579 utilities.assert_equals(
580 expect='200',
581 actual=Poststatus,
582 onpass="Post Port Success",
583 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
584
585 def CASE7( self, main ):
586
587 """
588 Test host go online and ping each other
589 """
590 import re
591 import time
592 import os,sys
593
594 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
595 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
596 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
597
598 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
599 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
600 stepResult = assignResult
601 utilities.assert_equals( expect=main.TRUE,
602 actual=stepResult,
603 onpass="ovsdb node 1 set ovs manager to to " +\
604 str( ctrlip ) + " sucess",
605 onfail="ovsdb node 1 set ovs manager to to " +\
606 str( ctrlip ) + " failed" )
607
608 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
609 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
610 stepResult = assignResult
611 utilities.assert_equals( expect=main.TRUE,
612 actual=stepResult,
613 onpass="ovsdb node 2 set ovs manager to " +\
614 str( ctrlip ) + " sucess",
615 onfail="ovsdb node 2 set ovs manager to " +\
616 str( ctrlip ) + " failed" )
617
618 main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) )
619 stepResult = main.OVSDB1.createHost( hostname="host1" )
620 utilities.assert_equals( expect=main.TRUE,
621 actual=stepResult,
622 onpass="Create host1 on node 1 " + str( OVSDB1Ip ) + " sucess",
623 onfail="Create host1 on node 1 " + str( OVSDB1Ip ) + " failed" )
624
625 main.step( "Create host2 on node 2 " + str( OVSDB2Ip ) )
626 stepResult = main.OVSDB2.createHost( hostname="host2" )
627 utilities.assert_equals( expect=main.TRUE,
628 actual=stepResult,
629 onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess",
630 onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" )
631
632 main.step( "Create port on host1 on the node " + str ( OVSDB1Ip ) )
633 stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" )
634 utilities.assert_equals( expect=main.TRUE,
635 actual=stepResult,
636 onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess",
637 onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" )
638
639 main.step( "Create port on host2 on the node " + str ( OVSDB2Ip ) )
640 stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" )
641 utilities.assert_equals( expect=main.TRUE,
642 actual=stepResult,
643 onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess",
644 onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" )
645
646 main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB1Ip ) )
647 stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001",
648 attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" )
649 utilities.assert_equals( expect=main.TRUE,
650 actual=stepResult,
651 onpass="Add port to ovs br-int and host go-online on the node " +\
652 str( OVSDB1Ip ) + " sucess",
653 onfail="Add port to ovs br-int and host go-online on the node " +\
654 str( OVSDB1Ip ) + " failed" )
655
656 main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB2Ip ) )
657 stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002",
658 attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" )
659 utilities.assert_equals( expect=main.TRUE,
660 actual=stepResult,
661 onpass="Add port to ovs br-int and host go-online on the node " +\
662 str( OVSDB2Ip ) + " sucess",
663 onfail="Add port to ovs br-int and host go-online on the node " +\
664 str( OVSDB2Ip ) + " failed" )
665
666 main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) )
667 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
668 if re.search( "00:00:00:00:00:01", response ):
669 stepResult = main.TRUE
670 else:
671 stepResult = main.FALSE
672 utilities.assert_equals( expect=main.TRUE,
673 actual=stepResult,
674 onpass="Check onos set host flows on the node " +\
675 str( OVSDB1Ip ) + " sucess",
676 onfail="Check onos set host flows on the node " +\
677 str( OVSDB1Ip ) + " failed" )
678
679 main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) )
680 response = main.OVSDB2.dumpFlows( sw="br-int", protocols="OpenFlow13" )
681 if re.search( "00:00:00:00:00:02", response ):
682 stepResult = main.TRUE
683 else:
684 stepResult = main.FALSE
685 utilities.assert_equals( expect=main.TRUE,
686 actual=stepResult,
687 onpass="Check onos set host flows on the node " +\
688 str( OVSDB2Ip ) + " sucess",
689 onfail="Check onos set host flows on the node " +\
690 str( OVSDB2Ip ) + " failed" )
691
692 main.step( "Check hosts can ping each other" )
693 main.OVSDB1.setHostportIp( hostname="host1", hostport1="host1-eth0", ip="10.0.0.1" )
694 main.OVSDB2.setHostportIp( hostname="host2", hostport1="host2-eth0", ip="10.0.0.2" )
695 pingResult1 = main.OVSDB1.hostPing( src="10.0.0.1", hostname="host1", target="10.0.0.2" )
696 pingResult2 = main.OVSDB2.hostPing( src="10.0.0.2", hostname="host2", target="10.0.0.1" )
697 stepResult = pingResult1 and pingResult2
698 utilities.assert_equals( expect=main.TRUE,
699 actual=stepResult,
700 onpass="Successfully host go online and ping each other,controller is " +\
701 str( ctrlip ),
702 onfail="Failed to host go online and ping each other,controller is " +\
703 str( ctrlip ) )
704
705 def CASE8( self, main ):
706
707 """
708 Clear ovs configuration and host configuration
709 """
710 import re
711 import time
712 import os,sys
713
714 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
715 OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
716 OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
717 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
718
719 main.step( "Delete ovsdb node 1 manager" )
720 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
721 stepResult = deleteResult
722 utilities.assert_equals( expect=main.TRUE,
723 actual=stepResult,
724 onpass="ovsdb node 1 delete manager sucess",
725 onfail="ovsdb node 1 delete manager failed" )
726
727 main.step( "Delete ovsdb node 2 manager" )
728 deleteResult = main.OVSDB2.delManager( delaytime=delaytime )
729 stepResult = deleteResult
730 utilities.assert_equals( expect=main.TRUE,
731 actual=stepResult,
732 onpass="ovsdb node 2 delete manager sucess",
733 onfail="ovsdb node 2 delete manager failed" )
734
735 main.step( "Delete ovsdb node 1 bridge br-int" )
736 deleteResult = main.OVSDB1.delBr( sw="br-int" )
737 stepResult = deleteResult
738 utilities.assert_equals( expect=main.TRUE,
739 actual=stepResult,
740 onpass="Delete ovsdb node 1 bridge br-int sucess",
741 onfail="Delete ovsdb node 1 bridge br-int failed" )
742
743 main.step( "Delete ovsdb node 2 bridge br-int" )
744 deleteResult = main.OVSDB2.delBr( sw="br-int" )
745 stepResult = deleteResult
746 utilities.assert_equals( expect=main.TRUE,
747 actual=stepResult,
748 onpass="Delete ovsdb node 2 bridge br-int sucess",
749 onfail="Delete ovsdb node 2 bridge br-int failed" )
750
751 main.step( "Delete ip netns host on the ovsdb node 1" )
752 deleteResult = main.OVSDB1.delHost( hostname="host1" )
753 stepResult = deleteResult
754 utilities.assert_equals( expect=main.TRUE,
755 actual=stepResult,
756 onpass="Delete ip netns host on the ovsdb node 1 sucess",
757 onfail="Delete ip netns host on the ovsdb node 1 failed" )
758
759 main.step( "Delete ip netns host on the ovsdb node 2" )
760 deleteResult = main.OVSDB2.delHost( hostname="host2" )
761 stepResult = deleteResult
762 utilities.assert_equals( expect=main.TRUE,
763 actual=stepResult,
764 onpass="Delete ip netns host on the ovsdb node 2 sucess",
765 onfail="Delete ip netns host on the ovsdb node 2 failed" )
766
767 main.step( "Check onoscli devices openflow session is false " + str( OVSDB1Ip ) )
768 response = main.ONOScli1.devices()
769 if re.search( OVSDB1Ip, response ) and not re.search( "true", response ):
770 stepResult = main.TRUE
771 else:
772 stepResult = main.FALSE
773 utilities.assert_equals( expect=main.TRUE,
774 actual=stepResult,
775 onpass="Check openflow session is false " + str( OVSDB1Ip ) + " sucess",
776 onfail="Check openflow session is false " + str( OVSDB1Ip ) + " failed" )
777
778 main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
779 response = main.ONOScli1.devices()
780 if re.search( OVSDB2Ip, response ) and not re.search( "true", response ):
781 stepResult = main.TRUE
782 else:
783 stepResult = main.FALSE
784 utilities.assert_equals( expect=main.TRUE,
785 actual=stepResult,
786 onpass="Check openflow session is false " + str( OVSDB2Ip ) + " sucess",
787 onfail="Check openflow session is false " + str( OVSDB2Ip ) + " failed" )