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' |
| 290 | network.shared = 'false' |
| 291 | postdata = network.DictoJson() |
| 292 | |
| 293 | network.shared = 'true' |
| 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", |
| 395 | onfail="Delete Failed " + str( Getstatus ) + str( result ) ) |
| 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( |
| 672 | expect='the subnet does not exists', |
| 673 | actual=result, |
| 674 | onpass="Get Subnet Success", |
| 675 | onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) ) |
| 676 | |
| 677 | if result != 'the subnet does not exists': |
| 678 | main.log.error( "Delete Subnet failed" ) |