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