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