blob: 5d471ad6397f6139d199f70f700a1596b132c55e [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" )
Devin Lim44075962017-08-11 10:56:37 -070077 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070078 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" )
Devin Lim44075962017-08-11 10:56:37 -070095 main.cleanAndExit()
lanqinglong77124b02015-08-06 11:47:38 +080096
97 main.step( "App Ids check" )
Devin Lim142b5342017-07-20 15:22:39 -070098 appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck()
lanqinglong77124b02015-08-06 11:47:38 +080099 if appCheck != main.TRUE:
Devin Lim142b5342017-07-20 15:22:39 -0700100 main.log.warn( main.Cluster.active( 0 ).CLI.apps() )
101 main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() )
lanqinglong77124b02015-08-06 11:47:38 +0800102 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
Jon Hallf52840a2017-05-24 16:49:52 -0700103 onpass="App Ids seem to be correct",
104 onfail="Something is wrong with app Ids" )
lanqinglong77124b02015-08-06 11:47:38 +0800105
GlennRCa0c395f2015-12-03 14:04:56 -0800106 main.step( "Install org.onosproject.vtn app" )
Devin Lim142b5342017-07-20 15:22:39 -0700107 installResults = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.vtn" )
lanqinglong77124b02015-08-06 11:47:38 +0800108 utilities.assert_equals( expect=main.TRUE, actual=installResults,
Jon Hallf52840a2017-05-24 16:49:52 -0700109 onpass="Install org.onosproject.vtn successful",
110 onfail="Install org.onosproject.vtn app failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800111
112 time.sleep( main.startUpSleep )
113
Jon Hallf52840a2017-05-24 16:49:52 -0700114 def CASE2( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800115 """
116 Test Post Network
117 """
lanqinglonge675e922015-08-13 21:17:28 +0800118 import os
119
lanqinglong77124b02015-08-06 11:47:38 +0800120 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700121 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800122 except ImportError:
123 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800124 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700125 main.cleanAndExit()
lanqinglong77124b02015-08-06 11:47:38 +0800126
127 main.log.info( "ONOS Network Post test Start" )
128 main.case( "Virtual Network NBI Test - Network" )
129 main.caseExplanation = "Test Network Post NBI " +\
130 "Verify Post Data same with Stored Data"
131
Jon Hallf52840a2017-05-24 16:49:52 -0700132 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
133 port = main.params[ 'HTTP' ][ 'port' ]
134 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800135
lanqinglongca0a0ee2015-09-22 16:19:08 +0800136 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800137 network = NetworkData()
138 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
139 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
140 postdata = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700141 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800142 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700143 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
144 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800145
146 utilities.assert_equals(
147 expect='200',
148 actual=Poststatus,
149 onpass="Post Success",
150 onfail="Post Failed " + str( Poststatus ) + str( result ) )
151
152 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" )
201 main.caseExplanation = "Test Network Update NBI " +\
202 "Verify Update Data same with Stored Data"
203
Jon Hallf52840a2017-05-24 16:49:52 -0700204 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
205 port = main.params[ 'HTTP' ][ 'port' ]
206 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800207
lanqinglongca0a0ee2015-09-22 16:19:08 +0800208 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800209 network = NetworkData()
210 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
211 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
lanqinglongd0dda2e2015-08-25 11:02:48 +0800212 network.shared = False
lanqinglong77124b02015-08-06 11:47:38 +0800213 postdata = network.DictoJson()
214
lanqinglongd0dda2e2015-08-25 11:02:48 +0800215 network.shared = True
lanqinglong77124b02015-08-06 11:47:38 +0800216 postdatanew = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700217 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800218 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700219 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks',
220 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800221 utilities.assert_equals(
222 expect='200',
223 actual=Poststatus,
224 onpass="Post Success",
225 onfail="Post Failed " + str( Poststatus ) + str( result ) )
226
227 main.step( "Update Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700228 Updatestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
229 'PUT', None, postdatanew )
lanqinglong77124b02015-08-06 11:47:38 +0800230 utilities.assert_equals(
231 expect='200',
232 actual=Updatestatus,
233 onpass="Update Success",
234 onfail="Update Failed " + str( Updatestatus ) + str( result ) )
235
236 main.step( "Get Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700237 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
238 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800239 utilities.assert_equals(
240 expect='200',
241 actual=Getstatus,
242 onpass="Get Success",
243 onfail="Get Failed " + str( Getstatus ) + str( result ) )
244
245 main.step( "Compare Update data." )
246 IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
247 TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
248 Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
249
250 Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
251 utilities.assert_equals(
252 expect=True,
253 actual=Cmpresult,
254 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700255 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
256 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800257 ",Name compare:" + str( Shareresult ) )
258
Devin Lim142b5342017-07-20 15:22:39 -0700259 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
260 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800261
262 utilities.assert_equals(
263 expect='200',
264 actual=deletestatus,
265 onpass="Delete Network Success",
266 onfail="Delete Network Failed" )
267
Jon Hallf52840a2017-05-24 16:49:52 -0700268 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800269 main.log.error( "Update Network compare failed" )
270
Jon Hallf52840a2017-05-24 16:49:52 -0700271 def CASE4( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800272 """
273 Test Delete Network
274 """
lanqinglonge675e922015-08-13 21:17:28 +0800275 import os
276
lanqinglong77124b02015-08-06 11:47:38 +0800277 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700278 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800279 except ImportError:
280 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800281 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700282 main.cleanAndExit()
lanqinglong77124b02015-08-06 11:47:38 +0800283
284 main.log.info( "ONOS Network Delete test Start" )
285 main.case( "Virtual Network NBI Test - Network" )
286 main.caseExplanation = "Test Network Delete NBI " +\
287 "Verify Stored Data is NULL after Delete"
288
Jon Hallf52840a2017-05-24 16:49:52 -0700289 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
290 port = main.params[ 'HTTP' ][ 'port' ]
291 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800292
lanqinglongca0a0ee2015-09-22 16:19:08 +0800293 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800294 network = NetworkData()
295 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
296 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
297 postdata = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700298 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800299 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700300 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
301 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800302 utilities.assert_equals(
303 expect='200',
304 actual=Poststatus,
305 onpass="Post Success",
306 onfail="Post Failed " + str( Poststatus ) + str( result ) )
307
308 main.step( "Delete Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700309 Deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
310 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800311 utilities.assert_equals(
312 expect='200',
313 actual=Deletestatus,
314 onpass="Delete Success",
lanqinglongd0dda2e2015-08-25 11:02:48 +0800315 onfail="Delete Failed " + str( Deletestatus ) + str( result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800316
317 main.step( "Get Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700318 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
319 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800320 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800321 expect='Network is not found',
lanqinglong77124b02015-08-06 11:47:38 +0800322 actual=result,
323 onpass="Get Success",
324 onfail="Get Failed " + str( Getstatus ) + str( result ) )
325
sunyulinf16bb8d2015-09-29 20:21:16 +0800326 if result != 'Network is not found':
lanqinglong77124b02015-08-06 11:47:38 +0800327 main.log.error( "Delete Network failed" )
lanqinglonge675e922015-08-13 21:17:28 +0800328
329 def CASE5( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800330 """
331 Test Post Subnet
332 """
333 import os
334
335 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700336 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
337 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800338 except ImportError:
339 main.log.exception( "Something wrong with import file or code error." )
340 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700341 main.cleanAndExit()
lanqinglonge675e922015-08-13 21:17:28 +0800342
343 main.log.info( "ONOS Subnet Post test Start" )
344 main.case( "Virtual Network NBI Test - Subnet" )
345 main.caseExplanation = "Test Subnet Post NBI " +\
346 "Verify Stored Data is same with Post Data"
347
Jon Hallf52840a2017-05-24 16:49:52 -0700348 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
349 port = main.params[ 'HTTP' ][ 'port' ]
350 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800351
lanqinglongca0a0ee2015-09-22 16:19:08 +0800352 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800353 network = NetworkData()
354 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
355 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
356 subnet = SubnetData()
357 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
358 subnet.tenant_id = network.tenant_id
359 subnet.network_id = network.id
360
361 networkpostdata = network.DictoJson()
362 subnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700363 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800364 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700365 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
366 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800367 utilities.assert_equals(
368 expect='200',
369 actual=Poststatus,
370 onpass="Post Network Success",
371 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
372
373 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700374 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
375 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800376 utilities.assert_equals(
377 expect='202',
378 actual=Poststatus,
379 onpass="Post Subnet Success",
380 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
381
382 main.step( "Get Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700383 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
384 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800385 utilities.assert_equals(
386 expect='200',
387 actual=Getstatus,
388 onpass="Get Subnet Success",
389 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
390
391 IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
392 TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
393 NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
394
395 main.step( "Compare Post Subnet Data via HTTP" )
396 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
397 utilities.assert_equals(
398 expect=True,
399 actual=Cmpresult,
400 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700401 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
402 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800403 ",Network id compare:" + str( NetoworkIDcmpresult ) )
404
Devin Lim142b5342017-07-20 15:22:39 -0700405 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
406 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800407 utilities.assert_equals(
408 expect='200',
409 actual=deletestatus,
410 onpass="Delete Network Success",
411 onfail="Delete Network Failed" )
412
Jon Hallf52840a2017-05-24 16:49:52 -0700413 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800414 main.log.error( "Post Subnet compare failed" )
415
416 def CASE6( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800417 """
418 Test Post Subnet
419 """
420 import os
421
422 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700423 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
424 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800425 except ImportError:
426 main.log.exception( "Something wrong with import file or code error." )
427 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700428 main.cleanAndExit()
lanqinglonge675e922015-08-13 21:17:28 +0800429
430 main.log.info( "ONOS Subnet Update test Start" )
431 main.case( "Virtual Network NBI Test - Subnet" )
432 main.caseExplanation = "Test Subnet Update NBI " +\
433 "Verify Stored Data is same with Update Data"
434
Jon Hallf52840a2017-05-24 16:49:52 -0700435 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
436 port = main.params[ 'HTTP' ][ 'port' ]
437 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800438
lanqinglongca0a0ee2015-09-22 16:19:08 +0800439 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800440 network = NetworkData()
441 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
442 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
443 subnet = SubnetData()
444 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
445 subnet.tenant_id = network.tenant_id
446 subnet.network_id = network.id
447 subnet.start = "192.168.2.1"
448 subnet.end = "192.168.2.255"
449 networkpostdata = network.DictoJson()
450 subnetpostdata = subnet.DictoJson()
451
452 #Change allocation_poolsdata scope
453 subnet.start = "192.168.102.1"
454 subnet.end = "192.168.102.255"
455 #end change
456 newsubnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700457 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800458 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700459 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
460 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800461 utilities.assert_equals(
462 expect='200',
463 actual=Poststatus,
464 onpass="Post Network Success",
465 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
466
467 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700468 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
469 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800470 utilities.assert_equals(
471 expect='202',
472 actual=Poststatus,
473 onpass="Post Subnet Success",
474 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
475
476 main.step( "Update Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700477 Putstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
478 'PUT', None, newsubnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800479 utilities.assert_equals(
480 expect='203',
481 actual=Putstatus,
482 onpass="Update Subnet Success",
483 onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
484
485 main.step( "Get Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700486 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
487 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800488 utilities.assert_equals(
489 expect='200',
490 actual=Getstatus,
491 onpass="Get Subnet Success",
492 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
493
494 IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
495 TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
496 Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
497
498 main.step( "Compare Subnet Data" )
499 Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
500 utilities.assert_equals(
501 expect=True,
502 actual=Cmpresult,
503 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700504 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
505 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800506 ",Pool compare:" + str( Poolcmpresult ) )
507
508 main.step( "Delete Subnet via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700509 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
510 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800511 utilities.assert_equals(
512 expect='200',
513 actual=deletestatus,
514 onpass="Delete Network Success",
515 onfail="Delete Network Failed" )
516
Jon Hallf52840a2017-05-24 16:49:52 -0700517 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800518 main.log.error( "Update Subnet compare failed" )
519
520 def CASE7( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800521 """
522 Test Delete Subnet
523 """
524 import os
525
526 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700527 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
528 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800529 except ImportError:
530 main.log.exception( "Something wrong with import file or code error." )
531 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700532 main.cleanAndExit()
lanqinglonge675e922015-08-13 21:17:28 +0800533
534 main.log.info( "ONOS Subnet Delete test Start" )
535 main.case( "Virtual Network NBI Test - Subnet" )
536 main.caseExplanation = "Test Subnet Delete NBI " +\
537 "Verify Stored Data is Null after Delete"
538
Jon Hallf52840a2017-05-24 16:49:52 -0700539 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
540 port = main.params[ 'HTTP' ][ 'port' ]
541 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800542
lanqinglongca0a0ee2015-09-22 16:19:08 +0800543 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800544 network = NetworkData()
545 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
546 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
547 subnet = SubnetData()
548 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
549 subnet.tenant_id = network.tenant_id
550 subnet.network_id = network.id
551
552 networkpostdata = network.DictoJson()
553 subnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700554 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800555 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700556 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
557 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800558 utilities.assert_equals(
559 expect='200',
560 actual=Poststatus,
561 onpass="Post Network Success",
562 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
563
564 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700565 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
566 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800567 utilities.assert_equals(
568 expect='202',
569 actual=Poststatus,
570 onpass="Post Subnet Success",
571 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
572
573 main.step( "Delete Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700574 Deletestatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
575 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800576 utilities.assert_equals(
577 expect='201',
578 actual=Deletestatus,
579 onpass="Delete Subnet Success",
580 onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
581
582 main.step( "Get Subnet Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700583 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
584 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800585 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800586 expect='Subnet is not found',
lanqinglonge675e922015-08-13 21:17:28 +0800587 actual=result,
588 onpass="Get Subnet Success",
589 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
590
sunyulinf16bb8d2015-09-29 20:21:16 +0800591 if result != 'Subnet is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800592 main.log.error( "Delete Subnet failed" )
593
594 def CASE8( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800595 """
596 Test Post Port
597 """
598 import os
599
600 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700601 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
602 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
603 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800604 except ImportError:
605 main.log.exception( "Something wrong with import file or code error." )
606 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700607 main.cleanAndExit()
lanqinglongd0dda2e2015-08-25 11:02:48 +0800608
609 main.log.info( "ONOS Port Post test Start" )
610 main.case( "Virtual Network NBI Test - Port" )
611 main.caseExplanation = "Test Port Post NBI " +\
612 "Verify Stored Data is same with Post Data"
613
Jon Hallf52840a2017-05-24 16:49:52 -0700614 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
615 httpport = main.params[ 'HTTP' ][ 'port' ]
616 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800617
lanqinglongca0a0ee2015-09-22 16:19:08 +0800618 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800619 network = NetworkData()
620 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
621 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
622 subnet = SubnetData()
623 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
624 subnet.tenant_id = network.tenant_id
625 subnet.network_id = network.id
626 port = VirtualPortData()
627 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
628 port.subnet_id = subnet.id
629 port.tenant_id = network.tenant_id
630 port.network_id = network.id
631
632 networkpostdata = network.DictoJson()
633 subnetpostdata = subnet.DictoJson()
634 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700635 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800636 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700637 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
638 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800639 utilities.assert_equals(
640 expect='200',
641 actual=Poststatus,
642 onpass="Post Network Success",
643 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
644
645 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700646 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
647 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800648 utilities.assert_equals(
649 expect='202',
650 actual=Poststatus,
651 onpass="Post Subnet Success",
652 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
653
654 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700655 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
656 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800657 utilities.assert_equals(
658 expect='200',
659 actual=Poststatus,
660 onpass="Post Port Success",
661 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
662
663 main.step( "Get Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700664 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
665 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800666 utilities.assert_equals(
667 expect='200',
668 actual=Getstatus,
669 onpass="Get Port Success",
670 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
671
672 main.step( "Compare Post Port Data" )
673 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
674 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
675 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
676 fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
677
678 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
679 utilities.assert_equals(
680 expect=True,
681 actual=Cmpresult,
682 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700683 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
684 ",Tenant id compare:" + str( TanantIDcmpresult ) +
685 ",Network id compare:" + str( NetoworkIDcmpresult ) +
lanqinglongd0dda2e2015-08-25 11:02:48 +0800686 ",FixIp compare:" + str( fixedIpresult ) )
687
688 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700689 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
690 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800691 utilities.assert_equals(
692 expect='200',
693 actual=deletestatus,
694 onpass="Delete Network Success",
695 onfail="Delete Network Failed" )
696
Jon Hallf52840a2017-05-24 16:49:52 -0700697 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800698 main.log.error( "Post port compare failed" )
699
700 def CASE9( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800701 """
702 Test Update Port
703 """
704 import os
705
706 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700707 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
708 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
709 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800710 except ImportError:
711 main.log.exception( "Something wrong with import file or code error." )
712 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700713 main.cleanAndExit()
lanqinglongd0dda2e2015-08-25 11:02:48 +0800714
715 main.log.info( "ONOS Port Update test Start" )
716 main.case( "Virtual Network NBI Test - Port" )
717 main.caseExplanation = "Test Port Update NBI " +\
718 "Verify Stored Data is same with New Post Data"
719
Jon Hallf52840a2017-05-24 16:49:52 -0700720 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
721 httpport = main.params[ 'HTTP' ][ 'port' ]
722 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800723
lanqinglongca0a0ee2015-09-22 16:19:08 +0800724 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800725 network = NetworkData()
726 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
727 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
728 subnet = SubnetData()
729 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
730 subnet.tenant_id = network.tenant_id
731 subnet.network_id = network.id
732 port = VirtualPortData()
733 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
734 port.subnet_id = subnet.id
735 port.tenant_id = network.tenant_id
736 port.network_id = network.id
737 port.name = "onos"
738
739 networkpostdata = network.DictoJson()
740 subnetpostdata = subnet.DictoJson()
741 portpostdata = port.DictoJson()
742
743 #create update data
744 port.name = "onos-new"
745 newportpostdata = port.DictoJson()
746 #end
Devin Lim142b5342017-07-20 15:22:39 -0700747 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800748 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700749 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
750 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800751 utilities.assert_equals(
752 expect='200',
753 actual=Poststatus,
754 onpass="Post Network Success",
755 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
756
757 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700758 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
759 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800760 utilities.assert_equals(
761 expect='202',
762 actual=Poststatus,
763 onpass="Post Subnet Success",
764 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
765
766 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700767 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
768 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800769 utilities.assert_equals(
770 expect='200',
771 actual=Poststatus,
772 onpass="Post Port Success",
773 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
774
775 main.step( "Update Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700776 Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
777 'PUT', None, newportpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800778 utilities.assert_equals(
779 expect='200',
780 actual=Poststatus,
781 onpass="Update Port Success",
782 onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )
783
784 main.step( "Get Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700785 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
786 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800787 utilities.assert_equals(
788 expect='200',
789 actual=Getstatus,
790 onpass="Get Port Success",
791 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
792
793 main.step( "Compare Update Port Data" )
794 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
795 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
796 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
797 Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )
798
799 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
800 utilities.assert_equals(
801 expect=True,
802 actual=Cmpresult,
803 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700804 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
805 ",Tenant id compare:" + str( TanantIDcmpresult ) +
806 ",Network id compare:" + str( NetoworkIDcmpresult ) +
807 ",Name compare:" + str( Nameresult ) )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800808
809 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700810 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
811 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800812 utilities.assert_equals(
813 expect='200',
814 actual=deletestatus,
815 onpass="Delete Network Success",
816 onfail="Delete Network Failed" )
817
Jon Hallf52840a2017-05-24 16:49:52 -0700818 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800819 main.log.error( "Update port compare failed" )
820
821 def CASE10( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800822 """
823 Test Delete Port
824 """
825 import os
826
827 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700828 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
829 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
830 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800831 except ImportError:
832 main.log.exception( "Something wrong with import file or code error." )
833 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700834 main.cleanAndExit()
lanqinglongd0dda2e2015-08-25 11:02:48 +0800835
836 main.log.info( "ONOS Port Delete test Start" )
837 main.case( "Virtual Network NBI Test - Port" )
838 main.caseExplanation = "Test Port Delete NBI " +\
839 "Verify port delete success"
840
Jon Hallf52840a2017-05-24 16:49:52 -0700841 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
842 httpport = main.params[ 'HTTP' ][ 'port' ]
843 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800844
lanqinglongca0a0ee2015-09-22 16:19:08 +0800845 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800846 network = NetworkData()
847 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
848 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
849 subnet = SubnetData()
850 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
851 subnet.tenant_id = network.tenant_id
852 subnet.network_id = network.id
853 port = VirtualPortData()
854 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
855 port.subnet_id = subnet.id
856 port.tenant_id = network.tenant_id
857 port.network_id = network.id
858
859 networkpostdata = network.DictoJson()
860 subnetpostdata = subnet.DictoJson()
861 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700862 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800863 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700864 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
865 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800866 utilities.assert_equals(
867 expect='200',
868 actual=Poststatus,
869 onpass="Post Network Success",
870 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
871
872 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700873 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
874 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800875 utilities.assert_equals(
876 expect='202',
877 actual=Poststatus,
878 onpass="Post Subnet Success",
879 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
880
881 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700882 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
883 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800884 utilities.assert_equals(
885 expect='200',
886 actual=Poststatus,
887 onpass="Post Port Success",
888 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
889
890 main.step( "Delete Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700891 Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
892 'Delete', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800893 utilities.assert_equals(
894 expect='200',
895 actual=Poststatus,
896 onpass="Delete Port Success",
897 onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )
898
899 main.step( "Get Port Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700900 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
901 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800902 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800903 expect='VirtualPort is not found',
lanqinglongd0dda2e2015-08-25 11:02:48 +0800904 actual=result,
905 onpass="Get Port Success",
906 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
907
sunyulinf16bb8d2015-09-29 20:21:16 +0800908 if result != 'VirtualPort is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800909 main.log.error( "Delete Port failed" )
910
911 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700912 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
913 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800914 utilities.assert_equals(
915 expect='200',
916 actual=deletestatus,
917 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700918 onfail="Delete Network Failed" )
ligenyud4ae1be2015-09-28 20:03:13 +0800919
Jon Hallf52840a2017-05-24 16:49:52 -0700920 def CASE11( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +0800921 """
922 Test Post Error Json Create Network
923 """
924 import os
925
926 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700927 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
ligenyud4ae1be2015-09-28 20:03:13 +0800928 except ImportError:
929 main.log.exception( "Something wrong with import file or code error." )
930 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700931 main.cleanAndExit()
ligenyud4ae1be2015-09-28 20:03:13 +0800932
933 main.log.info( "ONOS Post Error Json Create Network test Start" )
934 main.case( "Virtual Network NBI Test - Network" )
935 main.caseExplanation = "Test Network Post With Error json " +\
936 "The wrong Json can't post network successfully"
937
Jon Hallf52840a2017-05-24 16:49:52 -0700938 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
939 port = main.params[ 'HTTP' ][ 'port' ]
940 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +0800941
942 main.step( "Generate Post Data" )
943 network = NetworkData()
944 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
945 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
946 #The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post.
947 network.admin_state_up = 'tttttttttt'
948 #The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
949 network.routerExternal = 'ffffffffffff'
950 #The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
951 network.shared = 'ffffffffffffff'
952 postdata = network.DictoJson()
953
954 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700955 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
956 'POST', None, postdata )
ligenyud4ae1be2015-09-28 20:03:13 +0800957
958 utilities.assert_equals(
959 expect='500',
960 actual=Poststatus,
961 onpass="The Json is wrong,can't post",
962 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +0800963
Jon Hallf52840a2017-05-24 16:49:52 -0700964 def CASE12( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +0800965 """
966 Test Post Error Json Create Subnet
967 """
968 import os
969
970 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700971 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
972 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
ligenyud4ae1be2015-09-28 20:03:13 +0800973 except ImportError:
974 main.log.exception( "Something wrong with import file or code error." )
975 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700976 main.cleanAndExit()
ligenyud4ae1be2015-09-28 20:03:13 +0800977
978 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
979 main.case( "Virtual Network NBI Test - Subnet" )
980 main.caseExplanation = "Test Subnet Post With Error json " +\
981 "The wrong Json can't post network successfully"
982
Jon Hallf52840a2017-05-24 16:49:52 -0700983 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
984 port = main.params[ 'HTTP' ][ 'port' ]
985 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +0800986
987 main.step( "Generate Post Data" )
988 network = NetworkData()
989 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
990 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
991 subnet = SubnetData()
992 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
993 #The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post.
994 subnet.enable_dhcp = 'tttttttttttttt'
995 #The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post.
996 subnet.shared = 'ffffffffffffff'
997 subnet.tenant_id = network.tenant_id
998 subnet.network_id = network.id
999
1000 networkpostdata = network.DictoJson()
1001 subnetpostdata = subnet.DictoJson()
1002
1003 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -07001004 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
1005 'POST', None, networkpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001006 utilities.assert_equals(
1007 expect='200',
1008 actual=Poststatus,
1009 onpass="Post Network Success",
1010 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1011
1012 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -07001013 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'subnets/',
1014 'POST', None, subnetpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001015 utilities.assert_equals(
1016 expect='500',
1017 actual=Poststatus,
1018 onpass="The Json is wrong,can't post",
1019 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +08001020
Jon Hallf52840a2017-05-24 16:49:52 -07001021 def CASE13( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +08001022 """
1023 Test Post Error Json Create Virtualport
1024 """
1025 import os
1026
1027 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001028 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1029 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
1030 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
ligenyud4ae1be2015-09-28 20:03:13 +08001031 except ImportError:
1032 main.log.exception( "Something wrong with import file or code error." )
1033 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -07001034 main.cleanAndExit()
ligenyud4ae1be2015-09-28 20:03:13 +08001035
1036 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1037 main.case( "Virtual Network NBI Test - Port" )
1038 main.caseExplanation = "Test Subnet Post With Error json " +\
1039 "The wrong Json can't create port successfully"
1040
Jon Hallf52840a2017-05-24 16:49:52 -07001041 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1042 httpport = main.params[ 'HTTP' ][ 'port' ]
1043 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001044
1045 main.step( "Generate Post Data" )
1046 network = NetworkData()
1047 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1048 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1049 subnet = SubnetData()
1050 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1051 subnet.tenant_id = network.tenant_id
1052 subnet.network_id = network.id
1053 port = VirtualPortData()
1054 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
1055 port.subnet_id = subnet.id
1056 port.tenant_id = network.tenant_id
1057 port.network_id = network.id
1058 #The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
1059 port.adminStateUp = 'tttttttttttt'
1060
1061 networkpostdata = network.DictoJson()
1062 subnetpostdata = subnet.DictoJson()
1063 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -07001064 ctrl = main.Cluster.active( 0 )
ligenyud4ae1be2015-09-28 20:03:13 +08001065 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -07001066 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
1067 'POST', None, networkpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001068 utilities.assert_equals(
1069 expect='200',
1070 actual=Poststatus,
1071 onpass="Post Network Success",
1072 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1073
1074 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -07001075 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
1076 'POST', None, subnetpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001077 utilities.assert_equals(
1078 expect='202',
1079 actual=Poststatus,
1080 onpass="Post Subnet Success",
1081 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
1082
1083 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -07001084 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
1085 'POST', None, portpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001086 utilities.assert_equals(
1087 expect='500',
1088 actual=Poststatus,
1089 onpass="The Json is wrong,can't post",
Jon Hallce9c01e2015-10-22 16:39:02 +00001090 onfail="Wrong Json can post successfully" )