lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 2 | Copyright 2015 Open Networking Foundation (ONF) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 | """ |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 23 | Description: This test is to determine if North bound |
| 24 | can handle the request |
| 25 | |
| 26 | List of test cases: |
| 27 | CASE1 - Variable initialization and optional pull and build ONOS package |
| 28 | CASE2 - Create Network northbound test |
| 29 | CASE3 - Update Network northbound test |
| 30 | CASE4 - Delete Network northbound test |
| 31 | CASE5 - Create Subnet northbound test |
| 32 | CASE6 - Update Subnet northbound test |
| 33 | CASE7 - Delete Subnet northbound test |
| 34 | CASE8 - Create Virtualport northbound test |
| 35 | CASE9 - Update Virtualport northbound test |
| 36 | CASE10 - Delete Virtualport northbound test |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 37 | CASE11 - Post Error Json Create Network test |
| 38 | CASE12 - Post Error Json Create Subnet test |
| 39 | CASE13 - Post Error Json Create Virtualport test |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 40 | |
| 41 | lanqinglong@huawei.com |
| 42 | """ |
| 43 | import os |
| 44 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 45 | |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 46 | class 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 | """ |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 68 | import time |
| 69 | import os |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 70 | main.log.info( "ONOS Single node Start " + |
| 71 | "VirtualNet Northbound test - initialization" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 72 | try: |
| 73 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 74 | main.testSetUp = ONOSSetup() |
| 75 | except ImportError: |
| 76 | main.log.error( "ONOSSetup not found. exiting the test" ) |
| 77 | main.exit() |
| 78 | main.testSetUp.envSetupDescription() |
| 79 | stepResult = main.FALSE |
| 80 | try: |
| 81 | main.apps = main.params['ENV']['cellApps'] |
| 82 | cellName = main.params['ENV']['cellName'] |
| 83 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 84 | stepResult = main.testSetUp.envSetup() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 85 | except Exception as e: |
| 86 | main.testSetUp.envSetupException( e ) |
| 87 | main.testSetUp.evnSetupConclusion( stepResult ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 88 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 89 | main.maxNodes = 1 |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 90 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 91 | cliResults = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, |
| 92 | cellName=cellName, removeLog=True ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 93 | if cliResults == main.FALSE: |
| 94 | main.log.error( "Failed to start ONOS, stopping test" ) |
| 95 | main.cleanup() |
| 96 | main.exit() |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 97 | |
| 98 | main.step( "App Ids check" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 99 | appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck() |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 100 | if appCheck != main.TRUE: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 101 | main.log.warn( main.Cluster.active( 0 ).CLI.apps() ) |
| 102 | main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 103 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 104 | onpass="App Ids seem to be correct", |
| 105 | onfail="Something is wrong with app Ids" ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 106 | |
GlennRC | a0c395f | 2015-12-03 14:04:56 -0800 | [diff] [blame] | 107 | main.step( "Install org.onosproject.vtn app" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 108 | installResults = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.vtn" ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 109 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 110 | onpass="Install org.onosproject.vtn successful", |
| 111 | onfail="Install org.onosproject.vtn app failed" ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 112 | |
| 113 | time.sleep( main.startUpSleep ) |
| 114 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 115 | def CASE2( self, main ): |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 116 | """ |
| 117 | Test Post Network |
| 118 | """ |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 119 | import os |
| 120 | |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 121 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 122 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 123 | except ImportError: |
| 124 | main.log.exception( "Something wrong with import file or code error." ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 125 | main.log.info( "Import Error, please check!" ) |
| 126 | main.cleanup() |
| 127 | main.exit() |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 128 | |
| 129 | main.log.info( "ONOS Network Post test Start" ) |
| 130 | main.case( "Virtual Network NBI Test - Network" ) |
| 131 | main.caseExplanation = "Test Network Post NBI " +\ |
| 132 | "Verify Post Data same with Stored Data" |
| 133 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 134 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 135 | port = main.params[ 'HTTP' ][ 'port' ] |
| 136 | path = main.params[ 'HTTP' ][ 'path' ] |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 137 | |
lanqinglong | ca0a0ee | 2015-09-22 16:19:08 +0800 | [diff] [blame] | 138 | main.log.info( "Generate Post Data" ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 139 | network = NetworkData() |
| 140 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 141 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 142 | postdata = network.DictoJson() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 143 | ctrl = main.Cluster.active( 0 ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 144 | main.step( "Post Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 145 | Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/', |
| 146 | 'POST', None, postdata ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 147 | |
| 148 | utilities.assert_equals( |
| 149 | expect='200', |
| 150 | actual=Poststatus, |
| 151 | onpass="Post Success", |
| 152 | onfail="Post Failed " + str( Poststatus ) + str( result ) ) |
| 153 | |
| 154 | main.step( "Get Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 155 | Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/', |
| 156 | 'GET', None, None ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 157 | utilities.assert_equals( |
| 158 | expect='200', |
| 159 | actual=Getstatus, |
| 160 | onpass="Get Success", |
| 161 | onfail="Get Failed " + str( Getstatus ) + str( result ) ) |
| 162 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 163 | main.log.info( "Post Network Data is :%s\nGet Network Data is:%s" % ( postdata, result ) ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 164 | |
| 165 | main.step( "Compare Send Id and Get Id" ) |
| 166 | IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' ) |
| 167 | TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' ) |
| 168 | Cmpresult = IDcmpresult and TanantIDcmpresult |
| 169 | |
| 170 | utilities.assert_equals( |
| 171 | expect=True, |
| 172 | actual=Cmpresult, |
| 173 | onpass="Compare Success", |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 174 | onfail="Compare Failed:ID compare: " + str( IDcmpresult ) + |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 175 | ",Tenant id compare :" + str( TanantIDcmpresult ) ) |
| 176 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 177 | deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/', |
| 178 | 'DELETE', None, None ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 179 | utilities.assert_equals( |
| 180 | expect='200', |
| 181 | actual=deletestatus, |
| 182 | onpass="Delete Network Success", |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 183 | onfail="Delete Network Failed" ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 184 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 185 | if not Cmpresult: |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 186 | main.log.error( "Post Network compare failed" ) |
| 187 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 188 | def CASE3( self, main ): |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 189 | """ |
| 190 | Test Update Network |
| 191 | """ |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 192 | import os |
| 193 | |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 194 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 195 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 196 | except ImportError: |
| 197 | main.log.exception( "Something wrong with import file or code error." ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 198 | main.log.info( "Import Error, please check!" ) |
| 199 | main.cleanup() |
| 200 | main.exit() |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 201 | |
| 202 | main.log.info( "ONOS Network Update test Start" ) |
| 203 | main.case( "Virtual Network NBI Test - Network" ) |
| 204 | main.caseExplanation = "Test Network Update NBI " +\ |
| 205 | "Verify Update Data same with Stored Data" |
| 206 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 207 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 208 | port = main.params[ 'HTTP' ][ 'port' ] |
| 209 | path = main.params[ 'HTTP' ][ 'path' ] |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 210 | |
lanqinglong | ca0a0ee | 2015-09-22 16:19:08 +0800 | [diff] [blame] | 211 | main.log.info( "Generate Post Data" ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 212 | network = NetworkData() |
| 213 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 214 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 215 | network.shared = False |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 216 | postdata = network.DictoJson() |
| 217 | |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 218 | network.shared = True |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 219 | postdatanew = network.DictoJson() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 220 | ctrl = main.Cluster.active( 0 ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 221 | main.step( "Post Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 222 | Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks', |
| 223 | 'POST', None, postdata ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 224 | utilities.assert_equals( |
| 225 | expect='200', |
| 226 | actual=Poststatus, |
| 227 | onpass="Post Success", |
| 228 | onfail="Post Failed " + str( Poststatus ) + str( result ) ) |
| 229 | |
| 230 | main.step( "Update Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 231 | Updatestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/', |
| 232 | 'PUT', None, postdatanew ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 233 | utilities.assert_equals( |
| 234 | expect='200', |
| 235 | actual=Updatestatus, |
| 236 | onpass="Update Success", |
| 237 | onfail="Update Failed " + str( Updatestatus ) + str( result ) ) |
| 238 | |
| 239 | main.step( "Get Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 240 | Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/', |
| 241 | 'GET', None, None ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 242 | utilities.assert_equals( |
| 243 | expect='200', |
| 244 | actual=Getstatus, |
| 245 | onpass="Get Success", |
| 246 | onfail="Get Failed " + str( Getstatus ) + str( result ) ) |
| 247 | |
| 248 | main.step( "Compare Update data." ) |
| 249 | IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' ) |
| 250 | TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' ) |
| 251 | Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' ) |
| 252 | |
| 253 | Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult |
| 254 | utilities.assert_equals( |
| 255 | expect=True, |
| 256 | actual=Cmpresult, |
| 257 | onpass="Compare Success", |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 258 | onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + |
| 259 | ",Tenant id compare:" + str( TanantIDcmpresult ) + |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 260 | ",Name compare:" + str( Shareresult ) ) |
| 261 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 262 | deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/', |
| 263 | 'DELETE', None, None ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 264 | |
| 265 | utilities.assert_equals( |
| 266 | expect='200', |
| 267 | actual=deletestatus, |
| 268 | onpass="Delete Network Success", |
| 269 | onfail="Delete Network Failed" ) |
| 270 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 271 | if not Cmpresult: |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 272 | main.log.error( "Update Network compare failed" ) |
| 273 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 274 | def CASE4( self, main ): |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 275 | """ |
| 276 | Test Delete Network |
| 277 | """ |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 278 | import os |
| 279 | |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 280 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 281 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 282 | except ImportError: |
| 283 | main.log.exception( "Something wrong with import file or code error." ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 284 | main.log.info( "Import Error, please check!" ) |
| 285 | main.cleanup() |
| 286 | main.exit() |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 287 | |
| 288 | main.log.info( "ONOS Network Delete test Start" ) |
| 289 | main.case( "Virtual Network NBI Test - Network" ) |
| 290 | main.caseExplanation = "Test Network Delete NBI " +\ |
| 291 | "Verify Stored Data is NULL after Delete" |
| 292 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 293 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 294 | port = main.params[ 'HTTP' ][ 'port' ] |
| 295 | path = main.params[ 'HTTP' ][ 'path' ] |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 296 | |
lanqinglong | ca0a0ee | 2015-09-22 16:19:08 +0800 | [diff] [blame] | 297 | main.log.info( "Generate Post Data" ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 298 | network = NetworkData() |
| 299 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 300 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 301 | postdata = network.DictoJson() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 302 | ctrl = main.Cluster.active( 0 ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 303 | main.step( "Post Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 304 | Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/', |
| 305 | 'POST', None, postdata ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 306 | utilities.assert_equals( |
| 307 | expect='200', |
| 308 | actual=Poststatus, |
| 309 | onpass="Post Success", |
| 310 | onfail="Post Failed " + str( Poststatus ) + str( result ) ) |
| 311 | |
| 312 | main.step( "Delete Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 313 | Deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/', |
| 314 | 'DELETE', None, None ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 315 | utilities.assert_equals( |
| 316 | expect='200', |
| 317 | actual=Deletestatus, |
| 318 | onpass="Delete Success", |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 319 | onfail="Delete Failed " + str( Deletestatus ) + str( result ) ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 320 | |
| 321 | main.step( "Get Data is NULL" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 322 | Getstatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/', |
| 323 | 'GET', None, None ) |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 324 | utilities.assert_equals( |
sunyulin | f16bb8d | 2015-09-29 20:21:16 +0800 | [diff] [blame] | 325 | expect='Network is not found', |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 326 | actual=result, |
| 327 | onpass="Get Success", |
| 328 | onfail="Get Failed " + str( Getstatus ) + str( result ) ) |
| 329 | |
sunyulin | f16bb8d | 2015-09-29 20:21:16 +0800 | [diff] [blame] | 330 | if result != 'Network is not found': |
lanqinglong | 77124b0 | 2015-08-06 11:47:38 +0800 | [diff] [blame] | 331 | main.log.error( "Delete Network failed" ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 332 | |
| 333 | def CASE5( self, main ): |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 334 | """ |
| 335 | Test Post Subnet |
| 336 | """ |
| 337 | import os |
| 338 | |
| 339 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 340 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
| 341 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 342 | except ImportError: |
| 343 | main.log.exception( "Something wrong with import file or code error." ) |
| 344 | main.log.info( "Import Error, please check!" ) |
| 345 | main.cleanup() |
| 346 | main.exit() |
| 347 | |
| 348 | main.log.info( "ONOS Subnet Post test Start" ) |
| 349 | main.case( "Virtual Network NBI Test - Subnet" ) |
| 350 | main.caseExplanation = "Test Subnet Post NBI " +\ |
| 351 | "Verify Stored Data is same with Post Data" |
| 352 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 353 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 354 | port = main.params[ 'HTTP' ][ 'port' ] |
| 355 | path = main.params[ 'HTTP' ][ 'path' ] |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 356 | |
lanqinglong | ca0a0ee | 2015-09-22 16:19:08 +0800 | [diff] [blame] | 357 | main.log.info( "Generate Post Data" ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 358 | network = NetworkData() |
| 359 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 360 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 361 | subnet = SubnetData() |
| 362 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 363 | subnet.tenant_id = network.tenant_id |
| 364 | subnet.network_id = network.id |
| 365 | |
| 366 | networkpostdata = network.DictoJson() |
| 367 | subnetpostdata = subnet.DictoJson() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 368 | ctrl = main.Cluster.active( 0 ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 369 | main.step( "Post Network Data via HTTP(Post Subnet need post network)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 370 | Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/', |
| 371 | 'POST', None, networkpostdata ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 372 | utilities.assert_equals( |
| 373 | expect='200', |
| 374 | actual=Poststatus, |
| 375 | onpass="Post Network Success", |
| 376 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 377 | |
| 378 | main.step( "Post Subnet Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 379 | Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/', |
| 380 | 'POST', None, subnetpostdata ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 381 | utilities.assert_equals( |
| 382 | expect='202', |
| 383 | actual=Poststatus, |
| 384 | onpass="Post Subnet Success", |
| 385 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 386 | |
| 387 | main.step( "Get Subnet Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 388 | Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/', |
| 389 | 'GET', None, None ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 390 | utilities.assert_equals( |
| 391 | expect='200', |
| 392 | actual=Getstatus, |
| 393 | onpass="Get Subnet Success", |
| 394 | onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) ) |
| 395 | |
| 396 | IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' ) |
| 397 | TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' ) |
| 398 | NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' ) |
| 399 | |
| 400 | main.step( "Compare Post Subnet Data via HTTP" ) |
| 401 | Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult |
| 402 | utilities.assert_equals( |
| 403 | expect=True, |
| 404 | actual=Cmpresult, |
| 405 | onpass="Compare Success", |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 406 | onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + |
| 407 | ",Tenant id compare:" + str( TanantIDcmpresult ) + |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 408 | ",Network id compare:" + str( NetoworkIDcmpresult ) ) |
| 409 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 410 | deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/', |
| 411 | 'DELETE', None, None ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 412 | utilities.assert_equals( |
| 413 | expect='200', |
| 414 | actual=deletestatus, |
| 415 | onpass="Delete Network Success", |
| 416 | onfail="Delete Network Failed" ) |
| 417 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 418 | if not Cmpresult: |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 419 | main.log.error( "Post Subnet compare failed" ) |
| 420 | |
| 421 | def CASE6( self, main ): |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 422 | """ |
| 423 | Test Post Subnet |
| 424 | """ |
| 425 | import os |
| 426 | |
| 427 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 428 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
| 429 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 430 | except ImportError: |
| 431 | main.log.exception( "Something wrong with import file or code error." ) |
| 432 | main.log.info( "Import Error, please check!" ) |
| 433 | main.cleanup() |
| 434 | main.exit() |
| 435 | |
| 436 | main.log.info( "ONOS Subnet Update test Start" ) |
| 437 | main.case( "Virtual Network NBI Test - Subnet" ) |
| 438 | main.caseExplanation = "Test Subnet Update NBI " +\ |
| 439 | "Verify Stored Data is same with Update Data" |
| 440 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 441 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 442 | port = main.params[ 'HTTP' ][ 'port' ] |
| 443 | path = main.params[ 'HTTP' ][ 'path' ] |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 444 | |
lanqinglong | ca0a0ee | 2015-09-22 16:19:08 +0800 | [diff] [blame] | 445 | main.log.info( "Generate Post Data" ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 446 | network = NetworkData() |
| 447 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 448 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 449 | subnet = SubnetData() |
| 450 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 451 | subnet.tenant_id = network.tenant_id |
| 452 | subnet.network_id = network.id |
| 453 | subnet.start = "192.168.2.1" |
| 454 | subnet.end = "192.168.2.255" |
| 455 | networkpostdata = network.DictoJson() |
| 456 | subnetpostdata = subnet.DictoJson() |
| 457 | |
| 458 | #Change allocation_poolsdata scope |
| 459 | subnet.start = "192.168.102.1" |
| 460 | subnet.end = "192.168.102.255" |
| 461 | #end change |
| 462 | newsubnetpostdata = subnet.DictoJson() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 463 | ctrl = main.Cluster.active( 0 ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 464 | main.step( "Post Network Data via HTTP(Post Subnet need post network)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 465 | Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/', |
| 466 | 'POST', None, networkpostdata ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 467 | utilities.assert_equals( |
| 468 | expect='200', |
| 469 | actual=Poststatus, |
| 470 | onpass="Post Network Success", |
| 471 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 472 | |
| 473 | main.step( "Post Subnet Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 474 | Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/', |
| 475 | 'POST', None, subnetpostdata ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 476 | utilities.assert_equals( |
| 477 | expect='202', |
| 478 | actual=Poststatus, |
| 479 | onpass="Post Subnet Success", |
| 480 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 481 | |
| 482 | main.step( "Update Subnet Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 483 | Putstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/', |
| 484 | 'PUT', None, newsubnetpostdata ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 485 | utilities.assert_equals( |
| 486 | expect='203', |
| 487 | actual=Putstatus, |
| 488 | onpass="Update Subnet Success", |
| 489 | onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) ) |
| 490 | |
| 491 | main.step( "Get Subnet Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 492 | Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/', |
| 493 | 'GET', None, None ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 494 | utilities.assert_equals( |
| 495 | expect='200', |
| 496 | actual=Getstatus, |
| 497 | onpass="Get Subnet Success", |
| 498 | onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) ) |
| 499 | |
| 500 | IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' ) |
| 501 | TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' ) |
| 502 | Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' ) |
| 503 | |
| 504 | main.step( "Compare Subnet Data" ) |
| 505 | Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult |
| 506 | utilities.assert_equals( |
| 507 | expect=True, |
| 508 | actual=Cmpresult, |
| 509 | onpass="Compare Success", |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 510 | onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + |
| 511 | ",Tenant id compare:" + str( TanantIDcmpresult ) + |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 512 | ",Pool compare:" + str( Poolcmpresult ) ) |
| 513 | |
| 514 | main.step( "Delete Subnet via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 515 | deletestatus, result = ctrl.REST.send( ctrlip, port, network.id, path + 'networks/', |
| 516 | 'DELETE', None, None ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 517 | utilities.assert_equals( |
| 518 | expect='200', |
| 519 | actual=deletestatus, |
| 520 | onpass="Delete Network Success", |
| 521 | onfail="Delete Network Failed" ) |
| 522 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 523 | if not Cmpresult: |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 524 | main.log.error( "Update Subnet compare failed" ) |
| 525 | |
| 526 | def CASE7( self, main ): |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 527 | """ |
| 528 | Test Delete Subnet |
| 529 | """ |
| 530 | import os |
| 531 | |
| 532 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 533 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
| 534 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 535 | except ImportError: |
| 536 | main.log.exception( "Something wrong with import file or code error." ) |
| 537 | main.log.info( "Import Error, please check!" ) |
| 538 | main.cleanup() |
| 539 | main.exit() |
| 540 | |
| 541 | main.log.info( "ONOS Subnet Delete test Start" ) |
| 542 | main.case( "Virtual Network NBI Test - Subnet" ) |
| 543 | main.caseExplanation = "Test Subnet Delete NBI " +\ |
| 544 | "Verify Stored Data is Null after Delete" |
| 545 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 546 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 547 | port = main.params[ 'HTTP' ][ 'port' ] |
| 548 | path = main.params[ 'HTTP' ][ 'path' ] |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 549 | |
lanqinglong | ca0a0ee | 2015-09-22 16:19:08 +0800 | [diff] [blame] | 550 | main.log.info( "Generate Post Data" ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 551 | network = NetworkData() |
| 552 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 553 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 554 | subnet = SubnetData() |
| 555 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 556 | subnet.tenant_id = network.tenant_id |
| 557 | subnet.network_id = network.id |
| 558 | |
| 559 | networkpostdata = network.DictoJson() |
| 560 | subnetpostdata = subnet.DictoJson() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 561 | ctrl = main.Cluster.active( 0 ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 562 | main.step( "Post Network Data via HTTP(Post Subnet need post network)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 563 | Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'networks/', |
| 564 | 'POST', None, networkpostdata ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 565 | utilities.assert_equals( |
| 566 | expect='200', |
| 567 | actual=Poststatus, |
| 568 | onpass="Post Network Success", |
| 569 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 570 | |
| 571 | main.step( "Post Subnet Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 572 | Poststatus, result = ctrl.REST.send( ctrlip, port, '', path + 'subnets/', |
| 573 | 'POST', None, subnetpostdata ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 574 | utilities.assert_equals( |
| 575 | expect='202', |
| 576 | actual=Poststatus, |
| 577 | onpass="Post Subnet Success", |
| 578 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 579 | |
| 580 | main.step( "Delete Subnet Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 581 | Deletestatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/', |
| 582 | 'DELETE', None, None ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 583 | utilities.assert_equals( |
| 584 | expect='201', |
| 585 | actual=Deletestatus, |
| 586 | onpass="Delete Subnet Success", |
| 587 | onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) ) |
| 588 | |
| 589 | main.step( "Get Subnet Data is NULL" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 590 | Getstatus, result = ctrl.REST.send( ctrlip, port, subnet.id, path + 'subnets/', |
| 591 | 'GET', None, None ) |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 592 | utilities.assert_equals( |
sunyulin | f16bb8d | 2015-09-29 20:21:16 +0800 | [diff] [blame] | 593 | expect='Subnet is not found', |
lanqinglong | e675e92 | 2015-08-13 21:17:28 +0800 | [diff] [blame] | 594 | actual=result, |
| 595 | onpass="Get Subnet Success", |
| 596 | onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) ) |
| 597 | |
sunyulin | f16bb8d | 2015-09-29 20:21:16 +0800 | [diff] [blame] | 598 | if result != 'Subnet is not found': |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 599 | main.log.error( "Delete Subnet failed" ) |
| 600 | |
| 601 | def CASE8( self, main ): |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 602 | """ |
| 603 | Test Post Port |
| 604 | """ |
| 605 | import os |
| 606 | |
| 607 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 608 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
| 609 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData |
| 610 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 611 | except ImportError: |
| 612 | main.log.exception( "Something wrong with import file or code error." ) |
| 613 | main.log.info( "Import Error, please check!" ) |
| 614 | main.cleanup() |
| 615 | main.exit() |
| 616 | |
| 617 | main.log.info( "ONOS Port Post test Start" ) |
| 618 | main.case( "Virtual Network NBI Test - Port" ) |
| 619 | main.caseExplanation = "Test Port Post NBI " +\ |
| 620 | "Verify Stored Data is same with Post Data" |
| 621 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 622 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 623 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 624 | path = main.params[ 'HTTP' ][ 'path' ] |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 625 | |
lanqinglong | ca0a0ee | 2015-09-22 16:19:08 +0800 | [diff] [blame] | 626 | main.log.info( "Generate Post Data" ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 627 | network = NetworkData() |
| 628 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 629 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 630 | subnet = SubnetData() |
| 631 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 632 | subnet.tenant_id = network.tenant_id |
| 633 | subnet.network_id = network.id |
| 634 | port = VirtualPortData() |
| 635 | port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466" |
| 636 | port.subnet_id = subnet.id |
| 637 | port.tenant_id = network.tenant_id |
| 638 | port.network_id = network.id |
| 639 | |
| 640 | networkpostdata = network.DictoJson() |
| 641 | subnetpostdata = subnet.DictoJson() |
| 642 | portpostdata = port.DictoJson() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 643 | ctrl = main.Cluster.active( 0 ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 644 | main.step( "Post Network Data via HTTP(Post port need post network)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 645 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/', |
| 646 | 'POST', None, networkpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 647 | utilities.assert_equals( |
| 648 | expect='200', |
| 649 | actual=Poststatus, |
| 650 | onpass="Post Network Success", |
| 651 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 652 | |
| 653 | main.step( "Post Subnet Data via HTTP(Post port need post subnet)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 654 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/', |
| 655 | 'POST', None, subnetpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 656 | utilities.assert_equals( |
| 657 | expect='202', |
| 658 | actual=Poststatus, |
| 659 | onpass="Post Subnet Success", |
| 660 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 661 | |
| 662 | main.step( "Post Port Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 663 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/', |
| 664 | 'POST', None, portpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 665 | utilities.assert_equals( |
| 666 | expect='200', |
| 667 | actual=Poststatus, |
| 668 | onpass="Post Port Success", |
| 669 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 670 | |
| 671 | main.step( "Get Port Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 672 | Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/', |
| 673 | 'GET', None, None ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 674 | utilities.assert_equals( |
| 675 | expect='200', |
| 676 | actual=Getstatus, |
| 677 | onpass="Get Port Success", |
| 678 | onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) ) |
| 679 | |
| 680 | main.step( "Compare Post Port Data" ) |
| 681 | IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' ) |
| 682 | TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' ) |
| 683 | NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' ) |
| 684 | fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' ) |
| 685 | |
| 686 | Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult |
| 687 | utilities.assert_equals( |
| 688 | expect=True, |
| 689 | actual=Cmpresult, |
| 690 | onpass="Compare Success", |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 691 | onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + |
| 692 | ",Tenant id compare:" + str( TanantIDcmpresult ) + |
| 693 | ",Network id compare:" + str( NetoworkIDcmpresult ) + |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 694 | ",FixIp compare:" + str( fixedIpresult ) ) |
| 695 | |
| 696 | main.step( "Clean Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 697 | deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/', |
| 698 | 'DELETE', None, None ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 699 | utilities.assert_equals( |
| 700 | expect='200', |
| 701 | actual=deletestatus, |
| 702 | onpass="Delete Network Success", |
| 703 | onfail="Delete Network Failed" ) |
| 704 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 705 | if not Cmpresult: |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 706 | main.log.error( "Post port compare failed" ) |
| 707 | |
| 708 | def CASE9( self, main ): |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 709 | """ |
| 710 | Test Update Port |
| 711 | """ |
| 712 | import os |
| 713 | |
| 714 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 715 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
| 716 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData |
| 717 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 718 | except ImportError: |
| 719 | main.log.exception( "Something wrong with import file or code error." ) |
| 720 | main.log.info( "Import Error, please check!" ) |
| 721 | main.cleanup() |
| 722 | main.exit() |
| 723 | |
| 724 | main.log.info( "ONOS Port Update test Start" ) |
| 725 | main.case( "Virtual Network NBI Test - Port" ) |
| 726 | main.caseExplanation = "Test Port Update NBI " +\ |
| 727 | "Verify Stored Data is same with New Post Data" |
| 728 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 729 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 730 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 731 | path = main.params[ 'HTTP' ][ 'path' ] |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 732 | |
lanqinglong | ca0a0ee | 2015-09-22 16:19:08 +0800 | [diff] [blame] | 733 | main.log.info( "Generate Post Data" ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 734 | network = NetworkData() |
| 735 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 736 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 737 | subnet = SubnetData() |
| 738 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 739 | subnet.tenant_id = network.tenant_id |
| 740 | subnet.network_id = network.id |
| 741 | port = VirtualPortData() |
| 742 | port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466" |
| 743 | port.subnet_id = subnet.id |
| 744 | port.tenant_id = network.tenant_id |
| 745 | port.network_id = network.id |
| 746 | port.name = "onos" |
| 747 | |
| 748 | networkpostdata = network.DictoJson() |
| 749 | subnetpostdata = subnet.DictoJson() |
| 750 | portpostdata = port.DictoJson() |
| 751 | |
| 752 | #create update data |
| 753 | port.name = "onos-new" |
| 754 | newportpostdata = port.DictoJson() |
| 755 | #end |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 756 | ctrl = main.Cluster.active( 0 ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 757 | main.step( "Post Network Data via HTTP(Post port need post network)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 758 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/', |
| 759 | 'POST', None, networkpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 760 | utilities.assert_equals( |
| 761 | expect='200', |
| 762 | actual=Poststatus, |
| 763 | onpass="Post Network Success", |
| 764 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 765 | |
| 766 | main.step( "Post Subnet Data via HTTP(Post port need post subnet)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 767 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/', |
| 768 | 'POST', None, subnetpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 769 | utilities.assert_equals( |
| 770 | expect='202', |
| 771 | actual=Poststatus, |
| 772 | onpass="Post Subnet Success", |
| 773 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 774 | |
| 775 | main.step( "Post Port Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 776 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/', |
| 777 | 'POST', None, portpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 778 | utilities.assert_equals( |
| 779 | expect='200', |
| 780 | actual=Poststatus, |
| 781 | onpass="Post Port Success", |
| 782 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 783 | |
| 784 | main.step( "Update Port Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 785 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/', |
| 786 | 'PUT', None, newportpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 787 | utilities.assert_equals( |
| 788 | expect='200', |
| 789 | actual=Poststatus, |
| 790 | onpass="Update Port Success", |
| 791 | onfail="Update Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 792 | |
| 793 | main.step( "Get Port Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 794 | Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/', |
| 795 | 'GET', None, None ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 796 | utilities.assert_equals( |
| 797 | expect='200', |
| 798 | actual=Getstatus, |
| 799 | onpass="Get Port Success", |
| 800 | onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) ) |
| 801 | |
| 802 | main.step( "Compare Update Port Data" ) |
| 803 | IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' ) |
| 804 | TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' ) |
| 805 | NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' ) |
| 806 | Nameresult = subnet.JsonCompare( newportpostdata, result, 'port', 'name' ) |
| 807 | |
| 808 | Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and Nameresult |
| 809 | utilities.assert_equals( |
| 810 | expect=True, |
| 811 | actual=Cmpresult, |
| 812 | onpass="Compare Success", |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 813 | onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + |
| 814 | ",Tenant id compare:" + str( TanantIDcmpresult ) + |
| 815 | ",Network id compare:" + str( NetoworkIDcmpresult ) + |
| 816 | ",Name compare:" + str( Nameresult ) ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 817 | |
| 818 | main.step( "Clean Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 819 | deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/', |
| 820 | 'DELETE', None, None ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 821 | utilities.assert_equals( |
| 822 | expect='200', |
| 823 | actual=deletestatus, |
| 824 | onpass="Delete Network Success", |
| 825 | onfail="Delete Network Failed" ) |
| 826 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 827 | if not Cmpresult: |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 828 | main.log.error( "Update port compare failed" ) |
| 829 | |
| 830 | def CASE10( self, main ): |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 831 | """ |
| 832 | Test Delete Port |
| 833 | """ |
| 834 | import os |
| 835 | |
| 836 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 837 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
| 838 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData |
| 839 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 840 | except ImportError: |
| 841 | main.log.exception( "Something wrong with import file or code error." ) |
| 842 | main.log.info( "Import Error, please check!" ) |
| 843 | main.cleanup() |
| 844 | main.exit() |
| 845 | |
| 846 | main.log.info( "ONOS Port Delete test Start" ) |
| 847 | main.case( "Virtual Network NBI Test - Port" ) |
| 848 | main.caseExplanation = "Test Port Delete NBI " +\ |
| 849 | "Verify port delete success" |
| 850 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 851 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 852 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 853 | path = main.params[ 'HTTP' ][ 'path' ] |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 854 | |
lanqinglong | ca0a0ee | 2015-09-22 16:19:08 +0800 | [diff] [blame] | 855 | main.log.info( "Generate Post Data" ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 856 | network = NetworkData() |
| 857 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 858 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 859 | subnet = SubnetData() |
| 860 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 861 | subnet.tenant_id = network.tenant_id |
| 862 | subnet.network_id = network.id |
| 863 | port = VirtualPortData() |
| 864 | port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466" |
| 865 | port.subnet_id = subnet.id |
| 866 | port.tenant_id = network.tenant_id |
| 867 | port.network_id = network.id |
| 868 | |
| 869 | networkpostdata = network.DictoJson() |
| 870 | subnetpostdata = subnet.DictoJson() |
| 871 | portpostdata = port.DictoJson() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 872 | ctrl = main.Cluster.active( 0 ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 873 | main.step( "Post Network Data via HTTP(Post port need post network)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 874 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/', |
| 875 | 'POST', None, networkpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 876 | utilities.assert_equals( |
| 877 | expect='200', |
| 878 | actual=Poststatus, |
| 879 | onpass="Post Network Success", |
| 880 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 881 | |
| 882 | main.step( "Post Subnet Data via HTTP(Post port need post subnet)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 883 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/', |
| 884 | 'POST', None, subnetpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 885 | utilities.assert_equals( |
| 886 | expect='202', |
| 887 | actual=Poststatus, |
| 888 | onpass="Post Subnet Success", |
| 889 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 890 | |
| 891 | main.step( "Post Port Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 892 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/', |
| 893 | 'POST', None, portpostdata ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 894 | utilities.assert_equals( |
| 895 | expect='200', |
| 896 | actual=Poststatus, |
| 897 | onpass="Post Port Success", |
| 898 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 899 | |
| 900 | main.step( "Delete Port Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 901 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/', |
| 902 | 'Delete', None, None ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 903 | utilities.assert_equals( |
| 904 | expect='200', |
| 905 | actual=Poststatus, |
| 906 | onpass="Delete Port Success", |
| 907 | onfail="Delete Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 908 | |
| 909 | main.step( "Get Port Data is NULL" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 910 | Getstatus, result = ctrl.REST.send( ctrlip, httpport, port.id, path + 'ports/', |
| 911 | 'GET', None, None ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 912 | utilities.assert_equals( |
sunyulin | f16bb8d | 2015-09-29 20:21:16 +0800 | [diff] [blame] | 913 | expect='VirtualPort is not found', |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 914 | actual=result, |
| 915 | onpass="Get Port Success", |
| 916 | onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) ) |
| 917 | |
sunyulin | f16bb8d | 2015-09-29 20:21:16 +0800 | [diff] [blame] | 918 | if result != 'VirtualPort is not found': |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 919 | main.log.error( "Delete Port failed" ) |
| 920 | |
| 921 | main.step( "Clean Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 922 | deletestatus, result = ctrl.REST.send( ctrlip, httpport, network.id, path + 'networks/', |
| 923 | 'DELETE', None, None ) |
lanqinglong | d0dda2e | 2015-08-25 11:02:48 +0800 | [diff] [blame] | 924 | utilities.assert_equals( |
| 925 | expect='200', |
| 926 | actual=deletestatus, |
| 927 | onpass="Delete Network Success", |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 928 | onfail="Delete Network Failed" ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 929 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 930 | def CASE11( self, main ): |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 931 | """ |
| 932 | Test Post Error Json Create Network |
| 933 | """ |
| 934 | import os |
| 935 | |
| 936 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 937 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 938 | except ImportError: |
| 939 | main.log.exception( "Something wrong with import file or code error." ) |
| 940 | main.log.info( "Import Error, please check!" ) |
| 941 | main.cleanup() |
| 942 | main.exit() |
| 943 | |
| 944 | main.log.info( "ONOS Post Error Json Create Network test Start" ) |
| 945 | main.case( "Virtual Network NBI Test - Network" ) |
| 946 | main.caseExplanation = "Test Network Post With Error json " +\ |
| 947 | "The wrong Json can't post network successfully" |
| 948 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 949 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 950 | port = main.params[ 'HTTP' ][ 'port' ] |
| 951 | path = main.params[ 'HTTP' ][ 'path' ] |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 952 | |
| 953 | main.step( "Generate Post Data" ) |
| 954 | network = NetworkData() |
| 955 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 956 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 957 | #The network.admin_state_up should be True or False,when the admin_state_up is 'tttttttttt',the Json can't post. |
| 958 | network.admin_state_up = 'tttttttttt' |
| 959 | #The network.routerExternal should be True or False,when the routerExternal is 'ffffffffffff',the Json can't post. |
| 960 | network.routerExternal = 'ffffffffffff' |
| 961 | #The network.shared should be True or False,when the shared is 'ffffffffffffff',the Json can't post. |
| 962 | network.shared = 'ffffffffffffff' |
| 963 | postdata = network.DictoJson() |
| 964 | |
| 965 | main.step( "Post Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 966 | Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/', |
| 967 | 'POST', None, postdata ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 968 | |
| 969 | utilities.assert_equals( |
| 970 | expect='500', |
| 971 | actual=Poststatus, |
| 972 | onpass="The Json is wrong,can't post", |
| 973 | onfail="Wrong Json can post successfully " ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 974 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 975 | def CASE12( self, main ): |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 976 | """ |
| 977 | Test Post Error Json Create Subnet |
| 978 | """ |
| 979 | import os |
| 980 | |
| 981 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 982 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
| 983 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 984 | except ImportError: |
| 985 | main.log.exception( "Something wrong with import file or code error." ) |
| 986 | main.log.info( "Import Error, please check!" ) |
| 987 | main.cleanup() |
| 988 | main.exit() |
| 989 | |
| 990 | main.log.info( "ONOS Post Error Json Create Subnet test Start" ) |
| 991 | main.case( "Virtual Network NBI Test - Subnet" ) |
| 992 | main.caseExplanation = "Test Subnet Post With Error json " +\ |
| 993 | "The wrong Json can't post network successfully" |
| 994 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 995 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 996 | port = main.params[ 'HTTP' ][ 'port' ] |
| 997 | path = main.params[ 'HTTP' ][ 'path' ] |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 998 | |
| 999 | main.step( "Generate Post Data" ) |
| 1000 | network = NetworkData() |
| 1001 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 1002 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 1003 | subnet = SubnetData() |
| 1004 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 1005 | #The subnet.enable_dhcp should be True or False,when the enable_dhcp is 'tttttttttttttt',the Json can't post. |
| 1006 | subnet.enable_dhcp = 'tttttttttttttt' |
| 1007 | #The subnet.tenant_id should be True or False,when the tenant_id is ffffffffffffff',the Json can't post. |
| 1008 | subnet.shared = 'ffffffffffffff' |
| 1009 | subnet.tenant_id = network.tenant_id |
| 1010 | subnet.network_id = network.id |
| 1011 | |
| 1012 | networkpostdata = network.DictoJson() |
| 1013 | subnetpostdata = subnet.DictoJson() |
| 1014 | |
| 1015 | main.step( "Post Network Data via HTTP(Post Subnet need post network)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1016 | Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'networks/', |
| 1017 | 'POST', None, networkpostdata ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1018 | utilities.assert_equals( |
| 1019 | expect='200', |
| 1020 | actual=Poststatus, |
| 1021 | onpass="Post Network Success", |
| 1022 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 1023 | |
| 1024 | main.step( "Post Subnet Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1025 | Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, port, '', path + 'subnets/', |
| 1026 | 'POST', None, subnetpostdata ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1027 | utilities.assert_equals( |
| 1028 | expect='500', |
| 1029 | actual=Poststatus, |
| 1030 | onpass="The Json is wrong,can't post", |
| 1031 | onfail="Wrong Json can post successfully " ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1032 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 1033 | def CASE13( self, main ): |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1034 | """ |
| 1035 | Test Post Error Json Create Virtualport |
| 1036 | """ |
| 1037 | import os |
| 1038 | |
| 1039 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 1040 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import NetworkData |
| 1041 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import SubnetData |
| 1042 | from tests.FUNC.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1043 | except ImportError: |
| 1044 | main.log.exception( "Something wrong with import file or code error." ) |
| 1045 | main.log.info( "Import Error, please check!" ) |
| 1046 | main.cleanup() |
| 1047 | main.exit() |
| 1048 | |
| 1049 | main.log.info( "ONOS Post Error Json Create Subnet test Start" ) |
| 1050 | main.case( "Virtual Network NBI Test - Port" ) |
| 1051 | main.caseExplanation = "Test Subnet Post With Error json " +\ |
| 1052 | "The wrong Json can't create port successfully" |
| 1053 | |
Jon Hall | f52840a | 2017-05-24 16:49:52 -0700 | [diff] [blame] | 1054 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 1055 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 1056 | path = main.params[ 'HTTP' ][ 'path' ] |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1057 | |
| 1058 | main.step( "Generate Post Data" ) |
| 1059 | network = NetworkData() |
| 1060 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 1061 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 1062 | subnet = SubnetData() |
| 1063 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 1064 | subnet.tenant_id = network.tenant_id |
| 1065 | subnet.network_id = network.id |
| 1066 | port = VirtualPortData() |
| 1067 | port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466" |
| 1068 | port.subnet_id = subnet.id |
| 1069 | port.tenant_id = network.tenant_id |
| 1070 | port.network_id = network.id |
| 1071 | #The port.adminStateUp should be True or False,when the adminStateUp is 'tttttttttttt',the Json can't post. |
| 1072 | port.adminStateUp = 'tttttttttttt' |
| 1073 | |
| 1074 | networkpostdata = network.DictoJson() |
| 1075 | subnetpostdata = subnet.DictoJson() |
| 1076 | portpostdata = port.DictoJson() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1077 | ctrl = main.Cluster.active( 0 ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1078 | main.step( "Post Network Data via HTTP(Post port need post network)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1079 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'networks/', |
| 1080 | 'POST', None, networkpostdata ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1081 | utilities.assert_equals( |
| 1082 | expect='200', |
| 1083 | actual=Poststatus, |
| 1084 | onpass="Post Network Success", |
| 1085 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 1086 | |
| 1087 | main.step( "Post Subnet Data via HTTP(Post port need post subnet)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1088 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'subnets/', |
| 1089 | 'POST', None, subnetpostdata ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1090 | utilities.assert_equals( |
| 1091 | expect='202', |
| 1092 | actual=Poststatus, |
| 1093 | onpass="Post Subnet Success", |
| 1094 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 1095 | |
| 1096 | main.step( "Post Port Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1097 | Poststatus, result = ctrl.REST.send( ctrlip, httpport, '', path + 'ports/', |
| 1098 | 'POST', None, portpostdata ) |
ligenyu | d4ae1be | 2015-09-28 20:03:13 +0800 | [diff] [blame] | 1099 | utilities.assert_equals( |
| 1100 | expect='500', |
| 1101 | actual=Poststatus, |
| 1102 | onpass="The Json is wrong,can't post", |
Jon Hall | ce9c01e | 2015-10-22 16:39:02 +0000 | [diff] [blame] | 1103 | onfail="Wrong Json can post successfully" ) |