blob: dd46f797e1a8bd344f55c6ac3fbe87ad546cff25 [file] [log] [blame]
lanqinglong77124b02015-08-06 11:47:38 +08001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
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/>.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070020
lanqinglong77124b02015-08-06 11:47:38 +080021Description: This test is to determine if North bound
22 can handle the request
23
24List of test cases:
25CASE1 - Variable initialization and optional pull and build ONOS package
26CASE2 - Create Network northbound test
27CASE3 - Update Network northbound test
28CASE4 - Delete Network northbound test
29CASE5 - Create Subnet northbound test
30CASE6 - Update Subnet northbound test
31CASE7 - Delete Subnet northbound test
32CASE8 - Create Virtualport northbound test
33CASE9 - Update Virtualport northbound test
34CASE10 - Delete Virtualport northbound test
ligenyud4ae1be2015-09-28 20:03:13 +080035CASE11 - Post Error Json Create Network test
36CASE12 - Post Error Json Create Subnet test
37CASE13 - Post Error Json Create Virtualport test
lanqinglong77124b02015-08-06 11:47:38 +080038
39lanqinglong@huawei.com
40"""
41import os
42
Jon Hallf52840a2017-05-24 16:49:52 -070043
lanqinglong77124b02015-08-06 11:47:38 +080044class FUNCvirNetNB:
45
46 def __init__( self ):
47 self.default = ''
48
49 def CASE1( self, main ):
50 """
51 CASE1 is to compile ONOS and push it to the test machines
52
53 Startup sequence:
54 cell<name>
55 onos-verify-cell
56 NOTE:temporary - onos-remove-raft-logs
57 onos-uninstall
58 git pull
59 mvn clean install
60 onos-package
61 onos-install -f
62 onos-wait-for-start
63 start cli sessions
64 start vtnrsc
65 """
lanqinglong77124b02015-08-06 11:47:38 +080066 import time
67 import os
Jon Hallf52840a2017-05-24 16:49:52 -070068 main.log.info( "ONOS Single node Start " +
69 "VirtualNet Northbound test - initialization" )
Devin Lim58046fa2017-07-05 16:55:00 -070070 try:
71 from tests.dependencies.ONOSSetup import ONOSSetup
72 main.testSetUp = ONOSSetup()
73 except ImportError:
74 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070075 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070076 main.testSetUp.envSetupDescription()
77 stepResult = main.FALSE
78 try:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070079 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
80 cellName = main.params[ 'ENV' ][ 'cellName' ]
Devin Lim58046fa2017-07-05 16:55:00 -070081 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
Devin Lim142b5342017-07-20 15:22:39 -070082 stepResult = main.testSetUp.envSetup()
Devin Lim58046fa2017-07-05 16:55:00 -070083 except Exception as e:
84 main.testSetUp.envSetupException( e )
Jon Hallaa1d9b82020-07-30 13:49:42 -070085 main.testSetUp.envSetupConclusion( stepResult )
lanqinglong77124b02015-08-06 11:47:38 +080086
Devin Lim58046fa2017-07-05 16:55:00 -070087 main.maxNodes = 1
lanqinglong77124b02015-08-06 11:47:38 +080088
You Wanga0f6ff62018-01-11 15:46:30 -080089 cliResults = main.testSetUp.ONOSSetUp( main.Cluster,
Jon Hall3e6edb32018-08-21 16:20:30 -070090 cellName=cellName )
Devin Lim58046fa2017-07-05 16:55:00 -070091 if cliResults == main.FALSE:
92 main.log.error( "Failed to start ONOS, stopping test" )
Devin Lim44075962017-08-11 10:56:37 -070093 main.cleanAndExit()
lanqinglong77124b02015-08-06 11:47:38 +080094
95 main.step( "App Ids check" )
Devin Lim142b5342017-07-20 15:22:39 -070096 appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck()
lanqinglong77124b02015-08-06 11:47:38 +080097 if appCheck != main.TRUE:
Devin Lim142b5342017-07-20 15:22:39 -070098 main.log.warn( main.Cluster.active( 0 ).CLI.apps() )
99 main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() )
lanqinglong77124b02015-08-06 11:47:38 +0800100 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
Jon Hallf52840a2017-05-24 16:49:52 -0700101 onpass="App Ids seem to be correct",
102 onfail="Something is wrong with app Ids" )
lanqinglong77124b02015-08-06 11:47:38 +0800103
GlennRCa0c395f2015-12-03 14:04:56 -0800104 main.step( "Install org.onosproject.vtn app" )
Devin Lim142b5342017-07-20 15:22:39 -0700105 installResults = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.vtn" )
lanqinglong77124b02015-08-06 11:47:38 +0800106 utilities.assert_equals( expect=main.TRUE, actual=installResults,
Jon Hallf52840a2017-05-24 16:49:52 -0700107 onpass="Install org.onosproject.vtn successful",
108 onfail="Install org.onosproject.vtn app failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800109
110 time.sleep( main.startUpSleep )
111
Jon Hallf52840a2017-05-24 16:49:52 -0700112 def CASE2( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800113 """
114 Test Post Network
115 """
lanqinglonge675e922015-08-13 21:17:28 +0800116 import os
117
lanqinglong77124b02015-08-06 11:47:38 +0800118 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700119 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800120 except ImportError:
121 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800122 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700123 main.cleanAndExit()
lanqinglong77124b02015-08-06 11:47:38 +0800124
125 main.log.info( "ONOS Network Post test Start" )
126 main.case( "Virtual Network NBI Test - Network" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700127 main.caseExplanation = "Test Network Post NBI Verify Post Data same with Stored Data"
lanqinglong77124b02015-08-06 11:47:38 +0800128
Jon Hallf52840a2017-05-24 16:49:52 -0700129 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
130 port = main.params[ 'HTTP' ][ 'port' ]
131 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800132
lanqinglongca0a0ee2015-09-22 16:19:08 +0800133 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800134 network = NetworkData()
135 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
136 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
137 postdata = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700138 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800139 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700140 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
141 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800142
143 utilities.assert_equals(
144 expect='200',
145 actual=Poststatus,
146 onpass="Post Success",
147 onfail="Post Failed " + str( Poststatus ) + str( result ) )
148
You Wang7880b372019-02-27 16:50:47 -0800149 if not Poststatus:
150 main.cleanAndExit( alarm=False )
151
lanqinglong77124b02015-08-06 11:47:38 +0800152 main.step( "Get Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700153 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
154 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800155 utilities.assert_equals(
156 expect='200',
157 actual=Getstatus,
158 onpass="Get Success",
159 onfail="Get Failed " + str( Getstatus ) + str( result ) )
160
Jon Hallf52840a2017-05-24 16:49:52 -0700161 main.log.info( "Post Network Data is :%s\nGet Network Data is:%s" % ( postdata, result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800162
163 main.step( "Compare Send Id and Get Id" )
164 IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' )
165 TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' )
166 Cmpresult = IDcmpresult and TanantIDcmpresult
167
168 utilities.assert_equals(
169 expect=True,
170 actual=Cmpresult,
171 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700172 onfail="Compare Failed:ID compare: " + str( IDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800173 ",Tenant id compare :" + str( TanantIDcmpresult ) )
174
Devin Lim142b5342017-07-20 15:22:39 -0700175 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
176 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800177 utilities.assert_equals(
178 expect='200',
179 actual=deletestatus,
180 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700181 onfail="Delete Network Failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800182
Jon Hallf52840a2017-05-24 16:49:52 -0700183 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800184 main.log.error( "Post Network compare failed" )
185
Jon Hallf52840a2017-05-24 16:49:52 -0700186 def CASE3( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800187 """
188 Test Update Network
189 """
lanqinglonge675e922015-08-13 21:17:28 +0800190 import os
191
lanqinglong77124b02015-08-06 11:47:38 +0800192 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700193 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800194 except ImportError:
195 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800196 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700197 main.cleanAndExit()
lanqinglong77124b02015-08-06 11:47:38 +0800198
199 main.log.info( "ONOS Network Update test Start" )
200 main.case( "Virtual Network NBI Test - Network" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700201 main.caseExplanation = "Test Network Update NBI Verify Update Data same with Stored Data"
lanqinglong77124b02015-08-06 11:47:38 +0800202
Jon Hallf52840a2017-05-24 16:49:52 -0700203 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
204 port = main.params[ 'HTTP' ][ 'port' ]
205 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800206
lanqinglongca0a0ee2015-09-22 16:19:08 +0800207 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800208 network = NetworkData()
209 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
210 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
lanqinglongd0dda2e2015-08-25 11:02:48 +0800211 network.shared = False
lanqinglong77124b02015-08-06 11:47:38 +0800212 postdata = network.DictoJson()
213
lanqinglongd0dda2e2015-08-25 11:02:48 +0800214 network.shared = True
lanqinglong77124b02015-08-06 11:47:38 +0800215 postdatanew = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700216 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800217 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700218 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks',
219 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800220 utilities.assert_equals(
221 expect='200',
222 actual=Poststatus,
223 onpass="Post Success",
224 onfail="Post Failed " + str( Poststatus ) + str( result ) )
225
226 main.step( "Update Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700227 Updatestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
228 'PUT', None, postdatanew )
lanqinglong77124b02015-08-06 11:47:38 +0800229 utilities.assert_equals(
230 expect='200',
231 actual=Updatestatus,
232 onpass="Update Success",
233 onfail="Update Failed " + str( Updatestatus ) + str( result ) )
234
235 main.step( "Get Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700236 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
237 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800238 utilities.assert_equals(
239 expect='200',
240 actual=Getstatus,
241 onpass="Get Success",
242 onfail="Get Failed " + str( Getstatus ) + str( result ) )
243
244 main.step( "Compare Update data." )
245 IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
246 TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
247 Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
248
249 Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
250 utilities.assert_equals(
251 expect=True,
252 actual=Cmpresult,
253 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700254 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
255 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800256 ",Name compare:" + str( Shareresult ) )
257
Devin Lim142b5342017-07-20 15:22:39 -0700258 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
259 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800260
261 utilities.assert_equals(
262 expect='200',
263 actual=deletestatus,
264 onpass="Delete Network Success",
265 onfail="Delete Network Failed" )
266
Jon Hallf52840a2017-05-24 16:49:52 -0700267 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800268 main.log.error( "Update Network compare failed" )
269
Jon Hallf52840a2017-05-24 16:49:52 -0700270 def CASE4( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800271 """
272 Test Delete Network
273 """
lanqinglonge675e922015-08-13 21:17:28 +0800274 import os
275
lanqinglong77124b02015-08-06 11:47:38 +0800276 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700277 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800278 except ImportError:
279 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800280 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700281 main.cleanAndExit()
lanqinglong77124b02015-08-06 11:47:38 +0800282
283 main.log.info( "ONOS Network Delete test Start" )
284 main.case( "Virtual Network NBI Test - Network" )
285 main.caseExplanation = "Test Network Delete NBI " +\
286 "Verify Stored Data is NULL after Delete"
287
Jon Hallf52840a2017-05-24 16:49:52 -0700288 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
289 port = main.params[ 'HTTP' ][ 'port' ]
290 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800291
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'
296 postdata = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700297 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800298 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700299 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
300 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800301 utilities.assert_equals(
302 expect='200',
303 actual=Poststatus,
304 onpass="Post Success",
305 onfail="Post Failed " + str( Poststatus ) + str( result ) )
306
307 main.step( "Delete Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700308 Deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
309 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800310 utilities.assert_equals(
311 expect='200',
312 actual=Deletestatus,
313 onpass="Delete Success",
lanqinglongd0dda2e2015-08-25 11:02:48 +0800314 onfail="Delete Failed " + str( Deletestatus ) + str( result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800315
316 main.step( "Get Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700317 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
318 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800319 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800320 expect='Network is not found',
lanqinglong77124b02015-08-06 11:47:38 +0800321 actual=result,
322 onpass="Get Success",
323 onfail="Get Failed " + str( Getstatus ) + str( result ) )
324
sunyulinf16bb8d2015-09-29 20:21:16 +0800325 if result != 'Network is not found':
lanqinglong77124b02015-08-06 11:47:38 +0800326 main.log.error( "Delete Network failed" )
lanqinglonge675e922015-08-13 21:17:28 +0800327
328 def CASE5( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800329 """
330 Test Post Subnet
331 """
332 import os
333
334 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700335 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
336 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800337 except ImportError:
338 main.log.exception( "Something wrong with import file or code error." )
339 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700340 main.cleanAndExit()
lanqinglonge675e922015-08-13 21:17:28 +0800341
342 main.log.info( "ONOS Subnet Post test Start" )
343 main.case( "Virtual Network NBI Test - Subnet" )
344 main.caseExplanation = "Test Subnet Post NBI " +\
345 "Verify Stored Data is same with Post Data"
346
Jon Hallf52840a2017-05-24 16:49:52 -0700347 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
348 port = main.params[ 'HTTP' ][ 'port' ]
349 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800350
lanqinglongca0a0ee2015-09-22 16:19:08 +0800351 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800352 network = NetworkData()
353 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
354 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
355 subnet = SubnetData()
356 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
357 subnet.tenant_id = network.tenant_id
358 subnet.network_id = network.id
359
360 networkpostdata = network.DictoJson()
361 subnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700362 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800363 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700364 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
365 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800366 utilities.assert_equals(
367 expect='200',
368 actual=Poststatus,
369 onpass="Post Network Success",
370 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
371
372 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700373 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
374 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800375 utilities.assert_equals(
376 expect='202',
377 actual=Poststatus,
378 onpass="Post Subnet Success",
379 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
380
381 main.step( "Get Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700382 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
383 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800384 utilities.assert_equals(
385 expect='200',
386 actual=Getstatus,
387 onpass="Get Subnet Success",
388 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
389
390 IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
391 TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
392 NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
393
394 main.step( "Compare Post Subnet Data via HTTP" )
395 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
396 utilities.assert_equals(
397 expect=True,
398 actual=Cmpresult,
399 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700400 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
401 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800402 ",Network id compare:" + str( NetoworkIDcmpresult ) )
403
Devin Lim142b5342017-07-20 15:22:39 -0700404 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
405 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800406 utilities.assert_equals(
407 expect='200',
408 actual=deletestatus,
409 onpass="Delete Network Success",
410 onfail="Delete Network Failed" )
411
Jon Hallf52840a2017-05-24 16:49:52 -0700412 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800413 main.log.error( "Post Subnet compare failed" )
414
415 def CASE6( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800416 """
417 Test Post Subnet
418 """
419 import os
420
421 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700422 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
423 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800424 except ImportError:
425 main.log.exception( "Something wrong with import file or code error." )
426 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700427 main.cleanAndExit()
lanqinglonge675e922015-08-13 21:17:28 +0800428
429 main.log.info( "ONOS Subnet Update test Start" )
430 main.case( "Virtual Network NBI Test - Subnet" )
431 main.caseExplanation = "Test Subnet Update NBI " +\
432 "Verify Stored Data is same with Update Data"
433
Jon Hallf52840a2017-05-24 16:49:52 -0700434 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
435 port = main.params[ 'HTTP' ][ 'port' ]
436 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800437
lanqinglongca0a0ee2015-09-22 16:19:08 +0800438 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800439 network = NetworkData()
440 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
441 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
442 subnet = SubnetData()
443 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
444 subnet.tenant_id = network.tenant_id
445 subnet.network_id = network.id
446 subnet.start = "192.168.2.1"
447 subnet.end = "192.168.2.255"
448 networkpostdata = network.DictoJson()
449 subnetpostdata = subnet.DictoJson()
450
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700451 # Change allocation_poolsdata scope
lanqinglonge675e922015-08-13 21:17:28 +0800452 subnet.start = "192.168.102.1"
453 subnet.end = "192.168.102.255"
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700454 # end change
lanqinglonge675e922015-08-13 21:17:28 +0800455 newsubnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700456 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800457 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700458 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
459 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800460 utilities.assert_equals(
461 expect='200',
462 actual=Poststatus,
463 onpass="Post Network Success",
464 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
465
466 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700467 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
468 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800469 utilities.assert_equals(
470 expect='202',
471 actual=Poststatus,
472 onpass="Post Subnet Success",
473 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
474
475 main.step( "Update Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700476 Putstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
477 'PUT', None, newsubnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800478 utilities.assert_equals(
479 expect='203',
480 actual=Putstatus,
481 onpass="Update Subnet Success",
482 onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
483
484 main.step( "Get Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700485 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
486 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800487 utilities.assert_equals(
488 expect='200',
489 actual=Getstatus,
490 onpass="Get Subnet Success",
491 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
492
493 IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
494 TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
495 Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
496
497 main.step( "Compare Subnet Data" )
498 Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
499 utilities.assert_equals(
500 expect=True,
501 actual=Cmpresult,
502 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700503 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
504 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800505 ",Pool compare:" + str( Poolcmpresult ) )
506
507 main.step( "Delete Subnet via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700508 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
509 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800510 utilities.assert_equals(
511 expect='200',
512 actual=deletestatus,
513 onpass="Delete Network Success",
514 onfail="Delete Network Failed" )
515
Jon Hallf52840a2017-05-24 16:49:52 -0700516 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800517 main.log.error( "Update Subnet compare failed" )
518
519 def CASE7( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800520 """
521 Test Delete Subnet
522 """
523 import os
524
525 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700526 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
527 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800528 except ImportError:
529 main.log.exception( "Something wrong with import file or code error." )
530 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700531 main.cleanAndExit()
lanqinglonge675e922015-08-13 21:17:28 +0800532
533 main.log.info( "ONOS Subnet Delete test Start" )
534 main.case( "Virtual Network NBI Test - Subnet" )
535 main.caseExplanation = "Test Subnet Delete NBI " +\
536 "Verify Stored Data is Null after Delete"
537
Jon Hallf52840a2017-05-24 16:49:52 -0700538 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
539 port = main.params[ 'HTTP' ][ 'port' ]
540 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800541
lanqinglongca0a0ee2015-09-22 16:19:08 +0800542 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800543 network = NetworkData()
544 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
545 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
546 subnet = SubnetData()
547 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
548 subnet.tenant_id = network.tenant_id
549 subnet.network_id = network.id
550
551 networkpostdata = network.DictoJson()
552 subnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700553 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800554 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700555 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
556 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800557 utilities.assert_equals(
558 expect='200',
559 actual=Poststatus,
560 onpass="Post Network Success",
561 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
562
563 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700564 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
565 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800566 utilities.assert_equals(
567 expect='202',
568 actual=Poststatus,
569 onpass="Post Subnet Success",
570 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
571
572 main.step( "Delete Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700573 Deletestatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
574 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800575 utilities.assert_equals(
576 expect='201',
577 actual=Deletestatus,
578 onpass="Delete Subnet Success",
579 onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
580
581 main.step( "Get Subnet Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700582 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
583 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800584 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800585 expect='Subnet is not found',
lanqinglonge675e922015-08-13 21:17:28 +0800586 actual=result,
587 onpass="Get Subnet Success",
588 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
589
sunyulinf16bb8d2015-09-29 20:21:16 +0800590 if result != 'Subnet is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800591 main.log.error( "Delete Subnet failed" )
592
593 def CASE8( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800594 """
595 Test Post Port
596 """
597 import os
598
599 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700600 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
601 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
602 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800603 except ImportError:
604 main.log.exception( "Something wrong with import file or code error." )
605 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700606 main.cleanAndExit()
lanqinglongd0dda2e2015-08-25 11:02:48 +0800607
608 main.log.info( "ONOS Port Post test Start" )
609 main.case( "Virtual Network NBI Test - Port" )
610 main.caseExplanation = "Test Port Post NBI " +\
611 "Verify Stored Data is same with Post Data"
612
Jon Hallf52840a2017-05-24 16:49:52 -0700613 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
614 httpport = main.params[ 'HTTP' ][ 'port' ]
615 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800616
lanqinglongca0a0ee2015-09-22 16:19:08 +0800617 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800618 network = NetworkData()
619 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
620 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
621 subnet = SubnetData()
622 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
623 subnet.tenant_id = network.tenant_id
624 subnet.network_id = network.id
625 port = VirtualPortData()
626 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
627 port.subnet_id = subnet.id
628 port.tenant_id = network.tenant_id
629 port.network_id = network.id
630
631 networkpostdata = network.DictoJson()
632 subnetpostdata = subnet.DictoJson()
633 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700634 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800635 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700636 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
637 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800638 utilities.assert_equals(
639 expect='200',
640 actual=Poststatus,
641 onpass="Post Network Success",
642 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
643
644 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700645 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
646 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800647 utilities.assert_equals(
648 expect='202',
649 actual=Poststatus,
650 onpass="Post Subnet Success",
651 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
652
653 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700654 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
655 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800656 utilities.assert_equals(
657 expect='200',
658 actual=Poststatus,
659 onpass="Post Port Success",
660 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
661
662 main.step( "Get Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700663 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
664 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800665 utilities.assert_equals(
666 expect='200',
667 actual=Getstatus,
668 onpass="Get Port Success",
669 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
670
671 main.step( "Compare Post Port Data" )
672 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
673 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
674 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
675 fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
676
677 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
678 utilities.assert_equals(
679 expect=True,
680 actual=Cmpresult,
681 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700682 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
683 ",Tenant id compare:" + str( TanantIDcmpresult ) +
684 ",Network id compare:" + str( NetoworkIDcmpresult ) +
lanqinglongd0dda2e2015-08-25 11:02:48 +0800685 ",FixIp compare:" + str( fixedIpresult ) )
686
687 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700688 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
689 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800690 utilities.assert_equals(
691 expect='200',
692 actual=deletestatus,
693 onpass="Delete Network Success",
694 onfail="Delete Network Failed" )
695
Jon Hallf52840a2017-05-24 16:49:52 -0700696 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800697 main.log.error( "Post port compare failed" )
698
699 def CASE9( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800700 """
701 Test Update Port
702 """
703 import os
704
705 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700706 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
707 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
708 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800709 except ImportError:
710 main.log.exception( "Something wrong with import file or code error." )
711 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700712 main.cleanAndExit()
lanqinglongd0dda2e2015-08-25 11:02:48 +0800713
714 main.log.info( "ONOS Port Update test Start" )
715 main.case( "Virtual Network NBI Test - Port" )
716 main.caseExplanation = "Test Port Update NBI " +\
717 "Verify Stored Data is same with New Post Data"
718
Jon Hallf52840a2017-05-24 16:49:52 -0700719 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
720 httpport = main.params[ 'HTTP' ][ 'port' ]
721 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800722
lanqinglongca0a0ee2015-09-22 16:19:08 +0800723 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800724 network = NetworkData()
725 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
726 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
727 subnet = SubnetData()
728 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
729 subnet.tenant_id = network.tenant_id
730 subnet.network_id = network.id
731 port = VirtualPortData()
732 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
733 port.subnet_id = subnet.id
734 port.tenant_id = network.tenant_id
735 port.network_id = network.id
736 port.name = "onos"
737
738 networkpostdata = network.DictoJson()
739 subnetpostdata = subnet.DictoJson()
740 portpostdata = port.DictoJson()
741
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700742 # create update data
lanqinglongd0dda2e2015-08-25 11:02:48 +0800743 port.name = "onos-new"
744 newportpostdata = port.DictoJson()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700745 # end
Devin Lim142b5342017-07-20 15:22:39 -0700746 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800747 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700748 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
749 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800750 utilities.assert_equals(
751 expect='200',
752 actual=Poststatus,
753 onpass="Post Network Success",
754 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
755
756 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700757 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
758 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800759 utilities.assert_equals(
760 expect='202',
761 actual=Poststatus,
762 onpass="Post Subnet Success",
763 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
764
765 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700766 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
767 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800768 utilities.assert_equals(
769 expect='200',
770 actual=Poststatus,
771 onpass="Post Port Success",
772 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
773
774 main.step( "Update Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700775 Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
776 'PUT', None, newportpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800777 utilities.assert_equals(
778 expect='200',
779 actual=Poststatus,
780 onpass="Update Port Success",
781 onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )
782
783 main.step( "Get Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700784 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
785 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800786 utilities.assert_equals(
787 expect='200',
788 actual=Getstatus,
789 onpass="Get Port Success",
790 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
791
792 main.step( "Compare Update Port Data" )
793 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
794 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
795 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
796 Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )
797
798 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
799 utilities.assert_equals(
800 expect=True,
801 actual=Cmpresult,
802 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700803 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
804 ",Tenant id compare:" + str( TanantIDcmpresult ) +
805 ",Network id compare:" + str( NetoworkIDcmpresult ) +
806 ",Name compare:" + str( Nameresult ) )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800807
808 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700809 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
810 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800811 utilities.assert_equals(
812 expect='200',
813 actual=deletestatus,
814 onpass="Delete Network Success",
815 onfail="Delete Network Failed" )
816
Jon Hallf52840a2017-05-24 16:49:52 -0700817 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800818 main.log.error( "Update port compare failed" )
819
820 def CASE10( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800821 """
822 Test Delete Port
823 """
824 import os
825
826 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700827 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
828 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
829 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800830 except ImportError:
831 main.log.exception( "Something wrong with import file or code error." )
832 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700833 main.cleanAndExit()
lanqinglongd0dda2e2015-08-25 11:02:48 +0800834
835 main.log.info( "ONOS Port Delete test Start" )
836 main.case( "Virtual Network NBI Test - Port" )
837 main.caseExplanation = "Test Port Delete NBI " +\
838 "Verify port delete success"
839
Jon Hallf52840a2017-05-24 16:49:52 -0700840 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
841 httpport = main.params[ 'HTTP' ][ 'port' ]
842 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800843
lanqinglongca0a0ee2015-09-22 16:19:08 +0800844 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800845 network = NetworkData()
846 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
847 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
848 subnet = SubnetData()
849 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
850 subnet.tenant_id = network.tenant_id
851 subnet.network_id = network.id
852 port = VirtualPortData()
853 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
854 port.subnet_id = subnet.id
855 port.tenant_id = network.tenant_id
856 port.network_id = network.id
857
858 networkpostdata = network.DictoJson()
859 subnetpostdata = subnet.DictoJson()
860 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700861 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800862 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700863 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
864 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800865 utilities.assert_equals(
866 expect='200',
867 actual=Poststatus,
868 onpass="Post Network Success",
869 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
870
871 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700872 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
873 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800874 utilities.assert_equals(
875 expect='202',
876 actual=Poststatus,
877 onpass="Post Subnet Success",
878 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
879
880 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700881 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
882 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800883 utilities.assert_equals(
884 expect='200',
885 actual=Poststatus,
886 onpass="Post Port Success",
887 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
888
889 main.step( "Delete Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700890 Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
891 'Delete', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800892 utilities.assert_equals(
893 expect='200',
894 actual=Poststatus,
895 onpass="Delete Port Success",
896 onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )
897
898 main.step( "Get Port Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700899 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
900 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800901 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800902 expect='VirtualPort is not found',
lanqinglongd0dda2e2015-08-25 11:02:48 +0800903 actual=result,
904 onpass="Get Port Success",
905 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
906
sunyulinf16bb8d2015-09-29 20:21:16 +0800907 if result != 'VirtualPort is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800908 main.log.error( "Delete Port failed" )
909
910 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700911 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
912 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800913 utilities.assert_equals(
914 expect='200',
915 actual=deletestatus,
916 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700917 onfail="Delete Network Failed" )
ligenyud4ae1be2015-09-28 20:03:13 +0800918
Jon Hallf52840a2017-05-24 16:49:52 -0700919 def CASE11( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +0800920 """
921 Test Post Error Json Create Network
922 """
923 import os
924
925 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700926 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
ligenyud4ae1be2015-09-28 20:03:13 +0800927 except ImportError:
928 main.log.exception( "Something wrong with import file or code error." )
929 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700930 main.cleanAndExit()
ligenyud4ae1be2015-09-28 20:03:13 +0800931
932 main.log.info( "ONOS Post Error Json Create Network test Start" )
933 main.case( "Virtual Network NBI Test - Network" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700934 main.caseExplanation = "Test Network Post With Error json The wrong Json can't post network successfully"
ligenyud4ae1be2015-09-28 20:03:13 +0800935
Jon Hallf52840a2017-05-24 16:49:52 -0700936 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
937 port = main.params[ 'HTTP' ][ 'port' ]
938 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +0800939
940 main.step( "Generate Post Data" )
941 network = NetworkData()
942 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
943 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700944 # The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
ligenyud4ae1be2015-09-28 20:03:13 +0800945 network.admin_state_up = 'tttttttttt'
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700946 # The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
ligenyud4ae1be2015-09-28 20:03:13 +0800947 network.routerExternal = 'ffffffffffff'
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700948 # The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
ligenyud4ae1be2015-09-28 20:03:13 +0800949 network.shared = 'ffffffffffffff'
950 postdata = network.DictoJson()
951
952 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700953 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
954 'POST', None, postdata )
ligenyud4ae1be2015-09-28 20:03:13 +0800955
956 utilities.assert_equals(
957 expect='500',
958 actual=Poststatus,
959 onpass="The Json is wrong,can't post",
960 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +0800961
Jon Hallf52840a2017-05-24 16:49:52 -0700962 def CASE12( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +0800963 """
964 Test Post Error Json Create Subnet
965 """
966 import os
967
968 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700969 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
970 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
ligenyud4ae1be2015-09-28 20:03:13 +0800971 except ImportError:
972 main.log.exception( "Something wrong with import file or code error." )
973 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700974 main.cleanAndExit()
ligenyud4ae1be2015-09-28 20:03:13 +0800975
976 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
977 main.case( "Virtual Network NBI Test - Subnet" )
978 main.caseExplanation = "Test Subnet Post With Error json " +\
979 "The wrong Json can't post network successfully"
980
Jon Hallf52840a2017-05-24 16:49:52 -0700981 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
982 port = main.params[ 'HTTP' ][ 'port' ]
983 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +0800984
985 main.step( "Generate Post Data" )
986 network = NetworkData()
987 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
988 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
989 subnet = SubnetData()
990 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700991 # The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
ligenyud4ae1be2015-09-28 20:03:13 +0800992 subnet.enable_dhcp = 'tttttttttttttt'
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700993 # The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
ligenyud4ae1be2015-09-28 20:03:13 +0800994 subnet.shared = 'ffffffffffffff'
995 subnet.tenant_id = network.tenant_id
996 subnet.network_id = network.id
997
998 networkpostdata = network.DictoJson()
999 subnetpostdata = subnet.DictoJson()
1000
1001 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -07001002 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
1003 'POST', None, networkpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001004 utilities.assert_equals(
1005 expect='200',
1006 actual=Poststatus,
1007 onpass="Post Network Success",
1008 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1009
1010 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -07001011 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'subnets/',
1012 'POST', None, subnetpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001013 utilities.assert_equals(
1014 expect='500',
1015 actual=Poststatus,
1016 onpass="The Json is wrong,can't post",
1017 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +08001018
Jon Hallf52840a2017-05-24 16:49:52 -07001019 def CASE13( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +08001020 """
1021 Test Post Error Json Create Virtualport
1022 """
1023 import os
1024
1025 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001026 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1027 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
1028 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
ligenyud4ae1be2015-09-28 20:03:13 +08001029 except ImportError:
1030 main.log.exception( "Something wrong with import file or code error." )
1031 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -07001032 main.cleanAndExit()
ligenyud4ae1be2015-09-28 20:03:13 +08001033
1034 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1035 main.case( "Virtual Network NBI Test - Port" )
1036 main.caseExplanation = "Test Subnet Post With Error json " +\
1037 "The wrong Json can't create port successfully"
1038
Jon Hallf52840a2017-05-24 16:49:52 -07001039 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1040 httpport = main.params[ 'HTTP' ][ 'port' ]
1041 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001042
1043 main.step( "Generate Post Data" )
1044 network = NetworkData()
1045 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1046 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1047 subnet = SubnetData()
1048 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1049 subnet.tenant_id = network.tenant_id
1050 subnet.network_id = network.id
1051 port = VirtualPortData()
1052 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
1053 port.subnet_id = subnet.id
1054 port.tenant_id = network.tenant_id
1055 port.network_id = network.id
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001056 # The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
ligenyud4ae1be2015-09-28 20:03:13 +08001057 port.adminStateUp = 'tttttttttttt'
1058
1059 networkpostdata = network.DictoJson()
1060 subnetpostdata = subnet.DictoJson()
1061 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -07001062 ctrl = main.Cluster.active( 0 )
ligenyud4ae1be2015-09-28 20:03:13 +08001063 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -07001064 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
1065 'POST', None, networkpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001066 utilities.assert_equals(
1067 expect='200',
1068 actual=Poststatus,
1069 onpass="Post Network Success",
1070 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1071
1072 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -07001073 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
1074 'POST', None, subnetpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001075 utilities.assert_equals(
1076 expect='202',
1077 actual=Poststatus,
1078 onpass="Post Subnet Success",
1079 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
1080
1081 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -07001082 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
1083 'POST', None, portpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001084 utilities.assert_equals(
1085 expect='500',
1086 actual=Poststatus,
1087 onpass="The Json is wrong,can't post",
Jon Hallce9c01e2015-10-22 16:39:02 +00001088 onfail="Wrong Json can post successfully" )