blob: 4bbc0bb43627b9701568201e10ff28b9644c8bb2 [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
16
17lanqinglong@huawei.com
18"""
19import os
20
21class FUNCvirNetNB:
22
23 def __init__( self ):
24 self.default = ''
25
26 def CASE1( self, main ):
27 """
28 CASE1 is to compile ONOS and push it to the test machines
29
30 Startup sequence:
31 cell<name>
32 onos-verify-cell
33 NOTE:temporary - onos-remove-raft-logs
34 onos-uninstall
35 git pull
36 mvn clean install
37 onos-package
38 onos-install -f
39 onos-wait-for-start
40 start cli sessions
41 start vtnrsc
42 """
43
44 import time
45 import os
46 main.log.info( "ONOS Single node Start "+
47 "VirtualNet Northbound test - initialization" )
48 main.case( "Setting up test environment" )
49 main.caseExplanation = "Setup the test environment including "+\
50 "installing ONOS,start ONOS."
51
52 # load some variables from the params file
53 PULLCODE = False
54 if main.params['GIT']['pull'] =='True':
55 PULLCODE = True
56 gitBranch = main.params['GIT']['branch']
57 cellName = main.params['ENV']['cellName']
58 ipList = os.getenv( main.params['CTRL']['ip1'] )
59
lanqinglongca0a0ee2015-09-22 16:19:08 +080060 main.step("Create cell file and apply to environment")
lanqinglong77124b02015-08-06 11:47:38 +080061 cellAppString = main.params['ENV']['cellApps']
62 main.ONOSbench.createCellFile(main.ONOSbench.ip_address,cellName,
63 main.Mininet1.ip_address,
64 cellAppString,ipList )
65
lanqinglong77124b02015-08-06 11:47:38 +080066 cellResult = main.ONOSbench.setCell(cellName)
67 verifyResult = main.ONOSbench.verifyCell()
68
lanqinglongca0a0ee2015-09-22 16:19:08 +080069 stepResult = cellResult and verifyResult
70 utilities.assert_equals( expect=main.TRUE,
71 actual=stepResult,
72 onpass="Successfully applied cell to " + \
73 "environment",
74 onfail="Failed to apply cell to environment " )
75
lanqinglong77124b02015-08-06 11:47:38 +080076 #FIXME:this is short term fix
77 main.log.info( "Removing raft logs" )
lanqinglonge675e922015-08-13 21:17:28 +080078 main.ONOSbench.onosRemoveRaftLogs()
lanqinglong77124b02015-08-06 11:47:38 +080079
80 main.CLIs = []
81 main.nodes = []
82 main.numCtrls=1
83 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
84
85 for i in range ( 1, main.numCtrls +1):
86 try:
87 main.CLIs.append( getattr( main, 'ONOScli' + str(i) ) )
88 main.nodes.append( getattr( main, 'ONOS' + str(i) ) )
89 ipList.append( main.nodes[ -1 ].ip_address )
90 except AttributeError:
91 break
92
93 main.log.info( "Uninstalling ONOS" )
94 for node in main.nodes:
95 main.ONOSbench.onosUninstall( node.ip_address )
96
97 #Make sure ONOS is DEAD
98 main.log.info( "Killing any ONOS processes" )
99 killResults = main.TRUE
100 for node in main.nodes:
101 killed = main.ONOSbench.onosKill( node.ip_address )
102 killResults = killResults and killed
103
104 cleanInstallResult = main.TRUE
105 gitPullResult = main.TRUE
lanqinglongca0a0ee2015-09-22 16:19:08 +0800106 main.log.info( "Git checkout and pull " + gitBranch )
lanqinglong77124b02015-08-06 11:47:38 +0800107 if PULLCODE:
108 main.ONOSbench.gitCheckout ( gitBranch )
109 gitPullResult = main.ONOSbench.gitPull()
110 # values of 1 or 3 are good
111 utilities.assert_lesser ( expect=0, actual=gitPullResult,
112 onpass="Git pull successful",
113 onfail ="Git pull failed" )
114 main.ONOSbench.getVersion( report =True )
115 main.step( "Using mvn clean install" )
116 cleanInstallResult= main.TRUE
117 if PULLCODE and gitPullResult == main.TRUE:
118 cleanInstallResult = main.ONOSbench.cleanInstall()
119 else:
120 main.log.warn("Did not pull new code so skipping mvn "+
121 "clean install")
122
123 utilities.assert_equals( expect=main.TRUE,
124 actual=cleanInstallResult,
125 onpass="MCI successful",
126 onfail="MCI failed" )
127
128 main.step( "Creating ONOS package" )
129 packageResult = main.ONOSbench.onosPackage()
130 utilities.assert_equals( expect=main.TRUE,
131 actual=packageResult,
132 onpass="Successfully created ONOS package",
133 onfail="Failed to create ONOS package " )
134 time.sleep( main.startUpSleep )
135
136 main.step( "Installing ONOS package" )
137 onosInstallResult = main.ONOSbench.onosInstall(
138 options="-f",node=main.nodes[0].ip_address )
139 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
140 onpass="ONOS install successful",
141 onfail="ONOS install failed" )
142 time.sleep( main.startUpSleep )
143
144 main.step( "Checking if ONOS is up yet" )
145
146 for i in range( 2 ):
147 onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
148 if onos1Isup:
149 break
150 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
151 onpass="ONOS startup successful",
152 onfail="ONOS startup failed" )
153 time.sleep( main.startUpSleep )
154
155 main.log.step( "Starting ONOS CLI sessions" )
156
157 print main.nodes[0].ip_address
158 cliResults = main.ONOScli1.startOnosCli(main.nodes[0].ip_address)
159 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
160 onpass="ONOS cli startup successful",
161 onfail="ONOS cli startup failed" )
162 time.sleep( main.startUpSleep )
163
164 main.step( "App Ids check" )
165 appCheck = main.ONOScli1.appToIDCheck()
166 if appCheck != main.TRUE:
167 main.log.warn( main.CLIs[0].apps() )
168 main.log.warn( main.CLIs[0].appIDs() )
169 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
170 onpass="App Ids seem to be correct",
171 onfail="Something is wrong with app Ids" )
172
173 if cliResults == main.FALSE:
174 main.log.error( "Failed to start ONOS, stopping test" )
175 main.cleanup()
176 main.exit()
177
178 main.step( "Install onos-app-vtnrsc app" )
179 installResults = main.ONOScli1.featureInstall( "onos-app-vtnrsc" )
180 utilities.assert_equals( expect=main.TRUE, actual=installResults,
181 onpass="Install onos-app-vtnrsc successful",
182 onfail="Install onos-app-vtnrsc app failed" )
183
184 time.sleep( main.startUpSleep )
lanqinglonge675e922015-08-13 21:17:28 +0800185
lanqinglong77124b02015-08-06 11:47:38 +0800186 main.step( "Install onos-app-vtnweb app" )
187 installResults = main.ONOScli1.featureInstall( "onos-app-vtnweb" )
188 utilities.assert_equals( expect=main.TRUE, actual=installResults,
189 onpass="Install onos-app-vtnweb successful",
190 onfail="Install onos-app-vtnweb app failed" )
191
192 time.sleep( main.startUpSleep )
193
194 def CASE2 ( self,main ):
195
196 """
197 Test Post Network
198 """
lanqinglonge675e922015-08-13 21:17:28 +0800199 import os
200
lanqinglong77124b02015-08-06 11:47:38 +0800201 try:
202 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
203 except ImportError:
204 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800205 main.log.info( "Import Error, please check!" )
206 main.cleanup()
207 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800208
209 main.log.info( "ONOS Network Post test Start" )
210 main.case( "Virtual Network NBI Test - Network" )
211 main.caseExplanation = "Test Network Post NBI " +\
212 "Verify Post Data same with Stored Data"
213
214 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
215 port = main.params['HTTP']['port']
216 path = main.params['HTTP']['path']
217
lanqinglongca0a0ee2015-09-22 16:19:08 +0800218 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800219 network = NetworkData()
220 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
221 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
222 postdata = network.DictoJson()
223
224 main.step( "Post Data via HTTP" )
225 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks/',
226 'POST', None, postdata)
227
228 utilities.assert_equals(
229 expect='200',
230 actual=Poststatus,
231 onpass="Post Success",
232 onfail="Post Failed " + str( Poststatus ) + str( result ) )
233
234 main.step( "Get Data via HTTP" )
235 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
236 'GET', None, None)
237 utilities.assert_equals(
238 expect='200',
239 actual=Getstatus,
240 onpass="Get Success",
241 onfail="Get Failed " + str( Getstatus ) + str( result ) )
242
243 main.log.info("Post Network Data is :%s\nGet Network Data is:%s"%(postdata,result))
244
245 main.step( "Compare Send Id and Get Id" )
246 IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' )
247 TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' )
248 Cmpresult = IDcmpresult and TanantIDcmpresult
249
250 utilities.assert_equals(
251 expect=True,
252 actual=Cmpresult,
253 onpass="Compare Success",
254 onfail="Compare Failed:ID compare: " + str( IDcmpresult ) + \
255 ",Tenant id compare :" + str( TanantIDcmpresult ) )
256
257 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
258 'DELETE', None, None )
259 utilities.assert_equals(
260 expect='200',
261 actual=deletestatus,
262 onpass="Delete Network Success",
263 onfail="Delete Network Failed")
264
lanqinglonge675e922015-08-13 21:17:28 +0800265 if Cmpresult != True:
lanqinglong77124b02015-08-06 11:47:38 +0800266 main.log.error( "Post Network compare failed" )
267
268 def CASE3( self,main ):
269
270 """
271 Test Update Network
272 """
lanqinglonge675e922015-08-13 21:17:28 +0800273 import os
274
lanqinglong77124b02015-08-06 11:47:38 +0800275 try:
276 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
277 except ImportError:
278 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800279 main.log.info( "Import Error, please check!" )
280 main.cleanup()
281 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800282
283 main.log.info( "ONOS Network Update test Start" )
284 main.case( "Virtual Network NBI Test - Network" )
285 main.caseExplanation = "Test Network Update NBI " +\
286 "Verify Update Data same with Stored Data"
287
288 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
289 port = main.params['HTTP']['port']
290 path = main.params['HTTP']['path']
291
lanqinglongca0a0ee2015-09-22 16:19:08 +0800292 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800293 network = NetworkData()
294 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
295 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
lanqinglongd0dda2e2015-08-25 11:02:48 +0800296 network.shared = False
lanqinglong77124b02015-08-06 11:47:38 +0800297 postdata = network.DictoJson()
298
lanqinglongd0dda2e2015-08-25 11:02:48 +0800299 network.shared = True
lanqinglong77124b02015-08-06 11:47:38 +0800300 postdatanew = network.DictoJson()
301
302 main.step( "Post Data via HTTP" )
303 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks',
304 'POST', None, postdata )
305 utilities.assert_equals(
306 expect='200',
307 actual=Poststatus,
308 onpass="Post Success",
309 onfail="Post Failed " + str( Poststatus ) + str( result ) )
310
311 main.step( "Update Data via HTTP" )
312 Updatestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
313 'PUT', None, postdatanew)
314 utilities.assert_equals(
315 expect='200',
316 actual=Updatestatus,
317 onpass="Update Success",
318 onfail="Update Failed " + str( Updatestatus ) + str( result ) )
319
320 main.step( "Get Data via HTTP" )
321 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
322 'GET', None, None )
323 utilities.assert_equals(
324 expect='200',
325 actual=Getstatus,
326 onpass="Get Success",
327 onfail="Get Failed " + str( Getstatus ) + str( result ) )
328
329 main.step( "Compare Update data." )
330 IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
331 TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
332 Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
333
334 Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
335 utilities.assert_equals(
336 expect=True,
337 actual=Cmpresult,
338 onpass="Compare Success",
339 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
340 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
341 ",Name compare:" + str( Shareresult ) )
342
343 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
344 'DELETE', None, None )
345
346 utilities.assert_equals(
347 expect='200',
348 actual=deletestatus,
349 onpass="Delete Network Success",
350 onfail="Delete Network Failed" )
351
lanqinglonge675e922015-08-13 21:17:28 +0800352 if Cmpresult != True:
lanqinglong77124b02015-08-06 11:47:38 +0800353 main.log.error( "Update Network compare failed" )
354
355 def CASE4( self,main ):
356
357 """
358 Test Delete Network
359 """
lanqinglonge675e922015-08-13 21:17:28 +0800360 import os
361
lanqinglong77124b02015-08-06 11:47:38 +0800362 try:
363 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
364 except ImportError:
365 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800366 main.log.info( "Import Error, please check!" )
367 main.cleanup()
368 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800369
370 main.log.info( "ONOS Network Delete test Start" )
371 main.case( "Virtual Network NBI Test - Network" )
372 main.caseExplanation = "Test Network Delete NBI " +\
373 "Verify Stored Data is NULL after Delete"
374
375 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
376 port = main.params['HTTP']['port']
377 path = main.params['HTTP']['path']
378
lanqinglongca0a0ee2015-09-22 16:19:08 +0800379 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800380 network = NetworkData()
381 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
382 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
383 postdata = network.DictoJson()
384
385 main.step( "Post Data via HTTP" )
lanqinglonge675e922015-08-13 21:17:28 +0800386 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
387 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800388 utilities.assert_equals(
389 expect='200',
390 actual=Poststatus,
391 onpass="Post Success",
392 onfail="Post Failed " + str( Poststatus ) + str( result ) )
393
394 main.step( "Delete Data via HTTP" )
lanqinglonge675e922015-08-13 21:17:28 +0800395 Deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
lanqinglong77124b02015-08-06 11:47:38 +0800396 'DELETE', None, None )
397 utilities.assert_equals(
398 expect='200',
399 actual=Deletestatus,
400 onpass="Delete Success",
lanqinglongd0dda2e2015-08-25 11:02:48 +0800401 onfail="Delete Failed " + str( Deletestatus ) + str( result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800402
403 main.step( "Get Data is NULL" )
404 Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
405 'GET', None, None )
406 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800407 expect='Network is not found',
lanqinglong77124b02015-08-06 11:47:38 +0800408 actual=result,
409 onpass="Get Success",
410 onfail="Get Failed " + str( Getstatus ) + str( result ) )
411
sunyulinf16bb8d2015-09-29 20:21:16 +0800412 if result != 'Network is not found':
lanqinglong77124b02015-08-06 11:47:38 +0800413 main.log.error( "Delete Network failed" )
lanqinglonge675e922015-08-13 21:17:28 +0800414
415 def CASE5( self, main ):
416
417 """
418 Test Post Subnet
419 """
420 import os
421
422 try:
423 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
424 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
425 except ImportError:
426 main.log.exception( "Something wrong with import file or code error." )
427 main.log.info( "Import Error, please check!" )
428 main.cleanup()
429 main.exit()
430
431 main.log.info( "ONOS Subnet Post test Start" )
432 main.case( "Virtual Network NBI Test - Subnet" )
433 main.caseExplanation = "Test Subnet Post NBI " +\
434 "Verify Stored Data is same with Post Data"
435
436 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
437 port = main.params['HTTP']['port']
438 path = main.params['HTTP']['path']
439
lanqinglongca0a0ee2015-09-22 16:19:08 +0800440 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800441 network = NetworkData()
442 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
443 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
444 subnet = SubnetData()
445 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
446 subnet.tenant_id = network.tenant_id
447 subnet.network_id = network.id
448
449 networkpostdata = network.DictoJson()
450 subnetpostdata = subnet.DictoJson()
451
452 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
453 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
454 'POST', None, networkpostdata )
455 utilities.assert_equals(
456 expect='200',
457 actual=Poststatus,
458 onpass="Post Network Success",
459 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
460
461 main.step( "Post Subnet Data via HTTP" )
462 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
463 'POST', None, subnetpostdata )
464 utilities.assert_equals(
465 expect='202',
466 actual=Poststatus,
467 onpass="Post Subnet Success",
468 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
469
470 main.step( "Get Subnet Data via HTTP" )
471 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
472 'GET', None, None )
473 utilities.assert_equals(
474 expect='200',
475 actual=Getstatus,
476 onpass="Get Subnet Success",
477 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
478
479 IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
480 TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
481 NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
482
483 main.step( "Compare Post Subnet Data via HTTP" )
484 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
485 utilities.assert_equals(
486 expect=True,
487 actual=Cmpresult,
488 onpass="Compare Success",
489 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
490 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
491 ",Network id compare:" + str( NetoworkIDcmpresult ) )
492
493 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
494 'DELETE', None, None )
495 utilities.assert_equals(
496 expect='200',
497 actual=deletestatus,
498 onpass="Delete Network Success",
499 onfail="Delete Network Failed" )
500
501 if Cmpresult != True:
502 main.log.error( "Post Subnet compare failed" )
503
504 def CASE6( self, main ):
505
506 """
507 Test Post Subnet
508 """
509 import os
510
511 try:
512 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
513 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
514 except ImportError:
515 main.log.exception( "Something wrong with import file or code error." )
516 main.log.info( "Import Error, please check!" )
517 main.cleanup()
518 main.exit()
519
520 main.log.info( "ONOS Subnet Update test Start" )
521 main.case( "Virtual Network NBI Test - Subnet" )
522 main.caseExplanation = "Test Subnet Update NBI " +\
523 "Verify Stored Data is same with Update Data"
524
525 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
526 port = main.params['HTTP']['port']
527 path = main.params['HTTP']['path']
528
lanqinglongca0a0ee2015-09-22 16:19:08 +0800529 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800530 network = NetworkData()
531 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
532 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
533 subnet = SubnetData()
534 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
535 subnet.tenant_id = network.tenant_id
536 subnet.network_id = network.id
537 subnet.start = "192.168.2.1"
538 subnet.end = "192.168.2.255"
539 networkpostdata = network.DictoJson()
540 subnetpostdata = subnet.DictoJson()
541
542 #Change allocation_poolsdata scope
543 subnet.start = "192.168.102.1"
544 subnet.end = "192.168.102.255"
545 #end change
546 newsubnetpostdata = subnet.DictoJson()
547
548 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
549 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
550 'POST', None, networkpostdata )
551 utilities.assert_equals(
552 expect='200',
553 actual=Poststatus,
554 onpass="Post Network Success",
555 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
556
557 main.step( "Post Subnet Data via HTTP" )
558 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
559 'POST', None, subnetpostdata )
560 utilities.assert_equals(
561 expect='202',
562 actual=Poststatus,
563 onpass="Post Subnet Success",
564 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
565
566 main.step( "Update Subnet Data via HTTP" )
567 Putstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
568 'PUT', None, newsubnetpostdata )
569 utilities.assert_equals(
570 expect='203',
571 actual=Putstatus,
572 onpass="Update Subnet Success",
573 onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
574
575 main.step( "Get Subnet Data via HTTP" )
576 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
577 'GET', None, None )
578 utilities.assert_equals(
579 expect='200',
580 actual=Getstatus,
581 onpass="Get Subnet Success",
582 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
583
584 IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
585 TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
586 Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
587
588 main.step( "Compare Subnet Data" )
589 Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
590 utilities.assert_equals(
591 expect=True,
592 actual=Cmpresult,
593 onpass="Compare Success",
594 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
595 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
596 ",Pool compare:" + str( Poolcmpresult ) )
597
598 main.step( "Delete Subnet via HTTP" )
599 deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
600 'DELETE', None, None )
601 utilities.assert_equals(
602 expect='200',
603 actual=deletestatus,
604 onpass="Delete Network Success",
605 onfail="Delete Network Failed" )
606
607 if Cmpresult != True:
608 main.log.error( "Update Subnet compare failed" )
609
610 def CASE7( self, main ):
611
612 """
613 Test Delete Subnet
614 """
615 import os
616
617 try:
618 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
619 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
620 except ImportError:
621 main.log.exception( "Something wrong with import file or code error." )
622 main.log.info( "Import Error, please check!" )
623 main.cleanup()
624 main.exit()
625
626 main.log.info( "ONOS Subnet Delete test Start" )
627 main.case( "Virtual Network NBI Test - Subnet" )
628 main.caseExplanation = "Test Subnet Delete NBI " +\
629 "Verify Stored Data is Null after Delete"
630
631 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
632 port = main.params['HTTP']['port']
633 path = main.params['HTTP']['path']
634
lanqinglongca0a0ee2015-09-22 16:19:08 +0800635 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800636 network = NetworkData()
637 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
638 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
639 subnet = SubnetData()
640 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
641 subnet.tenant_id = network.tenant_id
642 subnet.network_id = network.id
643
644 networkpostdata = network.DictoJson()
645 subnetpostdata = subnet.DictoJson()
646
647 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
648 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
649 'POST', None, networkpostdata )
650 utilities.assert_equals(
651 expect='200',
652 actual=Poststatus,
653 onpass="Post Network Success",
654 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
655
656 main.step( "Post Subnet Data via HTTP" )
657 Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
658 'POST', None, subnetpostdata )
659 utilities.assert_equals(
660 expect='202',
661 actual=Poststatus,
662 onpass="Post Subnet Success",
663 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
664
665 main.step( "Delete Subnet Data via HTTP" )
666 Deletestatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
667 'DELETE', None, None )
668 utilities.assert_equals(
669 expect='201',
670 actual=Deletestatus,
671 onpass="Delete Subnet Success",
672 onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
673
674 main.step( "Get Subnet Data is NULL" )
675 Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
676 'GET', None, None )
677 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800678 expect='Subnet is not found',
lanqinglonge675e922015-08-13 21:17:28 +0800679 actual=result,
680 onpass="Get Subnet Success",
681 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
682
sunyulinf16bb8d2015-09-29 20:21:16 +0800683 if result != 'Subnet is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800684 main.log.error( "Delete Subnet failed" )
685
686 def CASE8( self, main ):
687
688 """
689 Test Post Port
690 """
691 import os
692
693 try:
694 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
695 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
696 from tests.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
697 except ImportError:
698 main.log.exception( "Something wrong with import file or code error." )
699 main.log.info( "Import Error, please check!" )
700 main.cleanup()
701 main.exit()
702
703 main.log.info( "ONOS Port Post test Start" )
704 main.case( "Virtual Network NBI Test - Port" )
705 main.caseExplanation = "Test Port Post NBI " +\
706 "Verify Stored Data is same with Post Data"
707
708 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
709 httpport = main.params['HTTP']['port']
710 path = main.params['HTTP']['path']
711
lanqinglongca0a0ee2015-09-22 16:19:08 +0800712 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800713 network = NetworkData()
714 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
715 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
716 subnet = SubnetData()
717 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
718 subnet.tenant_id = network.tenant_id
719 subnet.network_id = network.id
720 port = VirtualPortData()
721 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
722 port.subnet_id = subnet.id
723 port.tenant_id = network.tenant_id
724 port.network_id = network.id
725
726 networkpostdata = network.DictoJson()
727 subnetpostdata = subnet.DictoJson()
728 portpostdata = port.DictoJson()
729
730 main.step( "Post Network Data via HTTP(Post port need post network)" )
731 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
732 'POST', None, networkpostdata )
733 utilities.assert_equals(
734 expect='200',
735 actual=Poststatus,
736 onpass="Post Network Success",
737 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
738
739 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
740 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
741 'POST', None, subnetpostdata )
742 utilities.assert_equals(
743 expect='202',
744 actual=Poststatus,
745 onpass="Post Subnet Success",
746 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
747
748 main.step( "Post Port Data via HTTP" )
749 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
750 'POST', None, portpostdata )
751 utilities.assert_equals(
752 expect='200',
753 actual=Poststatus,
754 onpass="Post Port Success",
755 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
756
757 main.step( "Get Port Data via HTTP" )
758 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
759 'GET', None, None )
760 utilities.assert_equals(
761 expect='200',
762 actual=Getstatus,
763 onpass="Get Port Success",
764 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
765
766 main.step( "Compare Post Port Data" )
767 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
768 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
769 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
770 fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
771
772 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
773 utilities.assert_equals(
774 expect=True,
775 actual=Cmpresult,
776 onpass="Compare Success",
777 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
778 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
779 ",Network id compare:" + str( NetoworkIDcmpresult ) +\
780 ",FixIp compare:" + str( fixedIpresult ) )
781
782 main.step( "Clean Data via HTTP" )
783 deletestatus,result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
784 'DELETE', None, None )
785 utilities.assert_equals(
786 expect='200',
787 actual=deletestatus,
788 onpass="Delete Network Success",
789 onfail="Delete Network Failed" )
790
791 if Cmpresult != True:
792 main.log.error( "Post port compare failed" )
793
794 def CASE9( self, main ):
795
796 """
797 Test Update Port
798 """
799 import os
800
801 try:
802 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
803 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
804 from tests.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
805 except ImportError:
806 main.log.exception( "Something wrong with import file or code error." )
807 main.log.info( "Import Error, please check!" )
808 main.cleanup()
809 main.exit()
810
811 main.log.info( "ONOS Port Update test Start" )
812 main.case( "Virtual Network NBI Test - Port" )
813 main.caseExplanation = "Test Port Update NBI " +\
814 "Verify Stored Data is same with New Post Data"
815
816 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
817 httpport = main.params['HTTP']['port']
818 path = main.params['HTTP']['path']
819
lanqinglongca0a0ee2015-09-22 16:19:08 +0800820 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800821 network = NetworkData()
822 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
823 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
824 subnet = SubnetData()
825 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
826 subnet.tenant_id = network.tenant_id
827 subnet.network_id = network.id
828 port = VirtualPortData()
829 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
830 port.subnet_id = subnet.id
831 port.tenant_id = network.tenant_id
832 port.network_id = network.id
833 port.name = "onos"
834
835 networkpostdata = network.DictoJson()
836 subnetpostdata = subnet.DictoJson()
837 portpostdata = port.DictoJson()
838
839 #create update data
840 port.name = "onos-new"
841 newportpostdata = port.DictoJson()
842 #end
843
844 main.step( "Post Network Data via HTTP(Post port need post network)" )
845 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
846 'POST', None, networkpostdata )
847 utilities.assert_equals(
848 expect='200',
849 actual=Poststatus,
850 onpass="Post Network Success",
851 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
852
853 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
854 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
855 'POST', None, subnetpostdata )
856 utilities.assert_equals(
857 expect='202',
858 actual=Poststatus,
859 onpass="Post Subnet Success",
860 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
861
862 main.step( "Post Port Data via HTTP" )
863 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
864 'POST', None, portpostdata )
865 utilities.assert_equals(
866 expect='200',
867 actual=Poststatus,
868 onpass="Post Port Success",
869 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
870
871 main.step( "Update Port Data via HTTP" )
872 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
873 'PUT', None, newportpostdata )
874 utilities.assert_equals(
875 expect='200',
876 actual=Poststatus,
877 onpass="Update Port Success",
878 onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )
879
880 main.step( "Get Port Data via HTTP" )
881 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
882 'GET', None, None )
883 utilities.assert_equals(
884 expect='200',
885 actual=Getstatus,
886 onpass="Get Port Success",
887 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
888
889 main.step( "Compare Update Port Data" )
890 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
891 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
892 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
893 Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )
894
895 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
896 utilities.assert_equals(
897 expect=True,
898 actual=Cmpresult,
899 onpass="Compare Success",
900 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
901 ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
902 ",Network id compare:" + str( NetoworkIDcmpresult ) + \
903 ",Name compare:" + str(Nameresult) )
904
905 main.step( "Clean Data via HTTP" )
906 deletestatus,result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
907 'DELETE', None, None )
908 utilities.assert_equals(
909 expect='200',
910 actual=deletestatus,
911 onpass="Delete Network Success",
912 onfail="Delete Network Failed" )
913
914 if Cmpresult != True:
915 main.log.error( "Update port compare failed" )
916
917 def CASE10( self, main ):
918
919 """
920 Test Delete Port
921 """
922 import os
923
924 try:
925 from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
926 from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
927 from tests.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
928 except ImportError:
929 main.log.exception( "Something wrong with import file or code error." )
930 main.log.info( "Import Error, please check!" )
931 main.cleanup()
932 main.exit()
933
934 main.log.info( "ONOS Port Delete test Start" )
935 main.case( "Virtual Network NBI Test - Port" )
936 main.caseExplanation = "Test Port Delete NBI " +\
937 "Verify port delete success"
938
939 ctrlip = os.getenv( main.params['CTRL']['ip1'] )
940 httpport = main.params['HTTP']['port']
941 path = main.params['HTTP']['path']
942
lanqinglongca0a0ee2015-09-22 16:19:08 +0800943 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800944 network = NetworkData()
945 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
946 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
947 subnet = SubnetData()
948 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
949 subnet.tenant_id = network.tenant_id
950 subnet.network_id = network.id
951 port = VirtualPortData()
952 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
953 port.subnet_id = subnet.id
954 port.tenant_id = network.tenant_id
955 port.network_id = network.id
956
957 networkpostdata = network.DictoJson()
958 subnetpostdata = subnet.DictoJson()
959 portpostdata = port.DictoJson()
960
961 main.step( "Post Network Data via HTTP(Post port need post network)" )
962 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
963 'POST', None, networkpostdata )
964 utilities.assert_equals(
965 expect='200',
966 actual=Poststatus,
967 onpass="Post Network Success",
968 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
969
970 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
971 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
972 'POST', None, subnetpostdata )
973 utilities.assert_equals(
974 expect='202',
975 actual=Poststatus,
976 onpass="Post Subnet Success",
977 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
978
979 main.step( "Post Port Data via HTTP" )
980 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
981 'POST', None, portpostdata )
982 utilities.assert_equals(
983 expect='200',
984 actual=Poststatus,
985 onpass="Post Port Success",
986 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
987
988 main.step( "Delete Port Data via HTTP" )
989 Poststatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
990 'Delete', None, None )
991 utilities.assert_equals(
992 expect='200',
993 actual=Poststatus,
994 onpass="Delete Port Success",
995 onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )
996
997 main.step( "Get Port Data is NULL" )
998 Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
999 'GET', None, None )
1000 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +08001001 expect='VirtualPort is not found',
lanqinglongd0dda2e2015-08-25 11:02:48 +08001002 actual=result,
1003 onpass="Get Port Success",
1004 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
1005
sunyulinf16bb8d2015-09-29 20:21:16 +08001006 if result != 'VirtualPort is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +08001007 main.log.error( "Delete Port failed" )
1008
1009 main.step( "Clean Data via HTTP" )
1010 deletestatus,result = main.ONOSrest.send( ctrlip, httpport, network.id, path + 'networks/',
1011 'DELETE', None, None )
1012 utilities.assert_equals(
1013 expect='200',
1014 actual=deletestatus,
1015 onpass="Delete Network Success",
lanqinglongca0a0ee2015-09-22 16:19:08 +08001016 onfail="Delete Network Failed" )