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