blob: c5f741521ab52ff6b59b5b37a217e4d7a764c19f [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
Jon Hall8638b562017-05-24 16:39:59 -070017
zhanghaoyu451c1392015-08-07 19:21:16 +080018class FUNCovsdbtest:
19
20 def __init__( self ):
21 self.default = ''
22
23 def CASE1( self, main ):
24 """
25 CASE1 is to compile ONOS and push it to the test machines
26
27 Startup sequence:
alison6acef9f2016-09-28 12:29:08 -070028 Construct test variables
29 Safety check, kill all ONOS processes before setup
zhanghaoyu451c1392015-08-07 19:21:16 +080030 NOTE: temporary - onos-remove-raft-logs
alison6acef9f2016-09-28 12:29:08 -070031 Create ONOS package
32 Install ONOS package
zhanghaoyu451c1392015-08-07 19:21:16 +080033 start cli sessions
34 start ovsdb
35 start vtn apps
36 """
37 import os
alison6acef9f2016-09-28 12:29:08 -070038 import time
39 main.log.info( "ONOS Single node start ovsdb test - initialization" )
Devin Lim58046fa2017-07-05 16:55:00 -070040 try:
41 from tests.dependencies.ONOSSetup import ONOSSetup
42 main.testSetUp = ONOSSetup()
43 except ImportError:
44 main.log.error( "ONOSSetup not found. exiting the test" )
45 main.exit()
46 main.testSetUp.envSetupDescription()
47 stepResult = main.FALSE
zhanghaoyu451c1392015-08-07 19:21:16 +080048
Devin Lim58046fa2017-07-05 16:55:00 -070049 try:
50 # load some variables from the params file
51 main.step( "Constructing test variables" )
52 cellName = main.params[ 'ENV' ][ 'cellName' ]
53 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
54 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
zhanghaoyu451c1392015-08-07 19:21:16 +080055
Devin Lim58046fa2017-07-05 16:55:00 -070056 main.maxNodes = 1
zhanghaoyu451c1392015-08-07 19:21:16 +080057
Devin Lim58046fa2017-07-05 16:55:00 -070058 stepResult = main.testSetUp.envSetup( hasNode=True )
zhanghaoyu451c1392015-08-07 19:21:16 +080059
Devin Lim58046fa2017-07-05 16:55:00 -070060 except Exception as e:
61 main.testSetUp.envSetupException( e )
62 main.testSetUp.evnSetupConclusion( stepResult )
zhanghaoyu451c1392015-08-07 19:21:16 +080063
zhanghaoyu451c1392015-08-07 19:21:16 +080064
Devin Lim58046fa2017-07-05 16:55:00 -070065 cliResults = main.testSetUp.ONOSSetUp( main.OVSDB1, cellName=cellName, removeLog=True )
alison6acef9f2016-09-28 12:29:08 -070066
67 if cliResults == main.FALSE:
68 main.log.error( "Failed to start ONOS, stopping test" )
69 main.cleanup()
70 main.exit()
zhanghaoyu451c1392015-08-07 19:21:16 +080071
72 main.step( "App Ids check" )
73 appCheck = main.ONOScli1.appToIDCheck()
74
alison6acef9f2016-09-28 12:29:08 -070075 if appCheck != main.TRUE:
76 main.log.warn( main.CLIs[ 0 ].apps() )
77 main.log.warn( main.CLIs[ 0 ].appIDs() )
78
79 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
zhanghaoyu451c1392015-08-07 19:21:16 +080080 onpass="App Ids seem to be correct",
81 onfail="Something is wrong with app Ids" )
zhanghaoyu451c1392015-08-07 19:21:16 +080082
alisond9915ea2016-08-12 10:16:26 -070083 main.step( "Install onos-ovsdb" )
zhanghaoyu451c1392015-08-07 19:21:16 +080084 installResults = main.ONOScli1.activateApp( "org.onosproject.ovsdb" )
85 utilities.assert_equals( expect=main.TRUE, actual=installResults,
86 onpass="Install onos-ovsdatabase successful",
87 onfail="Install onos-ovsdatabase failed" )
88
zhanghaoyu451c1392015-08-07 19:21:16 +080089 main.step( "Install onos-app-vtn" )
90 installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" )
91 utilities.assert_equals( expect=main.TRUE, actual=installResults,
92 onpass="Install onos-app-vtn successful",
93 onfail="Install onos-app-vtn failed" )
94
zhanghaoyu451c1392015-08-07 19:21:16 +080095 def CASE2( self, main ):
zhanghaoyu451c1392015-08-07 19:21:16 +080096 """
97 Test ovsdb connection and teardown
98 """
alison6acef9f2016-09-28 12:29:08 -070099 import os
zhanghaoyu451c1392015-08-07 19:21:16 +0800100 import re
zhanghaoyu451c1392015-08-07 19:21:16 +0800101
102 main.case( "Test ovsdb connection and teardown" )
103 main.caseExplanation = "Test ovsdb connection create and delete" +\
104 " over ovsdb node and onos node "
105
106 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
107 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
108 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
109
110 main.step( "Set ovsdb node manager" )
111 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
112 stepResult = assignResult
113 utilities.assert_equals( expect=main.TRUE,
114 actual=stepResult,
115 onpass="Set ovsdb node manager sucess",
116 onfail="Set ovsdb node manager failed" )
117
118 main.step( "Check ovsdb node manager is " + str( ctrlip ) )
119 response = main.OVSDB1.getManager()
120 if re.search( ctrlip, response ):
121 stepResult = main.TRUE
122 else:
123 stepResult = main.FALSE
124 utilities.assert_equals( expect=main.TRUE,
125 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700126 onpass="Check ovsdb node manager is " + str( response ),
zhanghaoyu451c1392015-08-07 19:21:16 +0800127 onfail="Check ovsdb node manager failed" )
128
129 main.step( "Delete ovsdb node manager" )
130 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
131 stepResult = deleteResult
132 utilities.assert_equals( expect=main.TRUE,
133 actual=stepResult,
134 onpass="ovsdb node delete manager sucess",
135 onfail="ovsdb node delete manager failed" )
136
137 main.step( "Check ovsdb node delete manager " + str( ctrlip ) )
138 response = main.OVSDB1.getManager()
139 if not re.search( ctrlip, response ):
140 stepResult = main.TRUE
141 else:
142 stepResult = main.FALSE
143 utilities.assert_equals( expect=main.TRUE,
144 actual=stepResult,
145 onpass="Check ovsdb node delete manager sucess",
146 onfail="Check ovsdb node delete manager failed" )
147
148 def CASE3( self, main ):
zhanghaoyu451c1392015-08-07 19:21:16 +0800149 """
150 Test default br-int configuration and vxlan port
151 """
152 import re
alison6acef9f2016-09-28 12:29:08 -0700153 import os
zhanghaoyu451c1392015-08-07 19:21:16 +0800154
155 main.case( "Test default br-int configuration and vxlan port" )
156 main.caseExplanation = "onos create default br-int bridge and" +\
157 " vxlan port on the ovsdb node"
158
159 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
160 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
161 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
Jon Hall8638b562017-05-24 16:39:59 -0700162 OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
163 OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
zhanghaoyu451c1392015-08-07 19:21:16 +0800164
165 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
166 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
167 stepResult = assignResult
168 utilities.assert_equals( expect=main.TRUE,
169 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700170 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800171 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700172 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800173 str( ctrlip ) + " failed" )
174
175 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
176 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
177 stepResult = assignResult
178 utilities.assert_equals( expect=main.TRUE,
179 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700180 onpass="ovsdb node 2 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800181 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700182 onfail="ovsdb node 2 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800183 str( ctrlip ) + " failed" )
184
185 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
186 response = main.OVSDB1.getManager()
187 if re.search( ctrlip, response ):
188 stepResult = main.TRUE
189 else:
190 stepResult = main.FALSE
191 utilities.assert_equals( expect=main.TRUE,
192 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700193 onpass="ovsdb node 1 manager is " + str( response ),
zhanghaoyu451c1392015-08-07 19:21:16 +0800194 onfail="ovsdb node 1 manager check failed" )
195
196 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
197 response = main.OVSDB2.getManager()
198 if re.search( ctrlip, response ):
199 stepResult = main.TRUE
200 else:
201 stepResult = main.FALSE
202 utilities.assert_equals( expect=main.TRUE,
203 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700204 onpass="ovsdb node 2 manager is " + str( response ),
zhanghaoyu451c1392015-08-07 19:21:16 +0800205 onfail="ovsdb node 2 manager check failed" )
206
207 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) )
208 response = main.OVSDB1.listBr()
209 if re.search( "br-int", response ):
210 stepResult = main.TRUE
211 else:
212 stepResult = main.FALSE
213 utilities.assert_equals( expect=main.TRUE,
214 actual=stepResult,
215 onpass="onos add default bridge on the node 1 sucess",
216 onfail="onos add default bridge on the node 1 failed" )
217
218 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB2Ip ) )
219 response = main.OVSDB2.listBr()
220 if re.search( "br-int", response ):
221 stepResult = main.TRUE
222 else:
223 stepResult = main.FALSE
224 utilities.assert_equals( expect=main.TRUE,
225 actual=stepResult,
226 onpass="onos add default bridge on the node 2 sucess",
227 onfail="onos add default bridge on the node 2 failed" )
228
229 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB1Ip ) )
230 response = main.OVSDB1.listPorts( "br-int" )
231 if re.search( "vxlan", response ) and re.search( str( OVSDB2Ip ), response ):
232 stepResult = main.TRUE
233 else:
234 stepResult = main.FALSE
235 utilities.assert_equals( expect=main.TRUE,
236 actual=stepResult,
237 onpass="onos add default vxlan port on the node 1 sucess",
238 onfail="onos add default vxlan port on the node 1 failed" )
239
240 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB2Ip ) )
241 response = main.OVSDB2.listPorts( "br-int" )
242 if re.search( "vxlan", response ) and re.search( str( OVSDB1Ip ), response ):
243 stepResult = main.TRUE
244 else:
245 stepResult = main.FALSE
246 utilities.assert_equals( expect=main.TRUE,
247 actual=stepResult,
248 onpass="onos add default vxlan port on the node 2 sucess",
249 onfail="onos add default vxlan port on the node 2 failed" )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800250
251 def CASE4( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800252 """
253 Test default openflow configuration
254 """
255 import re
alison6acef9f2016-09-28 12:29:08 -0700256 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800257
258 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
259 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
260 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
261
262 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
263 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
264 stepResult = assignResult
265 utilities.assert_equals( expect=main.TRUE,
266 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700267 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800268 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700269 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800270 str( ctrlip ) + " failed" )
271
272 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
273 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
274 stepResult = assignResult
275 utilities.assert_equals( expect=main.TRUE,
276 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700277 onpass="ovsdb node 2 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800278 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700279 onfail="ovsdb node 2 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800280 str( ctrlip ) + " failed" )
281
282 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
283 response = main.OVSDB1.getManager()
284 if re.search( ctrlip, response ):
285 stepResult = main.TRUE
286 else:
287 stepResult = main.FALSE
288 utilities.assert_equals( expect=main.TRUE,
289 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700290 onpass="ovsdb node 1 manager is " + str( response ),
291 onfail="ovsdb node 1 manager check failed\n" +
sunyulin916e13e2015-10-15 20:27:23 +0800292 str( main.OVSDB1.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800293
294 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
295 response = main.OVSDB2.getManager()
296 if re.search( ctrlip, response ):
297 stepResult = main.TRUE
298 else:
299 stepResult = main.FALSE
300 utilities.assert_equals( expect=main.TRUE,
301 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700302 onpass="ovsdb node 2 manager is " + str( response ),
303 onfail="ovsdb node 2 manager check failed\n" +
sunyulin916e13e2015-10-15 20:27:23 +0800304 str( main.OVSDB2.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800305
306 main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) )
307 response = main.OVSDB1.getController( "br-int" )
308 if re.search( ctrlip, response ):
309 stepResult = main.TRUE
310 else:
311 stepResult = main.FALSE
312 utilities.assert_equals( expect=main.TRUE,
313 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700314 onpass="Check ovsdb node 1 bridge br-int controller set to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800315 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700316 onfail="Check ovsdb node 1 bridge br-int controller set to " +
sunyulin916e13e2015-10-15 20:27:23 +0800317 str( ctrlip ) + " failed\n" + str( main.OVSDB1.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800318
319 main.step( "Check ovsdb node 2 bridge br-int controller set to " + str( ctrlip ) )
320 response = main.OVSDB2.getController( "br-int" )
321 if re.search( ctrlip, response ):
322 stepResult = main.TRUE
323 else:
324 stepResult = main.FALSE
325 utilities.assert_equals( expect=main.TRUE,
326 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700327 onpass="Check ovsdb node 2 bridge br-int controller set to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800328 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700329 onfail="Check ovsdb node 2 bridge br-int controller set to " +
330 str( ctrlip ) + " failed\n" + str( main.OVSDB2.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800331
332 main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) )
333 response = main.ONOScli1.devices()
334 if re.search( OVSDB1Ip, response ) and not re.search( "false", response ):
335 stepResult = main.TRUE
336 else:
337 stepResult = main.FALSE
338 utilities.assert_equals( expect=main.TRUE,
339 actual=stepResult,
340 onpass="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " sucess",
341 onfail="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " failed" )
342
343 main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
344 response = main.ONOScli1.devices()
345 if re.search( OVSDB2Ip, response ) and not re.search( "false", response ):
346 stepResult = main.TRUE
347 else:
348 stepResult = main.FALSE
349 utilities.assert_equals( expect=main.TRUE,
350 actual=stepResult,
351 onpass="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " sucess",
352 onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" )
353
354 def CASE5( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800355 """
356 Test default flows
357 """
358 import re
alison6acef9f2016-09-28 12:29:08 -0700359 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800360
361 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
362 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
363 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
364
365 main.step( "ovsdb node 1 set ovs manager to onos" )
366 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
367 stepResult = assignResult
368 utilities.assert_equals( expect=main.TRUE,
369 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700370 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800371 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700372 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800373 str( ctrlip ) + " failed" )
374
375 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
376 response = main.OVSDB1.getManager()
377 if re.search( ctrlip, response ):
378 stepResult = main.TRUE
379 else:
380 stepResult = main.FALSE
381 utilities.assert_equals( expect=main.TRUE,
382 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700383 onpass="ovsdb node 1 manager is " + str( response ),
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800384 onfail="ovsdb node 1 manager check failed" )
385
386 main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) )
387 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
388 if re.search( "actions=CONTROLLER", response ):
389 stepResult = main.TRUE
390 else:
391 stepResult = main.FALSE
392 utilities.assert_equals( expect=main.TRUE,
393 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700394 onpass="Successfully set default flows " + str( ctrlip ),
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800395 onfail="Failed to set default flows " + str( ctrlip ) )
396
397 def CASE6( self, main ):
398 """
399 Configure Network Subnet Port
400 """
401 import os
402
403 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700404 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import NetworkData
405 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import SubnetData
406 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800407 except ImportError:
408 main.log.exception( "Something wrong with import file or code error." )
409 main.log.info( "Import Error, please check!" )
410 main.cleanup()
411 main.exit()
412
413 main.log.info( "Configure Network Subnet Port Start" )
414 main.case( "Configure Network Subnet Port" )
415 main.caseExplanation = "Configure Network Subnet Port " +\
416 "Verify post is OK"
417
Jon Hall8638b562017-05-24 16:39:59 -0700418 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
419 httpport = main.params[ 'HTTP' ][ 'port' ]
420 path = main.params[ 'HTTP' ][ 'path' ]
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800421
422 main.step( "Generate Post Data" )
423 network = NetworkData()
424 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
425 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
426 subnet = SubnetData()
427 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
428 subnet.tenant_id = network.tenant_id
429 subnet.network_id = network.id
430 subnet.start = "10.0.0.1"
431 subnet.end = "10.0.0.254"
432 subnet.cidr = "10.0.0.0/24"
433 port1 = VirtualPortData()
434 port1.id = "00000000-0000-0000-0000-000000000001"
435 port1.subnet_id = subnet.id
436 port1.tenant_id = network.tenant_id
437 port1.network_id = network.id
438 port1.macAddress = "00:00:00:00:00:01"
439 port1.ip_address = "10.0.0.1"
440 port2 = VirtualPortData()
441 port2.id = "00000000-0000-0000-0000-000000000002"
442 port2.subnet_id = subnet.id
443 port2.tenant_id = network.tenant_id
444 port2.network_id = network.id
445 port2.macAddress = "00:00:00:00:00:02"
446 port2.ip_address = "10.0.0.2"
447
448 networkpostdata = network.DictoJson()
449 subnetpostdata = subnet.DictoJson()
450 port1postdata = port1.DictoJson()
451 port2postdata = port2.DictoJson()
452
453 main.step( "Post Network Data via HTTP(Post port need post network)" )
454 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
455 'POST', None, networkpostdata )
456 utilities.assert_equals(
457 expect='200',
458 actual=Poststatus,
459 onpass="Post Network Success",
460 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
461
462 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
463 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
464 'POST', None, subnetpostdata )
465 utilities.assert_equals(
466 expect='202',
467 actual=Poststatus,
468 onpass="Post Subnet Success",
469 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
470
471 main.step( "Post Port1 Data via HTTP" )
472 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
473 'POST', None, port1postdata )
474 utilities.assert_equals(
475 expect='200',
476 actual=Poststatus,
477 onpass="Post Port Success",
478 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
479
480 main.step( "Post Port2 Data via HTTP" )
481 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
482 'POST', None, port2postdata )
483 utilities.assert_equals(
484 expect='200',
485 actual=Poststatus,
486 onpass="Post Port Success",
487 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
488
489 def CASE7( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800490 """
491 Test host go online and ping each other
492 """
493 import re
alison6acef9f2016-09-28 12:29:08 -0700494 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800495
496 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
497 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
498 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
499
500 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
501 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
502 stepResult = assignResult
503 utilities.assert_equals( expect=main.TRUE,
504 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700505 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800506 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700507 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800508 str( ctrlip ) + " failed" )
509
510 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
511 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
512 stepResult = assignResult
513 utilities.assert_equals( expect=main.TRUE,
514 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700515 onpass="ovsdb node 2 set ovs manager to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800516 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700517 onfail="ovsdb node 2 set ovs manager to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800518 str( ctrlip ) + " failed" )
519
520 main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) )
521 stepResult = main.OVSDB1.createHost( hostname="host1" )
522 utilities.assert_equals( expect=main.TRUE,
523 actual=stepResult,
524 onpass="Create host1 on node 1 " + str( OVSDB1Ip ) + " sucess",
525 onfail="Create host1 on node 1 " + str( OVSDB1Ip ) + " failed" )
526
527 main.step( "Create host2 on node 2 " + str( OVSDB2Ip ) )
528 stepResult = main.OVSDB2.createHost( hostname="host2" )
529 utilities.assert_equals( expect=main.TRUE,
530 actual=stepResult,
531 onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess",
532 onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" )
533
Jon Hall8638b562017-05-24 16:39:59 -0700534 main.step( "Create port on host1 on the node " + str( OVSDB1Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800535 stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" )
536 utilities.assert_equals( expect=main.TRUE,
537 actual=stepResult,
538 onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess",
539 onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" )
540
Jon Hall8638b562017-05-24 16:39:59 -0700541 main.step( "Create port on host2 on the node " + str( OVSDB2Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800542 stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" )
543 utilities.assert_equals( expect=main.TRUE,
544 actual=stepResult,
545 onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess",
546 onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" )
547
Jon Hall8638b562017-05-24 16:39:59 -0700548 main.step( "Add port to ovs br-int and host go-online on the node " + str( OVSDB1Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800549 stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001",
550 attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" )
551 utilities.assert_equals( expect=main.TRUE,
552 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700553 onpass="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800554 str( OVSDB1Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700555 onfail="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800556 str( OVSDB1Ip ) + " failed" )
557
Jon Hall8638b562017-05-24 16:39:59 -0700558 main.step( "Add port to ovs br-int and host go-online on the node " + str( OVSDB2Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800559 stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002",
560 attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" )
561 utilities.assert_equals( expect=main.TRUE,
562 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700563 onpass="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800564 str( OVSDB2Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700565 onfail="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800566 str( OVSDB2Ip ) + " failed" )
567
568 main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) )
569 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
570 if re.search( "00:00:00:00:00:01", response ):
571 stepResult = main.TRUE
572 else:
573 stepResult = main.FALSE
574 utilities.assert_equals( expect=main.TRUE,
575 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700576 onpass="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800577 str( OVSDB1Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700578 onfail="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800579 str( OVSDB1Ip ) + " failed" )
580
581 main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) )
582 response = main.OVSDB2.dumpFlows( sw="br-int", protocols="OpenFlow13" )
583 if re.search( "00:00:00:00:00:02", response ):
584 stepResult = main.TRUE
585 else:
586 stepResult = main.FALSE
587 utilities.assert_equals( expect=main.TRUE,
588 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700589 onpass="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800590 str( OVSDB2Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700591 onfail="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800592 str( OVSDB2Ip ) + " failed" )
593
594 main.step( "Check hosts can ping each other" )
595 main.OVSDB1.setHostportIp( hostname="host1", hostport1="host1-eth0", ip="10.0.0.1" )
596 main.OVSDB2.setHostportIp( hostname="host2", hostport1="host2-eth0", ip="10.0.0.2" )
597 pingResult1 = main.OVSDB1.hostPing( src="10.0.0.1", hostname="host1", target="10.0.0.2" )
598 pingResult2 = main.OVSDB2.hostPing( src="10.0.0.2", hostname="host2", target="10.0.0.1" )
599 stepResult = pingResult1 and pingResult2
600 utilities.assert_equals( expect=main.TRUE,
601 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700602 onpass="Successfully host go online and ping each other,controller is " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800603 str( ctrlip ),
Jon Hall8638b562017-05-24 16:39:59 -0700604 onfail="Failed to host go online and ping each other,controller is " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800605 str( ctrlip ) )
606
607 def CASE8( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800608 """
609 Clear ovs configuration and host configuration
610 """
611 import re
alison6acef9f2016-09-28 12:29:08 -0700612 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800613
614 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
615 OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
616 OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
617 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
618
619 main.step( "Delete ovsdb node 1 manager" )
620 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
621 stepResult = deleteResult
622 utilities.assert_equals( expect=main.TRUE,
623 actual=stepResult,
624 onpass="ovsdb node 1 delete manager sucess",
625 onfail="ovsdb node 1 delete manager failed" )
626
627 main.step( "Delete ovsdb node 2 manager" )
628 deleteResult = main.OVSDB2.delManager( delaytime=delaytime )
629 stepResult = deleteResult
630 utilities.assert_equals( expect=main.TRUE,
631 actual=stepResult,
632 onpass="ovsdb node 2 delete manager sucess",
633 onfail="ovsdb node 2 delete manager failed" )
634
635 main.step( "Delete ovsdb node 1 bridge br-int" )
636 deleteResult = main.OVSDB1.delBr( sw="br-int" )
637 stepResult = deleteResult
638 utilities.assert_equals( expect=main.TRUE,
639 actual=stepResult,
640 onpass="Delete ovsdb node 1 bridge br-int sucess",
641 onfail="Delete ovsdb node 1 bridge br-int failed" )
642
643 main.step( "Delete ovsdb node 2 bridge br-int" )
644 deleteResult = main.OVSDB2.delBr( sw="br-int" )
645 stepResult = deleteResult
646 utilities.assert_equals( expect=main.TRUE,
647 actual=stepResult,
648 onpass="Delete ovsdb node 2 bridge br-int sucess",
649 onfail="Delete ovsdb node 2 bridge br-int failed" )
650
651 main.step( "Delete ip netns host on the ovsdb node 1" )
652 deleteResult = main.OVSDB1.delHost( hostname="host1" )
653 stepResult = deleteResult
654 utilities.assert_equals( expect=main.TRUE,
655 actual=stepResult,
656 onpass="Delete ip netns host on the ovsdb node 1 sucess",
657 onfail="Delete ip netns host on the ovsdb node 1 failed" )
658
659 main.step( "Delete ip netns host on the ovsdb node 2" )
660 deleteResult = main.OVSDB2.delHost( hostname="host2" )
661 stepResult = deleteResult
662 utilities.assert_equals( expect=main.TRUE,
663 actual=stepResult,
664 onpass="Delete ip netns host on the ovsdb node 2 sucess",
665 onfail="Delete ip netns host on the ovsdb node 2 failed" )
666
667 main.step( "Check onoscli devices openflow session is false " + str( OVSDB1Ip ) )
668 response = main.ONOScli1.devices()
669 if re.search( OVSDB1Ip, response ) and not re.search( "true", response ):
670 stepResult = main.TRUE
671 else:
672 stepResult = main.FALSE
673 utilities.assert_equals( expect=main.TRUE,
674 actual=stepResult,
675 onpass="Check openflow session is false " + str( OVSDB1Ip ) + " sucess",
676 onfail="Check openflow session is false " + str( OVSDB1Ip ) + " failed" )
677
678 main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
679 response = main.ONOScli1.devices()
680 if re.search( OVSDB2Ip, response ) and not re.search( "true", response ):
681 stepResult = main.TRUE
682 else:
683 stepResult = main.FALSE
684 utilities.assert_equals( expect=main.TRUE,
685 actual=stepResult,
686 onpass="Check openflow session is false " + str( OVSDB2Ip ) + " sucess",
Jon Hall53c5e662016-04-13 16:06:56 -0700687 onfail="Check openflow session is false " + str( OVSDB2Ip ) + " failed" )