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