blob: 6b6ad9320760efac3e4f71e1032fe7f1ebf4088d [file] [log] [blame]
zhanghaoyu451c1392015-08-07 19:21:16 +08001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070021"""
zhanghaoyu451c1392015-08-07 19:21:16 +080022Description: This test is to check onos set configuration and flows with ovsdb connection.
23
24List of test cases:
25CASE1: Compile ONOS and push it to the test machines
26CASE2: Test ovsdb connection and tearDown
27CASE3: Test default br-int configuration and vxlan port
28CASE4: Test default openflow configuration
29CASE5: Test default flows
zhanghaoyu7474d8c62015-08-26 14:53:28 +080030CASE6: Configure Network Subnet Port
zhanghaoyu451c1392015-08-07 19:21:16 +080031CASE7: Test host go online and ping each other
zhanghaoyu7474d8c62015-08-26 14:53:28 +080032CASE8: Clear ovs configuration and host configuration
zhanghaoyu451c1392015-08-07 19:21:16 +080033zhanghaoyu7@huawei.com
34"""
35import os
36
Jon Hall8638b562017-05-24 16:39:59 -070037
zhanghaoyu451c1392015-08-07 19:21:16 +080038class FUNCovsdbtest:
39
40 def __init__( self ):
41 self.default = ''
42
43 def CASE1( self, main ):
44 """
45 CASE1 is to compile ONOS and push it to the test machines
46
47 Startup sequence:
alison6acef9f2016-09-28 12:29:08 -070048 Construct test variables
49 Safety check, kill all ONOS processes before setup
zhanghaoyu451c1392015-08-07 19:21:16 +080050 NOTE: temporary - onos-remove-raft-logs
alison6acef9f2016-09-28 12:29:08 -070051 Create ONOS package
52 Install ONOS package
zhanghaoyu451c1392015-08-07 19:21:16 +080053 start cli sessions
54 start ovsdb
55 start vtn apps
56 """
57 import os
alison6acef9f2016-09-28 12:29:08 -070058 import time
59 main.log.info( "ONOS Single node start ovsdb test - initialization" )
Devin Lim58046fa2017-07-05 16:55:00 -070060 try:
61 from tests.dependencies.ONOSSetup import ONOSSetup
62 main.testSetUp = ONOSSetup()
63 except ImportError:
64 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070065 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070066 main.testSetUp.envSetupDescription()
67 stepResult = main.FALSE
zhanghaoyu451c1392015-08-07 19:21:16 +080068
Devin Lim58046fa2017-07-05 16:55:00 -070069 try:
70 # load some variables from the params file
71 main.step( "Constructing test variables" )
72 cellName = main.params[ 'ENV' ][ 'cellName' ]
73 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
74 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Devin Lim142b5342017-07-20 15:22:39 -070075 stepResult = main.testSetUp.envSetup()
zhanghaoyu451c1392015-08-07 19:21:16 +080076
Devin Lim58046fa2017-07-05 16:55:00 -070077 except Exception as e:
78 main.testSetUp.envSetupException( e )
79 main.testSetUp.evnSetupConclusion( stepResult )
zhanghaoyu451c1392015-08-07 19:21:16 +080080
Devin Lim142b5342017-07-20 15:22:39 -070081 cliResults = main.testSetUp.ONOSSetUp( main.OVSDB1, main.Cluster,
82 cellName=cellName, removeLog=True )
alison6acef9f2016-09-28 12:29:08 -070083
84 if cliResults == main.FALSE:
85 main.log.error( "Failed to start ONOS, stopping test" )
Devin Lim44075962017-08-11 10:56:37 -070086 main.cleanAndExit()
zhanghaoyu451c1392015-08-07 19:21:16 +080087
88 main.step( "App Ids check" )
Devin Lim142b5342017-07-20 15:22:39 -070089 appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck()
zhanghaoyu451c1392015-08-07 19:21:16 +080090
alison6acef9f2016-09-28 12:29:08 -070091 if appCheck != main.TRUE:
Devin Lim142b5342017-07-20 15:22:39 -070092 main.log.warn( main.Cluster.active( 0 ).CLI.apps() )
93 main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() )
alison6acef9f2016-09-28 12:29:08 -070094
95 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
zhanghaoyu451c1392015-08-07 19:21:16 +080096 onpass="App Ids seem to be correct",
97 onfail="Something is wrong with app Ids" )
zhanghaoyu451c1392015-08-07 19:21:16 +080098
alisond9915ea2016-08-12 10:16:26 -070099 main.step( "Install onos-ovsdb" )
Devin Lim142b5342017-07-20 15:22:39 -0700100 installResults = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.ovsdb" )
zhanghaoyu451c1392015-08-07 19:21:16 +0800101 utilities.assert_equals( expect=main.TRUE, actual=installResults,
102 onpass="Install onos-ovsdatabase successful",
103 onfail="Install onos-ovsdatabase failed" )
104
zhanghaoyu451c1392015-08-07 19:21:16 +0800105 main.step( "Install onos-app-vtn" )
Devin Lim142b5342017-07-20 15:22:39 -0700106 installResults = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.vtn" )
zhanghaoyu451c1392015-08-07 19:21:16 +0800107 utilities.assert_equals( expect=main.TRUE, actual=installResults,
108 onpass="Install onos-app-vtn successful",
109 onfail="Install onos-app-vtn failed" )
110
zhanghaoyu451c1392015-08-07 19:21:16 +0800111 def CASE2( self, main ):
zhanghaoyu451c1392015-08-07 19:21:16 +0800112 """
113 Test ovsdb connection and teardown
114 """
alison6acef9f2016-09-28 12:29:08 -0700115 import os
zhanghaoyu451c1392015-08-07 19:21:16 +0800116 import re
zhanghaoyu451c1392015-08-07 19:21:16 +0800117
118 main.case( "Test ovsdb connection and teardown" )
119 main.caseExplanation = "Test ovsdb connection create and delete" +\
120 " over ovsdb node and onos node "
121
122 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
123 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
124 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
125
126 main.step( "Set ovsdb node manager" )
127 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
128 stepResult = assignResult
129 utilities.assert_equals( expect=main.TRUE,
130 actual=stepResult,
131 onpass="Set ovsdb node manager sucess",
132 onfail="Set ovsdb node manager failed" )
133
134 main.step( "Check ovsdb node manager is " + str( ctrlip ) )
135 response = main.OVSDB1.getManager()
136 if re.search( ctrlip, response ):
137 stepResult = main.TRUE
138 else:
139 stepResult = main.FALSE
140 utilities.assert_equals( expect=main.TRUE,
141 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700142 onpass="Check ovsdb node manager is " + str( response ),
zhanghaoyu451c1392015-08-07 19:21:16 +0800143 onfail="Check ovsdb node manager failed" )
144
145 main.step( "Delete ovsdb node manager" )
146 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
147 stepResult = deleteResult
148 utilities.assert_equals( expect=main.TRUE,
149 actual=stepResult,
150 onpass="ovsdb node delete manager sucess",
151 onfail="ovsdb node delete manager failed" )
152
153 main.step( "Check ovsdb node delete manager " + str( ctrlip ) )
154 response = main.OVSDB1.getManager()
155 if not re.search( ctrlip, response ):
156 stepResult = main.TRUE
157 else:
158 stepResult = main.FALSE
159 utilities.assert_equals( expect=main.TRUE,
160 actual=stepResult,
161 onpass="Check ovsdb node delete manager sucess",
162 onfail="Check ovsdb node delete manager failed" )
163
164 def CASE3( self, main ):
zhanghaoyu451c1392015-08-07 19:21:16 +0800165 """
166 Test default br-int configuration and vxlan port
167 """
168 import re
alison6acef9f2016-09-28 12:29:08 -0700169 import os
zhanghaoyu451c1392015-08-07 19:21:16 +0800170
171 main.case( "Test default br-int configuration and vxlan port" )
172 main.caseExplanation = "onos create default br-int bridge and" +\
173 " vxlan port on the ovsdb node"
174
175 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
176 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
177 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
Jon Hall8638b562017-05-24 16:39:59 -0700178 OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
179 OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
zhanghaoyu451c1392015-08-07 19:21:16 +0800180
181 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
182 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
183 stepResult = assignResult
184 utilities.assert_equals( expect=main.TRUE,
185 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700186 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800187 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700188 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800189 str( ctrlip ) + " failed" )
190
191 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
192 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
193 stepResult = assignResult
194 utilities.assert_equals( expect=main.TRUE,
195 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700196 onpass="ovsdb node 2 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800197 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700198 onfail="ovsdb node 2 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800199 str( ctrlip ) + " failed" )
200
201 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
202 response = main.OVSDB1.getManager()
203 if re.search( ctrlip, response ):
204 stepResult = main.TRUE
205 else:
206 stepResult = main.FALSE
207 utilities.assert_equals( expect=main.TRUE,
208 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700209 onpass="ovsdb node 1 manager is " + str( response ),
zhanghaoyu451c1392015-08-07 19:21:16 +0800210 onfail="ovsdb node 1 manager check failed" )
211
212 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
213 response = main.OVSDB2.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,
Jon Hall8638b562017-05-24 16:39:59 -0700220 onpass="ovsdb node 2 manager is " + str( response ),
zhanghaoyu451c1392015-08-07 19:21:16 +0800221 onfail="ovsdb node 2 manager check failed" )
222
223 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) )
224 response = main.OVSDB1.listBr()
225 if re.search( "br-int", response ):
226 stepResult = main.TRUE
227 else:
228 stepResult = main.FALSE
229 utilities.assert_equals( expect=main.TRUE,
230 actual=stepResult,
231 onpass="onos add default bridge on the node 1 sucess",
232 onfail="onos add default bridge on the node 1 failed" )
233
234 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB2Ip ) )
235 response = main.OVSDB2.listBr()
236 if re.search( "br-int", response ):
237 stepResult = main.TRUE
238 else:
239 stepResult = main.FALSE
240 utilities.assert_equals( expect=main.TRUE,
241 actual=stepResult,
242 onpass="onos add default bridge on the node 2 sucess",
243 onfail="onos add default bridge on the node 2 failed" )
244
245 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB1Ip ) )
246 response = main.OVSDB1.listPorts( "br-int" )
247 if re.search( "vxlan", response ) and re.search( str( OVSDB2Ip ), response ):
248 stepResult = main.TRUE
249 else:
250 stepResult = main.FALSE
251 utilities.assert_equals( expect=main.TRUE,
252 actual=stepResult,
253 onpass="onos add default vxlan port on the node 1 sucess",
254 onfail="onos add default vxlan port on the node 1 failed" )
255
256 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB2Ip ) )
257 response = main.OVSDB2.listPorts( "br-int" )
258 if re.search( "vxlan", response ) and re.search( str( OVSDB1Ip ), response ):
259 stepResult = main.TRUE
260 else:
261 stepResult = main.FALSE
262 utilities.assert_equals( expect=main.TRUE,
263 actual=stepResult,
264 onpass="onos add default vxlan port on the node 2 sucess",
265 onfail="onos add default vxlan port on the node 2 failed" )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800266
267 def CASE4( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800268 """
269 Test default openflow configuration
270 """
271 import re
alison6acef9f2016-09-28 12:29:08 -0700272 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800273
274 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
275 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
276 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
277
278 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
279 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
280 stepResult = assignResult
281 utilities.assert_equals( expect=main.TRUE,
282 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700283 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800284 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700285 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800286 str( ctrlip ) + " failed" )
287
288 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
289 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
290 stepResult = assignResult
291 utilities.assert_equals( expect=main.TRUE,
292 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700293 onpass="ovsdb node 2 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800294 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700295 onfail="ovsdb node 2 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800296 str( ctrlip ) + " failed" )
297
298 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
299 response = main.OVSDB1.getManager()
300 if re.search( ctrlip, response ):
301 stepResult = main.TRUE
302 else:
303 stepResult = main.FALSE
304 utilities.assert_equals( expect=main.TRUE,
305 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700306 onpass="ovsdb node 1 manager is " + str( response ),
307 onfail="ovsdb node 1 manager check failed\n" +
sunyulin916e13e2015-10-15 20:27:23 +0800308 str( main.OVSDB1.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800309
310 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
311 response = main.OVSDB2.getManager()
312 if re.search( ctrlip, response ):
313 stepResult = main.TRUE
314 else:
315 stepResult = main.FALSE
316 utilities.assert_equals( expect=main.TRUE,
317 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700318 onpass="ovsdb node 2 manager is " + str( response ),
319 onfail="ovsdb node 2 manager check failed\n" +
sunyulin916e13e2015-10-15 20:27:23 +0800320 str( main.OVSDB2.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800321
322 main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) )
323 response = main.OVSDB1.getController( "br-int" )
324 if re.search( ctrlip, response ):
325 stepResult = main.TRUE
326 else:
327 stepResult = main.FALSE
328 utilities.assert_equals( expect=main.TRUE,
329 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700330 onpass="Check ovsdb node 1 bridge br-int controller set to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800331 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700332 onfail="Check ovsdb node 1 bridge br-int controller set to " +
sunyulin916e13e2015-10-15 20:27:23 +0800333 str( ctrlip ) + " failed\n" + str( main.OVSDB1.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800334
335 main.step( "Check ovsdb node 2 bridge br-int controller set to " + str( ctrlip ) )
336 response = main.OVSDB2.getController( "br-int" )
337 if re.search( ctrlip, response ):
338 stepResult = main.TRUE
339 else:
340 stepResult = main.FALSE
341 utilities.assert_equals( expect=main.TRUE,
342 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700343 onpass="Check ovsdb node 2 bridge br-int controller set to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800344 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700345 onfail="Check ovsdb node 2 bridge br-int controller set to " +
346 str( ctrlip ) + " failed\n" + str( main.OVSDB2.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800347
348 main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) )
Devin Lim142b5342017-07-20 15:22:39 -0700349 response = main.Cluster.active( 0 ).CLI.devices()
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800350 if re.search( OVSDB1Ip, response ) and not re.search( "false", response ):
351 stepResult = main.TRUE
352 else:
353 stepResult = main.FALSE
354 utilities.assert_equals( expect=main.TRUE,
355 actual=stepResult,
356 onpass="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " sucess",
357 onfail="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " failed" )
358
359 main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
Devin Lim142b5342017-07-20 15:22:39 -0700360 response = main.Cluster.active( 0 ).CLI.devices()
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800361 if re.search( OVSDB2Ip, response ) and not re.search( "false", response ):
362 stepResult = main.TRUE
363 else:
364 stepResult = main.FALSE
365 utilities.assert_equals( expect=main.TRUE,
366 actual=stepResult,
367 onpass="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " sucess",
368 onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" )
369
370 def CASE5( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800371 """
372 Test default flows
373 """
374 import re
alison6acef9f2016-09-28 12:29:08 -0700375 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800376
377 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
378 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
379 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
380
381 main.step( "ovsdb node 1 set ovs manager to onos" )
382 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
383 stepResult = assignResult
384 utilities.assert_equals( expect=main.TRUE,
385 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700386 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800387 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700388 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800389 str( ctrlip ) + " failed" )
390
391 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
392 response = main.OVSDB1.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,
Jon Hall8638b562017-05-24 16:39:59 -0700399 onpass="ovsdb node 1 manager is " + str( response ),
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800400 onfail="ovsdb node 1 manager check failed" )
401
402 main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) )
403 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
404 if re.search( "actions=CONTROLLER", response ):
405 stepResult = main.TRUE
406 else:
407 stepResult = main.FALSE
408 utilities.assert_equals( expect=main.TRUE,
409 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700410 onpass="Successfully set default flows " + str( ctrlip ),
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800411 onfail="Failed to set default flows " + str( ctrlip ) )
412
413 def CASE6( self, main ):
414 """
415 Configure Network Subnet Port
416 """
417 import os
418
419 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700420 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import NetworkData
421 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import SubnetData
422 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800423 except ImportError:
424 main.log.exception( "Something wrong with import file or code error." )
425 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700426 main.cleanAndExit()
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800427
428 main.log.info( "Configure Network Subnet Port Start" )
429 main.case( "Configure Network Subnet Port" )
430 main.caseExplanation = "Configure Network Subnet Port " +\
431 "Verify post is OK"
432
Jon Hall8638b562017-05-24 16:39:59 -0700433 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
434 httpport = main.params[ 'HTTP' ][ 'port' ]
435 path = main.params[ 'HTTP' ][ 'path' ]
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800436
437 main.step( "Generate Post Data" )
438 network = NetworkData()
439 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
440 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
441 subnet = SubnetData()
442 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
443 subnet.tenant_id = network.tenant_id
444 subnet.network_id = network.id
445 subnet.start = "10.0.0.1"
446 subnet.end = "10.0.0.254"
447 subnet.cidr = "10.0.0.0/24"
448 port1 = VirtualPortData()
449 port1.id = "00000000-0000-0000-0000-000000000001"
450 port1.subnet_id = subnet.id
451 port1.tenant_id = network.tenant_id
452 port1.network_id = network.id
453 port1.macAddress = "00:00:00:00:00:01"
454 port1.ip_address = "10.0.0.1"
455 port2 = VirtualPortData()
456 port2.id = "00000000-0000-0000-0000-000000000002"
457 port2.subnet_id = subnet.id
458 port2.tenant_id = network.tenant_id
459 port2.network_id = network.id
460 port2.macAddress = "00:00:00:00:00:02"
461 port2.ip_address = "10.0.0.2"
462
463 networkpostdata = network.DictoJson()
464 subnetpostdata = subnet.DictoJson()
465 port1postdata = port1.DictoJson()
466 port2postdata = port2.DictoJson()
467
468 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700469 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, httpport, '', path + 'networks/',
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700470 'POST', None, networkpostdata )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800471 utilities.assert_equals(
472 expect='200',
473 actual=Poststatus,
474 onpass="Post Network Success",
475 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
476
477 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700478 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, httpport, '', path + 'subnets/',
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700479 'POST', None, subnetpostdata )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800480 utilities.assert_equals(
481 expect='202',
482 actual=Poststatus,
483 onpass="Post Subnet Success",
484 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
485
486 main.step( "Post Port1 Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700487 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, httpport, '', path + 'ports/',
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700488 'POST', None, port1postdata )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800489 utilities.assert_equals(
490 expect='200',
491 actual=Poststatus,
492 onpass="Post Port Success",
493 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
494
495 main.step( "Post Port2 Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700496 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, httpport, '', path + 'ports/',
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700497 'POST', None, port2postdata )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800498 utilities.assert_equals(
499 expect='200',
500 actual=Poststatus,
501 onpass="Post Port Success",
502 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
503
504 def CASE7( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800505 """
506 Test host go online and ping each other
507 """
508 import re
alison6acef9f2016-09-28 12:29:08 -0700509 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800510
511 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
512 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
513 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
514
515 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
516 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
517 stepResult = assignResult
518 utilities.assert_equals( expect=main.TRUE,
519 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700520 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800521 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700522 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800523 str( ctrlip ) + " failed" )
524
525 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
526 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
527 stepResult = assignResult
528 utilities.assert_equals( expect=main.TRUE,
529 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700530 onpass="ovsdb node 2 set ovs manager to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800531 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700532 onfail="ovsdb node 2 set ovs manager to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800533 str( ctrlip ) + " failed" )
534
535 main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) )
536 stepResult = main.OVSDB1.createHost( hostname="host1" )
537 utilities.assert_equals( expect=main.TRUE,
538 actual=stepResult,
539 onpass="Create host1 on node 1 " + str( OVSDB1Ip ) + " sucess",
540 onfail="Create host1 on node 1 " + str( OVSDB1Ip ) + " failed" )
541
542 main.step( "Create host2 on node 2 " + str( OVSDB2Ip ) )
543 stepResult = main.OVSDB2.createHost( hostname="host2" )
544 utilities.assert_equals( expect=main.TRUE,
545 actual=stepResult,
546 onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess",
547 onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" )
548
Jon Hall8638b562017-05-24 16:39:59 -0700549 main.step( "Create port on host1 on the node " + str( OVSDB1Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800550 stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" )
551 utilities.assert_equals( expect=main.TRUE,
552 actual=stepResult,
553 onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess",
554 onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" )
555
Jon Hall8638b562017-05-24 16:39:59 -0700556 main.step( "Create port on host2 on the node " + str( OVSDB2Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800557 stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" )
558 utilities.assert_equals( expect=main.TRUE,
559 actual=stepResult,
560 onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess",
561 onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" )
562
Jon Hall8638b562017-05-24 16:39:59 -0700563 main.step( "Add port to ovs br-int and host go-online on the node " + str( OVSDB1Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800564 stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001",
565 attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" )
566 utilities.assert_equals( expect=main.TRUE,
567 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700568 onpass="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800569 str( OVSDB1Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700570 onfail="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800571 str( OVSDB1Ip ) + " failed" )
572
Jon Hall8638b562017-05-24 16:39:59 -0700573 main.step( "Add port to ovs br-int and host go-online on the node " + str( OVSDB2Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800574 stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002",
575 attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" )
576 utilities.assert_equals( expect=main.TRUE,
577 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700578 onpass="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800579 str( OVSDB2Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700580 onfail="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800581 str( OVSDB2Ip ) + " failed" )
582
583 main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) )
584 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
585 if re.search( "00:00:00:00:00:01", response ):
586 stepResult = main.TRUE
587 else:
588 stepResult = main.FALSE
589 utilities.assert_equals( expect=main.TRUE,
590 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700591 onpass="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800592 str( OVSDB1Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700593 onfail="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800594 str( OVSDB1Ip ) + " failed" )
595
596 main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) )
597 response = main.OVSDB2.dumpFlows( sw="br-int", protocols="OpenFlow13" )
598 if re.search( "00:00:00:00:00:02", response ):
599 stepResult = main.TRUE
600 else:
601 stepResult = main.FALSE
602 utilities.assert_equals( expect=main.TRUE,
603 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700604 onpass="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800605 str( OVSDB2Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700606 onfail="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800607 str( OVSDB2Ip ) + " failed" )
608
609 main.step( "Check hosts can ping each other" )
610 main.OVSDB1.setHostportIp( hostname="host1", hostport1="host1-eth0", ip="10.0.0.1" )
611 main.OVSDB2.setHostportIp( hostname="host2", hostport1="host2-eth0", ip="10.0.0.2" )
612 pingResult1 = main.OVSDB1.hostPing( src="10.0.0.1", hostname="host1", target="10.0.0.2" )
613 pingResult2 = main.OVSDB2.hostPing( src="10.0.0.2", hostname="host2", target="10.0.0.1" )
614 stepResult = pingResult1 and pingResult2
615 utilities.assert_equals( expect=main.TRUE,
616 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700617 onpass="Successfully host go online and ping each other,controller is " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800618 str( ctrlip ),
Jon Hall8638b562017-05-24 16:39:59 -0700619 onfail="Failed to host go online and ping each other,controller is " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800620 str( ctrlip ) )
621
622 def CASE8( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800623 """
624 Clear ovs configuration and host configuration
625 """
626 import re
alison6acef9f2016-09-28 12:29:08 -0700627 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800628
629 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
630 OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
631 OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
632 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
633
634 main.step( "Delete ovsdb node 1 manager" )
635 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
636 stepResult = deleteResult
637 utilities.assert_equals( expect=main.TRUE,
638 actual=stepResult,
639 onpass="ovsdb node 1 delete manager sucess",
640 onfail="ovsdb node 1 delete manager failed" )
641
642 main.step( "Delete ovsdb node 2 manager" )
643 deleteResult = main.OVSDB2.delManager( delaytime=delaytime )
644 stepResult = deleteResult
645 utilities.assert_equals( expect=main.TRUE,
646 actual=stepResult,
647 onpass="ovsdb node 2 delete manager sucess",
648 onfail="ovsdb node 2 delete manager failed" )
649
650 main.step( "Delete ovsdb node 1 bridge br-int" )
651 deleteResult = main.OVSDB1.delBr( sw="br-int" )
652 stepResult = deleteResult
653 utilities.assert_equals( expect=main.TRUE,
654 actual=stepResult,
655 onpass="Delete ovsdb node 1 bridge br-int sucess",
656 onfail="Delete ovsdb node 1 bridge br-int failed" )
657
658 main.step( "Delete ovsdb node 2 bridge br-int" )
659 deleteResult = main.OVSDB2.delBr( sw="br-int" )
660 stepResult = deleteResult
661 utilities.assert_equals( expect=main.TRUE,
662 actual=stepResult,
663 onpass="Delete ovsdb node 2 bridge br-int sucess",
664 onfail="Delete ovsdb node 2 bridge br-int failed" )
665
666 main.step( "Delete ip netns host on the ovsdb node 1" )
667 deleteResult = main.OVSDB1.delHost( hostname="host1" )
668 stepResult = deleteResult
669 utilities.assert_equals( expect=main.TRUE,
670 actual=stepResult,
671 onpass="Delete ip netns host on the ovsdb node 1 sucess",
672 onfail="Delete ip netns host on the ovsdb node 1 failed" )
673
674 main.step( "Delete ip netns host on the ovsdb node 2" )
675 deleteResult = main.OVSDB2.delHost( hostname="host2" )
676 stepResult = deleteResult
677 utilities.assert_equals( expect=main.TRUE,
678 actual=stepResult,
679 onpass="Delete ip netns host on the ovsdb node 2 sucess",
680 onfail="Delete ip netns host on the ovsdb node 2 failed" )
681
682 main.step( "Check onoscli devices openflow session is false " + str( OVSDB1Ip ) )
Devin Lim142b5342017-07-20 15:22:39 -0700683 response = main.Cluster.active( 0 ).CLI.devices()
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800684 if re.search( OVSDB1Ip, response ) and not re.search( "true", response ):
685 stepResult = main.TRUE
686 else:
687 stepResult = main.FALSE
688 utilities.assert_equals( expect=main.TRUE,
689 actual=stepResult,
690 onpass="Check openflow session is false " + str( OVSDB1Ip ) + " sucess",
691 onfail="Check openflow session is false " + str( OVSDB1Ip ) + " failed" )
692
693 main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
Devin Lim142b5342017-07-20 15:22:39 -0700694 response = main.Cluster.active( 0 ).CLI.devices()
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800695 if re.search( OVSDB2Ip, response ) and not re.search( "true", response ):
696 stepResult = main.TRUE
697 else:
698 stepResult = main.FALSE
699 utilities.assert_equals( expect=main.TRUE,
700 actual=stepResult,
701 onpass="Check openflow session is false " + str( OVSDB2Ip ) + " sucess",
Jon Hall53c5e662016-04-13 16:06:56 -0700702 onfail="Check openflow session is false " + str( OVSDB2Ip ) + " failed" )