blob: 785c125de5c9e8e5e7bc4302f2bd4372eae8e686 [file] [log] [blame]
zhanghaoyu451c1392015-08-07 19:21:16 +08001"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002Copyright 2015 Open Networking Foundation (ONF)
3
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
11 (at your option) any later version.
12
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"""
21
22"""
zhanghaoyu451c1392015-08-07 19:21:16 +080023Description: This test is to check onos set configuration and flows with ovsdb connection.
24
25List of test cases:
26CASE1: Compile ONOS and push it to the test machines
27CASE2: Test ovsdb connection and tearDown
28CASE3: Test default br-int configuration and vxlan port
29CASE4: Test default openflow configuration
30CASE5: Test default flows
zhanghaoyu7474d8c62015-08-26 14:53:28 +080031CASE6: Configure Network Subnet Port
zhanghaoyu451c1392015-08-07 19:21:16 +080032CASE7: Test host go online and ping each other
zhanghaoyu7474d8c62015-08-26 14:53:28 +080033CASE8: Clear ovs configuration and host configuration
zhanghaoyu451c1392015-08-07 19:21:16 +080034zhanghaoyu7@huawei.com
35"""
36import os
37
Jon Hall8638b562017-05-24 16:39:59 -070038
zhanghaoyu451c1392015-08-07 19:21:16 +080039class FUNCovsdbtest:
40
41 def __init__( self ):
42 self.default = ''
43
44 def CASE1( self, main ):
45 """
46 CASE1 is to compile ONOS and push it to the test machines
47
48 Startup sequence:
alison6acef9f2016-09-28 12:29:08 -070049 Construct test variables
50 Safety check, kill all ONOS processes before setup
zhanghaoyu451c1392015-08-07 19:21:16 +080051 NOTE: temporary - onos-remove-raft-logs
alison6acef9f2016-09-28 12:29:08 -070052 Create ONOS package
53 Install ONOS package
zhanghaoyu451c1392015-08-07 19:21:16 +080054 start cli sessions
55 start ovsdb
56 start vtn apps
57 """
58 import os
alison6acef9f2016-09-28 12:29:08 -070059 import time
60 main.log.info( "ONOS Single node start ovsdb test - initialization" )
Devin Lim58046fa2017-07-05 16:55:00 -070061 try:
62 from tests.dependencies.ONOSSetup import ONOSSetup
63 main.testSetUp = ONOSSetup()
64 except ImportError:
65 main.log.error( "ONOSSetup not found. exiting the test" )
66 main.exit()
67 main.testSetUp.envSetupDescription()
68 stepResult = main.FALSE
zhanghaoyu451c1392015-08-07 19:21:16 +080069
Devin Lim58046fa2017-07-05 16:55:00 -070070 try:
71 # load some variables from the params file
72 main.step( "Constructing test variables" )
73 cellName = main.params[ 'ENV' ][ 'cellName' ]
74 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
75 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
zhanghaoyu451c1392015-08-07 19:21:16 +080076
Devin Lim58046fa2017-07-05 16:55:00 -070077 main.maxNodes = 1
zhanghaoyu451c1392015-08-07 19:21:16 +080078
Devin Lim58046fa2017-07-05 16:55:00 -070079 stepResult = main.testSetUp.envSetup( hasNode=True )
zhanghaoyu451c1392015-08-07 19:21:16 +080080
Devin Lim58046fa2017-07-05 16:55:00 -070081 except Exception as e:
82 main.testSetUp.envSetupException( e )
83 main.testSetUp.evnSetupConclusion( stepResult )
zhanghaoyu451c1392015-08-07 19:21:16 +080084
zhanghaoyu451c1392015-08-07 19:21:16 +080085
Devin Lim58046fa2017-07-05 16:55:00 -070086 cliResults = main.testSetUp.ONOSSetUp( main.OVSDB1, cellName=cellName, removeLog=True )
alison6acef9f2016-09-28 12:29:08 -070087
88 if cliResults == main.FALSE:
89 main.log.error( "Failed to start ONOS, stopping test" )
90 main.cleanup()
91 main.exit()
zhanghaoyu451c1392015-08-07 19:21:16 +080092
93 main.step( "App Ids check" )
94 appCheck = main.ONOScli1.appToIDCheck()
95
alison6acef9f2016-09-28 12:29:08 -070096 if appCheck != main.TRUE:
97 main.log.warn( main.CLIs[ 0 ].apps() )
98 main.log.warn( main.CLIs[ 0 ].appIDs() )
99
100 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
zhanghaoyu451c1392015-08-07 19:21:16 +0800101 onpass="App Ids seem to be correct",
102 onfail="Something is wrong with app Ids" )
zhanghaoyu451c1392015-08-07 19:21:16 +0800103
alisond9915ea2016-08-12 10:16:26 -0700104 main.step( "Install onos-ovsdb" )
zhanghaoyu451c1392015-08-07 19:21:16 +0800105 installResults = main.ONOScli1.activateApp( "org.onosproject.ovsdb" )
106 utilities.assert_equals( expect=main.TRUE, actual=installResults,
107 onpass="Install onos-ovsdatabase successful",
108 onfail="Install onos-ovsdatabase failed" )
109
zhanghaoyu451c1392015-08-07 19:21:16 +0800110 main.step( "Install onos-app-vtn" )
111 installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" )
112 utilities.assert_equals( expect=main.TRUE, actual=installResults,
113 onpass="Install onos-app-vtn successful",
114 onfail="Install onos-app-vtn failed" )
115
zhanghaoyu451c1392015-08-07 19:21:16 +0800116 def CASE2( self, main ):
zhanghaoyu451c1392015-08-07 19:21:16 +0800117 """
118 Test ovsdb connection and teardown
119 """
alison6acef9f2016-09-28 12:29:08 -0700120 import os
zhanghaoyu451c1392015-08-07 19:21:16 +0800121 import re
zhanghaoyu451c1392015-08-07 19:21:16 +0800122
123 main.case( "Test ovsdb connection and teardown" )
124 main.caseExplanation = "Test ovsdb connection create and delete" +\
125 " over ovsdb node and onos node "
126
127 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
128 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
129 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
130
131 main.step( "Set ovsdb node manager" )
132 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
133 stepResult = assignResult
134 utilities.assert_equals( expect=main.TRUE,
135 actual=stepResult,
136 onpass="Set ovsdb node manager sucess",
137 onfail="Set ovsdb node manager failed" )
138
139 main.step( "Check ovsdb node manager is " + str( ctrlip ) )
140 response = main.OVSDB1.getManager()
141 if re.search( ctrlip, response ):
142 stepResult = main.TRUE
143 else:
144 stepResult = main.FALSE
145 utilities.assert_equals( expect=main.TRUE,
146 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700147 onpass="Check ovsdb node manager is " + str( response ),
zhanghaoyu451c1392015-08-07 19:21:16 +0800148 onfail="Check ovsdb node manager failed" )
149
150 main.step( "Delete ovsdb node manager" )
151 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
152 stepResult = deleteResult
153 utilities.assert_equals( expect=main.TRUE,
154 actual=stepResult,
155 onpass="ovsdb node delete manager sucess",
156 onfail="ovsdb node delete manager failed" )
157
158 main.step( "Check ovsdb node delete manager " + str( ctrlip ) )
159 response = main.OVSDB1.getManager()
160 if not re.search( ctrlip, response ):
161 stepResult = main.TRUE
162 else:
163 stepResult = main.FALSE
164 utilities.assert_equals( expect=main.TRUE,
165 actual=stepResult,
166 onpass="Check ovsdb node delete manager sucess",
167 onfail="Check ovsdb node delete manager failed" )
168
169 def CASE3( self, main ):
zhanghaoyu451c1392015-08-07 19:21:16 +0800170 """
171 Test default br-int configuration and vxlan port
172 """
173 import re
alison6acef9f2016-09-28 12:29:08 -0700174 import os
zhanghaoyu451c1392015-08-07 19:21:16 +0800175
176 main.case( "Test default br-int configuration and vxlan port" )
177 main.caseExplanation = "onos create default br-int bridge and" +\
178 " vxlan port on the ovsdb node"
179
180 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
181 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
182 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
Jon Hall8638b562017-05-24 16:39:59 -0700183 OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
184 OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
zhanghaoyu451c1392015-08-07 19:21:16 +0800185
186 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
187 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
188 stepResult = assignResult
189 utilities.assert_equals( expect=main.TRUE,
190 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700191 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800192 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700193 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800194 str( ctrlip ) + " failed" )
195
196 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
197 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
198 stepResult = assignResult
199 utilities.assert_equals( expect=main.TRUE,
200 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700201 onpass="ovsdb node 2 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800202 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700203 onfail="ovsdb node 2 set ovs manager to to " +
zhanghaoyu451c1392015-08-07 19:21:16 +0800204 str( ctrlip ) + " failed" )
205
206 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
207 response = main.OVSDB1.getManager()
208 if re.search( ctrlip, response ):
209 stepResult = main.TRUE
210 else:
211 stepResult = main.FALSE
212 utilities.assert_equals( expect=main.TRUE,
213 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700214 onpass="ovsdb node 1 manager is " + str( response ),
zhanghaoyu451c1392015-08-07 19:21:16 +0800215 onfail="ovsdb node 1 manager check failed" )
216
217 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
218 response = main.OVSDB2.getManager()
219 if re.search( ctrlip, response ):
220 stepResult = main.TRUE
221 else:
222 stepResult = main.FALSE
223 utilities.assert_equals( expect=main.TRUE,
224 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700225 onpass="ovsdb node 2 manager is " + str( response ),
zhanghaoyu451c1392015-08-07 19:21:16 +0800226 onfail="ovsdb node 2 manager check failed" )
227
228 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) )
229 response = main.OVSDB1.listBr()
230 if re.search( "br-int", response ):
231 stepResult = main.TRUE
232 else:
233 stepResult = main.FALSE
234 utilities.assert_equals( expect=main.TRUE,
235 actual=stepResult,
236 onpass="onos add default bridge on the node 1 sucess",
237 onfail="onos add default bridge on the node 1 failed" )
238
239 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB2Ip ) )
240 response = main.OVSDB2.listBr()
241 if re.search( "br-int", response ):
242 stepResult = main.TRUE
243 else:
244 stepResult = main.FALSE
245 utilities.assert_equals( expect=main.TRUE,
246 actual=stepResult,
247 onpass="onos add default bridge on the node 2 sucess",
248 onfail="onos add default bridge on the node 2 failed" )
249
250 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB1Ip ) )
251 response = main.OVSDB1.listPorts( "br-int" )
252 if re.search( "vxlan", response ) and re.search( str( OVSDB2Ip ), response ):
253 stepResult = main.TRUE
254 else:
255 stepResult = main.FALSE
256 utilities.assert_equals( expect=main.TRUE,
257 actual=stepResult,
258 onpass="onos add default vxlan port on the node 1 sucess",
259 onfail="onos add default vxlan port on the node 1 failed" )
260
261 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB2Ip ) )
262 response = main.OVSDB2.listPorts( "br-int" )
263 if re.search( "vxlan", response ) and re.search( str( OVSDB1Ip ), response ):
264 stepResult = main.TRUE
265 else:
266 stepResult = main.FALSE
267 utilities.assert_equals( expect=main.TRUE,
268 actual=stepResult,
269 onpass="onos add default vxlan port on the node 2 sucess",
270 onfail="onos add default vxlan port on the node 2 failed" )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800271
272 def CASE4( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800273 """
274 Test default openflow configuration
275 """
276 import re
alison6acef9f2016-09-28 12:29:08 -0700277 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800278
279 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
280 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
281 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
282
283 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
284 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
285 stepResult = assignResult
286 utilities.assert_equals( expect=main.TRUE,
287 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700288 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800289 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700290 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800291 str( ctrlip ) + " failed" )
292
293 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
294 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
295 stepResult = assignResult
296 utilities.assert_equals( expect=main.TRUE,
297 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700298 onpass="ovsdb node 2 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800299 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700300 onfail="ovsdb node 2 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800301 str( ctrlip ) + " failed" )
302
303 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
304 response = main.OVSDB1.getManager()
305 if re.search( ctrlip, response ):
306 stepResult = main.TRUE
307 else:
308 stepResult = main.FALSE
309 utilities.assert_equals( expect=main.TRUE,
310 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700311 onpass="ovsdb node 1 manager is " + str( response ),
312 onfail="ovsdb node 1 manager check failed\n" +
sunyulin916e13e2015-10-15 20:27:23 +0800313 str( main.OVSDB1.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800314
315 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
316 response = main.OVSDB2.getManager()
317 if re.search( ctrlip, response ):
318 stepResult = main.TRUE
319 else:
320 stepResult = main.FALSE
321 utilities.assert_equals( expect=main.TRUE,
322 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700323 onpass="ovsdb node 2 manager is " + str( response ),
324 onfail="ovsdb node 2 manager check failed\n" +
sunyulin916e13e2015-10-15 20:27:23 +0800325 str( main.OVSDB2.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800326
327 main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) )
328 response = main.OVSDB1.getController( "br-int" )
329 if re.search( ctrlip, response ):
330 stepResult = main.TRUE
331 else:
332 stepResult = main.FALSE
333 utilities.assert_equals( expect=main.TRUE,
334 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700335 onpass="Check ovsdb node 1 bridge br-int controller set to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800336 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700337 onfail="Check ovsdb node 1 bridge br-int controller set to " +
sunyulin916e13e2015-10-15 20:27:23 +0800338 str( ctrlip ) + " failed\n" + str( main.OVSDB1.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800339
340 main.step( "Check ovsdb node 2 bridge br-int controller set to " + str( ctrlip ) )
341 response = main.OVSDB2.getController( "br-int" )
342 if re.search( ctrlip, response ):
343 stepResult = main.TRUE
344 else:
345 stepResult = main.FALSE
346 utilities.assert_equals( expect=main.TRUE,
347 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700348 onpass="Check ovsdb node 2 bridge br-int controller set to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800349 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700350 onfail="Check ovsdb node 2 bridge br-int controller set to " +
351 str( ctrlip ) + " failed\n" + str( main.OVSDB2.show() ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800352
353 main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) )
354 response = main.ONOScli1.devices()
355 if re.search( OVSDB1Ip, response ) and not re.search( "false", response ):
356 stepResult = main.TRUE
357 else:
358 stepResult = main.FALSE
359 utilities.assert_equals( expect=main.TRUE,
360 actual=stepResult,
361 onpass="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " sucess",
362 onfail="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " failed" )
363
364 main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
365 response = main.ONOScli1.devices()
366 if re.search( OVSDB2Ip, response ) and not re.search( "false", response ):
367 stepResult = main.TRUE
368 else:
369 stepResult = main.FALSE
370 utilities.assert_equals( expect=main.TRUE,
371 actual=stepResult,
372 onpass="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " sucess",
373 onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" )
374
375 def CASE5( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800376 """
377 Test default flows
378 """
379 import re
alison6acef9f2016-09-28 12:29:08 -0700380 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800381
382 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
383 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
384 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
385
386 main.step( "ovsdb node 1 set ovs manager to onos" )
387 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
388 stepResult = assignResult
389 utilities.assert_equals( expect=main.TRUE,
390 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700391 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800392 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700393 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800394 str( ctrlip ) + " failed" )
395
396 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
397 response = main.OVSDB1.getManager()
398 if re.search( ctrlip, response ):
399 stepResult = main.TRUE
400 else:
401 stepResult = main.FALSE
402 utilities.assert_equals( expect=main.TRUE,
403 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700404 onpass="ovsdb node 1 manager is " + str( response ),
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800405 onfail="ovsdb node 1 manager check failed" )
406
407 main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) )
408 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
409 if re.search( "actions=CONTROLLER", response ):
410 stepResult = main.TRUE
411 else:
412 stepResult = main.FALSE
413 utilities.assert_equals( expect=main.TRUE,
414 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700415 onpass="Successfully set default flows " + str( ctrlip ),
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800416 onfail="Failed to set default flows " + str( ctrlip ) )
417
418 def CASE6( self, main ):
419 """
420 Configure Network Subnet Port
421 """
422 import os
423
424 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700425 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import NetworkData
426 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import SubnetData
427 from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800428 except ImportError:
429 main.log.exception( "Something wrong with import file or code error." )
430 main.log.info( "Import Error, please check!" )
431 main.cleanup()
432 main.exit()
433
434 main.log.info( "Configure Network Subnet Port Start" )
435 main.case( "Configure Network Subnet Port" )
436 main.caseExplanation = "Configure Network Subnet Port " +\
437 "Verify post is OK"
438
Jon Hall8638b562017-05-24 16:39:59 -0700439 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
440 httpport = main.params[ 'HTTP' ][ 'port' ]
441 path = main.params[ 'HTTP' ][ 'path' ]
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800442
443 main.step( "Generate Post Data" )
444 network = NetworkData()
445 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
446 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
447 subnet = SubnetData()
448 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
449 subnet.tenant_id = network.tenant_id
450 subnet.network_id = network.id
451 subnet.start = "10.0.0.1"
452 subnet.end = "10.0.0.254"
453 subnet.cidr = "10.0.0.0/24"
454 port1 = VirtualPortData()
455 port1.id = "00000000-0000-0000-0000-000000000001"
456 port1.subnet_id = subnet.id
457 port1.tenant_id = network.tenant_id
458 port1.network_id = network.id
459 port1.macAddress = "00:00:00:00:00:01"
460 port1.ip_address = "10.0.0.1"
461 port2 = VirtualPortData()
462 port2.id = "00000000-0000-0000-0000-000000000002"
463 port2.subnet_id = subnet.id
464 port2.tenant_id = network.tenant_id
465 port2.network_id = network.id
466 port2.macAddress = "00:00:00:00:00:02"
467 port2.ip_address = "10.0.0.2"
468
469 networkpostdata = network.DictoJson()
470 subnetpostdata = subnet.DictoJson()
471 port1postdata = port1.DictoJson()
472 port2postdata = port2.DictoJson()
473
474 main.step( "Post Network Data via HTTP(Post port need post network)" )
475 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
476 'POST', None, networkpostdata )
477 utilities.assert_equals(
478 expect='200',
479 actual=Poststatus,
480 onpass="Post Network Success",
481 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
482
483 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
484 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
485 'POST', None, subnetpostdata )
486 utilities.assert_equals(
487 expect='202',
488 actual=Poststatus,
489 onpass="Post Subnet Success",
490 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
491
492 main.step( "Post Port1 Data via HTTP" )
493 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
494 'POST', None, port1postdata )
495 utilities.assert_equals(
496 expect='200',
497 actual=Poststatus,
498 onpass="Post Port Success",
499 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
500
501 main.step( "Post Port2 Data via HTTP" )
502 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
503 'POST', None, port2postdata )
504 utilities.assert_equals(
505 expect='200',
506 actual=Poststatus,
507 onpass="Post Port Success",
508 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
509
510 def CASE7( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800511 """
512 Test host go online and ping each other
513 """
514 import re
alison6acef9f2016-09-28 12:29:08 -0700515 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800516
517 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
518 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
519 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
520
521 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
522 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
523 stepResult = assignResult
524 utilities.assert_equals( expect=main.TRUE,
525 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700526 onpass="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800527 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700528 onfail="ovsdb node 1 set ovs manager to to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800529 str( ctrlip ) + " failed" )
530
531 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
532 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
533 stepResult = assignResult
534 utilities.assert_equals( expect=main.TRUE,
535 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700536 onpass="ovsdb node 2 set ovs manager to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800537 str( ctrlip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700538 onfail="ovsdb node 2 set ovs manager to " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800539 str( ctrlip ) + " failed" )
540
541 main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) )
542 stepResult = main.OVSDB1.createHost( hostname="host1" )
543 utilities.assert_equals( expect=main.TRUE,
544 actual=stepResult,
545 onpass="Create host1 on node 1 " + str( OVSDB1Ip ) + " sucess",
546 onfail="Create host1 on node 1 " + str( OVSDB1Ip ) + " failed" )
547
548 main.step( "Create host2 on node 2 " + str( OVSDB2Ip ) )
549 stepResult = main.OVSDB2.createHost( hostname="host2" )
550 utilities.assert_equals( expect=main.TRUE,
551 actual=stepResult,
552 onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess",
553 onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" )
554
Jon Hall8638b562017-05-24 16:39:59 -0700555 main.step( "Create port on host1 on the node " + str( OVSDB1Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800556 stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" )
557 utilities.assert_equals( expect=main.TRUE,
558 actual=stepResult,
559 onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess",
560 onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" )
561
Jon Hall8638b562017-05-24 16:39:59 -0700562 main.step( "Create port on host2 on the node " + str( OVSDB2Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800563 stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" )
564 utilities.assert_equals( expect=main.TRUE,
565 actual=stepResult,
566 onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess",
567 onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" )
568
Jon Hall8638b562017-05-24 16:39:59 -0700569 main.step( "Add port to ovs br-int and host go-online on the node " + str( OVSDB1Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800570 stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001",
571 attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" )
572 utilities.assert_equals( expect=main.TRUE,
573 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700574 onpass="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800575 str( OVSDB1Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700576 onfail="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800577 str( OVSDB1Ip ) + " failed" )
578
Jon Hall8638b562017-05-24 16:39:59 -0700579 main.step( "Add port to ovs br-int and host go-online on the node " + str( OVSDB2Ip ) )
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800580 stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002",
581 attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" )
582 utilities.assert_equals( expect=main.TRUE,
583 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700584 onpass="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800585 str( OVSDB2Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700586 onfail="Add port to ovs br-int and host go-online on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800587 str( OVSDB2Ip ) + " failed" )
588
589 main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) )
590 response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
591 if re.search( "00:00:00:00:00:01", response ):
592 stepResult = main.TRUE
593 else:
594 stepResult = main.FALSE
595 utilities.assert_equals( expect=main.TRUE,
596 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700597 onpass="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800598 str( OVSDB1Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700599 onfail="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800600 str( OVSDB1Ip ) + " failed" )
601
602 main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) )
603 response = main.OVSDB2.dumpFlows( sw="br-int", protocols="OpenFlow13" )
604 if re.search( "00:00:00:00:00:02", response ):
605 stepResult = main.TRUE
606 else:
607 stepResult = main.FALSE
608 utilities.assert_equals( expect=main.TRUE,
609 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700610 onpass="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800611 str( OVSDB2Ip ) + " sucess",
Jon Hall8638b562017-05-24 16:39:59 -0700612 onfail="Check onos set host flows on the node " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800613 str( OVSDB2Ip ) + " failed" )
614
615 main.step( "Check hosts can ping each other" )
616 main.OVSDB1.setHostportIp( hostname="host1", hostport1="host1-eth0", ip="10.0.0.1" )
617 main.OVSDB2.setHostportIp( hostname="host2", hostport1="host2-eth0", ip="10.0.0.2" )
618 pingResult1 = main.OVSDB1.hostPing( src="10.0.0.1", hostname="host1", target="10.0.0.2" )
619 pingResult2 = main.OVSDB2.hostPing( src="10.0.0.2", hostname="host2", target="10.0.0.1" )
620 stepResult = pingResult1 and pingResult2
621 utilities.assert_equals( expect=main.TRUE,
622 actual=stepResult,
Jon Hall8638b562017-05-24 16:39:59 -0700623 onpass="Successfully host go online and ping each other,controller is " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800624 str( ctrlip ),
Jon Hall8638b562017-05-24 16:39:59 -0700625 onfail="Failed to host go online and ping each other,controller is " +
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800626 str( ctrlip ) )
627
628 def CASE8( self, main ):
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800629 """
630 Clear ovs configuration and host configuration
631 """
632 import re
alison6acef9f2016-09-28 12:29:08 -0700633 import os
zhanghaoyu7474d8c62015-08-26 14:53:28 +0800634
635 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
636 OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
637 OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
638 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
639
640 main.step( "Delete ovsdb node 1 manager" )
641 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
642 stepResult = deleteResult
643 utilities.assert_equals( expect=main.TRUE,
644 actual=stepResult,
645 onpass="ovsdb node 1 delete manager sucess",
646 onfail="ovsdb node 1 delete manager failed" )
647
648 main.step( "Delete ovsdb node 2 manager" )
649 deleteResult = main.OVSDB2.delManager( delaytime=delaytime )
650 stepResult = deleteResult
651 utilities.assert_equals( expect=main.TRUE,
652 actual=stepResult,
653 onpass="ovsdb node 2 delete manager sucess",
654 onfail="ovsdb node 2 delete manager failed" )
655
656 main.step( "Delete ovsdb node 1 bridge br-int" )
657 deleteResult = main.OVSDB1.delBr( sw="br-int" )
658 stepResult = deleteResult
659 utilities.assert_equals( expect=main.TRUE,
660 actual=stepResult,
661 onpass="Delete ovsdb node 1 bridge br-int sucess",
662 onfail="Delete ovsdb node 1 bridge br-int failed" )
663
664 main.step( "Delete ovsdb node 2 bridge br-int" )
665 deleteResult = main.OVSDB2.delBr( sw="br-int" )
666 stepResult = deleteResult
667 utilities.assert_equals( expect=main.TRUE,
668 actual=stepResult,
669 onpass="Delete ovsdb node 2 bridge br-int sucess",
670 onfail="Delete ovsdb node 2 bridge br-int failed" )
671
672 main.step( "Delete ip netns host on the ovsdb node 1" )
673 deleteResult = main.OVSDB1.delHost( hostname="host1" )
674 stepResult = deleteResult
675 utilities.assert_equals( expect=main.TRUE,
676 actual=stepResult,
677 onpass="Delete ip netns host on the ovsdb node 1 sucess",
678 onfail="Delete ip netns host on the ovsdb node 1 failed" )
679
680 main.step( "Delete ip netns host on the ovsdb node 2" )
681 deleteResult = main.OVSDB2.delHost( hostname="host2" )
682 stepResult = deleteResult
683 utilities.assert_equals( expect=main.TRUE,
684 actual=stepResult,
685 onpass="Delete ip netns host on the ovsdb node 2 sucess",
686 onfail="Delete ip netns host on the ovsdb node 2 failed" )
687
688 main.step( "Check onoscli devices openflow session is false " + str( OVSDB1Ip ) )
689 response = main.ONOScli1.devices()
690 if re.search( OVSDB1Ip, response ) and not re.search( "true", response ):
691 stepResult = main.TRUE
692 else:
693 stepResult = main.FALSE
694 utilities.assert_equals( expect=main.TRUE,
695 actual=stepResult,
696 onpass="Check openflow session is false " + str( OVSDB1Ip ) + " sucess",
697 onfail="Check openflow session is false " + str( OVSDB1Ip ) + " failed" )
698
699 main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
700 response = main.ONOScli1.devices()
701 if re.search( OVSDB2Ip, response ) and not re.search( "true", response ):
702 stepResult = main.TRUE
703 else:
704 stepResult = main.FALSE
705 utilities.assert_equals( expect=main.TRUE,
706 actual=stepResult,
707 onpass="Check openflow session is false " + str( OVSDB2Ip ) + " sucess",
Jon Hall53c5e662016-04-13 16:06:56 -0700708 onfail="Check openflow session is false " + str( OVSDB2Ip ) + " failed" )