blob: c8a5c553eb5ed86df9be6296a2bce4d466bcbb75 [file] [log] [blame]
lanqinglong77124b02015-08-06 11:47:38 +08001"""
2Description: This test is to determine if North bound
3 can handle the request
4
5List of test cases:
6CASE1 - Variable initialization and optional pull and build ONOS package
7CASE2 - Create Network northbound test
8CASE3 - Update Network northbound test
9CASE4 - Delete Network northbound test
10CASE5 - Create Subnet northbound test
11CASE6 - Update Subnet northbound test
12CASE7 - Delete Subnet northbound test
13CASE8 - Create Virtualport northbound test
14CASE9 - Update Virtualport northbound test
15CASE10 - Delete Virtualport northbound test
ligenyud4ae1be2015-09-28 20:03:13 +080016CASE11 - Post Error Json Create Network test
17CASE12 - Post Error Json Create Subnet test
18CASE13 - Post Error Json Create Virtualport test
lanqinglong77124b02015-08-06 11:47:38 +080019
20lanqinglong@huawei.com
21"""
22import os
23
Jon Hallf52840a2017-05-24 16:49:52 -070024
lanqinglong77124b02015-08-06 11:47:38 +080025class FUNCvirNetNB:
26
27 def __init__( self ):
28 self.default = ''
29
30 def CASE1( self, main ):
31 """
32 CASE1 is to compile ONOS and push it to the test machines
33
34 Startup sequence:
35 cell<name>
36 onos-verify-cell
37 NOTE:temporary - onos-remove-raft-logs
38 onos-uninstall
39 git pull
40 mvn clean install
41 onos-package
42 onos-install -f
43 onos-wait-for-start
44 start cli sessions
45 start vtnrsc
46 """
lanqinglong77124b02015-08-06 11:47:38 +080047 import time
48 import os
Jon Hallf52840a2017-05-24 16:49:52 -070049 main.log.info( "ONOS Single node Start " +
50 "VirtualNet Northbound test - initialization" )
lanqinglong77124b02015-08-06 11:47:38 +080051 main.case( "Setting up test environment" )
Jon Hallf52840a2017-05-24 16:49:52 -070052 main.caseExplanation = "Setup the test environment including " +\
lanqinglong77124b02015-08-06 11:47:38 +080053 "installing ONOS,start ONOS."
54
55 # load some variables from the params file
56 PULLCODE = False
Jon Hallf52840a2017-05-24 16:49:52 -070057 if main.params[ 'GIT' ][ 'pull' ] == 'True':
lanqinglong77124b02015-08-06 11:47:38 +080058 PULLCODE = True
Jon Hallf52840a2017-05-24 16:49:52 -070059 gitBranch = main.params[ 'GIT' ][ 'branch' ]
60 cellName = main.params[ 'ENV' ][ 'cellName' ]
61 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
lanqinglong77124b02015-08-06 11:47:38 +080062
Jon Hallf52840a2017-05-24 16:49:52 -070063 main.step( "Create cell file and apply to environment" )
64 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
65 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
66 main.Mininet1.ip_address,
Devin Lim461f0872017-06-05 16:49:33 -070067 cellAppString, ipList, main.ONOScli1.user_name )
lanqinglong77124b02015-08-06 11:47:38 +080068
Jon Hallf52840a2017-05-24 16:49:52 -070069 cellResult = main.ONOSbench.setCell( cellName )
lanqinglong77124b02015-08-06 11:47:38 +080070 verifyResult = main.ONOSbench.verifyCell()
71
lanqinglongca0a0ee2015-09-22 16:19:08 +080072 stepResult = cellResult and verifyResult
73 utilities.assert_equals( expect=main.TRUE,
74 actual=stepResult,
Jon Hallf52840a2017-05-24 16:49:52 -070075 onpass="Successfully applied cell to " +
lanqinglongca0a0ee2015-09-22 16:19:08 +080076 "environment",
77 onfail="Failed to apply cell to environment " )
78
lanqinglong77124b02015-08-06 11:47:38 +080079 #FIXME:this is short term fix
80 main.log.info( "Removing raft logs" )
lanqinglonge675e922015-08-13 21:17:28 +080081 main.ONOSbench.onosRemoveRaftLogs()
lanqinglong77124b02015-08-06 11:47:38 +080082
83 main.CLIs = []
84 main.nodes = []
Jon Hallf52840a2017-05-24 16:49:52 -070085 main.numCtrls = 1
lanqinglong77124b02015-08-06 11:47:38 +080086 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
87
Jon Hallf52840a2017-05-24 16:49:52 -070088 for i in range( 1, main.numCtrls + 1 ):
lanqinglong77124b02015-08-06 11:47:38 +080089 try:
Jon Hallf52840a2017-05-24 16:49:52 -070090 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
91 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
lanqinglong77124b02015-08-06 11:47:38 +080092 ipList.append( main.nodes[ -1 ].ip_address )
93 except AttributeError:
94 break
95
96 main.log.info( "Uninstalling ONOS" )
97 for node in main.nodes:
98 main.ONOSbench.onosUninstall( node.ip_address )
99
100 #Make sure ONOS is DEAD
101 main.log.info( "Killing any ONOS processes" )
102 killResults = main.TRUE
103 for node in main.nodes:
104 killed = main.ONOSbench.onosKill( node.ip_address )
105 killResults = killResults and killed
106
107 cleanInstallResult = main.TRUE
108 gitPullResult = main.TRUE
lanqinglongca0a0ee2015-09-22 16:19:08 +0800109 main.log.info( "Git checkout and pull " + gitBranch )
lanqinglong77124b02015-08-06 11:47:38 +0800110 if PULLCODE:
Jon Hallf52840a2017-05-24 16:49:52 -0700111 main.ONOSbench.gitCheckout( gitBranch )
lanqinglong77124b02015-08-06 11:47:38 +0800112 gitPullResult = main.ONOSbench.gitPull()
113 # values of 1 or 3 are good
Jon Hallf52840a2017-05-24 16:49:52 -0700114 utilities.assert_lesser( expect=0, actual=gitPullResult,
lanqinglong77124b02015-08-06 11:47:38 +0800115 onpass="Git pull successful",
Jon Hallf52840a2017-05-24 16:49:52 -0700116 onfail="Git pull failed" )
117 main.ONOSbench.getVersion( report=True )
lanqinglong77124b02015-08-06 11:47:38 +0800118 main.step( "Using mvn clean install" )
Jon Hallf52840a2017-05-24 16:49:52 -0700119 cleanInstallResult = main.TRUE
lanqinglong77124b02015-08-06 11:47:38 +0800120 if PULLCODE and gitPullResult == main.TRUE:
121 cleanInstallResult = main.ONOSbench.cleanInstall()
122 else:
Jon Hallf52840a2017-05-24 16:49:52 -0700123 main.log.warn( "Did not pull new code so skipping mvn " +
124 "clean install" )
lanqinglong77124b02015-08-06 11:47:38 +0800125
126 utilities.assert_equals( expect=main.TRUE,
127 actual=cleanInstallResult,
128 onpass="MCI successful",
129 onfail="MCI failed" )
130
131 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700132 packageResult = main.ONOSbench.buckBuild()
lanqinglong77124b02015-08-06 11:47:38 +0800133 utilities.assert_equals( expect=main.TRUE,
134 actual=packageResult,
135 onpass="Successfully created ONOS package",
136 onfail="Failed to create ONOS package " )
137 time.sleep( main.startUpSleep )
138
139 main.step( "Installing ONOS package" )
140 onosInstallResult = main.ONOSbench.onosInstall(
Jon Hallf52840a2017-05-24 16:49:52 -0700141 options="-f", node=main.nodes[ 0 ].ip_address )
lanqinglong77124b02015-08-06 11:47:38 +0800142 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
Jon Hallf52840a2017-05-24 16:49:52 -0700143 onpass="ONOS install successful",
144 onfail="ONOS install failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800145 time.sleep( main.startUpSleep )
146
You Wangf5de25b2017-01-06 15:13:01 -0800147 main.step( "Set up ONOS secure SSH" )
Jon Hallf52840a2017-05-24 16:49:52 -0700148 secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[ 0 ].ip_address )
You Wangf5de25b2017-01-06 15:13:01 -0800149 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
150 onpass="Test step PASS",
151 onfail="Test step FAIL" )
152
lanqinglong77124b02015-08-06 11:47:38 +0800153 main.step( "Checking if ONOS is up yet" )
154
155 for i in range( 2 ):
Jon Hallf52840a2017-05-24 16:49:52 -0700156 onos1Isup = main.ONOSbench.isup( main.nodes[ 0 ].ip_address )
lanqinglong77124b02015-08-06 11:47:38 +0800157 if onos1Isup:
158 break
159 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
Jon Hallf52840a2017-05-24 16:49:52 -0700160 onpass="ONOS startup successful",
161 onfail="ONOS startup failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800162 time.sleep( main.startUpSleep )
163
Jon Hall6509dbf2016-06-21 17:01:17 -0700164 main.step( "Starting ONOS CLI sessions" )
lanqinglong77124b02015-08-06 11:47:38 +0800165
Jon Hallf52840a2017-05-24 16:49:52 -0700166 print main.nodes[ 0 ].ip_address
167 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
lanqinglong77124b02015-08-06 11:47:38 +0800168 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
Jon Hallf52840a2017-05-24 16:49:52 -0700169 onpass="ONOS cli startup successful",
170 onfail="ONOS cli startup failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800171 time.sleep( main.startUpSleep )
172
173 main.step( "App Ids check" )
174 appCheck = main.ONOScli1.appToIDCheck()
175 if appCheck != main.TRUE:
Jon Hallf52840a2017-05-24 16:49:52 -0700176 main.log.warn( main.CLIs[ 0 ].apps() )
177 main.log.warn( main.CLIs[ 0 ].appIDs() )
lanqinglong77124b02015-08-06 11:47:38 +0800178 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
Jon Hallf52840a2017-05-24 16:49:52 -0700179 onpass="App Ids seem to be correct",
180 onfail="Something is wrong with app Ids" )
lanqinglong77124b02015-08-06 11:47:38 +0800181
182 if cliResults == main.FALSE:
183 main.log.error( "Failed to start ONOS, stopping test" )
184 main.cleanup()
185 main.exit()
186
GlennRCa0c395f2015-12-03 14:04:56 -0800187 main.step( "Install org.onosproject.vtn app" )
188 installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" )
lanqinglong77124b02015-08-06 11:47:38 +0800189 utilities.assert_equals( expect=main.TRUE, actual=installResults,
Jon Hallf52840a2017-05-24 16:49:52 -0700190 onpass="Install org.onosproject.vtn successful",
191 onfail="Install org.onosproject.vtn app failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800192
193 time.sleep( main.startUpSleep )
194
Jon Hallf52840a2017-05-24 16:49:52 -0700195 def CASE2( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800196 """
197 Test Post Network
198 """
lanqinglonge675e922015-08-13 21:17:28 +0800199 import os
200
lanqinglong77124b02015-08-06 11:47:38 +0800201 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700202 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800203 except ImportError:
204 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800205 main.log.info( "Import Error, please check!" )
206 main.cleanup()
207 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800208
209 main.log.info( "ONOS Network Post test Start" )
210 main.case( "Virtual Network NBI Test - Network" )
211 main.caseExplanation = "Test Network Post NBI " +\
212 "Verify Post Data same with Stored Data"
213
Jon Hallf52840a2017-05-24 16:49:52 -0700214 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
215 port = main.params[ 'HTTP' ][ 'port' ]
216 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800217
lanqinglongca0a0ee2015-09-22 16:19:08 +0800218 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800219 network = NetworkData()
220 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
221 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
222 postdata = network.DictoJson()
223
224 main.step( "Post Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700225 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
226 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800227
228 utilities.assert_equals(
229 expect='200',
230 actual=Poststatus,
231 onpass="Post Success",
232 onfail="Post Failed " + str( Poststatus ) + str( result ) )
233
234 main.step( "Get Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700235 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
236 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800237 utilities.assert_equals(
238 expect='200',
239 actual=Getstatus,
240 onpass="Get Success",
241 onfail="Get Failed " + str( Getstatus ) + str( result ) )
242
Jon Hallf52840a2017-05-24 16:49:52 -0700243 main.log.info( "Post Network Data is :%s\nGet Network Data is:%s" % ( postdata, result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800244
245 main.step( "Compare Send Id and Get Id" )
246 IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' )
247 TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' )
248 Cmpresult = IDcmpresult and TanantIDcmpresult
249
250 utilities.assert_equals(
251 expect=True,
252 actual=Cmpresult,
253 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700254 onfail="Compare Failed:ID compare: " + str( IDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800255 ",Tenant id compare :" + str( TanantIDcmpresult ) )
256
Jon Hallf52840a2017-05-24 16:49:52 -0700257 deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
258 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800259 utilities.assert_equals(
260 expect='200',
261 actual=deletestatus,
262 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700263 onfail="Delete Network Failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800264
Jon Hallf52840a2017-05-24 16:49:52 -0700265 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800266 main.log.error( "Post Network compare failed" )
267
Jon Hallf52840a2017-05-24 16:49:52 -0700268 def CASE3( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800269 """
270 Test Update Network
271 """
lanqinglonge675e922015-08-13 21:17:28 +0800272 import os
273
lanqinglong77124b02015-08-06 11:47:38 +0800274 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700275 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800276 except ImportError:
277 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800278 main.log.info( "Import Error, please check!" )
279 main.cleanup()
280 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800281
282 main.log.info( "ONOS Network Update test Start" )
283 main.case( "Virtual Network NBI Test - Network" )
284 main.caseExplanation = "Test Network Update NBI " +\
285 "Verify Update Data same with Stored Data"
286
Jon Hallf52840a2017-05-24 16:49:52 -0700287 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
288 port = main.params[ 'HTTP' ][ 'port' ]
289 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800290
lanqinglongca0a0ee2015-09-22 16:19:08 +0800291 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800292 network = NetworkData()
293 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
294 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
lanqinglongd0dda2e2015-08-25 11:02:48 +0800295 network.shared = False
lanqinglong77124b02015-08-06 11:47:38 +0800296 postdata = network.DictoJson()
297
lanqinglongd0dda2e2015-08-25 11:02:48 +0800298 network.shared = True
lanqinglong77124b02015-08-06 11:47:38 +0800299 postdatanew = network.DictoJson()
300
301 main.step( "Post Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700302 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks',
lanqinglong77124b02015-08-06 11:47:38 +0800303 'POST', None, postdata )
304 utilities.assert_equals(
305 expect='200',
306 actual=Poststatus,
307 onpass="Post Success",
308 onfail="Post Failed " + str( Poststatus ) + str( result ) )
309
310 main.step( "Update Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700311 Updatestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
312 'PUT', None, postdatanew )
lanqinglong77124b02015-08-06 11:47:38 +0800313 utilities.assert_equals(
314 expect='200',
315 actual=Updatestatus,
316 onpass="Update Success",
317 onfail="Update Failed " + str( Updatestatus ) + str( result ) )
318
319 main.step( "Get Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700320 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
lanqinglong77124b02015-08-06 11:47:38 +0800321 'GET', None, None )
322 utilities.assert_equals(
323 expect='200',
324 actual=Getstatus,
325 onpass="Get Success",
326 onfail="Get Failed " + str( Getstatus ) + str( result ) )
327
328 main.step( "Compare Update data." )
329 IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
330 TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
331 Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
332
333 Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
334 utilities.assert_equals(
335 expect=True,
336 actual=Cmpresult,
337 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700338 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
339 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800340 ",Name compare:" + str( Shareresult ) )
341
Jon Hallf52840a2017-05-24 16:49:52 -0700342 deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
343 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800344
345 utilities.assert_equals(
346 expect='200',
347 actual=deletestatus,
348 onpass="Delete Network Success",
349 onfail="Delete Network Failed" )
350
Jon Hallf52840a2017-05-24 16:49:52 -0700351 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800352 main.log.error( "Update Network compare failed" )
353
Jon Hallf52840a2017-05-24 16:49:52 -0700354 def CASE4( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800355 """
356 Test Delete Network
357 """
lanqinglonge675e922015-08-13 21:17:28 +0800358 import os
359
lanqinglong77124b02015-08-06 11:47:38 +0800360 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700361 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800362 except ImportError:
363 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800364 main.log.info( "Import Error, please check!" )
365 main.cleanup()
366 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800367
368 main.log.info( "ONOS Network Delete test Start" )
369 main.case( "Virtual Network NBI Test - Network" )
370 main.caseExplanation = "Test Network Delete NBI " +\
371 "Verify Stored Data is NULL after Delete"
372
Jon Hallf52840a2017-05-24 16:49:52 -0700373 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
374 port = main.params[ 'HTTP' ][ 'port' ]
375 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800376
lanqinglongca0a0ee2015-09-22 16:19:08 +0800377 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800378 network = NetworkData()
379 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
380 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
381 postdata = network.DictoJson()
382
383 main.step( "Post Data via HTTP" )
lanqinglonge675e922015-08-13 21:17:28 +0800384 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
385 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800386 utilities.assert_equals(
387 expect='200',
388 actual=Poststatus,
389 onpass="Post Success",
390 onfail="Post Failed " + str( Poststatus ) + str( result ) )
391
392 main.step( "Delete Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700393 Deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
394 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800395 utilities.assert_equals(
396 expect='200',
397 actual=Deletestatus,
398 onpass="Delete Success",
lanqinglongd0dda2e2015-08-25 11:02:48 +0800399 onfail="Delete Failed " + str( Deletestatus ) + str( result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800400
401 main.step( "Get Data is NULL" )
Jon Hallf52840a2017-05-24 16:49:52 -0700402 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
lanqinglong77124b02015-08-06 11:47:38 +0800403 'GET', None, None )
404 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800405 expect='Network is not found',
lanqinglong77124b02015-08-06 11:47:38 +0800406 actual=result,
407 onpass="Get Success",
408 onfail="Get Failed " + str( Getstatus ) + str( result ) )
409
sunyulinf16bb8d2015-09-29 20:21:16 +0800410 if result != 'Network is not found':
lanqinglong77124b02015-08-06 11:47:38 +0800411 main.log.error( "Delete Network failed" )
lanqinglonge675e922015-08-13 21:17:28 +0800412
413 def CASE5( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800414 """
415 Test Post Subnet
416 """
417 import os
418
419 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700420 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
421 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800422 except ImportError:
423 main.log.exception( "Something wrong with import file or code error." )
424 main.log.info( "Import Error, please check!" )
425 main.cleanup()
426 main.exit()
427
428 main.log.info( "ONOS Subnet Post test Start" )
429 main.case( "Virtual Network NBI Test - Subnet" )
430 main.caseExplanation = "Test Subnet Post NBI " +\
431 "Verify Stored Data is same with Post Data"
432
Jon Hallf52840a2017-05-24 16:49:52 -0700433 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
434 port = main.params[ 'HTTP' ][ 'port' ]
435 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800436
lanqinglongca0a0ee2015-09-22 16:19:08 +0800437 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800438 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
446 networkpostdata = network.DictoJson()
447 subnetpostdata = subnet.DictoJson()
448
449 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
450 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
451 'POST', None, networkpostdata )
452 utilities.assert_equals(
453 expect='200',
454 actual=Poststatus,
455 onpass="Post Network Success",
456 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
457
458 main.step( "Post Subnet Data via HTTP" )
459 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
460 'POST', None, subnetpostdata )
461 utilities.assert_equals(
462 expect='202',
463 actual=Poststatus,
464 onpass="Post Subnet Success",
465 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
466
467 main.step( "Get Subnet Data via HTTP" )
468 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
469 'GET', None, None )
470 utilities.assert_equals(
471 expect='200',
472 actual=Getstatus,
473 onpass="Get Subnet Success",
474 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
475
476 IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
477 TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
478 NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
479
480 main.step( "Compare Post Subnet Data via HTTP" )
481 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
482 utilities.assert_equals(
483 expect=True,
484 actual=Cmpresult,
485 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700486 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
487 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800488 ",Network id compare:" + str( NetoworkIDcmpresult ) )
489
Jon Hallf52840a2017-05-24 16:49:52 -0700490 deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
491 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800492 utilities.assert_equals(
493 expect='200',
494 actual=deletestatus,
495 onpass="Delete Network Success",
496 onfail="Delete Network Failed" )
497
Jon Hallf52840a2017-05-24 16:49:52 -0700498 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800499 main.log.error( "Post Subnet compare failed" )
500
501 def CASE6( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800502 """
503 Test Post Subnet
504 """
505 import os
506
507 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700508 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
509 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800510 except ImportError:
511 main.log.exception( "Something wrong with import file or code error." )
512 main.log.info( "Import Error, please check!" )
513 main.cleanup()
514 main.exit()
515
516 main.log.info( "ONOS Subnet Update test Start" )
517 main.case( "Virtual Network NBI Test - Subnet" )
518 main.caseExplanation = "Test Subnet Update NBI " +\
519 "Verify Stored Data is same with Update Data"
520
Jon Hallf52840a2017-05-24 16:49:52 -0700521 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
522 port = main.params[ 'HTTP' ][ 'port' ]
523 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800524
lanqinglongca0a0ee2015-09-22 16:19:08 +0800525 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800526 network = NetworkData()
527 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
528 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
529 subnet = SubnetData()
530 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
531 subnet.tenant_id = network.tenant_id
532 subnet.network_id = network.id
533 subnet.start = "192.168.2.1"
534 subnet.end = "192.168.2.255"
535 networkpostdata = network.DictoJson()
536 subnetpostdata = subnet.DictoJson()
537
538 #Change allocation_poolsdata scope
539 subnet.start = "192.168.102.1"
540 subnet.end = "192.168.102.255"
541 #end change
542 newsubnetpostdata = subnet.DictoJson()
543
544 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
545 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
546 'POST', None, networkpostdata )
547 utilities.assert_equals(
548 expect='200',
549 actual=Poststatus,
550 onpass="Post Network Success",
551 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
552
553 main.step( "Post Subnet Data via HTTP" )
554 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
555 'POST', None, subnetpostdata )
556 utilities.assert_equals(
557 expect='202',
558 actual=Poststatus,
559 onpass="Post Subnet Success",
560 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
561
562 main.step( "Update Subnet Data via HTTP" )
563 Putstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
564 'PUT', None, newsubnetpostdata )
565 utilities.assert_equals(
566 expect='203',
567 actual=Putstatus,
568 onpass="Update Subnet Success",
569 onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
570
571 main.step( "Get Subnet Data via HTTP" )
572 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
573 'GET', None, None )
574 utilities.assert_equals(
575 expect='200',
576 actual=Getstatus,
577 onpass="Get Subnet Success",
578 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
579
580 IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
581 TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
582 Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
583
584 main.step( "Compare Subnet Data" )
585 Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
586 utilities.assert_equals(
587 expect=True,
588 actual=Cmpresult,
589 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700590 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
591 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800592 ",Pool compare:" + str( Poolcmpresult ) )
593
594 main.step( "Delete Subnet via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700595 deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
596 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800597 utilities.assert_equals(
598 expect='200',
599 actual=deletestatus,
600 onpass="Delete Network Success",
601 onfail="Delete Network Failed" )
602
Jon Hallf52840a2017-05-24 16:49:52 -0700603 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800604 main.log.error( "Update Subnet compare failed" )
605
606 def CASE7( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800607 """
608 Test Delete Subnet
609 """
610 import os
611
612 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700613 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
614 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800615 except ImportError:
616 main.log.exception( "Something wrong with import file or code error." )
617 main.log.info( "Import Error, please check!" )
618 main.cleanup()
619 main.exit()
620
621 main.log.info( "ONOS Subnet Delete test Start" )
622 main.case( "Virtual Network NBI Test - Subnet" )
623 main.caseExplanation = "Test Subnet Delete NBI " +\
624 "Verify Stored Data is Null after Delete"
625
Jon Hallf52840a2017-05-24 16:49:52 -0700626 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
627 port = main.params[ 'HTTP' ][ 'port' ]
628 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800629
lanqinglongca0a0ee2015-09-22 16:19:08 +0800630 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800631 network = NetworkData()
632 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
633 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
634 subnet = SubnetData()
635 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
636 subnet.tenant_id = network.tenant_id
637 subnet.network_id = network.id
638
639 networkpostdata = network.DictoJson()
640 subnetpostdata = subnet.DictoJson()
641
642 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
643 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
644 'POST', None, networkpostdata )
645 utilities.assert_equals(
646 expect='200',
647 actual=Poststatus,
648 onpass="Post Network Success",
649 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
650
651 main.step( "Post Subnet Data via HTTP" )
652 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
653 'POST', None, subnetpostdata )
654 utilities.assert_equals(
655 expect='202',
656 actual=Poststatus,
657 onpass="Post Subnet Success",
658 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
659
660 main.step( "Delete Subnet Data via HTTP" )
661 Deletestatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
Jon Hallf52840a2017-05-24 16:49:52 -0700662 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800663 utilities.assert_equals(
664 expect='201',
665 actual=Deletestatus,
666 onpass="Delete Subnet Success",
667 onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
668
669 main.step( "Get Subnet Data is NULL" )
670 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
671 'GET', None, None )
672 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800673 expect='Subnet is not found',
lanqinglonge675e922015-08-13 21:17:28 +0800674 actual=result,
675 onpass="Get Subnet Success",
676 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
677
sunyulinf16bb8d2015-09-29 20:21:16 +0800678 if result != 'Subnet is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800679 main.log.error( "Delete Subnet failed" )
680
681 def CASE8( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800682 """
683 Test Post Port
684 """
685 import os
686
687 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700688 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
689 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
690 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800691 except ImportError:
692 main.log.exception( "Something wrong with import file or code error." )
693 main.log.info( "Import Error, please check!" )
694 main.cleanup()
695 main.exit()
696
697 main.log.info( "ONOS Port Post test Start" )
698 main.case( "Virtual Network NBI Test - Port" )
699 main.caseExplanation = "Test Port Post NBI " +\
700 "Verify Stored Data is same with Post Data"
701
Jon Hallf52840a2017-05-24 16:49:52 -0700702 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
703 httpport = main.params[ 'HTTP' ][ 'port' ]
704 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800705
lanqinglongca0a0ee2015-09-22 16:19:08 +0800706 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800707 network = NetworkData()
708 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
709 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
710 subnet = SubnetData()
711 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
712 subnet.tenant_id = network.tenant_id
713 subnet.network_id = network.id
714 port = VirtualPortData()
715 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
716 port.subnet_id = subnet.id
717 port.tenant_id = network.tenant_id
718 port.network_id = network.id
719
720 networkpostdata = network.DictoJson()
721 subnetpostdata = subnet.DictoJson()
722 portpostdata = port.DictoJson()
723
724 main.step( "Post Network Data via HTTP(Post port need post network)" )
725 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
726 'POST', None, networkpostdata )
727 utilities.assert_equals(
728 expect='200',
729 actual=Poststatus,
730 onpass="Post Network Success",
731 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
732
733 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
734 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
735 'POST', None, subnetpostdata )
736 utilities.assert_equals(
737 expect='202',
738 actual=Poststatus,
739 onpass="Post Subnet Success",
740 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
741
742 main.step( "Post Port Data via HTTP" )
743 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
744 'POST', None, portpostdata )
745 utilities.assert_equals(
746 expect='200',
747 actual=Poststatus,
748 onpass="Post Port Success",
749 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
750
751 main.step( "Get Port Data via HTTP" )
752 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
753 'GET', None, None )
754 utilities.assert_equals(
755 expect='200',
756 actual=Getstatus,
757 onpass="Get Port Success",
758 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
759
760 main.step( "Compare Post Port Data" )
761 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
762 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
763 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
764 fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
765
766 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
767 utilities.assert_equals(
768 expect=True,
769 actual=Cmpresult,
770 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700771 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
772 ",Tenant id compare:" + str( TanantIDcmpresult ) +
773 ",Network id compare:" + str( NetoworkIDcmpresult ) +
lanqinglongd0dda2e2015-08-25 11:02:48 +0800774 ",FixIp compare:" + str( fixedIpresult ) )
775
776 main.step( "Clean Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700777 deletestatus, result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
778 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800779 utilities.assert_equals(
780 expect='200',
781 actual=deletestatus,
782 onpass="Delete Network Success",
783 onfail="Delete Network Failed" )
784
Jon Hallf52840a2017-05-24 16:49:52 -0700785 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800786 main.log.error( "Post port compare failed" )
787
788 def CASE9( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800789 """
790 Test Update Port
791 """
792 import os
793
794 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700795 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
796 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
797 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800798 except ImportError:
799 main.log.exception( "Something wrong with import file or code error." )
800 main.log.info( "Import Error, please check!" )
801 main.cleanup()
802 main.exit()
803
804 main.log.info( "ONOS Port Update test Start" )
805 main.case( "Virtual Network NBI Test - Port" )
806 main.caseExplanation = "Test Port Update NBI " +\
807 "Verify Stored Data is same with New Post Data"
808
Jon Hallf52840a2017-05-24 16:49:52 -0700809 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
810 httpport = main.params[ 'HTTP' ][ 'port' ]
811 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800812
lanqinglongca0a0ee2015-09-22 16:19:08 +0800813 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800814 network = NetworkData()
815 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
816 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
817 subnet = SubnetData()
818 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
819 subnet.tenant_id = network.tenant_id
820 subnet.network_id = network.id
821 port = VirtualPortData()
822 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
823 port.subnet_id = subnet.id
824 port.tenant_id = network.tenant_id
825 port.network_id = network.id
826 port.name = "onos"
827
828 networkpostdata = network.DictoJson()
829 subnetpostdata = subnet.DictoJson()
830 portpostdata = port.DictoJson()
831
832 #create update data
833 port.name = "onos-new"
834 newportpostdata = port.DictoJson()
835 #end
836
837 main.step( "Post Network Data via HTTP(Post port need post network)" )
838 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
839 'POST', None, networkpostdata )
840 utilities.assert_equals(
841 expect='200',
842 actual=Poststatus,
843 onpass="Post Network Success",
844 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
845
846 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
847 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
848 'POST', None, subnetpostdata )
849 utilities.assert_equals(
850 expect='202',
851 actual=Poststatus,
852 onpass="Post Subnet Success",
853 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
854
855 main.step( "Post Port Data via HTTP" )
856 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
857 'POST', None, portpostdata )
858 utilities.assert_equals(
859 expect='200',
860 actual=Poststatus,
861 onpass="Post Port Success",
862 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
863
864 main.step( "Update Port Data via HTTP" )
865 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
866 'PUT', None, newportpostdata )
867 utilities.assert_equals(
868 expect='200',
869 actual=Poststatus,
870 onpass="Update Port Success",
871 onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )
872
873 main.step( "Get Port Data via HTTP" )
874 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
875 'GET', None, None )
876 utilities.assert_equals(
877 expect='200',
878 actual=Getstatus,
879 onpass="Get Port Success",
880 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
881
882 main.step( "Compare Update Port Data" )
883 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
884 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
885 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
886 Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )
887
888 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
889 utilities.assert_equals(
890 expect=True,
891 actual=Cmpresult,
892 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700893 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
894 ",Tenant id compare:" + str( TanantIDcmpresult ) +
895 ",Network id compare:" + str( NetoworkIDcmpresult ) +
896 ",Name compare:" + str( Nameresult ) )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800897
898 main.step( "Clean Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700899 deletestatus, result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
900 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800901 utilities.assert_equals(
902 expect='200',
903 actual=deletestatus,
904 onpass="Delete Network Success",
905 onfail="Delete Network Failed" )
906
Jon Hallf52840a2017-05-24 16:49:52 -0700907 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800908 main.log.error( "Update port compare failed" )
909
910 def CASE10( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800911 """
912 Test Delete Port
913 """
914 import os
915
916 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700917 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
918 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
919 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800920 except ImportError:
921 main.log.exception( "Something wrong with import file or code error." )
922 main.log.info( "Import Error, please check!" )
923 main.cleanup()
924 main.exit()
925
926 main.log.info( "ONOS Port Delete test Start" )
927 main.case( "Virtual Network NBI Test - Port" )
928 main.caseExplanation = "Test Port Delete NBI " +\
929 "Verify port delete success"
930
Jon Hallf52840a2017-05-24 16:49:52 -0700931 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
932 httpport = main.params[ 'HTTP' ][ 'port' ]
933 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800934
lanqinglongca0a0ee2015-09-22 16:19:08 +0800935 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800936 network = NetworkData()
937 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
938 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
939 subnet = SubnetData()
940 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
941 subnet.tenant_id = network.tenant_id
942 subnet.network_id = network.id
943 port = VirtualPortData()
944 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
945 port.subnet_id = subnet.id
946 port.tenant_id = network.tenant_id
947 port.network_id = network.id
948
949 networkpostdata = network.DictoJson()
950 subnetpostdata = subnet.DictoJson()
951 portpostdata = port.DictoJson()
952
953 main.step( "Post Network Data via HTTP(Post port need post network)" )
954 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
955 'POST', None, networkpostdata )
956 utilities.assert_equals(
957 expect='200',
958 actual=Poststatus,
959 onpass="Post Network Success",
960 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
961
962 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
963 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
964 'POST', None, subnetpostdata )
965 utilities.assert_equals(
966 expect='202',
967 actual=Poststatus,
968 onpass="Post Subnet Success",
969 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
970
971 main.step( "Post Port Data via HTTP" )
972 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
973 'POST', None, portpostdata )
974 utilities.assert_equals(
975 expect='200',
976 actual=Poststatus,
977 onpass="Post Port Success",
978 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
979
980 main.step( "Delete Port Data via HTTP" )
981 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
982 'Delete', None, None )
983 utilities.assert_equals(
984 expect='200',
985 actual=Poststatus,
986 onpass="Delete Port Success",
987 onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )
988
989 main.step( "Get Port Data is NULL" )
990 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
991 'GET', None, None )
992 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800993 expect='VirtualPort is not found',
lanqinglongd0dda2e2015-08-25 11:02:48 +0800994 actual=result,
995 onpass="Get Port Success",
996 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
997
sunyulinf16bb8d2015-09-29 20:21:16 +0800998 if result != 'VirtualPort is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800999 main.log.error( "Delete Port failed" )
1000
1001 main.step( "Clean Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -07001002 deletestatus, result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
1003 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +08001004 utilities.assert_equals(
1005 expect='200',
1006 actual=deletestatus,
1007 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -07001008 onfail="Delete Network Failed" )
ligenyud4ae1be2015-09-28 20:03:13 +08001009
Jon Hallf52840a2017-05-24 16:49:52 -07001010 def CASE11( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +08001011 """
1012 Test Post Error Json Create Network
1013 """
1014 import os
1015
1016 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001017 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
ligenyud4ae1be2015-09-28 20:03:13 +08001018 except ImportError:
1019 main.log.exception( "Something wrong with import file or code error." )
1020 main.log.info( "Import Error, please check!" )
1021 main.cleanup()
1022 main.exit()
1023
1024 main.log.info( "ONOS Post Error Json Create Network test Start" )
1025 main.case( "Virtual Network NBI Test - Network" )
1026 main.caseExplanation = "Test Network Post With Error json " +\
1027 "The wrong Json can't post network successfully"
1028
Jon Hallf52840a2017-05-24 16:49:52 -07001029 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1030 port = main.params[ 'HTTP' ][ 'port' ]
1031 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001032
1033 main.step( "Generate Post Data" )
1034 network = NetworkData()
1035 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1036 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1037 #The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
1038 network.admin_state_up = 'tttttttttt'
1039 #The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
1040 network.routerExternal = 'ffffffffffff'
1041 #The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
1042 network.shared = 'ffffffffffffff'
1043 postdata = network.DictoJson()
1044
1045 main.step( "Post Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -07001046 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
1047 'POST', None, postdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001048
1049 utilities.assert_equals(
1050 expect='500',
1051 actual=Poststatus,
1052 onpass="The Json is wrong,can't post",
1053 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +08001054
Jon Hallf52840a2017-05-24 16:49:52 -07001055 def CASE12( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +08001056 """
1057 Test Post Error Json Create Subnet
1058 """
1059 import os
1060
1061 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001062 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1063 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
ligenyud4ae1be2015-09-28 20:03:13 +08001064 except ImportError:
1065 main.log.exception( "Something wrong with import file or code error." )
1066 main.log.info( "Import Error, please check!" )
1067 main.cleanup()
1068 main.exit()
1069
1070 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1071 main.case( "Virtual Network NBI Test - Subnet" )
1072 main.caseExplanation = "Test Subnet Post With Error json " +\
1073 "The wrong Json can't post network successfully"
1074
Jon Hallf52840a2017-05-24 16:49:52 -07001075 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1076 port = main.params[ 'HTTP' ][ 'port' ]
1077 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001078
1079 main.step( "Generate Post Data" )
1080 network = NetworkData()
1081 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1082 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1083 subnet = SubnetData()
1084 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1085 #The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
1086 subnet.enable_dhcp = 'tttttttttttttt'
1087 #The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
1088 subnet.shared = 'ffffffffffffff'
1089 subnet.tenant_id = network.tenant_id
1090 subnet.network_id = network.id
1091
1092 networkpostdata = network.DictoJson()
1093 subnetpostdata = subnet.DictoJson()
1094
1095 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
1096 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
1097 'POST', None, networkpostdata )
1098 utilities.assert_equals(
1099 expect='200',
1100 actual=Poststatus,
1101 onpass="Post Network Success",
1102 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1103
1104 main.step( "Post Subnet Data via HTTP" )
1105 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
1106 'POST', None, subnetpostdata )
1107 utilities.assert_equals(
1108 expect='500',
1109 actual=Poststatus,
1110 onpass="The Json is wrong,can't post",
1111 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +08001112
Jon Hallf52840a2017-05-24 16:49:52 -07001113 def CASE13( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +08001114 """
1115 Test Post Error Json Create Virtualport
1116 """
1117 import os
1118
1119 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001120 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1121 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
1122 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
ligenyud4ae1be2015-09-28 20:03:13 +08001123 except ImportError:
1124 main.log.exception( "Something wrong with import file or code error." )
1125 main.log.info( "Import Error, please check!" )
1126 main.cleanup()
1127 main.exit()
1128
1129 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1130 main.case( "Virtual Network NBI Test - Port" )
1131 main.caseExplanation = "Test Subnet Post With Error json " +\
1132 "The wrong Json can't create port successfully"
1133
Jon Hallf52840a2017-05-24 16:49:52 -07001134 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1135 httpport = main.params[ 'HTTP' ][ 'port' ]
1136 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001137
1138 main.step( "Generate Post Data" )
1139 network = NetworkData()
1140 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1141 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1142 subnet = SubnetData()
1143 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1144 subnet.tenant_id = network.tenant_id
1145 subnet.network_id = network.id
1146 port = VirtualPortData()
1147 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
1148 port.subnet_id = subnet.id
1149 port.tenant_id = network.tenant_id
1150 port.network_id = network.id
1151 #The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
1152 port.adminStateUp = 'tttttttttttt'
1153
1154 networkpostdata = network.DictoJson()
1155 subnetpostdata = subnet.DictoJson()
1156 portpostdata = port.DictoJson()
1157
1158 main.step( "Post Network Data via HTTP(Post port need post network)" )
1159 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
1160 'POST', None, networkpostdata )
1161 utilities.assert_equals(
1162 expect='200',
1163 actual=Poststatus,
1164 onpass="Post Network Success",
1165 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1166
1167 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
1168 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
1169 'POST', None, subnetpostdata )
1170 utilities.assert_equals(
1171 expect='202',
1172 actual=Poststatus,
1173 onpass="Post Subnet Success",
1174 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
1175
1176 main.step( "Post Port Data via HTTP" )
1177 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
1178 'POST', None, portpostdata )
1179 utilities.assert_equals(
1180 expect='500',
1181 actual=Poststatus,
1182 onpass="The Json is wrong,can't post",
Jon Hallce9c01e2015-10-22 16:39:02 +00001183 onfail="Wrong Json can post successfully" )