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