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