blob: 78939724a2f35880ad054105181d7d47acc52afb [file] [log] [blame]
lanqinglong77124b02015-08-06 11:47:38 +08001"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002Copyright 2015 Open Networking Foundation (ONF)
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
21
22"""
lanqinglong77124b02015-08-06 11:47:38 +080023Description: This test is to determine if North bound
24 can handle the request
25
26List of test cases:
27CASE1 - Variable initialization and optional pull and build ONOS package
28CASE2 - Create Network northbound test
29CASE3 - Update Network northbound test
30CASE4 - Delete Network northbound test
31CASE5 - Create Subnet northbound test
32CASE6 - Update Subnet northbound test
33CASE7 - Delete Subnet northbound test
34CASE8 - Create Virtualport northbound test
35CASE9 - Update Virtualport northbound test
36CASE10 - Delete Virtualport northbound test
ligenyud4ae1be2015-09-28 20:03:13 +080037CASE11 - Post Error Json Create Network test
38CASE12 - Post Error Json Create Subnet test
39CASE13 - Post Error Json Create Virtualport test
lanqinglong77124b02015-08-06 11:47:38 +080040
41lanqinglong@huawei.com
42"""
43import os
44
Jon Hallf52840a2017-05-24 16:49:52 -070045
lanqinglong77124b02015-08-06 11:47:38 +080046class FUNCvirNetNB:
47
48 def __init__( self ):
49 self.default = ''
50
51 def CASE1( self, main ):
52 """
53 CASE1 is to compile ONOS and push it to the test machines
54
55 Startup sequence:
56 cell<name>
57 onos-verify-cell
58 NOTE:temporary - onos-remove-raft-logs
59 onos-uninstall
60 git pull
61 mvn clean install
62 onos-package
63 onos-install -f
64 onos-wait-for-start
65 start cli sessions
66 start vtnrsc
67 """
lanqinglong77124b02015-08-06 11:47:38 +080068 import time
69 import os
Jon Hallf52840a2017-05-24 16:49:52 -070070 main.log.info( "ONOS Single node Start " +
71 "VirtualNet Northbound test - initialization" )
Devin Lim58046fa2017-07-05 16:55:00 -070072 try:
73 from tests.dependencies.ONOSSetup import ONOSSetup
74 main.testSetUp = ONOSSetup()
75 except ImportError:
76 main.log.error( "ONOSSetup not found. exiting the test" )
77 main.exit()
78 main.testSetUp.envSetupDescription()
79 stepResult = main.FALSE
80 try:
81 main.apps = main.params['ENV']['cellApps']
82 cellName = main.params['ENV']['cellName']
83 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
Devin Lim142b5342017-07-20 15:22:39 -070084 stepResult = main.testSetUp.envSetup()
Devin Lim58046fa2017-07-05 16:55:00 -070085 except Exception as e:
86 main.testSetUp.envSetupException( e )
87 main.testSetUp.evnSetupConclusion( stepResult )
lanqinglong77124b02015-08-06 11:47:38 +080088
Devin Lim58046fa2017-07-05 16:55:00 -070089 main.maxNodes = 1
lanqinglong77124b02015-08-06 11:47:38 +080090
Devin Lim142b5342017-07-20 15:22:39 -070091 cliResults = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster,
92 cellName=cellName, removeLog=True )
Devin Lim58046fa2017-07-05 16:55:00 -070093 if cliResults == main.FALSE:
94 main.log.error( "Failed to start ONOS, stopping test" )
95 main.cleanup()
96 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +080097
98 main.step( "App Ids check" )
Devin Lim142b5342017-07-20 15:22:39 -070099 appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck()
lanqinglong77124b02015-08-06 11:47:38 +0800100 if appCheck != main.TRUE:
Devin Lim142b5342017-07-20 15:22:39 -0700101 main.log.warn( main.Cluster.active( 0 ).CLI.apps() )
102 main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() )
lanqinglong77124b02015-08-06 11:47:38 +0800103 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
Jon Hallf52840a2017-05-24 16:49:52 -0700104 onpass="App Ids seem to be correct",
105 onfail="Something is wrong with app Ids" )
lanqinglong77124b02015-08-06 11:47:38 +0800106
GlennRCa0c395f2015-12-03 14:04:56 -0800107 main.step( "Install org.onosproject.vtn app" )
Devin Lim142b5342017-07-20 15:22:39 -0700108 installResults = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.vtn" )
lanqinglong77124b02015-08-06 11:47:38 +0800109 utilities.assert_equals( expect=main.TRUE, actual=installResults,
Jon Hallf52840a2017-05-24 16:49:52 -0700110 onpass="Install org.onosproject.vtn successful",
111 onfail="Install org.onosproject.vtn app failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800112
113 time.sleep( main.startUpSleep )
114
Jon Hallf52840a2017-05-24 16:49:52 -0700115 def CASE2( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800116 """
117 Test Post Network
118 """
lanqinglonge675e922015-08-13 21:17:28 +0800119 import os
120
lanqinglong77124b02015-08-06 11:47:38 +0800121 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700122 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800123 except ImportError:
124 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800125 main.log.info( "Import Error, please check!" )
126 main.cleanup()
127 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800128
129 main.log.info( "ONOS Network Post test Start" )
130 main.case( "Virtual Network NBI Test - Network" )
131 main.caseExplanation = "Test Network Post NBI " +\
132 "Verify Post Data same with Stored Data"
133
Jon Hallf52840a2017-05-24 16:49:52 -0700134 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
135 port = main.params[ 'HTTP' ][ 'port' ]
136 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800137
lanqinglongca0a0ee2015-09-22 16:19:08 +0800138 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800139 network = NetworkData()
140 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
141 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
142 postdata = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700143 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800144 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700145 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
146 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800147
148 utilities.assert_equals(
149 expect='200',
150 actual=Poststatus,
151 onpass="Post Success",
152 onfail="Post Failed " + str( Poststatus ) + str( result ) )
153
154 main.step( "Get Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700155 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
156 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800157 utilities.assert_equals(
158 expect='200',
159 actual=Getstatus,
160 onpass="Get Success",
161 onfail="Get Failed " + str( Getstatus ) + str( result ) )
162
Jon Hallf52840a2017-05-24 16:49:52 -0700163 main.log.info( "Post Network Data is :%s\nGet Network Data is:%s" % ( postdata, result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800164
165 main.step( "Compare Send Id and Get Id" )
166 IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' )
167 TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' )
168 Cmpresult = IDcmpresult and TanantIDcmpresult
169
170 utilities.assert_equals(
171 expect=True,
172 actual=Cmpresult,
173 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700174 onfail="Compare Failed:ID compare: " + str( IDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800175 ",Tenant id compare :" + str( TanantIDcmpresult ) )
176
Devin Lim142b5342017-07-20 15:22:39 -0700177 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
178 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800179 utilities.assert_equals(
180 expect='200',
181 actual=deletestatus,
182 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700183 onfail="Delete Network Failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800184
Jon Hallf52840a2017-05-24 16:49:52 -0700185 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800186 main.log.error( "Post Network compare failed" )
187
Jon Hallf52840a2017-05-24 16:49:52 -0700188 def CASE3( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800189 """
190 Test Update Network
191 """
lanqinglonge675e922015-08-13 21:17:28 +0800192 import os
193
lanqinglong77124b02015-08-06 11:47:38 +0800194 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700195 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800196 except ImportError:
197 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800198 main.log.info( "Import Error, please check!" )
199 main.cleanup()
200 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800201
202 main.log.info( "ONOS Network Update test Start" )
203 main.case( "Virtual Network NBI Test - Network" )
204 main.caseExplanation = "Test Network Update NBI " +\
205 "Verify Update Data same with Stored Data"
206
Jon Hallf52840a2017-05-24 16:49:52 -0700207 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
208 port = main.params[ 'HTTP' ][ 'port' ]
209 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800210
lanqinglongca0a0ee2015-09-22 16:19:08 +0800211 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800212 network = NetworkData()
213 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
214 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
lanqinglongd0dda2e2015-08-25 11:02:48 +0800215 network.shared = False
lanqinglong77124b02015-08-06 11:47:38 +0800216 postdata = network.DictoJson()
217
lanqinglongd0dda2e2015-08-25 11:02:48 +0800218 network.shared = True
lanqinglong77124b02015-08-06 11:47:38 +0800219 postdatanew = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700220 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800221 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700222 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks',
223 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800224 utilities.assert_equals(
225 expect='200',
226 actual=Poststatus,
227 onpass="Post Success",
228 onfail="Post Failed " + str( Poststatus ) + str( result ) )
229
230 main.step( "Update Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700231 Updatestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
232 'PUT', None, postdatanew )
lanqinglong77124b02015-08-06 11:47:38 +0800233 utilities.assert_equals(
234 expect='200',
235 actual=Updatestatus,
236 onpass="Update Success",
237 onfail="Update Failed " + str( Updatestatus ) + str( result ) )
238
239 main.step( "Get Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700240 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
241 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800242 utilities.assert_equals(
243 expect='200',
244 actual=Getstatus,
245 onpass="Get Success",
246 onfail="Get Failed " + str( Getstatus ) + str( result ) )
247
248 main.step( "Compare Update data." )
249 IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
250 TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
251 Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
252
253 Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
254 utilities.assert_equals(
255 expect=True,
256 actual=Cmpresult,
257 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700258 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
259 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800260 ",Name compare:" + str( Shareresult ) )
261
Devin Lim142b5342017-07-20 15:22:39 -0700262 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
263 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800264
265 utilities.assert_equals(
266 expect='200',
267 actual=deletestatus,
268 onpass="Delete Network Success",
269 onfail="Delete Network Failed" )
270
Jon Hallf52840a2017-05-24 16:49:52 -0700271 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800272 main.log.error( "Update Network compare failed" )
273
Jon Hallf52840a2017-05-24 16:49:52 -0700274 def CASE4( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800275 """
276 Test Delete Network
277 """
lanqinglonge675e922015-08-13 21:17:28 +0800278 import os
279
lanqinglong77124b02015-08-06 11:47:38 +0800280 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700281 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800282 except ImportError:
283 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800284 main.log.info( "Import Error, please check!" )
285 main.cleanup()
286 main.exit()
lanqinglong77124b02015-08-06 11:47:38 +0800287
288 main.log.info( "ONOS Network Delete test Start" )
289 main.case( "Virtual Network NBI Test - Network" )
290 main.caseExplanation = "Test Network Delete NBI " +\
291 "Verify Stored Data is NULL after Delete"
292
Jon Hallf52840a2017-05-24 16:49:52 -0700293 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
294 port = main.params[ 'HTTP' ][ 'port' ]
295 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800296
lanqinglongca0a0ee2015-09-22 16:19:08 +0800297 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800298 network = NetworkData()
299 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
300 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
301 postdata = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700302 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800303 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700304 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
305 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800306 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( "Delete Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700313 Deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
314 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800315 utilities.assert_equals(
316 expect='200',
317 actual=Deletestatus,
318 onpass="Delete Success",
lanqinglongd0dda2e2015-08-25 11:02:48 +0800319 onfail="Delete Failed " + str( Deletestatus ) + str( result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800320
321 main.step( "Get Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700322 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
323 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800324 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800325 expect='Network is not found',
lanqinglong77124b02015-08-06 11:47:38 +0800326 actual=result,
327 onpass="Get Success",
328 onfail="Get Failed " + str( Getstatus ) + str( result ) )
329
sunyulinf16bb8d2015-09-29 20:21:16 +0800330 if result != 'Network is not found':
lanqinglong77124b02015-08-06 11:47:38 +0800331 main.log.error( "Delete Network failed" )
lanqinglonge675e922015-08-13 21:17:28 +0800332
333 def CASE5( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800334 """
335 Test Post Subnet
336 """
337 import os
338
339 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700340 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
341 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800342 except ImportError:
343 main.log.exception( "Something wrong with import file or code error." )
344 main.log.info( "Import Error, please check!" )
345 main.cleanup()
346 main.exit()
347
348 main.log.info( "ONOS Subnet Post test Start" )
349 main.case( "Virtual Network NBI Test - Subnet" )
350 main.caseExplanation = "Test Subnet Post NBI " +\
351 "Verify Stored Data is same with Post Data"
352
Jon Hallf52840a2017-05-24 16:49:52 -0700353 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
354 port = main.params[ 'HTTP' ][ 'port' ]
355 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800356
lanqinglongca0a0ee2015-09-22 16:19:08 +0800357 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800358 network = NetworkData()
359 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
360 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
361 subnet = SubnetData()
362 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
363 subnet.tenant_id = network.tenant_id
364 subnet.network_id = network.id
365
366 networkpostdata = network.DictoJson()
367 subnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700368 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800369 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700370 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
371 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800372 utilities.assert_equals(
373 expect='200',
374 actual=Poststatus,
375 onpass="Post Network Success",
376 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
377
378 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700379 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
380 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800381 utilities.assert_equals(
382 expect='202',
383 actual=Poststatus,
384 onpass="Post Subnet Success",
385 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
386
387 main.step( "Get Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700388 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
389 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800390 utilities.assert_equals(
391 expect='200',
392 actual=Getstatus,
393 onpass="Get Subnet Success",
394 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
395
396 IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
397 TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
398 NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
399
400 main.step( "Compare Post Subnet Data via HTTP" )
401 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
402 utilities.assert_equals(
403 expect=True,
404 actual=Cmpresult,
405 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700406 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
407 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800408 ",Network id compare:" + str( NetoworkIDcmpresult ) )
409
Devin Lim142b5342017-07-20 15:22:39 -0700410 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
411 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800412 utilities.assert_equals(
413 expect='200',
414 actual=deletestatus,
415 onpass="Delete Network Success",
416 onfail="Delete Network Failed" )
417
Jon Hallf52840a2017-05-24 16:49:52 -0700418 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800419 main.log.error( "Post Subnet compare failed" )
420
421 def CASE6( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800422 """
423 Test Post Subnet
424 """
425 import os
426
427 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700428 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
429 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800430 except ImportError:
431 main.log.exception( "Something wrong with import file or code error." )
432 main.log.info( "Import Error, please check!" )
433 main.cleanup()
434 main.exit()
435
436 main.log.info( "ONOS Subnet Update test Start" )
437 main.case( "Virtual Network NBI Test - Subnet" )
438 main.caseExplanation = "Test Subnet Update NBI " +\
439 "Verify Stored Data is same with Update Data"
440
Jon Hallf52840a2017-05-24 16:49:52 -0700441 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
442 port = main.params[ 'HTTP' ][ 'port' ]
443 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800444
lanqinglongca0a0ee2015-09-22 16:19:08 +0800445 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800446 network = NetworkData()
447 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
448 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
449 subnet = SubnetData()
450 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
451 subnet.tenant_id = network.tenant_id
452 subnet.network_id = network.id
453 subnet.start = "192.168.2.1"
454 subnet.end = "192.168.2.255"
455 networkpostdata = network.DictoJson()
456 subnetpostdata = subnet.DictoJson()
457
458 #Change allocation_poolsdata scope
459 subnet.start = "192.168.102.1"
460 subnet.end = "192.168.102.255"
461 #end change
462 newsubnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700463 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800464 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700465 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
466 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800467 utilities.assert_equals(
468 expect='200',
469 actual=Poststatus,
470 onpass="Post Network Success",
471 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
472
473 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700474 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
475 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800476 utilities.assert_equals(
477 expect='202',
478 actual=Poststatus,
479 onpass="Post Subnet Success",
480 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
481
482 main.step( "Update Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700483 Putstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
484 'PUT', None, newsubnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800485 utilities.assert_equals(
486 expect='203',
487 actual=Putstatus,
488 onpass="Update Subnet Success",
489 onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
490
491 main.step( "Get Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700492 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
493 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800494 utilities.assert_equals(
495 expect='200',
496 actual=Getstatus,
497 onpass="Get Subnet Success",
498 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
499
500 IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
501 TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
502 Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
503
504 main.step( "Compare Subnet Data" )
505 Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
506 utilities.assert_equals(
507 expect=True,
508 actual=Cmpresult,
509 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700510 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
511 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800512 ",Pool compare:" + str( Poolcmpresult ) )
513
514 main.step( "Delete Subnet via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700515 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
516 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800517 utilities.assert_equals(
518 expect='200',
519 actual=deletestatus,
520 onpass="Delete Network Success",
521 onfail="Delete Network Failed" )
522
Jon Hallf52840a2017-05-24 16:49:52 -0700523 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800524 main.log.error( "Update Subnet compare failed" )
525
526 def CASE7( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800527 """
528 Test Delete Subnet
529 """
530 import os
531
532 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700533 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
534 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800535 except ImportError:
536 main.log.exception( "Something wrong with import file or code error." )
537 main.log.info( "Import Error, please check!" )
538 main.cleanup()
539 main.exit()
540
541 main.log.info( "ONOS Subnet Delete test Start" )
542 main.case( "Virtual Network NBI Test - Subnet" )
543 main.caseExplanation = "Test Subnet Delete NBI " +\
544 "Verify Stored Data is Null after Delete"
545
Jon Hallf52840a2017-05-24 16:49:52 -0700546 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
547 port = main.params[ 'HTTP' ][ 'port' ]
548 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800549
lanqinglongca0a0ee2015-09-22 16:19:08 +0800550 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800551 network = NetworkData()
552 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
553 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
554 subnet = SubnetData()
555 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
556 subnet.tenant_id = network.tenant_id
557 subnet.network_id = network.id
558
559 networkpostdata = network.DictoJson()
560 subnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700561 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800562 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700563 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
564 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800565 utilities.assert_equals(
566 expect='200',
567 actual=Poststatus,
568 onpass="Post Network Success",
569 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
570
571 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700572 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
573 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800574 utilities.assert_equals(
575 expect='202',
576 actual=Poststatus,
577 onpass="Post Subnet Success",
578 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
579
580 main.step( "Delete Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700581 Deletestatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
582 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800583 utilities.assert_equals(
584 expect='201',
585 actual=Deletestatus,
586 onpass="Delete Subnet Success",
587 onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
588
589 main.step( "Get Subnet Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700590 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
591 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800592 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800593 expect='Subnet is not found',
lanqinglonge675e922015-08-13 21:17:28 +0800594 actual=result,
595 onpass="Get Subnet Success",
596 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
597
sunyulinf16bb8d2015-09-29 20:21:16 +0800598 if result != 'Subnet is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800599 main.log.error( "Delete Subnet failed" )
600
601 def CASE8( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800602 """
603 Test Post Port
604 """
605 import os
606
607 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700608 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
609 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
610 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800611 except ImportError:
612 main.log.exception( "Something wrong with import file or code error." )
613 main.log.info( "Import Error, please check!" )
614 main.cleanup()
615 main.exit()
616
617 main.log.info( "ONOS Port Post test Start" )
618 main.case( "Virtual Network NBI Test - Port" )
619 main.caseExplanation = "Test Port Post NBI " +\
620 "Verify Stored Data is same with Post Data"
621
Jon Hallf52840a2017-05-24 16:49:52 -0700622 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
623 httpport = main.params[ 'HTTP' ][ 'port' ]
624 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800625
lanqinglongca0a0ee2015-09-22 16:19:08 +0800626 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800627 network = NetworkData()
628 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
629 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
630 subnet = SubnetData()
631 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
632 subnet.tenant_id = network.tenant_id
633 subnet.network_id = network.id
634 port = VirtualPortData()
635 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
636 port.subnet_id = subnet.id
637 port.tenant_id = network.tenant_id
638 port.network_id = network.id
639
640 networkpostdata = network.DictoJson()
641 subnetpostdata = subnet.DictoJson()
642 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700643 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800644 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700645 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
646 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800647 utilities.assert_equals(
648 expect='200',
649 actual=Poststatus,
650 onpass="Post Network Success",
651 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
652
653 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700654 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
655 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800656 utilities.assert_equals(
657 expect='202',
658 actual=Poststatus,
659 onpass="Post Subnet Success",
660 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
661
662 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700663 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
664 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800665 utilities.assert_equals(
666 expect='200',
667 actual=Poststatus,
668 onpass="Post Port Success",
669 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
670
671 main.step( "Get Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700672 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
673 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800674 utilities.assert_equals(
675 expect='200',
676 actual=Getstatus,
677 onpass="Get Port Success",
678 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
679
680 main.step( "Compare Post Port Data" )
681 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
682 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
683 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
684 fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
685
686 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
687 utilities.assert_equals(
688 expect=True,
689 actual=Cmpresult,
690 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700691 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
692 ",Tenant id compare:" + str( TanantIDcmpresult ) +
693 ",Network id compare:" + str( NetoworkIDcmpresult ) +
lanqinglongd0dda2e2015-08-25 11:02:48 +0800694 ",FixIp compare:" + str( fixedIpresult ) )
695
696 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700697 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
698 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800699 utilities.assert_equals(
700 expect='200',
701 actual=deletestatus,
702 onpass="Delete Network Success",
703 onfail="Delete Network Failed" )
704
Jon Hallf52840a2017-05-24 16:49:52 -0700705 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800706 main.log.error( "Post port compare failed" )
707
708 def CASE9( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800709 """
710 Test Update Port
711 """
712 import os
713
714 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700715 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
716 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
717 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800718 except ImportError:
719 main.log.exception( "Something wrong with import file or code error." )
720 main.log.info( "Import Error, please check!" )
721 main.cleanup()
722 main.exit()
723
724 main.log.info( "ONOS Port Update test Start" )
725 main.case( "Virtual Network NBI Test - Port" )
726 main.caseExplanation = "Test Port Update NBI " +\
727 "Verify Stored Data is same with New Post Data"
728
Jon Hallf52840a2017-05-24 16:49:52 -0700729 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
730 httpport = main.params[ 'HTTP' ][ 'port' ]
731 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800732
lanqinglongca0a0ee2015-09-22 16:19:08 +0800733 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800734 network = NetworkData()
735 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
736 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
737 subnet = SubnetData()
738 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
739 subnet.tenant_id = network.tenant_id
740 subnet.network_id = network.id
741 port = VirtualPortData()
742 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
743 port.subnet_id = subnet.id
744 port.tenant_id = network.tenant_id
745 port.network_id = network.id
746 port.name = "onos"
747
748 networkpostdata = network.DictoJson()
749 subnetpostdata = subnet.DictoJson()
750 portpostdata = port.DictoJson()
751
752 #create update data
753 port.name = "onos-new"
754 newportpostdata = port.DictoJson()
755 #end
Devin Lim142b5342017-07-20 15:22:39 -0700756 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800757 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700758 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
759 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800760 utilities.assert_equals(
761 expect='200',
762 actual=Poststatus,
763 onpass="Post Network Success",
764 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
765
766 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700767 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
768 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800769 utilities.assert_equals(
770 expect='202',
771 actual=Poststatus,
772 onpass="Post Subnet Success",
773 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
774
775 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700776 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
777 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800778 utilities.assert_equals(
779 expect='200',
780 actual=Poststatus,
781 onpass="Post Port Success",
782 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
783
784 main.step( "Update Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700785 Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
786 'PUT', None, newportpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800787 utilities.assert_equals(
788 expect='200',
789 actual=Poststatus,
790 onpass="Update Port Success",
791 onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )
792
793 main.step( "Get Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700794 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
795 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800796 utilities.assert_equals(
797 expect='200',
798 actual=Getstatus,
799 onpass="Get Port Success",
800 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
801
802 main.step( "Compare Update Port Data" )
803 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
804 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
805 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
806 Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )
807
808 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
809 utilities.assert_equals(
810 expect=True,
811 actual=Cmpresult,
812 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700813 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
814 ",Tenant id compare:" + str( TanantIDcmpresult ) +
815 ",Network id compare:" + str( NetoworkIDcmpresult ) +
816 ",Name compare:" + str( Nameresult ) )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800817
818 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700819 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
820 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800821 utilities.assert_equals(
822 expect='200',
823 actual=deletestatus,
824 onpass="Delete Network Success",
825 onfail="Delete Network Failed" )
826
Jon Hallf52840a2017-05-24 16:49:52 -0700827 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800828 main.log.error( "Update port compare failed" )
829
830 def CASE10( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800831 """
832 Test Delete Port
833 """
834 import os
835
836 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700837 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
838 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
839 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800840 except ImportError:
841 main.log.exception( "Something wrong with import file or code error." )
842 main.log.info( "Import Error, please check!" )
843 main.cleanup()
844 main.exit()
845
846 main.log.info( "ONOS Port Delete test Start" )
847 main.case( "Virtual Network NBI Test - Port" )
848 main.caseExplanation = "Test Port Delete NBI " +\
849 "Verify port delete success"
850
Jon Hallf52840a2017-05-24 16:49:52 -0700851 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
852 httpport = main.params[ 'HTTP' ][ 'port' ]
853 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800854
lanqinglongca0a0ee2015-09-22 16:19:08 +0800855 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800856 network = NetworkData()
857 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
858 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
859 subnet = SubnetData()
860 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
861 subnet.tenant_id = network.tenant_id
862 subnet.network_id = network.id
863 port = VirtualPortData()
864 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
865 port.subnet_id = subnet.id
866 port.tenant_id = network.tenant_id
867 port.network_id = network.id
868
869 networkpostdata = network.DictoJson()
870 subnetpostdata = subnet.DictoJson()
871 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700872 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800873 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700874 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
875 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800876 utilities.assert_equals(
877 expect='200',
878 actual=Poststatus,
879 onpass="Post Network Success",
880 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
881
882 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700883 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
884 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800885 utilities.assert_equals(
886 expect='202',
887 actual=Poststatus,
888 onpass="Post Subnet Success",
889 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
890
891 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700892 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
893 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800894 utilities.assert_equals(
895 expect='200',
896 actual=Poststatus,
897 onpass="Post Port Success",
898 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
899
900 main.step( "Delete Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700901 Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
902 'Delete', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800903 utilities.assert_equals(
904 expect='200',
905 actual=Poststatus,
906 onpass="Delete Port Success",
907 onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )
908
909 main.step( "Get Port Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700910 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
911 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800912 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800913 expect='VirtualPort is not found',
lanqinglongd0dda2e2015-08-25 11:02:48 +0800914 actual=result,
915 onpass="Get Port Success",
916 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
917
sunyulinf16bb8d2015-09-29 20:21:16 +0800918 if result != 'VirtualPort is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800919 main.log.error( "Delete Port failed" )
920
921 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700922 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
923 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800924 utilities.assert_equals(
925 expect='200',
926 actual=deletestatus,
927 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700928 onfail="Delete Network Failed" )
ligenyud4ae1be2015-09-28 20:03:13 +0800929
Jon Hallf52840a2017-05-24 16:49:52 -0700930 def CASE11( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +0800931 """
932 Test Post Error Json Create Network
933 """
934 import os
935
936 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700937 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
ligenyud4ae1be2015-09-28 20:03:13 +0800938 except ImportError:
939 main.log.exception( "Something wrong with import file or code error." )
940 main.log.info( "Import Error, please check!" )
941 main.cleanup()
942 main.exit()
943
944 main.log.info( "ONOS Post Error Json Create Network test Start" )
945 main.case( "Virtual Network NBI Test - Network" )
946 main.caseExplanation = "Test Network Post With Error json " +\
947 "The wrong Json can't post network successfully"
948
Jon Hallf52840a2017-05-24 16:49:52 -0700949 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
950 port = main.params[ 'HTTP' ][ 'port' ]
951 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +0800952
953 main.step( "Generate Post Data" )
954 network = NetworkData()
955 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
956 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
957 #The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
958 network.admin_state_up = 'tttttttttt'
959 #The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
960 network.routerExternal = 'ffffffffffff'
961 #The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
962 network.shared = 'ffffffffffffff'
963 postdata = network.DictoJson()
964
965 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700966 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
967 'POST', None, postdata )
ligenyud4ae1be2015-09-28 20:03:13 +0800968
969 utilities.assert_equals(
970 expect='500',
971 actual=Poststatus,
972 onpass="The Json is wrong,can't post",
973 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +0800974
Jon Hallf52840a2017-05-24 16:49:52 -0700975 def CASE12( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +0800976 """
977 Test Post Error Json Create Subnet
978 """
979 import os
980
981 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700982 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
983 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
ligenyud4ae1be2015-09-28 20:03:13 +0800984 except ImportError:
985 main.log.exception( "Something wrong with import file or code error." )
986 main.log.info( "Import Error, please check!" )
987 main.cleanup()
988 main.exit()
989
990 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
991 main.case( "Virtual Network NBI Test - Subnet" )
992 main.caseExplanation = "Test Subnet Post With Error json " +\
993 "The wrong Json can't post network successfully"
994
Jon Hallf52840a2017-05-24 16:49:52 -0700995 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
996 port = main.params[ 'HTTP' ][ 'port' ]
997 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +0800998
999 main.step( "Generate Post Data" )
1000 network = NetworkData()
1001 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1002 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1003 subnet = SubnetData()
1004 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1005 #The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
1006 subnet.enable_dhcp = 'tttttttttttttt'
1007 #The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
1008 subnet.shared = 'ffffffffffffff'
1009 subnet.tenant_id = network.tenant_id
1010 subnet.network_id = network.id
1011
1012 networkpostdata = network.DictoJson()
1013 subnetpostdata = subnet.DictoJson()
1014
1015 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -07001016 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
1017 'POST', None, networkpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001018 utilities.assert_equals(
1019 expect='200',
1020 actual=Poststatus,
1021 onpass="Post Network Success",
1022 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1023
1024 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -07001025 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'subnets/',
1026 'POST', None, subnetpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001027 utilities.assert_equals(
1028 expect='500',
1029 actual=Poststatus,
1030 onpass="The Json is wrong,can't post",
1031 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +08001032
Jon Hallf52840a2017-05-24 16:49:52 -07001033 def CASE13( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +08001034 """
1035 Test Post Error Json Create Virtualport
1036 """
1037 import os
1038
1039 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001040 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1041 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
1042 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
ligenyud4ae1be2015-09-28 20:03:13 +08001043 except ImportError:
1044 main.log.exception( "Something wrong with import file or code error." )
1045 main.log.info( "Import Error, please check!" )
1046 main.cleanup()
1047 main.exit()
1048
1049 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1050 main.case( "Virtual Network NBI Test - Port" )
1051 main.caseExplanation = "Test Subnet Post With Error json " +\
1052 "The wrong Json can't create port successfully"
1053
Jon Hallf52840a2017-05-24 16:49:52 -07001054 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1055 httpport = main.params[ 'HTTP' ][ 'port' ]
1056 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001057
1058 main.step( "Generate Post Data" )
1059 network = NetworkData()
1060 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1061 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1062 subnet = SubnetData()
1063 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1064 subnet.tenant_id = network.tenant_id
1065 subnet.network_id = network.id
1066 port = VirtualPortData()
1067 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
1068 port.subnet_id = subnet.id
1069 port.tenant_id = network.tenant_id
1070 port.network_id = network.id
1071 #The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
1072 port.adminStateUp = 'tttttttttttt'
1073
1074 networkpostdata = network.DictoJson()
1075 subnetpostdata = subnet.DictoJson()
1076 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -07001077 ctrl = main.Cluster.active( 0 )
ligenyud4ae1be2015-09-28 20:03:13 +08001078 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -07001079 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
1080 'POST', None, networkpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001081 utilities.assert_equals(
1082 expect='200',
1083 actual=Poststatus,
1084 onpass="Post Network Success",
1085 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1086
1087 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -07001088 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
1089 'POST', None, subnetpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001090 utilities.assert_equals(
1091 expect='202',
1092 actual=Poststatus,
1093 onpass="Post Subnet Success",
1094 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
1095
1096 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -07001097 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
1098 'POST', None, portpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001099 utilities.assert_equals(
1100 expect='500',
1101 actual=Poststatus,
1102 onpass="The Json is wrong,can't post",
Jon Hallce9c01e2015-10-22 16:39:02 +00001103 onfail="Wrong Json can post successfully" )