blob: 6d921be9f403b7adde541edc7067199e6f692c7a [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
10CASE6: Configure Network Subnet Port And Check On ONOS
11CASE7: Test host go online and ping each other
12zhanghaoyu7@huawei.com
13"""
14import os
15
16class FUNCovsdbtest:
17
18 def __init__( self ):
19 self.default = ''
20
21 def CASE1( self, main ):
22 """
23 CASE1 is to compile ONOS and push it to the test machines
24
25 Startup sequence:
26 cell <name>
27 onos-verify-cell
28 NOTE: temporary - onos-remove-raft-logs
29 onos-uninstall
30 start mininet
31 git pull
32 mvn clean install
33 onos-package
34 onos-install -f
35 onos-wait-for-start
36 start cli sessions
37 start ovsdb
38 start vtn apps
39 """
40 import os
41 main.log.info( "ONOS Single node start " +
42 "ovsdb test - initialization" )
43 main.case( "Setting up test environment" )
44 main.caseExplanation = "Setup the test environment including " +\
45 "installing ONOS, start ONOS."
46
47 # load some variables from the params file
48 PULLCODE = False
49 if main.params[ 'GIT' ][ 'pull' ] == 'True':
50 PULLCODE = True
51 gitBranch = main.params[ 'GIT' ][ 'branch' ]
52 cellName = main.params[ 'ENV' ][ 'cellName' ]
53 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
54 OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
55 OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
56
57 main.step( "Create cell file" )
58 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
59 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
60 main.OVSDB1.ip_address,
61 cellAppString, ipList )
62
63 main.step( "Applying cell variable to environment" )
64 cellResult = main.ONOSbench.setCell( cellName )
65 verifyResult = main.ONOSbench.verifyCell()
66
67 main.log.info( "Removing raft logs" )
68 main.ONOSbench.onosRemoveRaftLogs()
69
70 main.CLIs = []
71 main.nodes = []
72 main.numCtrls= 1
73
74 for i in range( 1, main.numCtrls + 1 ):
75 try:
76 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
77 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
78 ipList.append( main.nodes[ -1 ].ip_address )
79 except AttributeError:
80 break
81
82 main.log.info( "Uninstalling ONOS" )
83 for node in main.nodes:
84 main.ONOSbench.onosUninstall( node.ip_address )
85
86 # Make sure ONOS process is not running
87 main.log.info( "Killing any ONOS processes" )
88 killResults = main.TRUE
89 for node in main.nodes:
90 killed = main.ONOSbench.onosKill( node.ip_address )
91 killResults = killResults and killed
92
93 cleanInstallResult = main.TRUE
94 gitPullResult = main.TRUE
95 main.step( "Git checkout and pull" + gitBranch )
96 if PULLCODE:
97 main.ONOSbench.gitCheckout( gitBranch )
98 gitPullResult = main.ONOSbench.gitPull()
99 # values of 1 or 3 are good
100 utilities.assert_lesser( expect=0, actual=gitPullResult,
101 onpass="Git pull successful",
102 onfail="Git pull failed" )
103
104 main.ONOSbench.getVersion( report=True )
105
106 main.step( "Using mvn clean install" )
107 cleanInstallResult = main.TRUE
108 if PULLCODE and gitPullResult == main.TRUE:
109 cleanInstallResult = main.ONOSbench.cleanInstall()
110 else:
111 main.log.warn( "Did not pull new code so skipping mvn" +
112 "clean install" )
113 utilities.assert_equals( expect=main.TRUE,
114 actual=cleanInstallResult,
115 onpass="MCI successful",
116 onfail="MCI failed" )
117
118 main.step( "Creating ONOS package" )
119 packageResult = main.ONOSbench.onosPackage()
120 utilities.assert_equals( expect=main.TRUE,
121 actual=packageResult,
122 onpass="Successfully created ONOS package",
123 onfail="Failed to create ONOS package" )
124
125 main.step( "Installing ONOS package" )
126 onosInstallResult = main.ONOSbench.onosInstall(
127 options="-f", node=main.nodes[0].ip_address )
128 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
129 onpass="ONOS install successful",
130 onfail="ONOS install failed" )
131
132 main.step( "Checking if ONOS is up yet" )
133 print main.nodes[0].ip_address
134 for i in range( 2 ):
135 onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
136 if onos1Isup:
137 break
138 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
139 onpass="ONOS startup successful",
140 onfail="ONOS startup failed" )
141 main.log.step( "Starting ONOS CLI sessions" )
142 print main.nodes[0].ip_address
143 cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
144 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
145 onpass="ONOS cli startup successful",
146 onfail="ONOS cli startup failed" )
147
148 main.step( "App Ids check" )
149 appCheck = main.ONOScli1.appToIDCheck()
150
151 if appCheck !=main.TRUE:
152 main.log.warn( main.CLIs[0].apps() )
153 main.log.warn( main.CLIs[0].appIDs() )
154 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
155 onpass="App Ids seem to be correct",
156 onfail="Something is wrong with app Ids" )
157 if cliResults == main.FALSE:
158 main.log.error( "Failed to start ONOS,stopping test" )
159 main.cleanup()
160 main.exit()
161
162 main.step( "Install onos-ovsdatabase" )
163 installResults = main.ONOScli1.activateApp( "org.onosproject.ovsdb" )
164 utilities.assert_equals( expect=main.TRUE, actual=installResults,
165 onpass="Install onos-ovsdatabase successful",
166 onfail="Install onos-ovsdatabase failed" )
167
168 main.step( "Install onos-app-vtnrsc" )
169 installResults = main.ONOScli1.activateApp( "org.onosproject.vtnrsc" )
170 utilities.assert_equals( expect=main.TRUE, actual=installResults,
171 onpass="Install onos-app-vtnrsc successful",
172 onfail="Install onos-app-vtnrsc failed" )
173
174 main.step( "Install onos-app-vtn" )
175 installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" )
176 utilities.assert_equals( expect=main.TRUE, actual=installResults,
177 onpass="Install onos-app-vtn successful",
178 onfail="Install onos-app-vtn failed" )
179
180 main.step( "Install onos-app-vtnweb" )
181 installResults = main.ONOScli1.activateApp( "org.onosproject.vtnweb" )
182 utilities.assert_equals( expect=main.TRUE, actual=installResults,
183 onpass="Install onos-app-vtnweb successful",
184 onfail="Install onos-app-vtnweb failed" )
185
186 def CASE2( self, main ):
187
188 """
189 Test ovsdb connection and teardown
190 """
191 import os,sys
192 import re
193 import time
194
195 main.case( "Test ovsdb connection and teardown" )
196 main.caseExplanation = "Test ovsdb connection create and delete" +\
197 " over ovsdb node and onos node "
198
199 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
200 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
201 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
202
203 main.step( "Set ovsdb node manager" )
204 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
205 stepResult = assignResult
206 utilities.assert_equals( expect=main.TRUE,
207 actual=stepResult,
208 onpass="Set ovsdb node manager sucess",
209 onfail="Set ovsdb node manager failed" )
210
211 main.step( "Check ovsdb node manager is " + str( ctrlip ) )
212 response = main.OVSDB1.getManager()
213 if re.search( ctrlip, response ):
214 stepResult = main.TRUE
215 else:
216 stepResult = main.FALSE
217 utilities.assert_equals( expect=main.TRUE,
218 actual=stepResult,
219 onpass="Check ovsdb node manager is " + str( response ) ,
220 onfail="Check ovsdb node manager failed" )
221
222 main.step( "Delete ovsdb node manager" )
223 deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
224 stepResult = deleteResult
225 utilities.assert_equals( expect=main.TRUE,
226 actual=stepResult,
227 onpass="ovsdb node delete manager sucess",
228 onfail="ovsdb node delete manager failed" )
229
230 main.step( "Check ovsdb node delete manager " + str( ctrlip ) )
231 response = main.OVSDB1.getManager()
232 if not re.search( ctrlip, response ):
233 stepResult = main.TRUE
234 else:
235 stepResult = main.FALSE
236 utilities.assert_equals( expect=main.TRUE,
237 actual=stepResult,
238 onpass="Check ovsdb node delete manager sucess",
239 onfail="Check ovsdb node delete manager failed" )
240
241 def CASE3( self, main ):
242
243 """
244 Test default br-int configuration and vxlan port
245 """
246 import re
247 import time
248 import os,sys
249
250 main.case( "Test default br-int configuration and vxlan port" )
251 main.caseExplanation = "onos create default br-int bridge and" +\
252 " vxlan port on the ovsdb node"
253
254 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
255 ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
256 delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
257
258 main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
259 assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
260 stepResult = assignResult
261 utilities.assert_equals( expect=main.TRUE,
262 actual=stepResult,
263 onpass="ovsdb node 1 set ovs manager to to " +\
264 str( ctrlip ) + " sucess",
265 onfail="ovsdb node 1 set ovs manager to to " +\
266 str( ctrlip ) + " failed" )
267
268 main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
269 assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
270 stepResult = assignResult
271 utilities.assert_equals( expect=main.TRUE,
272 actual=stepResult,
273 onpass="ovsdb node 2 set ovs manager to to " +\
274 str( ctrlip ) + " sucess",
275 onfail="ovsdb node 2 set ovs manager to to " +\
276 str( ctrlip ) + " failed" )
277
278 main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
279 response = main.OVSDB1.getManager()
280 if re.search( ctrlip, response ):
281 stepResult = main.TRUE
282 else:
283 stepResult = main.FALSE
284 utilities.assert_equals( expect=main.TRUE,
285 actual=stepResult,
286 onpass="ovsdb node 1 manager is " + str( response ) ,
287 onfail="ovsdb node 1 manager check failed" )
288
289 main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
290 response = main.OVSDB2.getManager()
291 if re.search( ctrlip, response ):
292 stepResult = main.TRUE
293 else:
294 stepResult = main.FALSE
295 utilities.assert_equals( expect=main.TRUE,
296 actual=stepResult,
297 onpass="ovsdb node 2 manager is " + str( response ) ,
298 onfail="ovsdb node 2 manager check failed" )
299
300 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) )
301 response = main.OVSDB1.listBr()
302 if re.search( "br-int", response ):
303 stepResult = main.TRUE
304 else:
305 stepResult = main.FALSE
306 utilities.assert_equals( expect=main.TRUE,
307 actual=stepResult,
308 onpass="onos add default bridge on the node 1 sucess",
309 onfail="onos add default bridge on the node 1 failed" )
310
311 main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB2Ip ) )
312 response = main.OVSDB2.listBr()
313 if re.search( "br-int", response ):
314 stepResult = main.TRUE
315 else:
316 stepResult = main.FALSE
317 utilities.assert_equals( expect=main.TRUE,
318 actual=stepResult,
319 onpass="onos add default bridge on the node 2 sucess",
320 onfail="onos add default bridge on the node 2 failed" )
321
322 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB1Ip ) )
323 response = main.OVSDB1.listPorts( "br-int" )
324 if re.search( "vxlan", response ) and re.search( str( OVSDB2Ip ), response ):
325 stepResult = main.TRUE
326 else:
327 stepResult = main.FALSE
328 utilities.assert_equals( expect=main.TRUE,
329 actual=stepResult,
330 onpass="onos add default vxlan port on the node 1 sucess",
331 onfail="onos add default vxlan port on the node 1 failed" )
332
333 main.step( "Check default vxlan port on ovsdb node " + str( OVSDB2Ip ) )
334 response = main.OVSDB2.listPorts( "br-int" )
335 if re.search( "vxlan", response ) and re.search( str( OVSDB1Ip ), response ):
336 stepResult = main.TRUE
337 else:
338 stepResult = main.FALSE
339 utilities.assert_equals( expect=main.TRUE,
340 actual=stepResult,
341 onpass="onos add default vxlan port on the node 2 sucess",
342 onfail="onos add default vxlan port on the node 2 failed" )