blob: 499aa77039305ac7f354d1f16fb9c7c9058c2541 [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
lanqinglong77124b02015-08-06 11:47:38 +0800107 gitPullResult = main.TRUE
lanqinglongca0a0ee2015-09-22 16:19:08 +0800108 main.log.info( "Git checkout and pull " + gitBranch )
lanqinglong77124b02015-08-06 11:47:38 +0800109 if PULLCODE:
Jon Hallf52840a2017-05-24 16:49:52 -0700110 main.ONOSbench.gitCheckout( gitBranch )
lanqinglong77124b02015-08-06 11:47:38 +0800111 gitPullResult = main.ONOSbench.gitPull()
112 # values of 1 or 3 are good
Jon Hallf52840a2017-05-24 16:49:52 -0700113 utilities.assert_lesser( expect=0, actual=gitPullResult,
lanqinglong77124b02015-08-06 11:47:38 +0800114 onpass="Git pull successful",
Jon Hallf52840a2017-05-24 16:49:52 -0700115 onfail="Git pull failed" )
116 main.ONOSbench.getVersion( report=True )
lanqinglong77124b02015-08-06 11:47:38 +0800117
118 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700119 packageResult = main.ONOSbench.buckBuild()
lanqinglong77124b02015-08-06 11:47:38 +0800120 utilities.assert_equals( expect=main.TRUE,
121 actual=packageResult,
122 onpass="Successfully created ONOS package",
123 onfail="Failed to create ONOS package " )
124 time.sleep( main.startUpSleep )
125
126 main.step( "Installing ONOS package" )
127 onosInstallResult = main.ONOSbench.onosInstall(
Jon Hallf52840a2017-05-24 16:49:52 -0700128 options="-f", node=main.nodes[ 0 ].ip_address )
lanqinglong77124b02015-08-06 11:47:38 +0800129 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
Jon Hallf52840a2017-05-24 16:49:52 -0700130 onpass="ONOS install successful",
131 onfail="ONOS install failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800132 time.sleep( main.startUpSleep )
133
You Wangf5de25b2017-01-06 15:13:01 -0800134 main.step( "Set up ONOS secure SSH" )
Jon Hallf52840a2017-05-24 16:49:52 -0700135 secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[ 0 ].ip_address )
You Wangf5de25b2017-01-06 15:13:01 -0800136 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
137 onpass="Test step PASS",
138 onfail="Test step FAIL" )
139
lanqinglong77124b02015-08-06 11:47:38 +0800140 main.step( "Checking if ONOS is up yet" )
141
142 for i in range( 2 ):
Jon Hallf52840a2017-05-24 16:49:52 -0700143 onos1Isup = main.ONOSbench.isup( main.nodes[ 0 ].ip_address )
lanqinglong77124b02015-08-06 11:47:38 +0800144 if onos1Isup:
145 break
146 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
Jon Hallf52840a2017-05-24 16:49:52 -0700147 onpass="ONOS startup successful",
148 onfail="ONOS startup failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800149 time.sleep( main.startUpSleep )
150
Jon Hall6509dbf2016-06-21 17:01:17 -0700151 main.step( "Starting ONOS CLI sessions" )
lanqinglong77124b02015-08-06 11:47:38 +0800152
Jon Hallf52840a2017-05-24 16:49:52 -0700153 print main.nodes[ 0 ].ip_address
154 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
lanqinglong77124b02015-08-06 11:47:38 +0800155 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
Jon Hallf52840a2017-05-24 16:49:52 -0700156 onpass="ONOS cli startup successful",
157 onfail="ONOS cli startup failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800158 time.sleep( main.startUpSleep )
159
160 main.step( "App Ids check" )
161 appCheck = main.ONOScli1.appToIDCheck()
162 if appCheck != main.TRUE:
Jon Hallf52840a2017-05-24 16:49:52 -0700163 main.log.warn( main.CLIs[ 0 ].apps() )
164 main.log.warn( main.CLIs[ 0 ].appIDs() )
lanqinglong77124b02015-08-06 11:47:38 +0800165 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
Jon Hallf52840a2017-05-24 16:49:52 -0700166 onpass="App Ids seem to be correct",
167 onfail="Something is wrong with app Ids" )
lanqinglong77124b02015-08-06 11:47:38 +0800168
169 if cliResults == main.FALSE:
170 main.log.error( "Failed to start ONOS, stopping test" )
171 main.cleanup()
172 main.exit()
173
GlennRCa0c395f2015-12-03 14:04:56 -0800174 main.step( "Install org.onosproject.vtn app" )
175 installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" )
lanqinglong77124b02015-08-06 11:47:38 +0800176 utilities.assert_equals( expect=main.TRUE, actual=installResults,
Jon Hallf52840a2017-05-24 16:49:52 -0700177 onpass="Install org.onosproject.vtn successful",
178 onfail="Install org.onosproject.vtn app failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800179
180 time.sleep( main.startUpSleep )
181
Jon Hallf52840a2017-05-24 16:49:52 -0700182 def CASE2( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800183 """
184 Test Post Network
185 """
lanqinglonge675e922015-08-13 21:17:28 +0800186 import os
187
lanqinglong77124b02015-08-06 11:47:38 +0800188 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700189 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800190 except ImportError:
191 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800192 main.log.info( "Import Error, please check!" )
193 main.cleanup()
194 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800195
196 main.log.info( "ONOS Network Post test Start" )
197 main.case( "Virtual Network NBI Test - Network" )
198 main.caseExplanation = "Test Network Post NBI " +\
199 "Verify Post Data same with Stored Data"
200
Jon Hallf52840a2017-05-24 16:49:52 -0700201 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
202 port = main.params[ 'HTTP' ][ 'port' ]
203 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800204
lanqinglongca0a0ee2015-09-22 16:19:08 +0800205 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800206 network = NetworkData()
207 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
208 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
209 postdata = network.DictoJson()
210
211 main.step( "Post Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700212 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
213 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800214
215 utilities.assert_equals(
216 expect='200',
217 actual=Poststatus,
218 onpass="Post Success",
219 onfail="Post Failed " + str( Poststatus ) + str( result ) )
220
221 main.step( "Get Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700222 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
223 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800224 utilities.assert_equals(
225 expect='200',
226 actual=Getstatus,
227 onpass="Get Success",
228 onfail="Get Failed " + str( Getstatus ) + str( result ) )
229
Jon Hallf52840a2017-05-24 16:49:52 -0700230 main.log.info( "Post Network Data is :%s\nGet Network Data is:%s" % ( postdata, result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800231
232 main.step( "Compare Send Id and Get Id" )
233 IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' )
234 TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' )
235 Cmpresult = IDcmpresult and TanantIDcmpresult
236
237 utilities.assert_equals(
238 expect=True,
239 actual=Cmpresult,
240 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700241 onfail="Compare Failed:ID compare: " + str( IDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800242 ",Tenant id compare :" + str( TanantIDcmpresult ) )
243
Jon Hallf52840a2017-05-24 16:49:52 -0700244 deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
245 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800246 utilities.assert_equals(
247 expect='200',
248 actual=deletestatus,
249 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700250 onfail="Delete Network Failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800251
Jon Hallf52840a2017-05-24 16:49:52 -0700252 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800253 main.log.error( "Post Network compare failed" )
254
Jon Hallf52840a2017-05-24 16:49:52 -0700255 def CASE3( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800256 """
257 Test Update Network
258 """
lanqinglonge675e922015-08-13 21:17:28 +0800259 import os
260
lanqinglong77124b02015-08-06 11:47:38 +0800261 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700262 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800263 except ImportError:
264 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800265 main.log.info( "Import Error, please check!" )
266 main.cleanup()
267 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800268
269 main.log.info( "ONOS Network Update test Start" )
270 main.case( "Virtual Network NBI Test - Network" )
271 main.caseExplanation = "Test Network Update NBI " +\
272 "Verify Update Data same with Stored Data"
273
Jon Hallf52840a2017-05-24 16:49:52 -0700274 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
275 port = main.params[ 'HTTP' ][ 'port' ]
276 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800277
lanqinglongca0a0ee2015-09-22 16:19:08 +0800278 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800279 network = NetworkData()
280 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
281 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
lanqinglongd0dda2e2015-08-25 11:02:48 +0800282 network.shared = False
lanqinglong77124b02015-08-06 11:47:38 +0800283 postdata = network.DictoJson()
284
lanqinglongd0dda2e2015-08-25 11:02:48 +0800285 network.shared = True
lanqinglong77124b02015-08-06 11:47:38 +0800286 postdatanew = network.DictoJson()
287
288 main.step( "Post Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700289 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks',
lanqinglong77124b02015-08-06 11:47:38 +0800290 'POST', None, postdata )
291 utilities.assert_equals(
292 expect='200',
293 actual=Poststatus,
294 onpass="Post Success",
295 onfail="Post Failed " + str( Poststatus ) + str( result ) )
296
297 main.step( "Update Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700298 Updatestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
299 'PUT', None, postdatanew )
lanqinglong77124b02015-08-06 11:47:38 +0800300 utilities.assert_equals(
301 expect='200',
302 actual=Updatestatus,
303 onpass="Update Success",
304 onfail="Update Failed " + str( Updatestatus ) + str( result ) )
305
306 main.step( "Get Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700307 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
lanqinglong77124b02015-08-06 11:47:38 +0800308 'GET', None, None )
309 utilities.assert_equals(
310 expect='200',
311 actual=Getstatus,
312 onpass="Get Success",
313 onfail="Get Failed " + str( Getstatus ) + str( result ) )
314
315 main.step( "Compare Update data." )
316 IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
317 TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
318 Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
319
320 Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
321 utilities.assert_equals(
322 expect=True,
323 actual=Cmpresult,
324 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700325 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
326 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800327 ",Name compare:" + str( Shareresult ) )
328
Jon Hallf52840a2017-05-24 16:49:52 -0700329 deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
330 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800331
332 utilities.assert_equals(
333 expect='200',
334 actual=deletestatus,
335 onpass="Delete Network Success",
336 onfail="Delete Network Failed" )
337
Jon Hallf52840a2017-05-24 16:49:52 -0700338 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800339 main.log.error( "Update Network compare failed" )
340
Jon Hallf52840a2017-05-24 16:49:52 -0700341 def CASE4( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800342 """
343 Test Delete Network
344 """
lanqinglonge675e922015-08-13 21:17:28 +0800345 import os
346
lanqinglong77124b02015-08-06 11:47:38 +0800347 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700348 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800349 except ImportError:
350 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800351 main.log.info( "Import Error, please check!" )
352 main.cleanup()
353 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800354
355 main.log.info( "ONOS Network Delete test Start" )
356 main.case( "Virtual Network NBI Test - Network" )
357 main.caseExplanation = "Test Network Delete NBI " +\
358 "Verify Stored Data is NULL after Delete"
359
Jon Hallf52840a2017-05-24 16:49:52 -0700360 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
361 port = main.params[ 'HTTP' ][ 'port' ]
362 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800363
lanqinglongca0a0ee2015-09-22 16:19:08 +0800364 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800365 network = NetworkData()
366 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
367 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
368 postdata = network.DictoJson()
369
370 main.step( "Post Data via HTTP" )
lanqinglonge675e922015-08-13 21:17:28 +0800371 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
372 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800373 utilities.assert_equals(
374 expect='200',
375 actual=Poststatus,
376 onpass="Post Success",
377 onfail="Post Failed " + str( Poststatus ) + str( result ) )
378
379 main.step( "Delete Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700380 Deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
381 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800382 utilities.assert_equals(
383 expect='200',
384 actual=Deletestatus,
385 onpass="Delete Success",
lanqinglongd0dda2e2015-08-25 11:02:48 +0800386 onfail="Delete Failed " + str( Deletestatus ) + str( result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800387
388 main.step( "Get Data is NULL" )
Jon Hallf52840a2017-05-24 16:49:52 -0700389 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
lanqinglong77124b02015-08-06 11:47:38 +0800390 'GET', None, None )
391 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800392 expect='Network is not found',
lanqinglong77124b02015-08-06 11:47:38 +0800393 actual=result,
394 onpass="Get Success",
395 onfail="Get Failed " + str( Getstatus ) + str( result ) )
396
sunyulinf16bb8d2015-09-29 20:21:16 +0800397 if result != 'Network is not found':
lanqinglong77124b02015-08-06 11:47:38 +0800398 main.log.error( "Delete Network failed" )
lanqinglonge675e922015-08-13 21:17:28 +0800399
400 def CASE5( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800401 """
402 Test Post Subnet
403 """
404 import os
405
406 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700407 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
408 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800409 except ImportError:
410 main.log.exception( "Something wrong with import file or code error." )
411 main.log.info( "Import Error, please check!" )
412 main.cleanup()
413 main.exit()
414
415 main.log.info( "ONOS Subnet Post test Start" )
416 main.case( "Virtual Network NBI Test - Subnet" )
417 main.caseExplanation = "Test Subnet Post NBI " +\
418 "Verify Stored Data is same with Post Data"
419
Jon Hallf52840a2017-05-24 16:49:52 -0700420 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
421 port = main.params[ 'HTTP' ][ 'port' ]
422 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800423
lanqinglongca0a0ee2015-09-22 16:19:08 +0800424 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800425 network = NetworkData()
426 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
427 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
428 subnet = SubnetData()
429 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
430 subnet.tenant_id = network.tenant_id
431 subnet.network_id = network.id
432
433 networkpostdata = network.DictoJson()
434 subnetpostdata = subnet.DictoJson()
435
436 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
437 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
438 'POST', None, networkpostdata )
439 utilities.assert_equals(
440 expect='200',
441 actual=Poststatus,
442 onpass="Post Network Success",
443 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
444
445 main.step( "Post Subnet Data via HTTP" )
446 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
447 'POST', None, subnetpostdata )
448 utilities.assert_equals(
449 expect='202',
450 actual=Poststatus,
451 onpass="Post Subnet Success",
452 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
453
454 main.step( "Get Subnet Data via HTTP" )
455 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
456 'GET', None, None )
457 utilities.assert_equals(
458 expect='200',
459 actual=Getstatus,
460 onpass="Get Subnet Success",
461 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
462
463 IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
464 TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
465 NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
466
467 main.step( "Compare Post Subnet Data via HTTP" )
468 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
469 utilities.assert_equals(
470 expect=True,
471 actual=Cmpresult,
472 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700473 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
474 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800475 ",Network id compare:" + str( NetoworkIDcmpresult ) )
476
Jon Hallf52840a2017-05-24 16:49:52 -0700477 deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
478 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800479 utilities.assert_equals(
480 expect='200',
481 actual=deletestatus,
482 onpass="Delete Network Success",
483 onfail="Delete Network Failed" )
484
Jon Hallf52840a2017-05-24 16:49:52 -0700485 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800486 main.log.error( "Post Subnet compare failed" )
487
488 def CASE6( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800489 """
490 Test Post Subnet
491 """
492 import os
493
494 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700495 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
496 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800497 except ImportError:
498 main.log.exception( "Something wrong with import file or code error." )
499 main.log.info( "Import Error, please check!" )
500 main.cleanup()
501 main.exit()
502
503 main.log.info( "ONOS Subnet Update test Start" )
504 main.case( "Virtual Network NBI Test - Subnet" )
505 main.caseExplanation = "Test Subnet Update NBI " +\
506 "Verify Stored Data is same with Update Data"
507
Jon Hallf52840a2017-05-24 16:49:52 -0700508 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
509 port = main.params[ 'HTTP' ][ 'port' ]
510 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800511
lanqinglongca0a0ee2015-09-22 16:19:08 +0800512 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800513 network = NetworkData()
514 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
515 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
516 subnet = SubnetData()
517 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
518 subnet.tenant_id = network.tenant_id
519 subnet.network_id = network.id
520 subnet.start = "192.168.2.1"
521 subnet.end = "192.168.2.255"
522 networkpostdata = network.DictoJson()
523 subnetpostdata = subnet.DictoJson()
524
525 #Change allocation_poolsdata scope
526 subnet.start = "192.168.102.1"
527 subnet.end = "192.168.102.255"
528 #end change
529 newsubnetpostdata = subnet.DictoJson()
530
531 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
532 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
533 'POST', None, networkpostdata )
534 utilities.assert_equals(
535 expect='200',
536 actual=Poststatus,
537 onpass="Post Network Success",
538 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
539
540 main.step( "Post Subnet Data via HTTP" )
541 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
542 'POST', None, subnetpostdata )
543 utilities.assert_equals(
544 expect='202',
545 actual=Poststatus,
546 onpass="Post Subnet Success",
547 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
548
549 main.step( "Update Subnet Data via HTTP" )
550 Putstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
551 'PUT', None, newsubnetpostdata )
552 utilities.assert_equals(
553 expect='203',
554 actual=Putstatus,
555 onpass="Update Subnet Success",
556 onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
557
558 main.step( "Get Subnet Data via HTTP" )
559 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
560 'GET', None, None )
561 utilities.assert_equals(
562 expect='200',
563 actual=Getstatus,
564 onpass="Get Subnet Success",
565 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
566
567 IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
568 TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
569 Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
570
571 main.step( "Compare Subnet Data" )
572 Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
573 utilities.assert_equals(
574 expect=True,
575 actual=Cmpresult,
576 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700577 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
578 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800579 ",Pool compare:" + str( Poolcmpresult ) )
580
581 main.step( "Delete Subnet via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700582 deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path + 'networks/',
583 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800584 utilities.assert_equals(
585 expect='200',
586 actual=deletestatus,
587 onpass="Delete Network Success",
588 onfail="Delete Network Failed" )
589
Jon Hallf52840a2017-05-24 16:49:52 -0700590 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800591 main.log.error( "Update Subnet compare failed" )
592
593 def CASE7( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800594 """
595 Test Delete Subnet
596 """
597 import os
598
599 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700600 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
601 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800602 except ImportError:
603 main.log.exception( "Something wrong with import file or code error." )
604 main.log.info( "Import Error, please check!" )
605 main.cleanup()
606 main.exit()
607
608 main.log.info( "ONOS Subnet Delete test Start" )
609 main.case( "Virtual Network NBI Test - Subnet" )
610 main.caseExplanation = "Test Subnet Delete NBI " +\
611 "Verify Stored Data is Null after Delete"
612
Jon Hallf52840a2017-05-24 16:49:52 -0700613 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
614 port = main.params[ 'HTTP' ][ 'port' ]
615 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800616
lanqinglongca0a0ee2015-09-22 16:19:08 +0800617 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800618 network = NetworkData()
619 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
620 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
621 subnet = SubnetData()
622 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
623 subnet.tenant_id = network.tenant_id
624 subnet.network_id = network.id
625
626 networkpostdata = network.DictoJson()
627 subnetpostdata = subnet.DictoJson()
628
629 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
630 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
631 'POST', None, networkpostdata )
632 utilities.assert_equals(
633 expect='200',
634 actual=Poststatus,
635 onpass="Post Network Success",
636 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
637
638 main.step( "Post Subnet Data via HTTP" )
639 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
640 'POST', None, subnetpostdata )
641 utilities.assert_equals(
642 expect='202',
643 actual=Poststatus,
644 onpass="Post Subnet Success",
645 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
646
647 main.step( "Delete Subnet Data via HTTP" )
648 Deletestatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
Jon Hallf52840a2017-05-24 16:49:52 -0700649 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800650 utilities.assert_equals(
651 expect='201',
652 actual=Deletestatus,
653 onpass="Delete Subnet Success",
654 onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
655
656 main.step( "Get Subnet Data is NULL" )
657 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
658 'GET', None, None )
659 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800660 expect='Subnet is not found',
lanqinglonge675e922015-08-13 21:17:28 +0800661 actual=result,
662 onpass="Get Subnet Success",
663 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
664
sunyulinf16bb8d2015-09-29 20:21:16 +0800665 if result != 'Subnet is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800666 main.log.error( "Delete Subnet failed" )
667
668 def CASE8( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800669 """
670 Test Post Port
671 """
672 import os
673
674 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700675 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
676 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
677 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800678 except ImportError:
679 main.log.exception( "Something wrong with import file or code error." )
680 main.log.info( "Import Error, please check!" )
681 main.cleanup()
682 main.exit()
683
684 main.log.info( "ONOS Port Post test Start" )
685 main.case( "Virtual Network NBI Test - Port" )
686 main.caseExplanation = "Test Port Post NBI " +\
687 "Verify Stored Data is same with Post Data"
688
Jon Hallf52840a2017-05-24 16:49:52 -0700689 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
690 httpport = main.params[ 'HTTP' ][ 'port' ]
691 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800692
lanqinglongca0a0ee2015-09-22 16:19:08 +0800693 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800694 network = NetworkData()
695 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
696 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
697 subnet = SubnetData()
698 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
699 subnet.tenant_id = network.tenant_id
700 subnet.network_id = network.id
701 port = VirtualPortData()
702 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
703 port.subnet_id = subnet.id
704 port.tenant_id = network.tenant_id
705 port.network_id = network.id
706
707 networkpostdata = network.DictoJson()
708 subnetpostdata = subnet.DictoJson()
709 portpostdata = port.DictoJson()
710
711 main.step( "Post Network Data via HTTP(Post port need post network)" )
712 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
713 'POST', None, networkpostdata )
714 utilities.assert_equals(
715 expect='200',
716 actual=Poststatus,
717 onpass="Post Network Success",
718 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
719
720 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
721 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
722 'POST', None, subnetpostdata )
723 utilities.assert_equals(
724 expect='202',
725 actual=Poststatus,
726 onpass="Post Subnet Success",
727 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
728
729 main.step( "Post Port Data via HTTP" )
730 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
731 'POST', None, portpostdata )
732 utilities.assert_equals(
733 expect='200',
734 actual=Poststatus,
735 onpass="Post Port Success",
736 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
737
738 main.step( "Get Port Data via HTTP" )
739 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
740 'GET', None, None )
741 utilities.assert_equals(
742 expect='200',
743 actual=Getstatus,
744 onpass="Get Port Success",
745 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
746
747 main.step( "Compare Post Port Data" )
748 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
749 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
750 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
751 fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
752
753 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
754 utilities.assert_equals(
755 expect=True,
756 actual=Cmpresult,
757 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700758 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
759 ",Tenant id compare:" + str( TanantIDcmpresult ) +
760 ",Network id compare:" + str( NetoworkIDcmpresult ) +
lanqinglongd0dda2e2015-08-25 11:02:48 +0800761 ",FixIp compare:" + str( fixedIpresult ) )
762
763 main.step( "Clean Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700764 deletestatus, result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
765 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800766 utilities.assert_equals(
767 expect='200',
768 actual=deletestatus,
769 onpass="Delete Network Success",
770 onfail="Delete Network Failed" )
771
Jon Hallf52840a2017-05-24 16:49:52 -0700772 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800773 main.log.error( "Post port compare failed" )
774
775 def CASE9( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800776 """
777 Test Update Port
778 """
779 import os
780
781 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700782 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
783 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
784 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800785 except ImportError:
786 main.log.exception( "Something wrong with import file or code error." )
787 main.log.info( "Import Error, please check!" )
788 main.cleanup()
789 main.exit()
790
791 main.log.info( "ONOS Port Update test Start" )
792 main.case( "Virtual Network NBI Test - Port" )
793 main.caseExplanation = "Test Port Update NBI " +\
794 "Verify Stored Data is same with New Post Data"
795
Jon Hallf52840a2017-05-24 16:49:52 -0700796 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
797 httpport = main.params[ 'HTTP' ][ 'port' ]
798 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800799
lanqinglongca0a0ee2015-09-22 16:19:08 +0800800 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800801 network = NetworkData()
802 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
803 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
804 subnet = SubnetData()
805 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
806 subnet.tenant_id = network.tenant_id
807 subnet.network_id = network.id
808 port = VirtualPortData()
809 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
810 port.subnet_id = subnet.id
811 port.tenant_id = network.tenant_id
812 port.network_id = network.id
813 port.name = "onos"
814
815 networkpostdata = network.DictoJson()
816 subnetpostdata = subnet.DictoJson()
817 portpostdata = port.DictoJson()
818
819 #create update data
820 port.name = "onos-new"
821 newportpostdata = port.DictoJson()
822 #end
823
824 main.step( "Post Network Data via HTTP(Post port need post network)" )
825 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
826 'POST', None, networkpostdata )
827 utilities.assert_equals(
828 expect='200',
829 actual=Poststatus,
830 onpass="Post Network Success",
831 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
832
833 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
834 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
835 'POST', None, subnetpostdata )
836 utilities.assert_equals(
837 expect='202',
838 actual=Poststatus,
839 onpass="Post Subnet Success",
840 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
841
842 main.step( "Post Port Data via HTTP" )
843 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
844 'POST', None, portpostdata )
845 utilities.assert_equals(
846 expect='200',
847 actual=Poststatus,
848 onpass="Post Port Success",
849 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
850
851 main.step( "Update Port Data via HTTP" )
852 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
853 'PUT', None, newportpostdata )
854 utilities.assert_equals(
855 expect='200',
856 actual=Poststatus,
857 onpass="Update Port Success",
858 onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )
859
860 main.step( "Get Port Data via HTTP" )
861 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
862 'GET', None, None )
863 utilities.assert_equals(
864 expect='200',
865 actual=Getstatus,
866 onpass="Get Port Success",
867 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
868
869 main.step( "Compare Update Port Data" )
870 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
871 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
872 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
873 Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )
874
875 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
876 utilities.assert_equals(
877 expect=True,
878 actual=Cmpresult,
879 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700880 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
881 ",Tenant id compare:" + str( TanantIDcmpresult ) +
882 ",Network id compare:" + str( NetoworkIDcmpresult ) +
883 ",Name compare:" + str( Nameresult ) )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800884
885 main.step( "Clean Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700886 deletestatus, result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
887 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800888 utilities.assert_equals(
889 expect='200',
890 actual=deletestatus,
891 onpass="Delete Network Success",
892 onfail="Delete Network Failed" )
893
Jon Hallf52840a2017-05-24 16:49:52 -0700894 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800895 main.log.error( "Update port compare failed" )
896
897 def CASE10( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800898 """
899 Test Delete Port
900 """
901 import os
902
903 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700904 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
905 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
906 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800907 except ImportError:
908 main.log.exception( "Something wrong with import file or code error." )
909 main.log.info( "Import Error, please check!" )
910 main.cleanup()
911 main.exit()
912
913 main.log.info( "ONOS Port Delete test Start" )
914 main.case( "Virtual Network NBI Test - Port" )
915 main.caseExplanation = "Test Port Delete NBI " +\
916 "Verify port delete success"
917
Jon Hallf52840a2017-05-24 16:49:52 -0700918 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
919 httpport = main.params[ 'HTTP' ][ 'port' ]
920 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800921
lanqinglongca0a0ee2015-09-22 16:19:08 +0800922 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800923 network = NetworkData()
924 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
925 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
926 subnet = SubnetData()
927 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
928 subnet.tenant_id = network.tenant_id
929 subnet.network_id = network.id
930 port = VirtualPortData()
931 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
932 port.subnet_id = subnet.id
933 port.tenant_id = network.tenant_id
934 port.network_id = network.id
935
936 networkpostdata = network.DictoJson()
937 subnetpostdata = subnet.DictoJson()
938 portpostdata = port.DictoJson()
939
940 main.step( "Post Network Data via HTTP(Post port need post network)" )
941 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
942 'POST', None, networkpostdata )
943 utilities.assert_equals(
944 expect='200',
945 actual=Poststatus,
946 onpass="Post Network Success",
947 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
948
949 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
950 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
951 'POST', None, subnetpostdata )
952 utilities.assert_equals(
953 expect='202',
954 actual=Poststatus,
955 onpass="Post Subnet Success",
956 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
957
958 main.step( "Post Port Data via HTTP" )
959 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
960 'POST', None, portpostdata )
961 utilities.assert_equals(
962 expect='200',
963 actual=Poststatus,
964 onpass="Post Port Success",
965 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
966
967 main.step( "Delete Port Data via HTTP" )
968 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
969 'Delete', None, None )
970 utilities.assert_equals(
971 expect='200',
972 actual=Poststatus,
973 onpass="Delete Port Success",
974 onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )
975
976 main.step( "Get Port Data is NULL" )
977 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
978 'GET', None, None )
979 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800980 expect='VirtualPort is not found',
lanqinglongd0dda2e2015-08-25 11:02:48 +0800981 actual=result,
982 onpass="Get Port Success",
983 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
984
sunyulinf16bb8d2015-09-29 20:21:16 +0800985 if result != 'VirtualPort is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800986 main.log.error( "Delete Port failed" )
987
988 main.step( "Clean Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -0700989 deletestatus, result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
990 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800991 utilities.assert_equals(
992 expect='200',
993 actual=deletestatus,
994 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700995 onfail="Delete Network Failed" )
ligenyud4ae1be2015-09-28 20:03:13 +0800996
Jon Hallf52840a2017-05-24 16:49:52 -0700997 def CASE11( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +0800998 """
999 Test Post Error Json Create Network
1000 """
1001 import os
1002
1003 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001004 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
ligenyud4ae1be2015-09-28 20:03:13 +08001005 except ImportError:
1006 main.log.exception( "Something wrong with import file or code error." )
1007 main.log.info( "Import Error, please check!" )
1008 main.cleanup()
1009 main.exit()
1010
1011 main.log.info( "ONOS Post Error Json Create Network test Start" )
1012 main.case( "Virtual Network NBI Test - Network" )
1013 main.caseExplanation = "Test Network Post With Error json " +\
1014 "The wrong Json can't post network successfully"
1015
Jon Hallf52840a2017-05-24 16:49:52 -07001016 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1017 port = main.params[ 'HTTP' ][ 'port' ]
1018 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001019
1020 main.step( "Generate Post Data" )
1021 network = NetworkData()
1022 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1023 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1024 #The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
1025 network.admin_state_up = 'tttttttttt'
1026 #The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
1027 network.routerExternal = 'ffffffffffff'
1028 #The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
1029 network.shared = 'ffffffffffffff'
1030 postdata = network.DictoJson()
1031
1032 main.step( "Post Data via HTTP" )
Jon Hallf52840a2017-05-24 16:49:52 -07001033 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
1034 'POST', None, postdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001035
1036 utilities.assert_equals(
1037 expect='500',
1038 actual=Poststatus,
1039 onpass="The Json is wrong,can't post",
1040 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +08001041
Jon Hallf52840a2017-05-24 16:49:52 -07001042 def CASE12( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +08001043 """
1044 Test Post Error Json Create Subnet
1045 """
1046 import os
1047
1048 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001049 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1050 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
ligenyud4ae1be2015-09-28 20:03:13 +08001051 except ImportError:
1052 main.log.exception( "Something wrong with import file or code error." )
1053 main.log.info( "Import Error, please check!" )
1054 main.cleanup()
1055 main.exit()
1056
1057 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1058 main.case( "Virtual Network NBI Test - Subnet" )
1059 main.caseExplanation = "Test Subnet Post With Error json " +\
1060 "The wrong Json can't post network successfully"
1061
Jon Hallf52840a2017-05-24 16:49:52 -07001062 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1063 port = main.params[ 'HTTP' ][ 'port' ]
1064 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001065
1066 main.step( "Generate Post Data" )
1067 network = NetworkData()
1068 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1069 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1070 subnet = SubnetData()
1071 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1072 #The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
1073 subnet.enable_dhcp = 'tttttttttttttt'
1074 #The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
1075 subnet.shared = 'ffffffffffffff'
1076 subnet.tenant_id = network.tenant_id
1077 subnet.network_id = network.id
1078
1079 networkpostdata = network.DictoJson()
1080 subnetpostdata = subnet.DictoJson()
1081
1082 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
1083 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
1084 'POST', None, networkpostdata )
1085 utilities.assert_equals(
1086 expect='200',
1087 actual=Poststatus,
1088 onpass="Post Network Success",
1089 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1090
1091 main.step( "Post Subnet Data via HTTP" )
1092 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
1093 'POST', None, subnetpostdata )
1094 utilities.assert_equals(
1095 expect='500',
1096 actual=Poststatus,
1097 onpass="The Json is wrong,can't post",
1098 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +08001099
Jon Hallf52840a2017-05-24 16:49:52 -07001100 def CASE13( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +08001101 """
1102 Test Post Error Json Create Virtualport
1103 """
1104 import os
1105
1106 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001107 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1108 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
1109 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
ligenyud4ae1be2015-09-28 20:03:13 +08001110 except ImportError:
1111 main.log.exception( "Something wrong with import file or code error." )
1112 main.log.info( "Import Error, please check!" )
1113 main.cleanup()
1114 main.exit()
1115
1116 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1117 main.case( "Virtual Network NBI Test - Port" )
1118 main.caseExplanation = "Test Subnet Post With Error json " +\
1119 "The wrong Json can't create port successfully"
1120
Jon Hallf52840a2017-05-24 16:49:52 -07001121 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1122 httpport = main.params[ 'HTTP' ][ 'port' ]
1123 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001124
1125 main.step( "Generate Post Data" )
1126 network = NetworkData()
1127 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1128 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1129 subnet = SubnetData()
1130 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1131 subnet.tenant_id = network.tenant_id
1132 subnet.network_id = network.id
1133 port = VirtualPortData()
1134 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
1135 port.subnet_id = subnet.id
1136 port.tenant_id = network.tenant_id
1137 port.network_id = network.id
1138 #The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
1139 port.adminStateUp = 'tttttttttttt'
1140
1141 networkpostdata = network.DictoJson()
1142 subnetpostdata = subnet.DictoJson()
1143 portpostdata = port.DictoJson()
1144
1145 main.step( "Post Network Data via HTTP(Post port need post network)" )
1146 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
1147 'POST', None, networkpostdata )
1148 utilities.assert_equals(
1149 expect='200',
1150 actual=Poststatus,
1151 onpass="Post Network Success",
1152 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1153
1154 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
1155 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
1156 'POST', None, subnetpostdata )
1157 utilities.assert_equals(
1158 expect='202',
1159 actual=Poststatus,
1160 onpass="Post Subnet Success",
1161 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
1162
1163 main.step( "Post Port Data via HTTP" )
1164 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
1165 'POST', None, portpostdata )
1166 utilities.assert_equals(
1167 expect='500',
1168 actual=Poststatus,
1169 onpass="The Json is wrong,can't post",
Jon Hallce9c01e2015-10-22 16:39:02 +00001170 onfail="Wrong Json can post successfully" )