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