blob: 91475c6432f76466c959c3090a18c5606f923ce2 [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:
alison6acef9f2016-09-28 12:29:08 -070027 Construct test variables
28 Safety check, kill all ONOS processes before setup
zhanghaoyu451c1392015-08-07 19:21:16 +080029 NOTE: temporary - onos-remove-raft-logs
alison6acef9f2016-09-28 12:29:08 -070030 Create ONOS package
31 Install ONOS package
zhanghaoyu451c1392015-08-07 19:21:16 +080032 start cli sessions
33 start ovsdb
34 start vtn apps
35 """
36 import os
alison6acef9f2016-09-28 12:29:08 -070037 import time
38 main.log.info( "ONOS Single node start ovsdb test - initialization" )
zhanghaoyu451c1392015-08-07 19:21:16 +080039 main.case( "Setting up test environment" )
40 main.caseExplanation = "Setup the test environment including " +\
41 "installing ONOS, start ONOS."
42
43 # load some variables from the params file
alison6acef9f2016-09-28 12:29:08 -070044 main.step( "Constructing test variables" )
45 gitPull = main.params[ 'GIT' ][ 'pull' ]
zhanghaoyu451c1392015-08-07 19:21:16 +080046 gitBranch = main.params[ 'GIT' ][ 'branch' ]
47 cellName = main.params[ 'ENV' ][ 'cellName' ]
48 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
alison6acef9f2016-09-28 12:29:08 -070049 main.startUpSleep = int( main.params['SLEEP']['startup'] )
50 cellAppString = main.params['ENV']['cellApps']
zhanghaoyu451c1392015-08-07 19:21:16 +080051
alison6acef9f2016-09-28 12:29:08 -070052 if gitPull == 'True':
53 main.step( "Building ONOS in " + gitBranch + "branch" )
54 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
55 stepResult = onosBuildResult
56 utilities.assert_equals( expect=main.TRUE,
57 actual=stepResult,
58 onpass="Successfully compiled latest ONOS",
59 onfail="Failed to compile latest ONOS")
60 else:
61 main.log.warn( "Did not pull new code so skipping mvn " +
62 "clean install" )
63 main.ONOSbench.getVersion( report=True )
zhanghaoyu451c1392015-08-07 19:21:16 +080064
alison6acef9f2016-09-28 12:29:08 -070065 main.log.info( "Safety check, killing all ONOS processes" +
66 " before initiating environment setup" )
zhanghaoyu451c1392015-08-07 19:21:16 +080067
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
alison6acef9f2016-09-28 12:29:08 -070083 main.step( "Uninstalling ONOS package" )
84 onosUninstallResult = main.TRUE
zhanghaoyu451c1392015-08-07 19:21:16 +080085 for node in main.nodes:
alison6acef9f2016-09-28 12:29:08 -070086 onosUninstallResult = onosUninstallResult and main.ONOSbench.onosUninstall( node.ip_address )
87 utilities.assert_equals( expect=main.TRUE,
88 actual=onosUninstallResult,
89 onpass="Successfully uninstalled ONOS package",
90 onfail="Failed to uninstall ONOS package" )
91 time.sleep( main.startUpSleep )
zhanghaoyu451c1392015-08-07 19:21:16 +080092
93 # Make sure ONOS process is not running
94 main.log.info( "Killing any ONOS processes" )
95 killResults = main.TRUE
96 for node in main.nodes:
97 killed = main.ONOSbench.onosKill( node.ip_address )
98 killResults = killResults and killed
zhanghaoyu451c1392015-08-07 19:21:16 +080099 utilities.assert_equals( expect=main.TRUE,
alison6acef9f2016-09-28 12:29:08 -0700100 actual=onosUninstallResult,
101 onpass="Successfully kill all ONOS processes",
102 onfail="Failed to kill all ONOS processes" )
103
104 main.step( "Create cell file" )
105 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
106 main.OVSDB1.ip_address,
107 cellAppString, ipList )
108
109 main.step( "Apply cell to environment" )
110 cellResult = main.ONOSbench.setCell( cellName )
111 verifyResult = main.ONOSbench.verifyCell()
112 stepResult = cellResult and verifyResult
113 utilities.assert_equals( expect=main.TRUE,
114 actual=stepResult,
115 onpass="Successfully applied cell to environment",
116 onfail="Failed to apply cell to environment" )
117
zhanghaoyu451c1392015-08-07 19:21:16 +0800118
119 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700120 packageResult = main.ONOSbench.buckBuild()
zhanghaoyu451c1392015-08-07 19:21:16 +0800121 utilities.assert_equals( expect=main.TRUE,
alison6acef9f2016-09-28 12:29:08 -0700122 actual=packageResult,
123 onpass="Successfully created ONOS package",
124 onfail="Failed to create ONOS package" )
zhanghaoyu451c1392015-08-07 19:21:16 +0800125
alison6acef9f2016-09-28 12:29:08 -0700126 time.sleep( main.startUpSleep )
zhanghaoyu451c1392015-08-07 19:21:16 +0800127 main.step( "Installing ONOS package" )
alison6acef9f2016-09-28 12:29:08 -0700128 onosInstallResult = main.ONOSbench.onosInstall( options="-f", node=main.nodes[0].ip_address )
zhanghaoyu451c1392015-08-07 19:21:16 +0800129 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
alison6acef9f2016-09-28 12:29:08 -0700130 onpass="Successfully installed ONOS package",
131 onfail="Failed to install ONOS package" )
zhanghaoyu451c1392015-08-07 19:21:16 +0800132
alison6acef9f2016-09-28 12:29:08 -0700133 time.sleep( main.startUpSleep )
134 main.step("Starting ONOS service")
135 stopResult = main.TRUE
136 startResult = main.TRUE
137 onos1Isup = main.TRUE
zhanghaoyu451c1392015-08-07 19:21:16 +0800138 for i in range( 2 ):
alison6acef9f2016-09-28 12:29:08 -0700139 Isup = main.ONOSbench.isup( main.nodes[ 0 ].ip_address )
140 onos1Isup = onos1Isup and Isup
zhanghaoyu451c1392015-08-07 19:21:16 +0800141 if onos1Isup:
alison6acef9f2016-09-28 12:29:08 -0700142 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
143 else:
144 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
145 "start ONOS again" )
146 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
147 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
148 if not startResult or stopResult:
149 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) )
150 stepResult = onos1Isup and stopResult and startResult
151 utilities.assert_equals( expect=main.TRUE, actual=stepResult,
152 onpass="ONOS service is ready on all nodes",
153 onfail="ONOS service did not start properly on all nodes" )
154
Jon Hall6509dbf2016-06-21 17:01:17 -0700155 main.step( "Starting ONOS CLI sessions" )
alison6acef9f2016-09-28 12:29:08 -0700156 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
zhanghaoyu451c1392015-08-07 19:21:16 +0800157 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
alison6acef9f2016-09-28 12:29:08 -0700158 onpass="Successfully start ONOS cli",
159 onfail="Failed to start ONOS cli" )
160
161 if cliResults == main.FALSE:
162 main.log.error( "Failed to start ONOS, stopping test" )
163 main.cleanup()
164 main.exit()
zhanghaoyu451c1392015-08-07 19:21:16 +0800165
166 main.step( "App Ids check" )
167 appCheck = main.ONOScli1.appToIDCheck()
168
alison6acef9f2016-09-28 12:29:08 -0700169 if appCheck != main.TRUE:
170 main.log.warn( main.CLIs[ 0 ].apps() )
171 main.log.warn( main.CLIs[ 0 ].appIDs() )
172
173 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
zhanghaoyu451c1392015-08-07 19:21:16 +0800174 onpass="App Ids seem to be correct",
175 onfail="Something is wrong with app Ids" )
zhanghaoyu451c1392015-08-07 19:21:16 +0800176
alisond9915ea2016-08-12 10:16:26 -0700177 main.step( "Install onos-ovsdb" )
zhanghaoyu451c1392015-08-07 19:21:16 +0800178 installResults = main.ONOScli1.activateApp( "org.onosproject.ovsdb" )
179 utilities.assert_equals( expect=main.TRUE, actual=installResults,
180 onpass="Install onos-ovsdatabase successful",
181 onfail="Install onos-ovsdatabase failed" )
182
zhanghaoyu451c1392015-08-07 19:21:16 +0800183 main.step( "Install onos-app-vtn" )
184 installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" )
185 utilities.assert_equals( expect=main.TRUE, actual=installResults,
186 onpass="Install onos-app-vtn successful",
187 onfail="Install onos-app-vtn failed" )
188
zhanghaoyu451c1392015-08-07 19:21:16 +0800189 def CASE2( self, main ):
190
191 """
192 Test ovsdb connection and teardown
193 """
alison6acef9f2016-09-28 12:29:08 -0700194 import os
zhanghaoyu451c1392015-08-07 19:21:16 +0800195 import re
zhanghaoyu451c1392015-08-07 19:21:16 +0800196
197 main.case( "Test ovsdb connection and teardown" )
198 main.caseExplanation = "Test ovsdb connection create and delete" +\
199 " over ovsdb node and onos node "
200
201 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
202 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
203 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
204
205 main.step( "Set ovsdb node manager" )
206 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
207 stepResult = assignResult
208 utilities.assert_equals( expect=main.TRUE,
209 actual=stepResult,
210 onpass="Set ovsdb node manager sucess",
211 onfail="Set ovsdb node manager failed" )
212
213 main.step( "Check ovsdb node manager is " + str( ctrlip ) )
214 response = main.OVSDB1.getManager()
215 if re.search( ctrlip, response ):
216 stepResult = main.TRUE
217 else:
218 stepResult = main.FALSE
219 utilities.assert_equals( expect=main.TRUE,
220 actual=stepResult,
221 onpass="Check ovsdb node manager is " + str( response ) ,
222 onfail="Check ovsdb node manager failed" )
223
224 main.step( "Delete ovsdb node manager" )
225 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
226 stepResult = deleteResult
227 utilities.assert_equals( expect=main.TRUE,
228 actual=stepResult,
229 onpass="ovsdb node delete manager sucess",
230 onfail="ovsdb node delete manager failed" )
231
232 main.step( "Check ovsdb node delete manager " + str( ctrlip ) )
233 response = main.OVSDB1.getManager()
234 if not re.search( ctrlip, response ):
235 stepResult = main.TRUE
236 else:
237 stepResult = main.FALSE
238 utilities.assert_equals( expect=main.TRUE,
239 actual=stepResult,
240 onpass="Check ovsdb node delete manager sucess",
241 onfail="Check ovsdb node delete manager failed" )
242
243 def CASE3( self, main ):
244
245 """
246 Test default br-int configuration and vxlan port
247 """
248 import re
alison6acef9f2016-09-28 12:29:08 -0700249 import os
zhanghaoyu451c1392015-08-07 19:21:16 +0800250
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' ]
alison6acef9f2016-09-28 12:29:08 -0700258 OVSDB1Ip = os.getenv( main.params['OVSDB']['ip1'] )
259 OVSDB2Ip = os.getenv( main.params['OVSDB']['ip2'] )
zhanghaoyu451c1392015-08-07 19:21:16 +0800260
261 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
262 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
263 stepResult = assignResult
264 utilities.assert_equals( expect=main.TRUE,
265 actual=stepResult,
266 onpass="ovsdb node 1 set ovs manager to to " +\
267 str( ctrlip ) + " sucess",
268 onfail="ovsdb node 1 set ovs manager to to " +\
269 str( ctrlip ) + " failed" )
270
271 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
272 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
273 stepResult = assignResult
274 utilities.assert_equals( expect=main.TRUE,
275 actual=stepResult,
276 onpass="ovsdb node 2 set ovs manager to to " +\
277 str( ctrlip ) + " sucess",
278 onfail="ovsdb node 2 set ovs manager to to " +\
279 str( ctrlip ) + " failed" )
280
281 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
282 response = main.OVSDB1.getManager()
283 if re.search( ctrlip, response ):
284 stepResult = main.TRUE
285 else:
286 stepResult = main.FALSE
287 utilities.assert_equals( expect=main.TRUE,
288 actual=stepResult,
289 onpass="ovsdb node 1 manager is " + str( response ) ,
290 onfail="ovsdb node 1 manager check failed" )
291
292 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
293 response = main.OVSDB2.getManager()
294 if re.search( ctrlip, response ):
295 stepResult = main.TRUE
296 else:
297 stepResult = main.FALSE
298 utilities.assert_equals( expect=main.TRUE,
299 actual=stepResult,
300 onpass="ovsdb node 2 manager is " + str( response ) ,
301 onfail="ovsdb node 2 manager check failed" )
302
303 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) )
304 response = main.OVSDB1.listBr()
305 if re.search( "br-int", response ):
306 stepResult = main.TRUE
307 else:
308 stepResult = main.FALSE
309 utilities.assert_equals( expect=main.TRUE,
310 actual=stepResult,
311 onpass="onos add default bridge on the node 1 sucess",
312 onfail="onos add default bridge on the node 1 failed" )
313
314 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB2Ip ) )
315 response = main.OVSDB2.listBr()
316 if re.search( "br-int", response ):
317 stepResult = main.TRUE
318 else:
319 stepResult = main.FALSE
320 utilities.assert_equals( expect=main.TRUE,
321 actual=stepResult,
322 onpass="onos add default bridge on the node 2 sucess",
323 onfail="onos add default bridge on the node 2 failed" )
324
325 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB1Ip ) )
326 response = main.OVSDB1.listPorts( "br-int" )
327 if re.search( "vxlan", response ) and re.search( str( OVSDB2Ip ), response ):
328 stepResult = main.TRUE
329 else:
330 stepResult = main.FALSE
331 utilities.assert_equals( expect=main.TRUE,
332 actual=stepResult,
333 onpass="onos add default vxlan port on the node 1 sucess",
334 onfail="onos add default vxlan port on the node 1 failed" )
335
336 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB2Ip ) )
337 response = main.OVSDB2.listPorts( "br-int" )
338 if re.search( "vxlan", response ) and re.search( str( OVSDB1Ip ), response ):
339 stepResult = main.TRUE
340 else:
341 stepResult = main.FALSE
342 utilities.assert_equals( expect=main.TRUE,
343 actual=stepResult,
344 onpass="onos add default vxlan port on the node 2 sucess",
345 onfail="onos add default vxlan port on the node 2 failed" )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800346
347 def CASE4( self, main ):
348
349 """
350 Test default openflow configuration
351 """
352 import re
alison6acef9f2016-09-28 12:29:08 -0700353 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800354
355 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
356 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
357 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
358
359 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
360 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
361 stepResult = assignResult
362 utilities.assert_equals( expect=main.TRUE,
363 actual=stepResult,
364 onpass="ovsdb node 1 set ovs manager to to " +\
365 str( ctrlip ) + " sucess",
366 onfail="ovsdb node 1 set ovs manager to to " +\
367 str( ctrlip ) + " failed" )
368
369 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
370 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
371 stepResult = assignResult
372 utilities.assert_equals( expect=main.TRUE,
373 actual=stepResult,
374 onpass="ovsdb node 2 set ovs manager to to " +\
375 str( ctrlip ) + " sucess",
376 onfail="ovsdb node 2 set ovs manager to to " +\
377 str( ctrlip ) + " failed" )
378
379 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
380 response = main.OVSDB1.getManager()
381 if re.search( ctrlip, response ):
382 stepResult = main.TRUE
383 else:
384 stepResult = main.FALSE
385 utilities.assert_equals( expect=main.TRUE,
386 actual=stepResult,
387 onpass="ovsdb node 1 manager is " + str( response ) ,
sunyulin916e13e2015-10-15 20:27:23 +0800388 onfail="ovsdb node 1 manager check failed\n" +\
389 str( main.OVSDB1.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800390
391 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
392 response = main.OVSDB2.getManager()
393 if re.search( ctrlip, response ):
394 stepResult = main.TRUE
395 else:
396 stepResult = main.FALSE
397 utilities.assert_equals( expect=main.TRUE,
398 actual=stepResult,
399 onpass="ovsdb node 2 manager is " + str( response ) ,
sunyulin916e13e2015-10-15 20:27:23 +0800400 onfail="ovsdb node 2 manager check failed\n" +\
401 str( main.OVSDB2.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800402
403 main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) )
404 response = main.OVSDB1.getController( "br-int" )
405 if re.search( ctrlip, response ):
406 stepResult = main.TRUE
407 else:
408 stepResult = main.FALSE
409 utilities.assert_equals( expect=main.TRUE,
410 actual=stepResult,
411 onpass="Check ovsdb node 1 bridge br-int controller set to " +\
412 str( ctrlip ) + " sucess",
413 onfail="Check ovsdb node 1 bridge br-int controller set to " +\
sunyulin916e13e2015-10-15 20:27:23 +0800414 str( ctrlip ) + " failed\n" + str( main.OVSDB1.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800415
416 main.step( "Check ovsdb node 2 bridge br-int controller set to " + str( ctrlip ) )
417 response = main.OVSDB2.getController( "br-int" )
418 if re.search( ctrlip, response ):
419 stepResult = main.TRUE
420 else:
421 stepResult = main.FALSE
422 utilities.assert_equals( expect=main.TRUE,
423 actual=stepResult,
424 onpass="Check ovsdb node 2 bridge br-int controller set to " +\
425 str( ctrlip ) + " sucess",
426 onfail="Check ovsdb node 2 bridge br-int controller set to " +\
sunyulin916e13e2015-10-15 20:27:23 +0800427 str( ctrlip ) + " failed\n" + str( main.OVSDB2.show()) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800428
429 main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) )
430 response = main.ONOScli1.devices()
431 if re.search( OVSDB1Ip, response ) and not re.search( "false", response ):
432 stepResult = main.TRUE
433 else:
434 stepResult = main.FALSE
435 utilities.assert_equals( expect=main.TRUE,
436 actual=stepResult,
437 onpass="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " sucess",
438 onfail="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " failed" )
439
440 main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
441 response = main.ONOScli1.devices()
442 if re.search( OVSDB2Ip, response ) and not re.search( "false", response ):
443 stepResult = main.TRUE
444 else:
445 stepResult = main.FALSE
446 utilities.assert_equals( expect=main.TRUE,
447 actual=stepResult,
448 onpass="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " sucess",
449 onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" )
450
451 def CASE5( self, main ):
452
453 """
454 Test default flows
455 """
456 import re
alison6acef9f2016-09-28 12:29:08 -0700457 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800458
459 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
460 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
461 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
462
463 main.step( "ovsdb node 1 set ovs manager to onos" )
464 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
465 stepResult = assignResult
466 utilities.assert_equals( expect=main.TRUE,
467 actual=stepResult,
468 onpass="ovsdb node 1 set ovs manager to to " +\
469 str( ctrlip ) + " sucess",
470 onfail="ovsdb node 1 set ovs manager to to " +\
471 str( ctrlip ) + " failed" )
472
473 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
474 response = main.OVSDB1.getManager()
475 if re.search( ctrlip, response ):
476 stepResult = main.TRUE
477 else:
478 stepResult = main.FALSE
479 utilities.assert_equals( expect=main.TRUE,
480 actual=stepResult,
481 onpass="ovsdb node 1 manager is " + str( response ) ,
482 onfail="ovsdb node 1 manager check failed" )
483
484 main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) )
485 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
486 if re.search( "actions=CONTROLLER", response ):
487 stepResult = main.TRUE
488 else:
489 stepResult = main.FALSE
490 utilities.assert_equals( expect=main.TRUE,
491 actual=stepResult,
492 onpass="Successfully set default flows " + str( ctrlip ) ,
493 onfail="Failed to set default flows " + str( ctrlip ) )
494
495 def CASE6( self, main ):
496 """
497 Configure Network Subnet Port
498 """
499 import os
500
501 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700502 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import NetworkData
503 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import SubnetData
504 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800505 except ImportError:
506 main.log.exception( "Something wrong with import file or code error." )
507 main.log.info( "Import Error, please check!" )
508 main.cleanup()
509 main.exit()
510
511 main.log.info( "Configure Network Subnet Port Start" )
512 main.case( "Configure Network Subnet Port" )
513 main.caseExplanation = "Configure Network Subnet Port " +\
514 "Verify post is OK"
515
516 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
517 httpport = main.params['HTTP']['port']
518 path = main.params['HTTP']['path']
519
520 main.step( "Generate Post Data" )
521 network = NetworkData()
522 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
523 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
524 subnet = SubnetData()
525 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
526 subnet.tenant_id = network.tenant_id
527 subnet.network_id = network.id
528 subnet.start = "10.0.0.1"
529 subnet.end = "10.0.0.254"
530 subnet.cidr = "10.0.0.0/24"
531 port1 = VirtualPortData()
532 port1.id = "00000000-0000-0000-0000-000000000001"
533 port1.subnet_id = subnet.id
534 port1.tenant_id = network.tenant_id
535 port1.network_id = network.id
536 port1.macAddress = "00:00:00:00:00:01"
537 port1.ip_address = "10.0.0.1"
538 port2 = VirtualPortData()
539 port2.id = "00000000-0000-0000-0000-000000000002"
540 port2.subnet_id = subnet.id
541 port2.tenant_id = network.tenant_id
542 port2.network_id = network.id
543 port2.macAddress = "00:00:00:00:00:02"
544 port2.ip_address = "10.0.0.2"
545
546 networkpostdata = network.DictoJson()
547 subnetpostdata = subnet.DictoJson()
548 port1postdata = port1.DictoJson()
549 port2postdata = port2.DictoJson()
550
551 main.step( "Post Network Data via HTTP(Post port need post network)" )
552 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
553 'POST', None, networkpostdata )
554 utilities.assert_equals(
555 expect='200',
556 actual=Poststatus,
557 onpass="Post Network Success",
558 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
559
560 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
561 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
562 'POST', None, subnetpostdata )
563 utilities.assert_equals(
564 expect='202',
565 actual=Poststatus,
566 onpass="Post Subnet Success",
567 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
568
569 main.step( "Post Port1 Data via HTTP" )
570 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
571 'POST', None, port1postdata )
572 utilities.assert_equals(
573 expect='200',
574 actual=Poststatus,
575 onpass="Post Port Success",
576 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
577
578 main.step( "Post Port2 Data via HTTP" )
579 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
580 'POST', None, port2postdata )
581 utilities.assert_equals(
582 expect='200',
583 actual=Poststatus,
584 onpass="Post Port Success",
585 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
586
587 def CASE7( self, main ):
588
589 """
590 Test host go online and ping each other
591 """
592 import re
alison6acef9f2016-09-28 12:29:08 -0700593 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800594
595 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
596 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
597 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
598
599 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
600 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
601 stepResult = assignResult
602 utilities.assert_equals( expect=main.TRUE,
603 actual=stepResult,
604 onpass="ovsdb node 1 set ovs manager to to " +\
605 str( ctrlip ) + " sucess",
606 onfail="ovsdb node 1 set ovs manager to to " +\
607 str( ctrlip ) + " failed" )
608
609 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
610 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
611 stepResult = assignResult
612 utilities.assert_equals( expect=main.TRUE,
613 actual=stepResult,
614 onpass="ovsdb node 2 set ovs manager to " +\
615 str( ctrlip ) + " sucess",
616 onfail="ovsdb node 2 set ovs manager to " +\
617 str( ctrlip ) + " failed" )
618
619 main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) )
620 stepResult = main.OVSDB1.createHost( hostname="host1" )
621 utilities.assert_equals( expect=main.TRUE,
622 actual=stepResult,
623 onpass="Create host1 on node 1 " + str( OVSDB1Ip ) + " sucess",
624 onfail="Create host1 on node 1 " + str( OVSDB1Ip ) + " failed" )
625
626 main.step( "Create host2 on node 2 " + str( OVSDB2Ip ) )
627 stepResult = main.OVSDB2.createHost( hostname="host2" )
628 utilities.assert_equals( expect=main.TRUE,
629 actual=stepResult,
630 onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess",
631 onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" )
632
633 main.step( "Create port on host1 on the node " + str ( OVSDB1Ip ) )
634 stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" )
635 utilities.assert_equals( expect=main.TRUE,
636 actual=stepResult,
637 onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess",
638 onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" )
639
640 main.step( "Create port on host2 on the node " + str ( OVSDB2Ip ) )
641 stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" )
642 utilities.assert_equals( expect=main.TRUE,
643 actual=stepResult,
644 onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess",
645 onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" )
646
647 main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB1Ip ) )
648 stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001",
649 attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" )
650 utilities.assert_equals( expect=main.TRUE,
651 actual=stepResult,
652 onpass="Add port to ovs br-int and host go-online on the node " +\
653 str( OVSDB1Ip ) + " sucess",
654 onfail="Add port to ovs br-int and host go-online on the node " +\
655 str( OVSDB1Ip ) + " failed" )
656
657 main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB2Ip ) )
658 stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002",
659 attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" )
660 utilities.assert_equals( expect=main.TRUE,
661 actual=stepResult,
662 onpass="Add port to ovs br-int and host go-online on the node " +\
663 str( OVSDB2Ip ) + " sucess",
664 onfail="Add port to ovs br-int and host go-online on the node " +\
665 str( OVSDB2Ip ) + " failed" )
666
667 main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) )
668 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
669 if re.search( "00:00:00:00:00:01", response ):
670 stepResult = main.TRUE
671 else:
672 stepResult = main.FALSE
673 utilities.assert_equals( expect=main.TRUE,
674 actual=stepResult,
675 onpass="Check onos set host flows on the node " +\
676 str( OVSDB1Ip ) + " sucess",
677 onfail="Check onos set host flows on the node " +\
678 str( OVSDB1Ip ) + " failed" )
679
680 main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) )
681 response = main.OVSDB2.dumpFlows( sw="br-int", protocols="OpenFlow13" )
682 if re.search( "00:00:00:00:00:02", response ):
683 stepResult = main.TRUE
684 else:
685 stepResult = main.FALSE
686 utilities.assert_equals( expect=main.TRUE,
687 actual=stepResult,
688 onpass="Check onos set host flows on the node " +\
689 str( OVSDB2Ip ) + " sucess",
690 onfail="Check onos set host flows on the node " +\
691 str( OVSDB2Ip ) + " failed" )
692
693 main.step( "Check hosts can ping each other" )
694 main.OVSDB1.setHostportIp( hostname="host1", hostport1="host1-eth0", ip="10.0.0.1" )
695 main.OVSDB2.setHostportIp( hostname="host2", hostport1="host2-eth0", ip="10.0.0.2" )
696 pingResult1 = main.OVSDB1.hostPing( src="10.0.0.1", hostname="host1", target="10.0.0.2" )
697 pingResult2 = main.OVSDB2.hostPing( src="10.0.0.2", hostname="host2", target="10.0.0.1" )
698 stepResult = pingResult1 and pingResult2
699 utilities.assert_equals( expect=main.TRUE,
700 actual=stepResult,
701 onpass="Successfully host go online and ping each other,controller is " +\
702 str( ctrlip ),
703 onfail="Failed to host go online and ping each other,controller is " +\
704 str( ctrlip ) )
705
706 def CASE8( self, main ):
707
708 """
709 Clear ovs configuration and host configuration
710 """
711 import re
alison6acef9f2016-09-28 12:29:08 -0700712 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800713
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",
Jon Hall53c5e662016-04-13 16:06:56 -0700787 onfail="Check openflow session is false " + str( OVSDB2Ip ) + " failed" )