blob: fd828e09fc7490415c51f71069bd799c2b5b9e1e [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
24class FUNCvirNetNB:
25
26 def __init__( self ):
27 self.default = ''
28
29 def CASE1( self, main ):
30 """
31 CASE1 is to compile ONOS and push it to the test machines
32
33 Startup sequence:
34 cell<name>
35 onos-verify-cell
36 NOTE:temporary - onos-remove-raft-logs
37 onos-uninstall
38 git pull
39 mvn clean install
40 onos-package
41 onos-install -f
42 onos-wait-for-start
43 start cli sessions
44 start vtnrsc
45 """
46
47 import time
48 import os
49 main.log.info( "ONOS Single node Start "+
50 "VirtualNet Northbound test - initialization" )
51 main.case( "Setting up test environment" )
52 main.caseExplanation = "Setup the test environment including "+\
53 "installing ONOS,start ONOS."
54
55 # load some variables from the params file
56 PULLCODE = False
57 if main.params['GIT']['pull'] =='True':
58 PULLCODE = True
59 gitBranch = main.params['GIT']['branch']
60 cellName = main.params['ENV']['cellName']
61 ipList = os.getenv( main.params['CTRL']['ip1'] )
62
lanqinglongca0a0ee2015-09-22 16:19:08 +080063 main.step("Create cell file and apply to environment")
lanqinglong77124b02015-08-06 11:47:38 +080064 cellAppString = main.params['ENV']['cellApps']
65 main.ONOSbench.createCellFile(main.ONOSbench.ip_address,cellName,
66 main.Mininet1.ip_address,
67 cellAppString,ipList )
68
lanqinglong77124b02015-08-06 11:47:38 +080069 cellResult = main.ONOSbench.setCell(cellName)
70 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,
75 onpass="Successfully applied cell to " + \
76 "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 = []
85 main.numCtrls=1
86 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
87
88 for i in range ( 1, main.numCtrls +1):
89 try:
90 main.CLIs.append( getattr( main, 'ONOScli' + str(i) ) )
91 main.nodes.append( getattr( main, 'ONOS' + str(i) ) )
92 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:
111 main.ONOSbench.gitCheckout ( gitBranch )
112 gitPullResult = main.ONOSbench.gitPull()
113 # values of 1 or 3 are good
114 utilities.assert_lesser ( expect=0, actual=gitPullResult,
115 onpass="Git pull successful",
116 onfail ="Git pull failed" )
117 main.ONOSbench.getVersion( report =True )
118 main.step( "Using mvn clean install" )
119 cleanInstallResult= main.TRUE
120 if PULLCODE and gitPullResult == main.TRUE:
121 cleanInstallResult = main.ONOSbench.cleanInstall()
122 else:
123 main.log.warn("Did not pull new code so skipping mvn "+
124 "clean install")
125
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" )
132 packageResult = main.ONOSbench.onosPackage()
133 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(
141 options="-f",node=main.nodes[0].ip_address )
142 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
143 onpass="ONOS install successful",
144 onfail="ONOS install failed" )
145 time.sleep( main.startUpSleep )
146
147 main.step( "Checking if ONOS is up yet" )
148
149 for i in range( 2 ):
150 onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
151 if onos1Isup:
152 break
153 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
154 onpass="ONOS startup successful",
155 onfail="ONOS startup failed" )
156 time.sleep( main.startUpSleep )
157
158 main.log.step( "Starting ONOS CLI sessions" )
159
160 print main.nodes[0].ip_address
161 cliResults = main.ONOScli1.startOnosCli(main.nodes[0].ip_address)
162 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
163 onpass="ONOS cli startup successful",
164 onfail="ONOS cli startup failed" )
165 time.sleep( main.startUpSleep )
166
167 main.step( "App Ids check" )
168 appCheck = main.ONOScli1.appToIDCheck()
169 if appCheck != main.TRUE:
170 main.log.warn( main.CLIs[0].apps() )
171 main.log.warn( main.CLIs[0].appIDs() )
172 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
173 onpass="App Ids seem to be correct",
174 onfail="Something is wrong with app Ids" )
175
176 if cliResults == main.FALSE:
177 main.log.error( "Failed to start ONOS, stopping test" )
178 main.cleanup()
179 main.exit()
180
181 main.step( "Install onos-app-vtnrsc app" )
182 installResults = main.ONOScli1.featureInstall( "onos-app-vtnrsc" )
183 utilities.assert_equals( expect=main.TRUE, actual=installResults,
184 onpass="Install onos-app-vtnrsc successful",
185 onfail="Install onos-app-vtnrsc app failed" )
186
187 time.sleep( main.startUpSleep )
lanqinglonge675e922015-08-13 21:17:28 +0800188
lanqinglong77124b02015-08-06 11:47:38 +0800189 main.step( "Install onos-app-vtnweb app" )
190 installResults = main.ONOScli1.featureInstall( "onos-app-vtnweb" )
191 utilities.assert_equals( expect=main.TRUE, actual=installResults,
192 onpass="Install onos-app-vtnweb successful",
193 onfail="Install onos-app-vtnweb app failed" )
194
195 time.sleep( main.startUpSleep )
196
197 def CASE2 ( self,main ):
198
199 """
200 Test Post Network
201 """
lanqinglonge675e922015-08-13 21:17:28 +0800202 import os
203
lanqinglong77124b02015-08-06 11:47:38 +0800204 try:
205 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
206 except ImportError:
207 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800208 main.log.info( "Import Error, please check!" )
209 main.cleanup()
210 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800211
212 main.log.info( "ONOS Network Post test Start" )
213 main.case( "Virtual Network NBI Test - Network" )
214 main.caseExplanation = "Test Network Post NBI " +\
215 "Verify Post Data same with Stored Data"
216
217 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
218 port = main.params['HTTP']['port']
219 path = main.params['HTTP']['path']
220
lanqinglongca0a0ee2015-09-22 16:19:08 +0800221 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800222 network = NetworkData()
223 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
224 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
225 postdata = network.DictoJson()
226
227 main.step( "Post Data via HTTP" )
228 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks/',
229 'POST', None, postdata)
230
231 utilities.assert_equals(
232 expect='200',
233 actual=Poststatus,
234 onpass="Post Success",
235 onfail="Post Failed " + str( Poststatus ) + str( result ) )
236
237 main.step( "Get Data via HTTP" )
238 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
239 'GET', None, None)
240 utilities.assert_equals(
241 expect='200',
242 actual=Getstatus,
243 onpass="Get Success",
244 onfail="Get Failed " + str( Getstatus ) + str( result ) )
245
246 main.log.info("Post Network Data is :%s\nGet Network Data is:%s"%(postdata,result))
247
248 main.step( "Compare Send Id and Get Id" )
249 IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' )
250 TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' )
251 Cmpresult = IDcmpresult and TanantIDcmpresult
252
253 utilities.assert_equals(
254 expect=True,
255 actual=Cmpresult,
256 onpass="Compare Success",
257 onfail="Compare Failed:ID compare: " + str( IDcmpresult ) + \
258 ",Tenant id compare :" + str( TanantIDcmpresult ) )
259
260 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
261 'DELETE', None, None )
262 utilities.assert_equals(
263 expect='200',
264 actual=deletestatus,
265 onpass="Delete Network Success",
266 onfail="Delete Network Failed")
267
lanqinglonge675e922015-08-13 21:17:28 +0800268 if Cmpresult != True:
lanqinglong77124b02015-08-06 11:47:38 +0800269 main.log.error( "Post Network compare failed" )
270
271 def CASE3( self,main ):
272
273 """
274 Test Update Network
275 """
lanqinglonge675e922015-08-13 21:17:28 +0800276 import os
277
lanqinglong77124b02015-08-06 11:47:38 +0800278 try:
279 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
280 except ImportError:
281 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800282 main.log.info( "Import Error, please check!" )
283 main.cleanup()
284 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800285
286 main.log.info( "ONOS Network Update test Start" )
287 main.case( "Virtual Network NBI Test - Network" )
288 main.caseExplanation = "Test Network Update NBI " +\
289 "Verify Update Data same with Stored Data"
290
291 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
292 port = main.params['HTTP']['port']
293 path = main.params['HTTP']['path']
294
lanqinglongca0a0ee2015-09-22 16:19:08 +0800295 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800296 network = NetworkData()
297 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
298 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
lanqinglongd0dda2e2015-08-25 11:02:48 +0800299 network.shared = False
lanqinglong77124b02015-08-06 11:47:38 +0800300 postdata = network.DictoJson()
301
lanqinglongd0dda2e2015-08-25 11:02:48 +0800302 network.shared = True
lanqinglong77124b02015-08-06 11:47:38 +0800303 postdatanew = network.DictoJson()
304
305 main.step( "Post Data via HTTP" )
306 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks',
307 'POST', None, postdata )
308 utilities.assert_equals(
309 expect='200',
310 actual=Poststatus,
311 onpass="Post Success",
312 onfail="Post Failed " + str( Poststatus ) + str( result ) )
313
314 main.step( "Update Data via HTTP" )
315 Updatestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
316 'PUT', None, postdatanew)
317 utilities.assert_equals(
318 expect='200',
319 actual=Updatestatus,
320 onpass="Update Success",
321 onfail="Update Failed " + str( Updatestatus ) + str( result ) )
322
323 main.step( "Get Data via HTTP" )
324 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
325 'GET', None, None )
326 utilities.assert_equals(
327 expect='200',
328 actual=Getstatus,
329 onpass="Get Success",
330 onfail="Get Failed " + str( Getstatus ) + str( result ) )
331
332 main.step( "Compare Update data." )
333 IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
334 TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
335 Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
336
337 Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
338 utilities.assert_equals(
339 expect=True,
340 actual=Cmpresult,
341 onpass="Compare Success",
342 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
343 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
344 ",Name compare:" + str( Shareresult ) )
345
346 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
347 'DELETE', None, None )
348
349 utilities.assert_equals(
350 expect='200',
351 actual=deletestatus,
352 onpass="Delete Network Success",
353 onfail="Delete Network Failed" )
354
lanqinglonge675e922015-08-13 21:17:28 +0800355 if Cmpresult != True:
lanqinglong77124b02015-08-06 11:47:38 +0800356 main.log.error( "Update Network compare failed" )
357
358 def CASE4( self,main ):
359
360 """
361 Test Delete Network
362 """
lanqinglonge675e922015-08-13 21:17:28 +0800363 import os
364
lanqinglong77124b02015-08-06 11:47:38 +0800365 try:
366 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
367 except ImportError:
368 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800369 main.log.info( "Import Error, please check!" )
370 main.cleanup()
371 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800372
373 main.log.info( "ONOS Network Delete test Start" )
374 main.case( "Virtual Network NBI Test - Network" )
375 main.caseExplanation = "Test Network Delete NBI " +\
376 "Verify Stored Data is NULL after Delete"
377
378 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
379 port = main.params['HTTP']['port']
380 path = main.params['HTTP']['path']
381
lanqinglongca0a0ee2015-09-22 16:19:08 +0800382 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800383 network = NetworkData()
384 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
385 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
386 postdata = network.DictoJson()
387
388 main.step( "Post Data via HTTP" )
lanqinglonge675e922015-08-13 21:17:28 +0800389 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
390 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800391 utilities.assert_equals(
392 expect='200',
393 actual=Poststatus,
394 onpass="Post Success",
395 onfail="Post Failed " + str( Poststatus ) + str( result ) )
396
397 main.step( "Delete Data via HTTP" )
lanqinglonge675e922015-08-13 21:17:28 +0800398 Deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
lanqinglong77124b02015-08-06 11:47:38 +0800399 'DELETE', None, None )
400 utilities.assert_equals(
401 expect='200',
402 actual=Deletestatus,
403 onpass="Delete Success",
lanqinglongd0dda2e2015-08-25 11:02:48 +0800404 onfail="Delete Failed " + str( Deletestatus ) + str( result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800405
406 main.step( "Get Data is NULL" )
407 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
408 'GET', None, None )
409 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800410 expect='Network is not found',
lanqinglong77124b02015-08-06 11:47:38 +0800411 actual=result,
412 onpass="Get Success",
413 onfail="Get Failed " + str( Getstatus ) + str( result ) )
414
sunyulinf16bb8d2015-09-29 20:21:16 +0800415 if result != 'Network is not found':
lanqinglong77124b02015-08-06 11:47:38 +0800416 main.log.error( "Delete Network failed" )
lanqinglonge675e922015-08-13 21:17:28 +0800417
418 def CASE5( self, main ):
419
420 """
421 Test Post Subnet
422 """
423 import os
424
425 try:
426 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
427 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
428 except ImportError:
429 main.log.exception( "Something wrong with import file or code error." )
430 main.log.info( "Import Error, please check!" )
431 main.cleanup()
432 main.exit()
433
434 main.log.info( "ONOS Subnet Post test Start" )
435 main.case( "Virtual Network NBI Test - Subnet" )
436 main.caseExplanation = "Test Subnet Post NBI " +\
437 "Verify Stored Data is same with Post Data"
438
439 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
440 port = main.params['HTTP']['port']
441 path = main.params['HTTP']['path']
442
lanqinglongca0a0ee2015-09-22 16:19:08 +0800443 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800444 network = NetworkData()
445 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
446 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
447 subnet = SubnetData()
448 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
449 subnet.tenant_id = network.tenant_id
450 subnet.network_id = network.id
451
452 networkpostdata = network.DictoJson()
453 subnetpostdata = subnet.DictoJson()
454
455 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
456 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
457 'POST', None, networkpostdata )
458 utilities.assert_equals(
459 expect='200',
460 actual=Poststatus,
461 onpass="Post Network Success",
462 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
463
464 main.step( "Post Subnet Data via HTTP" )
465 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
466 'POST', None, subnetpostdata )
467 utilities.assert_equals(
468 expect='202',
469 actual=Poststatus,
470 onpass="Post Subnet Success",
471 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
472
473 main.step( "Get Subnet Data via HTTP" )
474 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
475 'GET', None, None )
476 utilities.assert_equals(
477 expect='200',
478 actual=Getstatus,
479 onpass="Get Subnet Success",
480 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
481
482 IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
483 TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
484 NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
485
486 main.step( "Compare Post Subnet Data via HTTP" )
487 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
488 utilities.assert_equals(
489 expect=True,
490 actual=Cmpresult,
491 onpass="Compare Success",
492 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
493 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
494 ",Network id compare:" + str( NetoworkIDcmpresult ) )
495
496 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
497 'DELETE', None, None )
498 utilities.assert_equals(
499 expect='200',
500 actual=deletestatus,
501 onpass="Delete Network Success",
502 onfail="Delete Network Failed" )
503
504 if Cmpresult != True:
505 main.log.error( "Post Subnet compare failed" )
506
507 def CASE6( self, main ):
508
509 """
510 Test Post Subnet
511 """
512 import os
513
514 try:
515 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
516 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
517 except ImportError:
518 main.log.exception( "Something wrong with import file or code error." )
519 main.log.info( "Import Error, please check!" )
520 main.cleanup()
521 main.exit()
522
523 main.log.info( "ONOS Subnet Update test Start" )
524 main.case( "Virtual Network NBI Test - Subnet" )
525 main.caseExplanation = "Test Subnet Update NBI " +\
526 "Verify Stored Data is same with Update Data"
527
528 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
529 port = main.params['HTTP']['port']
530 path = main.params['HTTP']['path']
531
lanqinglongca0a0ee2015-09-22 16:19:08 +0800532 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800533 network = NetworkData()
534 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
535 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
536 subnet = SubnetData()
537 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
538 subnet.tenant_id = network.tenant_id
539 subnet.network_id = network.id
540 subnet.start = "192.168.2.1"
541 subnet.end = "192.168.2.255"
542 networkpostdata = network.DictoJson()
543 subnetpostdata = subnet.DictoJson()
544
545 #Change allocation_poolsdata scope
546 subnet.start = "192.168.102.1"
547 subnet.end = "192.168.102.255"
548 #end change
549 newsubnetpostdata = subnet.DictoJson()
550
551 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
552 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
553 'POST', None, networkpostdata )
554 utilities.assert_equals(
555 expect='200',
556 actual=Poststatus,
557 onpass="Post Network Success",
558 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
559
560 main.step( "Post Subnet Data via HTTP" )
561 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
562 'POST', None, subnetpostdata )
563 utilities.assert_equals(
564 expect='202',
565 actual=Poststatus,
566 onpass="Post Subnet Success",
567 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
568
569 main.step( "Update Subnet Data via HTTP" )
570 Putstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
571 'PUT', None, newsubnetpostdata )
572 utilities.assert_equals(
573 expect='203',
574 actual=Putstatus,
575 onpass="Update Subnet Success",
576 onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
577
578 main.step( "Get Subnet Data via HTTP" )
579 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
580 'GET', None, None )
581 utilities.assert_equals(
582 expect='200',
583 actual=Getstatus,
584 onpass="Get Subnet Success",
585 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
586
587 IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
588 TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
589 Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
590
591 main.step( "Compare Subnet Data" )
592 Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
593 utilities.assert_equals(
594 expect=True,
595 actual=Cmpresult,
596 onpass="Compare Success",
597 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
598 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
599 ",Pool compare:" + str( Poolcmpresult ) )
600
601 main.step( "Delete Subnet via HTTP" )
602 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
603 'DELETE', None, None )
604 utilities.assert_equals(
605 expect='200',
606 actual=deletestatus,
607 onpass="Delete Network Success",
608 onfail="Delete Network Failed" )
609
610 if Cmpresult != True:
611 main.log.error( "Update Subnet compare failed" )
612
613 def CASE7( self, main ):
614
615 """
616 Test Delete Subnet
617 """
618 import os
619
620 try:
621 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
622 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
623 except ImportError:
624 main.log.exception( "Something wrong with import file or code error." )
625 main.log.info( "Import Error, please check!" )
626 main.cleanup()
627 main.exit()
628
629 main.log.info( "ONOS Subnet Delete test Start" )
630 main.case( "Virtual Network NBI Test - Subnet" )
631 main.caseExplanation = "Test Subnet Delete NBI " +\
632 "Verify Stored Data is Null after Delete"
633
634 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
635 port = main.params['HTTP']['port']
636 path = main.params['HTTP']['path']
637
lanqinglongca0a0ee2015-09-22 16:19:08 +0800638 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800639 network = NetworkData()
640 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
641 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
642 subnet = SubnetData()
643 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
644 subnet.tenant_id = network.tenant_id
645 subnet.network_id = network.id
646
647 networkpostdata = network.DictoJson()
648 subnetpostdata = subnet.DictoJson()
649
650 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
651 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
652 'POST', None, networkpostdata )
653 utilities.assert_equals(
654 expect='200',
655 actual=Poststatus,
656 onpass="Post Network Success",
657 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
658
659 main.step( "Post Subnet Data via HTTP" )
660 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
661 'POST', None, subnetpostdata )
662 utilities.assert_equals(
663 expect='202',
664 actual=Poststatus,
665 onpass="Post Subnet Success",
666 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
667
668 main.step( "Delete Subnet Data via HTTP" )
669 Deletestatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
670 'DELETE', None, None )
671 utilities.assert_equals(
672 expect='201',
673 actual=Deletestatus,
674 onpass="Delete Subnet Success",
675 onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
676
677 main.step( "Get Subnet Data is NULL" )
678 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
679 'GET', None, None )
680 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800681 expect='Subnet is not found',
lanqinglonge675e922015-08-13 21:17:28 +0800682 actual=result,
683 onpass="Get Subnet Success",
684 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
685
sunyulinf16bb8d2015-09-29 20:21:16 +0800686 if result != 'Subnet is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800687 main.log.error( "Delete Subnet failed" )
688
689 def CASE8( self, main ):
690
691 """
692 Test Post Port
693 """
694 import os
695
696 try:
697 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
698 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
699 from tests.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
700 except ImportError:
701 main.log.exception( "Something wrong with import file or code error." )
702 main.log.info( "Import Error, please check!" )
703 main.cleanup()
704 main.exit()
705
706 main.log.info( "ONOS Port Post test Start" )
707 main.case( "Virtual Network NBI Test - Port" )
708 main.caseExplanation = "Test Port Post NBI " +\
709 "Verify Stored Data is same with Post Data"
710
711 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
712 httpport = main.params['HTTP']['port']
713 path = main.params['HTTP']['path']
714
lanqinglongca0a0ee2015-09-22 16:19:08 +0800715 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800716 network = NetworkData()
717 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
718 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
719 subnet = SubnetData()
720 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
721 subnet.tenant_id = network.tenant_id
722 subnet.network_id = network.id
723 port = VirtualPortData()
724 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
725 port.subnet_id = subnet.id
726 port.tenant_id = network.tenant_id
727 port.network_id = network.id
728
729 networkpostdata = network.DictoJson()
730 subnetpostdata = subnet.DictoJson()
731 portpostdata = port.DictoJson()
732
733 main.step( "Post Network Data via HTTP(Post port need post network)" )
734 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
735 'POST', None, networkpostdata )
736 utilities.assert_equals(
737 expect='200',
738 actual=Poststatus,
739 onpass="Post Network Success",
740 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
741
742 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
743 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
744 'POST', None, subnetpostdata )
745 utilities.assert_equals(
746 expect='202',
747 actual=Poststatus,
748 onpass="Post Subnet Success",
749 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
750
751 main.step( "Post Port Data via HTTP" )
752 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
753 'POST', None, portpostdata )
754 utilities.assert_equals(
755 expect='200',
756 actual=Poststatus,
757 onpass="Post Port Success",
758 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
759
760 main.step( "Get Port Data via HTTP" )
761 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
762 'GET', None, None )
763 utilities.assert_equals(
764 expect='200',
765 actual=Getstatus,
766 onpass="Get Port Success",
767 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
768
769 main.step( "Compare Post Port Data" )
770 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
771 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
772 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
773 fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
774
775 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
776 utilities.assert_equals(
777 expect=True,
778 actual=Cmpresult,
779 onpass="Compare Success",
780 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
781 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
782 ",Network id compare:" + str( NetoworkIDcmpresult ) +\
783 ",FixIp compare:" + str( fixedIpresult ) )
784
785 main.step( "Clean Data via HTTP" )
786 deletestatus,result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
787 'DELETE', None, None )
788 utilities.assert_equals(
789 expect='200',
790 actual=deletestatus,
791 onpass="Delete Network Success",
792 onfail="Delete Network Failed" )
793
794 if Cmpresult != True:
795 main.log.error( "Post port compare failed" )
796
797 def CASE9( self, main ):
798
799 """
800 Test Update Port
801 """
802 import os
803
804 try:
805 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
806 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
807 from tests.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
808 except ImportError:
809 main.log.exception( "Something wrong with import file or code error." )
810 main.log.info( "Import Error, please check!" )
811 main.cleanup()
812 main.exit()
813
814 main.log.info( "ONOS Port Update test Start" )
815 main.case( "Virtual Network NBI Test - Port" )
816 main.caseExplanation = "Test Port Update NBI " +\
817 "Verify Stored Data is same with New Post Data"
818
819 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
820 httpport = main.params['HTTP']['port']
821 path = main.params['HTTP']['path']
822
lanqinglongca0a0ee2015-09-22 16:19:08 +0800823 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800824 network = NetworkData()
825 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
826 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
827 subnet = SubnetData()
828 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
829 subnet.tenant_id = network.tenant_id
830 subnet.network_id = network.id
831 port = VirtualPortData()
832 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
833 port.subnet_id = subnet.id
834 port.tenant_id = network.tenant_id
835 port.network_id = network.id
836 port.name = "onos"
837
838 networkpostdata = network.DictoJson()
839 subnetpostdata = subnet.DictoJson()
840 portpostdata = port.DictoJson()
841
842 #create update data
843 port.name = "onos-new"
844 newportpostdata = port.DictoJson()
845 #end
846
847 main.step( "Post Network Data via HTTP(Post port need post network)" )
848 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
849 'POST', None, networkpostdata )
850 utilities.assert_equals(
851 expect='200',
852 actual=Poststatus,
853 onpass="Post Network Success",
854 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
855
856 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
857 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
858 'POST', None, subnetpostdata )
859 utilities.assert_equals(
860 expect='202',
861 actual=Poststatus,
862 onpass="Post Subnet Success",
863 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
864
865 main.step( "Post Port Data via HTTP" )
866 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
867 'POST', None, portpostdata )
868 utilities.assert_equals(
869 expect='200',
870 actual=Poststatus,
871 onpass="Post Port Success",
872 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
873
874 main.step( "Update Port Data via HTTP" )
875 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
876 'PUT', None, newportpostdata )
877 utilities.assert_equals(
878 expect='200',
879 actual=Poststatus,
880 onpass="Update Port Success",
881 onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )
882
883 main.step( "Get Port Data via HTTP" )
884 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
885 'GET', None, None )
886 utilities.assert_equals(
887 expect='200',
888 actual=Getstatus,
889 onpass="Get Port Success",
890 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
891
892 main.step( "Compare Update Port Data" )
893 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
894 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
895 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
896 Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )
897
898 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
899 utilities.assert_equals(
900 expect=True,
901 actual=Cmpresult,
902 onpass="Compare Success",
903 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
904 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
905 ",Network id compare:" + str( NetoworkIDcmpresult ) + \
906 ",Name compare:" + str(Nameresult) )
907
908 main.step( "Clean Data via HTTP" )
909 deletestatus,result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
910 'DELETE', None, None )
911 utilities.assert_equals(
912 expect='200',
913 actual=deletestatus,
914 onpass="Delete Network Success",
915 onfail="Delete Network Failed" )
916
917 if Cmpresult != True:
918 main.log.error( "Update port compare failed" )
919
920 def CASE10( self, main ):
921
922 """
923 Test Delete Port
924 """
925 import os
926
927 try:
928 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
929 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
930 from tests.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
931 except ImportError:
932 main.log.exception( "Something wrong with import file or code error." )
933 main.log.info( "Import Error, please check!" )
934 main.cleanup()
935 main.exit()
936
937 main.log.info( "ONOS Port Delete test Start" )
938 main.case( "Virtual Network NBI Test - Port" )
939 main.caseExplanation = "Test Port Delete NBI " +\
940 "Verify port delete success"
941
942 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
943 httpport = main.params['HTTP']['port']
944 path = main.params['HTTP']['path']
945
lanqinglongca0a0ee2015-09-22 16:19:08 +0800946 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800947 network = NetworkData()
948 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
949 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
950 subnet = SubnetData()
951 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
952 subnet.tenant_id = network.tenant_id
953 subnet.network_id = network.id
954 port = VirtualPortData()
955 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
956 port.subnet_id = subnet.id
957 port.tenant_id = network.tenant_id
958 port.network_id = network.id
959
960 networkpostdata = network.DictoJson()
961 subnetpostdata = subnet.DictoJson()
962 portpostdata = port.DictoJson()
963
964 main.step( "Post Network Data via HTTP(Post port need post network)" )
965 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
966 'POST', None, networkpostdata )
967 utilities.assert_equals(
968 expect='200',
969 actual=Poststatus,
970 onpass="Post Network Success",
971 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
972
973 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
974 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
975 'POST', None, subnetpostdata )
976 utilities.assert_equals(
977 expect='202',
978 actual=Poststatus,
979 onpass="Post Subnet Success",
980 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
981
982 main.step( "Post Port Data via HTTP" )
983 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
984 'POST', None, portpostdata )
985 utilities.assert_equals(
986 expect='200',
987 actual=Poststatus,
988 onpass="Post Port Success",
989 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
990
991 main.step( "Delete Port Data via HTTP" )
992 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
993 'Delete', None, None )
994 utilities.assert_equals(
995 expect='200',
996 actual=Poststatus,
997 onpass="Delete Port Success",
998 onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )
999
1000 main.step( "Get Port Data is NULL" )
1001 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
1002 'GET', None, None )
1003 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +08001004 expect='VirtualPort is not found',
lanqinglongd0dda2e2015-08-25 11:02:48 +08001005 actual=result,
1006 onpass="Get Port Success",
1007 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
1008
sunyulinf16bb8d2015-09-29 20:21:16 +08001009 if result != 'VirtualPort is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +08001010 main.log.error( "Delete Port failed" )
1011
1012 main.step( "Clean Data via HTTP" )
1013 deletestatus,result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
1014 'DELETE', None, None )
1015 utilities.assert_equals(
1016 expect='200',
1017 actual=deletestatus,
1018 onpass="Delete Network Success",
ligenyud4ae1be2015-09-28 20:03:13 +08001019 onfail="Delete Network Failed" )
1020 def CASE11 ( self,main ):
1021
1022 """
1023 Test Post Error Json Create Network
1024 """
1025 import os
1026
1027 try:
1028 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1029 except ImportError:
1030 main.log.exception( "Something wrong with import file or code error." )
1031 main.log.info( "Import Error, please check!" )
1032 main.cleanup()
1033 main.exit()
1034
1035 main.log.info( "ONOS Post Error Json Create Network test Start" )
1036 main.case( "Virtual Network NBI Test - Network" )
1037 main.caseExplanation = "Test Network Post With Error json " +\
1038 "The wrong Json can't post network successfully"
1039
1040 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
1041 port = main.params['HTTP']['port']
1042 path = main.params['HTTP']['path']
1043
1044 main.step( "Generate Post Data" )
1045 network = NetworkData()
1046 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1047 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1048 #The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
1049 network.admin_state_up = 'tttttttttt'
1050 #The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
1051 network.routerExternal = 'ffffffffffff'
1052 #The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
1053 network.shared = 'ffffffffffffff'
1054 postdata = network.DictoJson()
1055
1056 main.step( "Post Data via HTTP" )
1057 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks/',
1058 'POST', None, postdata)
1059
1060 utilities.assert_equals(
1061 expect='500',
1062 actual=Poststatus,
1063 onpass="The Json is wrong,can't post",
1064 onfail="Wrong Json can post successfully " )
1065 def CASE12( self, main ):
1066
1067 """
1068 Test Post Error Json Create Subnet
1069 """
1070 import os
1071
1072 try:
1073 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1074 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
1075 except ImportError:
1076 main.log.exception( "Something wrong with import file or code error." )
1077 main.log.info( "Import Error, please check!" )
1078 main.cleanup()
1079 main.exit()
1080
1081 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1082 main.case( "Virtual Network NBI Test - Subnet" )
1083 main.caseExplanation = "Test Subnet Post With Error json " +\
1084 "The wrong Json can't post network successfully"
1085
1086 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
1087 port = main.params['HTTP']['port']
1088 path = main.params['HTTP']['path']
1089
1090 main.step( "Generate Post Data" )
1091 network = NetworkData()
1092 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1093 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1094 subnet = SubnetData()
1095 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1096 #The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
1097 subnet.enable_dhcp = 'tttttttttttttt'
1098 #The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
1099 subnet.shared = 'ffffffffffffff'
1100 subnet.tenant_id = network.tenant_id
1101 subnet.network_id = network.id
1102
1103 networkpostdata = network.DictoJson()
1104 subnetpostdata = subnet.DictoJson()
1105
1106 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
1107 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
1108 'POST', None, networkpostdata )
1109 utilities.assert_equals(
1110 expect='200',
1111 actual=Poststatus,
1112 onpass="Post Network Success",
1113 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1114
1115 main.step( "Post Subnet Data via HTTP" )
1116 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
1117 'POST', None, subnetpostdata )
1118 utilities.assert_equals(
1119 expect='500',
1120 actual=Poststatus,
1121 onpass="The Json is wrong,can't post",
1122 onfail="Wrong Json can post successfully " )
1123 def CASE13( self, main ):
1124
1125 """
1126 Test Post Error Json Create Virtualport
1127 """
1128 import os
1129
1130 try:
1131 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1132 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
1133 from tests.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
1134 except ImportError:
1135 main.log.exception( "Something wrong with import file or code error." )
1136 main.log.info( "Import Error, please check!" )
1137 main.cleanup()
1138 main.exit()
1139
1140 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1141 main.case( "Virtual Network NBI Test - Port" )
1142 main.caseExplanation = "Test Subnet Post With Error json " +\
1143 "The wrong Json can't create port successfully"
1144
1145 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
1146 httpport = main.params['HTTP']['port']
1147 path = main.params['HTTP']['path']
1148
1149 main.step( "Generate Post Data" )
1150 network = NetworkData()
1151 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1152 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1153 subnet = SubnetData()
1154 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1155 subnet.tenant_id = network.tenant_id
1156 subnet.network_id = network.id
1157 port = VirtualPortData()
1158 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
1159 port.subnet_id = subnet.id
1160 port.tenant_id = network.tenant_id
1161 port.network_id = network.id
1162 #The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
1163 port.adminStateUp = 'tttttttttttt'
1164
1165 networkpostdata = network.DictoJson()
1166 subnetpostdata = subnet.DictoJson()
1167 portpostdata = port.DictoJson()
1168
1169 main.step( "Post Network Data via HTTP(Post port need post network)" )
1170 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
1171 'POST', None, networkpostdata )
1172 utilities.assert_equals(
1173 expect='200',
1174 actual=Poststatus,
1175 onpass="Post Network Success",
1176 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1177
1178 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
1179 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
1180 'POST', None, subnetpostdata )
1181 utilities.assert_equals(
1182 expect='202',
1183 actual=Poststatus,
1184 onpass="Post Subnet Success",
1185 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
1186
1187 main.step( "Post Port Data via HTTP" )
1188 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
1189 'POST', None, portpostdata )
1190 utilities.assert_equals(
1191 expect='500',
1192 actual=Poststatus,
1193 onpass="The Json is wrong,can't post",
Jon Hallce9c01e2015-10-22 16:39:02 +00001194 onfail="Wrong Json can post successfully" )