blob: 81eb698dd168a47d7b5728c16b70f0f70c268edc [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" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700132 packageResult = main.ONOSbench.buckBuild()
lanqinglong77124b02015-08-06 11:47:38 +0800133 utilities.assert_equals( expect=main.TRUE,
134 actual=packageResult,
135 onpass="Successfully created ONOS package",
136 onfail="Failed to create ONOS package " )
137 time.sleep( main.startUpSleep )
138
139 main.step( "Installing ONOS package" )
140 onosInstallResult = main.ONOSbench.onosInstall(
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
You Wangf5de25b2017-01-06 15:13:01 -0800147 main.step( "Set up ONOS secure SSH" )
148 secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[0].ip_address )
149 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
150 onpass="Test step PASS",
151 onfail="Test step FAIL" )
152
lanqinglong77124b02015-08-06 11:47:38 +0800153 main.step( "Checking if ONOS is up yet" )
154
155 for i in range( 2 ):
156 onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
157 if onos1Isup:
158 break
159 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
160 onpass="ONOS startup successful",
161 onfail="ONOS startup failed" )
162 time.sleep( main.startUpSleep )
163
Jon Hall6509dbf2016-06-21 17:01:17 -0700164 main.step( "Starting ONOS CLI sessions" )
lanqinglong77124b02015-08-06 11:47:38 +0800165
166 print main.nodes[0].ip_address
167 cliResults = main.ONOScli1.startOnosCli(main.nodes[0].ip_address)
168 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
169 onpass="ONOS cli startup successful",
170 onfail="ONOS cli startup failed" )
171 time.sleep( main.startUpSleep )
172
173 main.step( "App Ids check" )
174 appCheck = main.ONOScli1.appToIDCheck()
175 if appCheck != main.TRUE:
176 main.log.warn( main.CLIs[0].apps() )
177 main.log.warn( main.CLIs[0].appIDs() )
178 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
179 onpass="App Ids seem to be correct",
180 onfail="Something is wrong with app Ids" )
181
182 if cliResults == main.FALSE:
183 main.log.error( "Failed to start ONOS, stopping test" )
184 main.cleanup()
185 main.exit()
186
GlennRCa0c395f2015-12-03 14:04:56 -0800187 main.step( "Install org.onosproject.vtn app" )
188 installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" )
lanqinglong77124b02015-08-06 11:47:38 +0800189 utilities.assert_equals( expect=main.TRUE, actual=installResults,
GlennRCa0c395f2015-12-03 14:04:56 -0800190 onpass="Install org.onosproject.vtn successful",
191 onfail="Install org.onosproject.vtn app failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800192
193 time.sleep( main.startUpSleep )
194
195 def CASE2 ( self,main ):
196
197 """
198 Test Post Network
199 """
lanqinglonge675e922015-08-13 21:17:28 +0800200 import os
201
lanqinglong77124b02015-08-06 11:47:38 +0800202 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700203 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800204 except ImportError:
205 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800206 main.log.info( "Import Error, please check!" )
207 main.cleanup()
208 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800209
210 main.log.info( "ONOS Network Post test Start" )
211 main.case( "Virtual Network NBI Test - Network" )
212 main.caseExplanation = "Test Network Post NBI " +\
213 "Verify Post Data same with Stored Data"
214
215 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
216 port = main.params['HTTP']['port']
217 path = main.params['HTTP']['path']
218
lanqinglongca0a0ee2015-09-22 16:19:08 +0800219 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800220 network = NetworkData()
221 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
222 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
223 postdata = network.DictoJson()
224
225 main.step( "Post Data via HTTP" )
226 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks/',
227 'POST', None, postdata)
228
229 utilities.assert_equals(
230 expect='200',
231 actual=Poststatus,
232 onpass="Post Success",
233 onfail="Post Failed " + str( Poststatus ) + str( result ) )
234
235 main.step( "Get Data via HTTP" )
236 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
237 'GET', None, None)
238 utilities.assert_equals(
239 expect='200',
240 actual=Getstatus,
241 onpass="Get Success",
242 onfail="Get Failed " + str( Getstatus ) + str( result ) )
243
244 main.log.info("Post Network Data is :%s\nGet Network Data is:%s"%(postdata,result))
245
246 main.step( "Compare Send Id and Get Id" )
247 IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' )
248 TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' )
249 Cmpresult = IDcmpresult and TanantIDcmpresult
250
251 utilities.assert_equals(
252 expect=True,
253 actual=Cmpresult,
254 onpass="Compare Success",
255 onfail="Compare Failed:ID compare: " + str( IDcmpresult ) + \
256 ",Tenant id compare :" + str( TanantIDcmpresult ) )
257
258 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
259 'DELETE', None, None )
260 utilities.assert_equals(
261 expect='200',
262 actual=deletestatus,
263 onpass="Delete Network Success",
264 onfail="Delete Network Failed")
265
lanqinglonge675e922015-08-13 21:17:28 +0800266 if Cmpresult != True:
lanqinglong77124b02015-08-06 11:47:38 +0800267 main.log.error( "Post Network compare failed" )
268
269 def CASE3( self,main ):
270
271 """
272 Test Update Network
273 """
lanqinglonge675e922015-08-13 21:17:28 +0800274 import os
275
lanqinglong77124b02015-08-06 11:47:38 +0800276 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700277 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800278 except ImportError:
279 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800280 main.log.info( "Import Error, please check!" )
281 main.cleanup()
282 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800283
284 main.log.info( "ONOS Network Update test Start" )
285 main.case( "Virtual Network NBI Test - Network" )
286 main.caseExplanation = "Test Network Update NBI " +\
287 "Verify Update Data same with Stored Data"
288
289 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
290 port = main.params['HTTP']['port']
291 path = main.params['HTTP']['path']
292
lanqinglongca0a0ee2015-09-22 16:19:08 +0800293 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800294 network = NetworkData()
295 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
296 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
lanqinglongd0dda2e2015-08-25 11:02:48 +0800297 network.shared = False
lanqinglong77124b02015-08-06 11:47:38 +0800298 postdata = network.DictoJson()
299
lanqinglongd0dda2e2015-08-25 11:02:48 +0800300 network.shared = True
lanqinglong77124b02015-08-06 11:47:38 +0800301 postdatanew = network.DictoJson()
302
303 main.step( "Post Data via HTTP" )
304 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks',
305 'POST', None, postdata )
306 utilities.assert_equals(
307 expect='200',
308 actual=Poststatus,
309 onpass="Post Success",
310 onfail="Post Failed " + str( Poststatus ) + str( result ) )
311
312 main.step( "Update Data via HTTP" )
313 Updatestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
314 'PUT', None, postdatanew)
315 utilities.assert_equals(
316 expect='200',
317 actual=Updatestatus,
318 onpass="Update Success",
319 onfail="Update Failed " + str( Updatestatus ) + str( result ) )
320
321 main.step( "Get Data via HTTP" )
322 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
323 'GET', None, None )
324 utilities.assert_equals(
325 expect='200',
326 actual=Getstatus,
327 onpass="Get Success",
328 onfail="Get Failed " + str( Getstatus ) + str( result ) )
329
330 main.step( "Compare Update data." )
331 IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
332 TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
333 Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
334
335 Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
336 utilities.assert_equals(
337 expect=True,
338 actual=Cmpresult,
339 onpass="Compare Success",
340 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
341 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
342 ",Name compare:" + str( Shareresult ) )
343
344 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
345 'DELETE', None, None )
346
347 utilities.assert_equals(
348 expect='200',
349 actual=deletestatus,
350 onpass="Delete Network Success",
351 onfail="Delete Network Failed" )
352
lanqinglonge675e922015-08-13 21:17:28 +0800353 if Cmpresult != True:
lanqinglong77124b02015-08-06 11:47:38 +0800354 main.log.error( "Update Network compare failed" )
355
356 def CASE4( self,main ):
357
358 """
359 Test Delete Network
360 """
lanqinglonge675e922015-08-13 21:17:28 +0800361 import os
362
lanqinglong77124b02015-08-06 11:47:38 +0800363 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700364 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800365 except ImportError:
366 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800367 main.log.info( "Import Error, please check!" )
368 main.cleanup()
369 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800370
371 main.log.info( "ONOS Network Delete test Start" )
372 main.case( "Virtual Network NBI Test - Network" )
373 main.caseExplanation = "Test Network Delete NBI " +\
374 "Verify Stored Data is NULL after Delete"
375
376 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
377 port = main.params['HTTP']['port']
378 path = main.params['HTTP']['path']
379
lanqinglongca0a0ee2015-09-22 16:19:08 +0800380 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800381 network = NetworkData()
382 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
383 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
384 postdata = network.DictoJson()
385
386 main.step( "Post Data via HTTP" )
lanqinglonge675e922015-08-13 21:17:28 +0800387 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
388 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800389 utilities.assert_equals(
390 expect='200',
391 actual=Poststatus,
392 onpass="Post Success",
393 onfail="Post Failed " + str( Poststatus ) + str( result ) )
394
395 main.step( "Delete Data via HTTP" )
lanqinglonge675e922015-08-13 21:17:28 +0800396 Deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
lanqinglong77124b02015-08-06 11:47:38 +0800397 'DELETE', None, None )
398 utilities.assert_equals(
399 expect='200',
400 actual=Deletestatus,
401 onpass="Delete Success",
lanqinglongd0dda2e2015-08-25 11:02:48 +0800402 onfail="Delete Failed " + str( Deletestatus ) + str( result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800403
404 main.step( "Get Data is NULL" )
405 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
406 'GET', None, None )
407 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800408 expect='Network is not found',
lanqinglong77124b02015-08-06 11:47:38 +0800409 actual=result,
410 onpass="Get Success",
411 onfail="Get Failed " + str( Getstatus ) + str( result ) )
412
sunyulinf16bb8d2015-09-29 20:21:16 +0800413 if result != 'Network is not found':
lanqinglong77124b02015-08-06 11:47:38 +0800414 main.log.error( "Delete Network failed" )
lanqinglonge675e922015-08-13 21:17:28 +0800415
416 def CASE5( self, main ):
417
418 """
419 Test Post Subnet
420 """
421 import os
422
423 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700424 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
425 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800426 except ImportError:
427 main.log.exception( "Something wrong with import file or code error." )
428 main.log.info( "Import Error, please check!" )
429 main.cleanup()
430 main.exit()
431
432 main.log.info( "ONOS Subnet Post test Start" )
433 main.case( "Virtual Network NBI Test - Subnet" )
434 main.caseExplanation = "Test Subnet Post NBI " +\
435 "Verify Stored Data is same with Post Data"
436
437 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
438 port = main.params['HTTP']['port']
439 path = main.params['HTTP']['path']
440
lanqinglongca0a0ee2015-09-22 16:19:08 +0800441 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800442 network = NetworkData()
443 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
444 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
445 subnet = SubnetData()
446 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
447 subnet.tenant_id = network.tenant_id
448 subnet.network_id = network.id
449
450 networkpostdata = network.DictoJson()
451 subnetpostdata = subnet.DictoJson()
452
453 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
454 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
455 'POST', None, networkpostdata )
456 utilities.assert_equals(
457 expect='200',
458 actual=Poststatus,
459 onpass="Post Network Success",
460 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
461
462 main.step( "Post Subnet Data via HTTP" )
463 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
464 'POST', None, subnetpostdata )
465 utilities.assert_equals(
466 expect='202',
467 actual=Poststatus,
468 onpass="Post Subnet Success",
469 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
470
471 main.step( "Get Subnet Data via HTTP" )
472 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
473 'GET', None, None )
474 utilities.assert_equals(
475 expect='200',
476 actual=Getstatus,
477 onpass="Get Subnet Success",
478 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
479
480 IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
481 TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
482 NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
483
484 main.step( "Compare Post Subnet Data via HTTP" )
485 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
486 utilities.assert_equals(
487 expect=True,
488 actual=Cmpresult,
489 onpass="Compare Success",
490 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
491 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
492 ",Network id compare:" + str( NetoworkIDcmpresult ) )
493
494 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
495 'DELETE', None, None )
496 utilities.assert_equals(
497 expect='200',
498 actual=deletestatus,
499 onpass="Delete Network Success",
500 onfail="Delete Network Failed" )
501
502 if Cmpresult != True:
503 main.log.error( "Post Subnet compare failed" )
504
505 def CASE6( self, main ):
506
507 """
508 Test Post Subnet
509 """
510 import os
511
512 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700513 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
514 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800515 except ImportError:
516 main.log.exception( "Something wrong with import file or code error." )
517 main.log.info( "Import Error, please check!" )
518 main.cleanup()
519 main.exit()
520
521 main.log.info( "ONOS Subnet Update test Start" )
522 main.case( "Virtual Network NBI Test - Subnet" )
523 main.caseExplanation = "Test Subnet Update NBI " +\
524 "Verify Stored Data is same with Update Data"
525
526 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
527 port = main.params['HTTP']['port']
528 path = main.params['HTTP']['path']
529
lanqinglongca0a0ee2015-09-22 16:19:08 +0800530 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800531 network = NetworkData()
532 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
533 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
534 subnet = SubnetData()
535 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
536 subnet.tenant_id = network.tenant_id
537 subnet.network_id = network.id
538 subnet.start = "192.168.2.1"
539 subnet.end = "192.168.2.255"
540 networkpostdata = network.DictoJson()
541 subnetpostdata = subnet.DictoJson()
542
543 #Change allocation_poolsdata scope
544 subnet.start = "192.168.102.1"
545 subnet.end = "192.168.102.255"
546 #end change
547 newsubnetpostdata = subnet.DictoJson()
548
549 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
550 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
551 'POST', None, networkpostdata )
552 utilities.assert_equals(
553 expect='200',
554 actual=Poststatus,
555 onpass="Post Network Success",
556 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
557
558 main.step( "Post Subnet Data via HTTP" )
559 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
560 'POST', None, subnetpostdata )
561 utilities.assert_equals(
562 expect='202',
563 actual=Poststatus,
564 onpass="Post Subnet Success",
565 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
566
567 main.step( "Update Subnet Data via HTTP" )
568 Putstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
569 'PUT', None, newsubnetpostdata )
570 utilities.assert_equals(
571 expect='203',
572 actual=Putstatus,
573 onpass="Update Subnet Success",
574 onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
575
576 main.step( "Get Subnet Data via HTTP" )
577 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
578 'GET', None, None )
579 utilities.assert_equals(
580 expect='200',
581 actual=Getstatus,
582 onpass="Get Subnet Success",
583 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
584
585 IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
586 TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
587 Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
588
589 main.step( "Compare Subnet Data" )
590 Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
591 utilities.assert_equals(
592 expect=True,
593 actual=Cmpresult,
594 onpass="Compare Success",
595 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
596 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
597 ",Pool compare:" + str( Poolcmpresult ) )
598
599 main.step( "Delete Subnet via HTTP" )
600 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
601 'DELETE', None, None )
602 utilities.assert_equals(
603 expect='200',
604 actual=deletestatus,
605 onpass="Delete Network Success",
606 onfail="Delete Network Failed" )
607
608 if Cmpresult != True:
609 main.log.error( "Update Subnet compare failed" )
610
611 def CASE7( self, main ):
612
613 """
614 Test Delete Subnet
615 """
616 import os
617
618 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700619 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
620 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800621 except ImportError:
622 main.log.exception( "Something wrong with import file or code error." )
623 main.log.info( "Import Error, please check!" )
624 main.cleanup()
625 main.exit()
626
627 main.log.info( "ONOS Subnet Delete test Start" )
628 main.case( "Virtual Network NBI Test - Subnet" )
629 main.caseExplanation = "Test Subnet Delete NBI " +\
630 "Verify Stored Data is Null after Delete"
631
632 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
633 port = main.params['HTTP']['port']
634 path = main.params['HTTP']['path']
635
lanqinglongca0a0ee2015-09-22 16:19:08 +0800636 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800637 network = NetworkData()
638 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
639 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
640 subnet = SubnetData()
641 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
642 subnet.tenant_id = network.tenant_id
643 subnet.network_id = network.id
644
645 networkpostdata = network.DictoJson()
646 subnetpostdata = subnet.DictoJson()
647
648 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
649 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
650 'POST', None, networkpostdata )
651 utilities.assert_equals(
652 expect='200',
653 actual=Poststatus,
654 onpass="Post Network Success",
655 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
656
657 main.step( "Post Subnet Data via HTTP" )
658 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
659 'POST', None, subnetpostdata )
660 utilities.assert_equals(
661 expect='202',
662 actual=Poststatus,
663 onpass="Post Subnet Success",
664 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
665
666 main.step( "Delete Subnet Data via HTTP" )
667 Deletestatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
668 'DELETE', None, None )
669 utilities.assert_equals(
670 expect='201',
671 actual=Deletestatus,
672 onpass="Delete Subnet Success",
673 onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
674
675 main.step( "Get Subnet Data is NULL" )
676 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
677 'GET', None, None )
678 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800679 expect='Subnet is not found',
lanqinglonge675e922015-08-13 21:17:28 +0800680 actual=result,
681 onpass="Get Subnet Success",
682 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
683
sunyulinf16bb8d2015-09-29 20:21:16 +0800684 if result != 'Subnet is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800685 main.log.error( "Delete Subnet failed" )
686
687 def CASE8( self, main ):
688
689 """
690 Test Post Port
691 """
692 import os
693
694 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700695 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
696 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
697 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800698 except ImportError:
699 main.log.exception( "Something wrong with import file or code error." )
700 main.log.info( "Import Error, please check!" )
701 main.cleanup()
702 main.exit()
703
704 main.log.info( "ONOS Port Post test Start" )
705 main.case( "Virtual Network NBI Test - Port" )
706 main.caseExplanation = "Test Port Post NBI " +\
707 "Verify Stored Data is same with Post Data"
708
709 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
710 httpport = main.params['HTTP']['port']
711 path = main.params['HTTP']['path']
712
lanqinglongca0a0ee2015-09-22 16:19:08 +0800713 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800714 network = NetworkData()
715 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
716 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
717 subnet = SubnetData()
718 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
719 subnet.tenant_id = network.tenant_id
720 subnet.network_id = network.id
721 port = VirtualPortData()
722 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
723 port.subnet_id = subnet.id
724 port.tenant_id = network.tenant_id
725 port.network_id = network.id
726
727 networkpostdata = network.DictoJson()
728 subnetpostdata = subnet.DictoJson()
729 portpostdata = port.DictoJson()
730
731 main.step( "Post Network Data via HTTP(Post port need post network)" )
732 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
733 'POST', None, networkpostdata )
734 utilities.assert_equals(
735 expect='200',
736 actual=Poststatus,
737 onpass="Post Network Success",
738 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
739
740 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
741 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
742 'POST', None, subnetpostdata )
743 utilities.assert_equals(
744 expect='202',
745 actual=Poststatus,
746 onpass="Post Subnet Success",
747 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
748
749 main.step( "Post Port Data via HTTP" )
750 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
751 'POST', None, portpostdata )
752 utilities.assert_equals(
753 expect='200',
754 actual=Poststatus,
755 onpass="Post Port Success",
756 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
757
758 main.step( "Get Port Data via HTTP" )
759 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
760 'GET', None, None )
761 utilities.assert_equals(
762 expect='200',
763 actual=Getstatus,
764 onpass="Get Port Success",
765 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
766
767 main.step( "Compare Post Port Data" )
768 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
769 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
770 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
771 fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
772
773 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
774 utilities.assert_equals(
775 expect=True,
776 actual=Cmpresult,
777 onpass="Compare Success",
778 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
779 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
780 ",Network id compare:" + str( NetoworkIDcmpresult ) +\
781 ",FixIp compare:" + str( fixedIpresult ) )
782
783 main.step( "Clean Data via HTTP" )
784 deletestatus,result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
785 'DELETE', None, None )
786 utilities.assert_equals(
787 expect='200',
788 actual=deletestatus,
789 onpass="Delete Network Success",
790 onfail="Delete Network Failed" )
791
792 if Cmpresult != True:
793 main.log.error( "Post port compare failed" )
794
795 def CASE9( self, main ):
796
797 """
798 Test Update Port
799 """
800 import os
801
802 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700803 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
804 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
805 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800806 except ImportError:
807 main.log.exception( "Something wrong with import file or code error." )
808 main.log.info( "Import Error, please check!" )
809 main.cleanup()
810 main.exit()
811
812 main.log.info( "ONOS Port Update test Start" )
813 main.case( "Virtual Network NBI Test - Port" )
814 main.caseExplanation = "Test Port Update NBI " +\
815 "Verify Stored Data is same with New Post Data"
816
817 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
818 httpport = main.params['HTTP']['port']
819 path = main.params['HTTP']['path']
820
lanqinglongca0a0ee2015-09-22 16:19:08 +0800821 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800822 network = NetworkData()
823 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
824 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
825 subnet = SubnetData()
826 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
827 subnet.tenant_id = network.tenant_id
828 subnet.network_id = network.id
829 port = VirtualPortData()
830 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
831 port.subnet_id = subnet.id
832 port.tenant_id = network.tenant_id
833 port.network_id = network.id
834 port.name = "onos"
835
836 networkpostdata = network.DictoJson()
837 subnetpostdata = subnet.DictoJson()
838 portpostdata = port.DictoJson()
839
840 #create update data
841 port.name = "onos-new"
842 newportpostdata = port.DictoJson()
843 #end
844
845 main.step( "Post Network Data via HTTP(Post port need post network)" )
846 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
847 'POST', None, networkpostdata )
848 utilities.assert_equals(
849 expect='200',
850 actual=Poststatus,
851 onpass="Post Network Success",
852 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
853
854 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
855 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
856 'POST', None, subnetpostdata )
857 utilities.assert_equals(
858 expect='202',
859 actual=Poststatus,
860 onpass="Post Subnet Success",
861 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
862
863 main.step( "Post Port Data via HTTP" )
864 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
865 'POST', None, portpostdata )
866 utilities.assert_equals(
867 expect='200',
868 actual=Poststatus,
869 onpass="Post Port Success",
870 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
871
872 main.step( "Update Port Data via HTTP" )
873 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
874 'PUT', None, newportpostdata )
875 utilities.assert_equals(
876 expect='200',
877 actual=Poststatus,
878 onpass="Update Port Success",
879 onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )
880
881 main.step( "Get Port Data via HTTP" )
882 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
883 'GET', None, None )
884 utilities.assert_equals(
885 expect='200',
886 actual=Getstatus,
887 onpass="Get Port Success",
888 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
889
890 main.step( "Compare Update Port Data" )
891 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
892 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
893 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
894 Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )
895
896 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
897 utilities.assert_equals(
898 expect=True,
899 actual=Cmpresult,
900 onpass="Compare Success",
901 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
902 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
903 ",Network id compare:" + str( NetoworkIDcmpresult ) + \
904 ",Name compare:" + str(Nameresult) )
905
906 main.step( "Clean Data via HTTP" )
907 deletestatus,result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
908 'DELETE', None, None )
909 utilities.assert_equals(
910 expect='200',
911 actual=deletestatus,
912 onpass="Delete Network Success",
913 onfail="Delete Network Failed" )
914
915 if Cmpresult != True:
916 main.log.error( "Update port compare failed" )
917
918 def CASE10( self, main ):
919
920 """
921 Test Delete Port
922 """
923 import os
924
925 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700926 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
927 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
928 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800929 except ImportError:
930 main.log.exception( "Something wrong with import file or code error." )
931 main.log.info( "Import Error, please check!" )
932 main.cleanup()
933 main.exit()
934
935 main.log.info( "ONOS Port Delete test Start" )
936 main.case( "Virtual Network NBI Test - Port" )
937 main.caseExplanation = "Test Port Delete NBI " +\
938 "Verify port delete success"
939
940 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
941 httpport = main.params['HTTP']['port']
942 path = main.params['HTTP']['path']
943
lanqinglongca0a0ee2015-09-22 16:19:08 +0800944 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800945 network = NetworkData()
946 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
947 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
948 subnet = SubnetData()
949 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
950 subnet.tenant_id = network.tenant_id
951 subnet.network_id = network.id
952 port = VirtualPortData()
953 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
954 port.subnet_id = subnet.id
955 port.tenant_id = network.tenant_id
956 port.network_id = network.id
957
958 networkpostdata = network.DictoJson()
959 subnetpostdata = subnet.DictoJson()
960 portpostdata = port.DictoJson()
961
962 main.step( "Post Network Data via HTTP(Post port need post network)" )
963 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
964 'POST', None, networkpostdata )
965 utilities.assert_equals(
966 expect='200',
967 actual=Poststatus,
968 onpass="Post Network Success",
969 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
970
971 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
972 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
973 'POST', None, subnetpostdata )
974 utilities.assert_equals(
975 expect='202',
976 actual=Poststatus,
977 onpass="Post Subnet Success",
978 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
979
980 main.step( "Post Port Data via HTTP" )
981 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
982 'POST', None, portpostdata )
983 utilities.assert_equals(
984 expect='200',
985 actual=Poststatus,
986 onpass="Post Port Success",
987 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
988
989 main.step( "Delete Port Data via HTTP" )
990 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
991 'Delete', None, None )
992 utilities.assert_equals(
993 expect='200',
994 actual=Poststatus,
995 onpass="Delete Port Success",
996 onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )
997
998 main.step( "Get Port Data is NULL" )
999 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
1000 'GET', None, None )
1001 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +08001002 expect='VirtualPort is not found',
lanqinglongd0dda2e2015-08-25 11:02:48 +08001003 actual=result,
1004 onpass="Get Port Success",
1005 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
1006
sunyulinf16bb8d2015-09-29 20:21:16 +08001007 if result != 'VirtualPort is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +08001008 main.log.error( "Delete Port failed" )
1009
1010 main.step( "Clean Data via HTTP" )
1011 deletestatus,result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
1012 'DELETE', None, None )
1013 utilities.assert_equals(
1014 expect='200',
1015 actual=deletestatus,
1016 onpass="Delete Network Success",
ligenyud4ae1be2015-09-28 20:03:13 +08001017 onfail="Delete Network Failed" )
1018 def CASE11 ( self,main ):
1019
1020 """
1021 Test Post Error Json Create Network
1022 """
1023 import os
1024
1025 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001026 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
ligenyud4ae1be2015-09-28 20:03:13 +08001027 except ImportError:
1028 main.log.exception( "Something wrong with import file or code error." )
1029 main.log.info( "Import Error, please check!" )
1030 main.cleanup()
1031 main.exit()
1032
1033 main.log.info( "ONOS Post Error Json Create Network test Start" )
1034 main.case( "Virtual Network NBI Test - Network" )
1035 main.caseExplanation = "Test Network Post With Error json " +\
1036 "The wrong Json can't post network successfully"
1037
1038 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
1039 port = main.params['HTTP']['port']
1040 path = main.params['HTTP']['path']
1041
1042 main.step( "Generate Post Data" )
1043 network = NetworkData()
1044 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1045 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1046 #The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
1047 network.admin_state_up = 'tttttttttt'
1048 #The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
1049 network.routerExternal = 'ffffffffffff'
1050 #The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
1051 network.shared = 'ffffffffffffff'
1052 postdata = network.DictoJson()
1053
1054 main.step( "Post Data via HTTP" )
1055 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks/',
1056 'POST', None, postdata)
1057
1058 utilities.assert_equals(
1059 expect='500',
1060 actual=Poststatus,
1061 onpass="The Json is wrong,can't post",
1062 onfail="Wrong Json can post successfully " )
1063 def CASE12( self, main ):
1064
1065 """
1066 Test Post Error Json Create Subnet
1067 """
1068 import os
1069
1070 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001071 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1072 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
ligenyud4ae1be2015-09-28 20:03:13 +08001073 except ImportError:
1074 main.log.exception( "Something wrong with import file or code error." )
1075 main.log.info( "Import Error, please check!" )
1076 main.cleanup()
1077 main.exit()
1078
1079 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1080 main.case( "Virtual Network NBI Test - Subnet" )
1081 main.caseExplanation = "Test Subnet Post With Error json " +\
1082 "The wrong Json can't post network successfully"
1083
1084 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
1085 port = main.params['HTTP']['port']
1086 path = main.params['HTTP']['path']
1087
1088 main.step( "Generate Post Data" )
1089 network = NetworkData()
1090 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1091 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1092 subnet = SubnetData()
1093 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1094 #The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
1095 subnet.enable_dhcp = 'tttttttttttttt'
1096 #The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
1097 subnet.shared = 'ffffffffffffff'
1098 subnet.tenant_id = network.tenant_id
1099 subnet.network_id = network.id
1100
1101 networkpostdata = network.DictoJson()
1102 subnetpostdata = subnet.DictoJson()
1103
1104 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
1105 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
1106 'POST', None, networkpostdata )
1107 utilities.assert_equals(
1108 expect='200',
1109 actual=Poststatus,
1110 onpass="Post Network Success",
1111 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1112
1113 main.step( "Post Subnet Data via HTTP" )
1114 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
1115 'POST', None, subnetpostdata )
1116 utilities.assert_equals(
1117 expect='500',
1118 actual=Poststatus,
1119 onpass="The Json is wrong,can't post",
1120 onfail="Wrong Json can post successfully " )
1121 def CASE13( self, main ):
1122
1123 """
1124 Test Post Error Json Create Virtualport
1125 """
1126 import os
1127
1128 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001129 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1130 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
1131 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
ligenyud4ae1be2015-09-28 20:03:13 +08001132 except ImportError:
1133 main.log.exception( "Something wrong with import file or code error." )
1134 main.log.info( "Import Error, please check!" )
1135 main.cleanup()
1136 main.exit()
1137
1138 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1139 main.case( "Virtual Network NBI Test - Port" )
1140 main.caseExplanation = "Test Subnet Post With Error json " +\
1141 "The wrong Json can't create port successfully"
1142
1143 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
1144 httpport = main.params['HTTP']['port']
1145 path = main.params['HTTP']['path']
1146
1147 main.step( "Generate Post Data" )
1148 network = NetworkData()
1149 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1150 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1151 subnet = SubnetData()
1152 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1153 subnet.tenant_id = network.tenant_id
1154 subnet.network_id = network.id
1155 port = VirtualPortData()
1156 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
1157 port.subnet_id = subnet.id
1158 port.tenant_id = network.tenant_id
1159 port.network_id = network.id
1160 #The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
1161 port.adminStateUp = 'tttttttttttt'
1162
1163 networkpostdata = network.DictoJson()
1164 subnetpostdata = subnet.DictoJson()
1165 portpostdata = port.DictoJson()
1166
1167 main.step( "Post Network Data via HTTP(Post port need post network)" )
1168 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
1169 'POST', None, networkpostdata )
1170 utilities.assert_equals(
1171 expect='200',
1172 actual=Poststatus,
1173 onpass="Post Network Success",
1174 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1175
1176 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
1177 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
1178 'POST', None, subnetpostdata )
1179 utilities.assert_equals(
1180 expect='202',
1181 actual=Poststatus,
1182 onpass="Post Subnet Success",
1183 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
1184
1185 main.step( "Post Port Data via HTTP" )
1186 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
1187 'POST', None, portpostdata )
1188 utilities.assert_equals(
1189 expect='500',
1190 actual=Poststatus,
1191 onpass="The Json is wrong,can't post",
Jon Hallce9c01e2015-10-22 16:39:02 +00001192 onfail="Wrong Json can post successfully" )