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