blob: 73e7f4adcb93af9705a4de1fcdf3df14035dfe0f [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 )
85 main.testSetUp.evnSetupConclusion( 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
Devin Lim142b5342017-07-20 15:22:39 -070089 cliResults = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster,
90 cellName=cellName, removeLog=True )
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
149 main.step( "Get Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700150 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
151 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800152 utilities.assert_equals(
153 expect='200',
154 actual=Getstatus,
155 onpass="Get Success",
156 onfail="Get Failed " + str( Getstatus ) + str( result ) )
157
Jon Hallf52840a2017-05-24 16:49:52 -0700158 main.log.info( "Post Network Data is :%s\nGet Network Data is:%s" % ( postdata, result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800159
160 main.step( "Compare Send Id and Get Id" )
161 IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' )
162 TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' )
163 Cmpresult = IDcmpresult and TanantIDcmpresult
164
165 utilities.assert_equals(
166 expect=True,
167 actual=Cmpresult,
168 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700169 onfail="Compare Failed:ID compare: " + str( IDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800170 ",Tenant id compare :" + str( TanantIDcmpresult ) )
171
Devin Lim142b5342017-07-20 15:22:39 -0700172 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
173 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800174 utilities.assert_equals(
175 expect='200',
176 actual=deletestatus,
177 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700178 onfail="Delete Network Failed" )
lanqinglong77124b02015-08-06 11:47:38 +0800179
Jon Hallf52840a2017-05-24 16:49:52 -0700180 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800181 main.log.error( "Post Network compare failed" )
182
Jon Hallf52840a2017-05-24 16:49:52 -0700183 def CASE3( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800184 """
185 Test Update Network
186 """
lanqinglonge675e922015-08-13 21:17:28 +0800187 import os
188
lanqinglong77124b02015-08-06 11:47:38 +0800189 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700190 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800191 except ImportError:
192 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800193 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700194 main.cleanAndExit()
lanqinglong77124b02015-08-06 11:47:38 +0800195
196 main.log.info( "ONOS Network Update test Start" )
197 main.case( "Virtual Network NBI Test - Network" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700198 main.caseExplanation = "Test Network Update NBI Verify Update Data same with Stored Data"
lanqinglong77124b02015-08-06 11:47:38 +0800199
Jon Hallf52840a2017-05-24 16:49:52 -0700200 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
201 port = main.params[ 'HTTP' ][ 'port' ]
202 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800203
lanqinglongca0a0ee2015-09-22 16:19:08 +0800204 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800205 network = NetworkData()
206 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
207 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
lanqinglongd0dda2e2015-08-25 11:02:48 +0800208 network.shared = False
lanqinglong77124b02015-08-06 11:47:38 +0800209 postdata = network.DictoJson()
210
lanqinglongd0dda2e2015-08-25 11:02:48 +0800211 network.shared = True
lanqinglong77124b02015-08-06 11:47:38 +0800212 postdatanew = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700213 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800214 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700215 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks',
216 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800217 utilities.assert_equals(
218 expect='200',
219 actual=Poststatus,
220 onpass="Post Success",
221 onfail="Post Failed " + str( Poststatus ) + str( result ) )
222
223 main.step( "Update Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700224 Updatestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
225 'PUT', None, postdatanew )
lanqinglong77124b02015-08-06 11:47:38 +0800226 utilities.assert_equals(
227 expect='200',
228 actual=Updatestatus,
229 onpass="Update Success",
230 onfail="Update Failed " + str( Updatestatus ) + str( result ) )
231
232 main.step( "Get Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700233 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
234 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800235 utilities.assert_equals(
236 expect='200',
237 actual=Getstatus,
238 onpass="Get Success",
239 onfail="Get Failed " + str( Getstatus ) + str( result ) )
240
241 main.step( "Compare Update data." )
242 IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
243 TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
244 Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
245
246 Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
247 utilities.assert_equals(
248 expect=True,
249 actual=Cmpresult,
250 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700251 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
252 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglong77124b02015-08-06 11:47:38 +0800253 ",Name compare:" + str( Shareresult ) )
254
Devin Lim142b5342017-07-20 15:22:39 -0700255 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
256 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800257
258 utilities.assert_equals(
259 expect='200',
260 actual=deletestatus,
261 onpass="Delete Network Success",
262 onfail="Delete Network Failed" )
263
Jon Hallf52840a2017-05-24 16:49:52 -0700264 if not Cmpresult:
lanqinglong77124b02015-08-06 11:47:38 +0800265 main.log.error( "Update Network compare failed" )
266
Jon Hallf52840a2017-05-24 16:49:52 -0700267 def CASE4( self, main ):
lanqinglong77124b02015-08-06 11:47:38 +0800268 """
269 Test Delete Network
270 """
lanqinglonge675e922015-08-13 21:17:28 +0800271 import os
272
lanqinglong77124b02015-08-06 11:47:38 +0800273 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700274 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
lanqinglong77124b02015-08-06 11:47:38 +0800275 except ImportError:
276 main.log.exception( "Something wrong with import file or code error." )
lanqinglonge675e922015-08-13 21:17:28 +0800277 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700278 main.cleanAndExit()
lanqinglong77124b02015-08-06 11:47:38 +0800279
280 main.log.info( "ONOS Network Delete test Start" )
281 main.case( "Virtual Network NBI Test - Network" )
282 main.caseExplanation = "Test Network Delete NBI " +\
283 "Verify Stored Data is NULL after Delete"
284
Jon Hallf52840a2017-05-24 16:49:52 -0700285 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
286 port = main.params[ 'HTTP' ][ 'port' ]
287 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglong77124b02015-08-06 11:47:38 +0800288
lanqinglongca0a0ee2015-09-22 16:19:08 +0800289 main.log.info( "Generate Post Data" )
lanqinglong77124b02015-08-06 11:47:38 +0800290 network = NetworkData()
291 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
292 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
293 postdata = network.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700294 ctrl = main.Cluster.active( 0 )
lanqinglong77124b02015-08-06 11:47:38 +0800295 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700296 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
297 'POST', None, postdata )
lanqinglong77124b02015-08-06 11:47:38 +0800298 utilities.assert_equals(
299 expect='200',
300 actual=Poststatus,
301 onpass="Post Success",
302 onfail="Post Failed " + str( Poststatus ) + str( result ) )
303
304 main.step( "Delete Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700305 Deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
306 'DELETE', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800307 utilities.assert_equals(
308 expect='200',
309 actual=Deletestatus,
310 onpass="Delete Success",
lanqinglongd0dda2e2015-08-25 11:02:48 +0800311 onfail="Delete Failed " + str( Deletestatus ) + str( result ) )
lanqinglong77124b02015-08-06 11:47:38 +0800312
313 main.step( "Get Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700314 Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
315 'GET', None, None )
lanqinglong77124b02015-08-06 11:47:38 +0800316 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800317 expect='Network is not found',
lanqinglong77124b02015-08-06 11:47:38 +0800318 actual=result,
319 onpass="Get Success",
320 onfail="Get Failed " + str( Getstatus ) + str( result ) )
321
sunyulinf16bb8d2015-09-29 20:21:16 +0800322 if result != 'Network is not found':
lanqinglong77124b02015-08-06 11:47:38 +0800323 main.log.error( "Delete Network failed" )
lanqinglonge675e922015-08-13 21:17:28 +0800324
325 def CASE5( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800326 """
327 Test Post Subnet
328 """
329 import os
330
331 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700332 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
333 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800334 except ImportError:
335 main.log.exception( "Something wrong with import file or code error." )
336 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700337 main.cleanAndExit()
lanqinglonge675e922015-08-13 21:17:28 +0800338
339 main.log.info( "ONOS Subnet Post test Start" )
340 main.case( "Virtual Network NBI Test - Subnet" )
341 main.caseExplanation = "Test Subnet Post NBI " +\
342 "Verify Stored Data is same with Post Data"
343
Jon Hallf52840a2017-05-24 16:49:52 -0700344 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
345 port = main.params[ 'HTTP' ][ 'port' ]
346 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800347
lanqinglongca0a0ee2015-09-22 16:19:08 +0800348 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800349 network = NetworkData()
350 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
351 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
352 subnet = SubnetData()
353 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
354 subnet.tenant_id = network.tenant_id
355 subnet.network_id = network.id
356
357 networkpostdata = network.DictoJson()
358 subnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700359 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800360 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700361 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
362 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800363 utilities.assert_equals(
364 expect='200',
365 actual=Poststatus,
366 onpass="Post Network Success",
367 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
368
369 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700370 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
371 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800372 utilities.assert_equals(
373 expect='202',
374 actual=Poststatus,
375 onpass="Post Subnet Success",
376 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
377
378 main.step( "Get Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700379 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
380 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800381 utilities.assert_equals(
382 expect='200',
383 actual=Getstatus,
384 onpass="Get Subnet Success",
385 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
386
387 IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
388 TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
389 NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
390
391 main.step( "Compare Post Subnet Data via HTTP" )
392 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
393 utilities.assert_equals(
394 expect=True,
395 actual=Cmpresult,
396 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700397 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
398 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800399 ",Network id compare:" + str( NetoworkIDcmpresult ) )
400
Devin Lim142b5342017-07-20 15:22:39 -0700401 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
402 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800403 utilities.assert_equals(
404 expect='200',
405 actual=deletestatus,
406 onpass="Delete Network Success",
407 onfail="Delete Network Failed" )
408
Jon Hallf52840a2017-05-24 16:49:52 -0700409 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800410 main.log.error( "Post Subnet compare failed" )
411
412 def CASE6( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800413 """
414 Test Post Subnet
415 """
416 import os
417
418 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700419 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
420 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800421 except ImportError:
422 main.log.exception( "Something wrong with import file or code error." )
423 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700424 main.cleanAndExit()
lanqinglonge675e922015-08-13 21:17:28 +0800425
426 main.log.info( "ONOS Subnet Update test Start" )
427 main.case( "Virtual Network NBI Test - Subnet" )
428 main.caseExplanation = "Test Subnet Update NBI " +\
429 "Verify Stored Data is same with Update Data"
430
Jon Hallf52840a2017-05-24 16:49:52 -0700431 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
432 port = main.params[ 'HTTP' ][ 'port' ]
433 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800434
lanqinglongca0a0ee2015-09-22 16:19:08 +0800435 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800436 network = NetworkData()
437 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
438 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
439 subnet = SubnetData()
440 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
441 subnet.tenant_id = network.tenant_id
442 subnet.network_id = network.id
443 subnet.start = "192.168.2.1"
444 subnet.end = "192.168.2.255"
445 networkpostdata = network.DictoJson()
446 subnetpostdata = subnet.DictoJson()
447
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700448 # Change allocation_poolsdata scope
lanqinglonge675e922015-08-13 21:17:28 +0800449 subnet.start = "192.168.102.1"
450 subnet.end = "192.168.102.255"
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700451 # end change
lanqinglonge675e922015-08-13 21:17:28 +0800452 newsubnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700453 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800454 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700455 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
456 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800457 utilities.assert_equals(
458 expect='200',
459 actual=Poststatus,
460 onpass="Post Network Success",
461 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
462
463 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700464 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
465 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800466 utilities.assert_equals(
467 expect='202',
468 actual=Poststatus,
469 onpass="Post Subnet Success",
470 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
471
472 main.step( "Update Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700473 Putstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
474 'PUT', None, newsubnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800475 utilities.assert_equals(
476 expect='203',
477 actual=Putstatus,
478 onpass="Update Subnet Success",
479 onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
480
481 main.step( "Get Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700482 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
483 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800484 utilities.assert_equals(
485 expect='200',
486 actual=Getstatus,
487 onpass="Get Subnet Success",
488 onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
489
490 IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
491 TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
492 Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
493
494 main.step( "Compare Subnet Data" )
495 Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
496 utilities.assert_equals(
497 expect=True,
498 actual=Cmpresult,
499 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700500 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
501 ",Tenant id compare:" + str( TanantIDcmpresult ) +
lanqinglonge675e922015-08-13 21:17:28 +0800502 ",Pool compare:" + str( Poolcmpresult ) )
503
504 main.step( "Delete Subnet via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700505 deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/',
506 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800507 utilities.assert_equals(
508 expect='200',
509 actual=deletestatus,
510 onpass="Delete Network Success",
511 onfail="Delete Network Failed" )
512
Jon Hallf52840a2017-05-24 16:49:52 -0700513 if not Cmpresult:
lanqinglonge675e922015-08-13 21:17:28 +0800514 main.log.error( "Update Subnet compare failed" )
515
516 def CASE7( self, main ):
lanqinglonge675e922015-08-13 21:17:28 +0800517 """
518 Test Delete Subnet
519 """
520 import os
521
522 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700523 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
524 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
lanqinglonge675e922015-08-13 21:17:28 +0800525 except ImportError:
526 main.log.exception( "Something wrong with import file or code error." )
527 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700528 main.cleanAndExit()
lanqinglonge675e922015-08-13 21:17:28 +0800529
530 main.log.info( "ONOS Subnet Delete test Start" )
531 main.case( "Virtual Network NBI Test - Subnet" )
532 main.caseExplanation = "Test Subnet Delete NBI " +\
533 "Verify Stored Data is Null after Delete"
534
Jon Hallf52840a2017-05-24 16:49:52 -0700535 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
536 port = main.params[ 'HTTP' ][ 'port' ]
537 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglonge675e922015-08-13 21:17:28 +0800538
lanqinglongca0a0ee2015-09-22 16:19:08 +0800539 main.log.info( "Generate Post Data" )
lanqinglonge675e922015-08-13 21:17:28 +0800540 network = NetworkData()
541 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
542 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
543 subnet = SubnetData()
544 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
545 subnet.tenant_id = network.tenant_id
546 subnet.network_id = network.id
547
548 networkpostdata = network.DictoJson()
549 subnetpostdata = subnet.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700550 ctrl = main.Cluster.active( 0 )
lanqinglonge675e922015-08-13 21:17:28 +0800551 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700552 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/',
553 'POST', None, networkpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800554 utilities.assert_equals(
555 expect='200',
556 actual=Poststatus,
557 onpass="Post Network Success",
558 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
559
560 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700561 Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/',
562 'POST', None, subnetpostdata )
lanqinglonge675e922015-08-13 21:17:28 +0800563 utilities.assert_equals(
564 expect='202',
565 actual=Poststatus,
566 onpass="Post Subnet Success",
567 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
568
569 main.step( "Delete Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700570 Deletestatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
571 'DELETE', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800572 utilities.assert_equals(
573 expect='201',
574 actual=Deletestatus,
575 onpass="Delete Subnet Success",
576 onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
577
578 main.step( "Get Subnet Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700579 Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/',
580 'GET', None, None )
lanqinglonge675e922015-08-13 21:17:28 +0800581 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800582 expect='Subnet is not found',
lanqinglonge675e922015-08-13 21:17:28 +0800583 actual=result,
584 onpass="Get Subnet Success",
585 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
586
sunyulinf16bb8d2015-09-29 20:21:16 +0800587 if result != 'Subnet is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800588 main.log.error( "Delete Subnet failed" )
589
590 def CASE8( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800591 """
592 Test Post Port
593 """
594 import os
595
596 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700597 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
598 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
599 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800600 except ImportError:
601 main.log.exception( "Something wrong with import file or code error." )
602 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700603 main.cleanAndExit()
lanqinglongd0dda2e2015-08-25 11:02:48 +0800604
605 main.log.info( "ONOS Port Post test Start" )
606 main.case( "Virtual Network NBI Test - Port" )
607 main.caseExplanation = "Test Port Post NBI " +\
608 "Verify Stored Data is same with Post Data"
609
Jon Hallf52840a2017-05-24 16:49:52 -0700610 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
611 httpport = main.params[ 'HTTP' ][ 'port' ]
612 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800613
lanqinglongca0a0ee2015-09-22 16:19:08 +0800614 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800615 network = NetworkData()
616 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
617 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
618 subnet = SubnetData()
619 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
620 subnet.tenant_id = network.tenant_id
621 subnet.network_id = network.id
622 port = VirtualPortData()
623 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
624 port.subnet_id = subnet.id
625 port.tenant_id = network.tenant_id
626 port.network_id = network.id
627
628 networkpostdata = network.DictoJson()
629 subnetpostdata = subnet.DictoJson()
630 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700631 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800632 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700633 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
634 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800635 utilities.assert_equals(
636 expect='200',
637 actual=Poststatus,
638 onpass="Post Network Success",
639 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
640
641 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700642 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
643 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800644 utilities.assert_equals(
645 expect='202',
646 actual=Poststatus,
647 onpass="Post Subnet Success",
648 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
649
650 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700651 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
652 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800653 utilities.assert_equals(
654 expect='200',
655 actual=Poststatus,
656 onpass="Post Port Success",
657 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
658
659 main.step( "Get Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700660 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
661 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800662 utilities.assert_equals(
663 expect='200',
664 actual=Getstatus,
665 onpass="Get Port Success",
666 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
667
668 main.step( "Compare Post Port Data" )
669 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
670 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
671 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
672 fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
673
674 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
675 utilities.assert_equals(
676 expect=True,
677 actual=Cmpresult,
678 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700679 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
680 ",Tenant id compare:" + str( TanantIDcmpresult ) +
681 ",Network id compare:" + str( NetoworkIDcmpresult ) +
lanqinglongd0dda2e2015-08-25 11:02:48 +0800682 ",FixIp compare:" + str( fixedIpresult ) )
683
684 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700685 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
686 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800687 utilities.assert_equals(
688 expect='200',
689 actual=deletestatus,
690 onpass="Delete Network Success",
691 onfail="Delete Network Failed" )
692
Jon Hallf52840a2017-05-24 16:49:52 -0700693 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800694 main.log.error( "Post port compare failed" )
695
696 def CASE9( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800697 """
698 Test Update Port
699 """
700 import os
701
702 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700703 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
704 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
705 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800706 except ImportError:
707 main.log.exception( "Something wrong with import file or code error." )
708 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700709 main.cleanAndExit()
lanqinglongd0dda2e2015-08-25 11:02:48 +0800710
711 main.log.info( "ONOS Port Update test Start" )
712 main.case( "Virtual Network NBI Test - Port" )
713 main.caseExplanation = "Test Port Update NBI " +\
714 "Verify Stored Data is same with New Post Data"
715
Jon Hallf52840a2017-05-24 16:49:52 -0700716 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
717 httpport = main.params[ 'HTTP' ][ 'port' ]
718 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800719
lanqinglongca0a0ee2015-09-22 16:19:08 +0800720 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800721 network = NetworkData()
722 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
723 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
724 subnet = SubnetData()
725 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
726 subnet.tenant_id = network.tenant_id
727 subnet.network_id = network.id
728 port = VirtualPortData()
729 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
730 port.subnet_id = subnet.id
731 port.tenant_id = network.tenant_id
732 port.network_id = network.id
733 port.name = "onos"
734
735 networkpostdata = network.DictoJson()
736 subnetpostdata = subnet.DictoJson()
737 portpostdata = port.DictoJson()
738
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700739 # create update data
lanqinglongd0dda2e2015-08-25 11:02:48 +0800740 port.name = "onos-new"
741 newportpostdata = port.DictoJson()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700742 # end
Devin Lim142b5342017-07-20 15:22:39 -0700743 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800744 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700745 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
746 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800747 utilities.assert_equals(
748 expect='200',
749 actual=Poststatus,
750 onpass="Post Network Success",
751 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
752
753 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700754 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
755 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800756 utilities.assert_equals(
757 expect='202',
758 actual=Poststatus,
759 onpass="Post Subnet Success",
760 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
761
762 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700763 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
764 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800765 utilities.assert_equals(
766 expect='200',
767 actual=Poststatus,
768 onpass="Post Port Success",
769 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
770
771 main.step( "Update Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700772 Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
773 'PUT', None, newportpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800774 utilities.assert_equals(
775 expect='200',
776 actual=Poststatus,
777 onpass="Update Port Success",
778 onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) )
779
780 main.step( "Get Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700781 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
782 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800783 utilities.assert_equals(
784 expect='200',
785 actual=Getstatus,
786 onpass="Get Port Success",
787 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
788
789 main.step( "Compare Update Port Data" )
790 IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
791 TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
792 NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
793 Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' )
794
795 Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult
796 utilities.assert_equals(
797 expect=True,
798 actual=Cmpresult,
799 onpass="Compare Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700800 onfail="Compare Failed:ID compare:" + str( IDcmpresult ) +
801 ",Tenant id compare:" + str( TanantIDcmpresult ) +
802 ",Network id compare:" + str( NetoworkIDcmpresult ) +
803 ",Name compare:" + str( Nameresult ) )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800804
805 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700806 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
807 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800808 utilities.assert_equals(
809 expect='200',
810 actual=deletestatus,
811 onpass="Delete Network Success",
812 onfail="Delete Network Failed" )
813
Jon Hallf52840a2017-05-24 16:49:52 -0700814 if not Cmpresult:
lanqinglongd0dda2e2015-08-25 11:02:48 +0800815 main.log.error( "Update port compare failed" )
816
817 def CASE10( self, main ):
lanqinglongd0dda2e2015-08-25 11:02:48 +0800818 """
819 Test Delete Port
820 """
821 import os
822
823 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700824 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
825 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
826 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
lanqinglongd0dda2e2015-08-25 11:02:48 +0800827 except ImportError:
828 main.log.exception( "Something wrong with import file or code error." )
829 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700830 main.cleanAndExit()
lanqinglongd0dda2e2015-08-25 11:02:48 +0800831
832 main.log.info( "ONOS Port Delete test Start" )
833 main.case( "Virtual Network NBI Test - Port" )
834 main.caseExplanation = "Test Port Delete NBI " +\
835 "Verify port delete success"
836
Jon Hallf52840a2017-05-24 16:49:52 -0700837 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
838 httpport = main.params[ 'HTTP' ][ 'port' ]
839 path = main.params[ 'HTTP' ][ 'path' ]
lanqinglongd0dda2e2015-08-25 11:02:48 +0800840
lanqinglongca0a0ee2015-09-22 16:19:08 +0800841 main.log.info( "Generate Post Data" )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800842 network = NetworkData()
843 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
844 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
845 subnet = SubnetData()
846 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
847 subnet.tenant_id = network.tenant_id
848 subnet.network_id = network.id
849 port = VirtualPortData()
850 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
851 port.subnet_id = subnet.id
852 port.tenant_id = network.tenant_id
853 port.network_id = network.id
854
855 networkpostdata = network.DictoJson()
856 subnetpostdata = subnet.DictoJson()
857 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -0700858 ctrl = main.Cluster.active( 0 )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800859 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700860 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
861 'POST', None, networkpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800862 utilities.assert_equals(
863 expect='200',
864 actual=Poststatus,
865 onpass="Post Network Success",
866 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
867
868 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -0700869 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
870 'POST', None, subnetpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800871 utilities.assert_equals(
872 expect='202',
873 actual=Poststatus,
874 onpass="Post Subnet Success",
875 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
876
877 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700878 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
879 'POST', None, portpostdata )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800880 utilities.assert_equals(
881 expect='200',
882 actual=Poststatus,
883 onpass="Post Port Success",
884 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
885
886 main.step( "Delete Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700887 Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
888 'Delete', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800889 utilities.assert_equals(
890 expect='200',
891 actual=Poststatus,
892 onpass="Delete Port Success",
893 onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) )
894
895 main.step( "Get Port Data is NULL" )
Devin Lim142b5342017-07-20 15:22:39 -0700896 Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/',
897 'GET', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800898 utilities.assert_equals(
sunyulinf16bb8d2015-09-29 20:21:16 +0800899 expect='VirtualPort is not found',
lanqinglongd0dda2e2015-08-25 11:02:48 +0800900 actual=result,
901 onpass="Get Port Success",
902 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
903
sunyulinf16bb8d2015-09-29 20:21:16 +0800904 if result != 'VirtualPort is not found':
lanqinglongd0dda2e2015-08-25 11:02:48 +0800905 main.log.error( "Delete Port failed" )
906
907 main.step( "Clean Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700908 deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/',
909 'DELETE', None, None )
lanqinglongd0dda2e2015-08-25 11:02:48 +0800910 utilities.assert_equals(
911 expect='200',
912 actual=deletestatus,
913 onpass="Delete Network Success",
Jon Hallf52840a2017-05-24 16:49:52 -0700914 onfail="Delete Network Failed" )
ligenyud4ae1be2015-09-28 20:03:13 +0800915
Jon Hallf52840a2017-05-24 16:49:52 -0700916 def CASE11( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +0800917 """
918 Test Post Error Json Create Network
919 """
920 import os
921
922 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700923 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
ligenyud4ae1be2015-09-28 20:03:13 +0800924 except ImportError:
925 main.log.exception( "Something wrong with import file or code error." )
926 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700927 main.cleanAndExit()
ligenyud4ae1be2015-09-28 20:03:13 +0800928
929 main.log.info( "ONOS Post Error Json Create Network test Start" )
930 main.case( "Virtual Network NBI Test - Network" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700931 main.caseExplanation = "Test Network Post With Error json The wrong Json can't post network successfully"
ligenyud4ae1be2015-09-28 20:03:13 +0800932
Jon Hallf52840a2017-05-24 16:49:52 -0700933 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
934 port = main.params[ 'HTTP' ][ 'port' ]
935 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +0800936
937 main.step( "Generate Post Data" )
938 network = NetworkData()
939 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
940 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700941 # 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 +0800942 network.admin_state_up = 'tttttttttt'
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700943 # The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post.
ligenyud4ae1be2015-09-28 20:03:13 +0800944 network.routerExternal = 'ffffffffffff'
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700945 # The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post.
ligenyud4ae1be2015-09-28 20:03:13 +0800946 network.shared = 'ffffffffffffff'
947 postdata = network.DictoJson()
948
949 main.step( "Post Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -0700950 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
951 'POST', None, postdata )
ligenyud4ae1be2015-09-28 20:03:13 +0800952
953 utilities.assert_equals(
954 expect='500',
955 actual=Poststatus,
956 onpass="The Json is wrong,can't post",
957 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +0800958
Jon Hallf52840a2017-05-24 16:49:52 -0700959 def CASE12( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +0800960 """
961 Test Post Error Json Create Subnet
962 """
963 import os
964
965 try:
Jon Hall53c5e662016-04-13 16:06:56 -0700966 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
967 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
ligenyud4ae1be2015-09-28 20:03:13 +0800968 except ImportError:
969 main.log.exception( "Something wrong with import file or code error." )
970 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700971 main.cleanAndExit()
ligenyud4ae1be2015-09-28 20:03:13 +0800972
973 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
974 main.case( "Virtual Network NBI Test - Subnet" )
975 main.caseExplanation = "Test Subnet Post With Error json " +\
976 "The wrong Json can't post network successfully"
977
Jon Hallf52840a2017-05-24 16:49:52 -0700978 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
979 port = main.params[ 'HTTP' ][ 'port' ]
980 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +0800981
982 main.step( "Generate Post Data" )
983 network = NetworkData()
984 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
985 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
986 subnet = SubnetData()
987 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700988 # 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 +0800989 subnet.enable_dhcp = 'tttttttttttttt'
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700990 # 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 +0800991 subnet.shared = 'ffffffffffffff'
992 subnet.tenant_id = network.tenant_id
993 subnet.network_id = network.id
994
995 networkpostdata = network.DictoJson()
996 subnetpostdata = subnet.DictoJson()
997
998 main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -0700999 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/',
1000 'POST', None, networkpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001001 utilities.assert_equals(
1002 expect='200',
1003 actual=Poststatus,
1004 onpass="Post Network Success",
1005 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1006
1007 main.step( "Post Subnet Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -07001008 Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'subnets/',
1009 'POST', None, subnetpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001010 utilities.assert_equals(
1011 expect='500',
1012 actual=Poststatus,
1013 onpass="The Json is wrong,can't post",
1014 onfail="Wrong Json can post successfully " )
ligenyud4ae1be2015-09-28 20:03:13 +08001015
Jon Hallf52840a2017-05-24 16:49:52 -07001016 def CASE13( self, main ):
ligenyud4ae1be2015-09-28 20:03:13 +08001017 """
1018 Test Post Error Json Create Virtualport
1019 """
1020 import os
1021
1022 try:
Jon Hall53c5e662016-04-13 16:06:56 -07001023 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData
1024 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData
1025 from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
ligenyud4ae1be2015-09-28 20:03:13 +08001026 except ImportError:
1027 main.log.exception( "Something wrong with import file or code error." )
1028 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -07001029 main.cleanAndExit()
ligenyud4ae1be2015-09-28 20:03:13 +08001030
1031 main.log.info( "ONOS Post Error Json Create Subnet test Start" )
1032 main.case( "Virtual Network NBI Test - Port" )
1033 main.caseExplanation = "Test Subnet Post With Error json " +\
1034 "The wrong Json can't create port successfully"
1035
Jon Hallf52840a2017-05-24 16:49:52 -07001036 ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
1037 httpport = main.params[ 'HTTP' ][ 'port' ]
1038 path = main.params[ 'HTTP' ][ 'path' ]
ligenyud4ae1be2015-09-28 20:03:13 +08001039
1040 main.step( "Generate Post Data" )
1041 network = NetworkData()
1042 network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
1043 network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
1044 subnet = SubnetData()
1045 subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
1046 subnet.tenant_id = network.tenant_id
1047 subnet.network_id = network.id
1048 port = VirtualPortData()
1049 port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
1050 port.subnet_id = subnet.id
1051 port.tenant_id = network.tenant_id
1052 port.network_id = network.id
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001053 # The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post.
ligenyud4ae1be2015-09-28 20:03:13 +08001054 port.adminStateUp = 'tttttttttttt'
1055
1056 networkpostdata = network.DictoJson()
1057 subnetpostdata = subnet.DictoJson()
1058 portpostdata = port.DictoJson()
Devin Lim142b5342017-07-20 15:22:39 -07001059 ctrl = main.Cluster.active( 0 )
ligenyud4ae1be2015-09-28 20:03:13 +08001060 main.step( "Post Network Data via HTTP(Post port need post network)" )
Devin Lim142b5342017-07-20 15:22:39 -07001061 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/',
1062 'POST', None, networkpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001063 utilities.assert_equals(
1064 expect='200',
1065 actual=Poststatus,
1066 onpass="Post Network Success",
1067 onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
1068
1069 main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
Devin Lim142b5342017-07-20 15:22:39 -07001070 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/',
1071 'POST', None, subnetpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001072 utilities.assert_equals(
1073 expect='202',
1074 actual=Poststatus,
1075 onpass="Post Subnet Success",
1076 onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
1077
1078 main.step( "Post Port Data via HTTP" )
Devin Lim142b5342017-07-20 15:22:39 -07001079 Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/',
1080 'POST', None, portpostdata )
ligenyud4ae1be2015-09-28 20:03:13 +08001081 utilities.assert_equals(
1082 expect='500',
1083 actual=Poststatus,
1084 onpass="The Json is wrong,can't post",
Jon Hallce9c01e2015-10-22 16:39:02 +00001085 onfail="Wrong Json can post successfully" )