zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 1 | """ |
| 2 | Description: This test is to check onos set configuration and flows with ovsdb connection. |
| 3 | |
| 4 | List of test cases: |
| 5 | CASE1: Compile ONOS and push it to the test machines |
| 6 | CASE2: Test ovsdb connection and tearDown |
| 7 | CASE3: Test default br-int configuration and vxlan port |
| 8 | CASE4: Test default openflow configuration |
| 9 | CASE5: Test default flows |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 10 | CASE6: Configure Network Subnet Port |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 11 | CASE7: Test host go online and ping each other |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 12 | CASE8: Clear ovs configuration and host configuration |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 13 | zhanghaoyu7@huawei.com |
| 14 | """ |
| 15 | import os |
| 16 | |
| 17 | class FUNCovsdbtest: |
| 18 | |
| 19 | def __init__( self ): |
| 20 | self.default = '' |
| 21 | |
| 22 | def CASE1( self, main ): |
| 23 | """ |
| 24 | CASE1 is to compile ONOS and push it to the test machines |
| 25 | |
| 26 | Startup sequence: |
| 27 | cell <name> |
| 28 | onos-verify-cell |
| 29 | NOTE: temporary - onos-remove-raft-logs |
| 30 | onos-uninstall |
| 31 | start mininet |
| 32 | git pull |
| 33 | mvn clean install |
| 34 | onos-package |
| 35 | onos-install -f |
| 36 | onos-wait-for-start |
| 37 | start cli sessions |
| 38 | start ovsdb |
| 39 | start vtn apps |
| 40 | """ |
| 41 | import os |
| 42 | main.log.info( "ONOS Single node start " + |
| 43 | "ovsdb test - initialization" ) |
| 44 | main.case( "Setting up test environment" ) |
| 45 | main.caseExplanation = "Setup the test environment including " +\ |
| 46 | "installing ONOS, start ONOS." |
| 47 | |
| 48 | # load some variables from the params file |
| 49 | PULLCODE = False |
| 50 | if main.params[ 'GIT' ][ 'pull' ] == 'True': |
| 51 | PULLCODE = True |
| 52 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 53 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 54 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 55 | OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] ) |
| 56 | OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] ) |
| 57 | |
| 58 | main.step( "Create cell file" ) |
| 59 | cellAppString = main.params[ 'ENV' ][ 'cellApps' ] |
| 60 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName, |
| 61 | main.OVSDB1.ip_address, |
| 62 | cellAppString, ipList ) |
| 63 | |
| 64 | main.step( "Applying cell variable to environment" ) |
| 65 | cellResult = main.ONOSbench.setCell( cellName ) |
| 66 | verifyResult = main.ONOSbench.verifyCell() |
| 67 | |
| 68 | main.log.info( "Removing raft logs" ) |
| 69 | main.ONOSbench.onosRemoveRaftLogs() |
| 70 | |
| 71 | main.CLIs = [] |
| 72 | main.nodes = [] |
| 73 | main.numCtrls= 1 |
| 74 | |
| 75 | for i in range( 1, main.numCtrls + 1 ): |
| 76 | try: |
| 77 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 78 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 79 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 80 | except AttributeError: |
| 81 | break |
| 82 | |
| 83 | main.log.info( "Uninstalling ONOS" ) |
| 84 | for node in main.nodes: |
| 85 | main.ONOSbench.onosUninstall( node.ip_address ) |
| 86 | |
| 87 | # Make sure ONOS process is not running |
| 88 | main.log.info( "Killing any ONOS processes" ) |
| 89 | killResults = main.TRUE |
| 90 | for node in main.nodes: |
| 91 | killed = main.ONOSbench.onosKill( node.ip_address ) |
| 92 | killResults = killResults and killed |
| 93 | |
| 94 | cleanInstallResult = main.TRUE |
| 95 | gitPullResult = main.TRUE |
| 96 | main.step( "Git checkout and pull" + gitBranch ) |
| 97 | if PULLCODE: |
| 98 | main.ONOSbench.gitCheckout( gitBranch ) |
| 99 | gitPullResult = main.ONOSbench.gitPull() |
| 100 | # values of 1 or 3 are good |
| 101 | utilities.assert_lesser( expect=0, actual=gitPullResult, |
| 102 | onpass="Git pull successful", |
| 103 | onfail="Git pull failed" ) |
| 104 | |
| 105 | main.ONOSbench.getVersion( report=True ) |
| 106 | |
| 107 | main.step( "Using mvn clean install" ) |
| 108 | cleanInstallResult = main.TRUE |
| 109 | if PULLCODE and gitPullResult == main.TRUE: |
| 110 | cleanInstallResult = main.ONOSbench.cleanInstall() |
| 111 | else: |
| 112 | main.log.warn( "Did not pull new code so skipping mvn" + |
| 113 | "clean install" ) |
| 114 | utilities.assert_equals( expect=main.TRUE, |
| 115 | actual=cleanInstallResult, |
| 116 | onpass="MCI successful", |
| 117 | onfail="MCI failed" ) |
| 118 | |
| 119 | main.step( "Creating ONOS package" ) |
| 120 | packageResult = main.ONOSbench.onosPackage() |
| 121 | utilities.assert_equals( expect=main.TRUE, |
| 122 | actual=packageResult, |
| 123 | onpass="Successfully created ONOS package", |
| 124 | onfail="Failed to create ONOS package" ) |
| 125 | |
| 126 | main.step( "Installing ONOS package" ) |
| 127 | onosInstallResult = main.ONOSbench.onosInstall( |
| 128 | options="-f", node=main.nodes[0].ip_address ) |
| 129 | utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult, |
| 130 | onpass="ONOS install successful", |
| 131 | onfail="ONOS install failed" ) |
| 132 | |
| 133 | main.step( "Checking if ONOS is up yet" ) |
| 134 | print main.nodes[0].ip_address |
| 135 | for i in range( 2 ): |
| 136 | onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address ) |
| 137 | if onos1Isup: |
| 138 | break |
| 139 | utilities.assert_equals( expect=main.TRUE, actual=onos1Isup, |
| 140 | onpass="ONOS startup successful", |
| 141 | onfail="ONOS startup failed" ) |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 142 | main.step( "Starting ONOS CLI sessions" ) |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 143 | print main.nodes[0].ip_address |
| 144 | cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address ) |
| 145 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 146 | onpass="ONOS cli startup successful", |
| 147 | onfail="ONOS cli startup failed" ) |
| 148 | |
| 149 | main.step( "App Ids check" ) |
| 150 | appCheck = main.ONOScli1.appToIDCheck() |
| 151 | |
| 152 | if appCheck !=main.TRUE: |
| 153 | main.log.warn( main.CLIs[0].apps() ) |
| 154 | main.log.warn( main.CLIs[0].appIDs() ) |
| 155 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 156 | onpass="App Ids seem to be correct", |
| 157 | onfail="Something is wrong with app Ids" ) |
| 158 | if cliResults == main.FALSE: |
| 159 | main.log.error( "Failed to start ONOS,stopping test" ) |
| 160 | main.cleanup() |
| 161 | main.exit() |
| 162 | |
alison | d9915ea | 2016-08-12 10:16:26 -0700 | [diff] [blame] | 163 | main.step( "Install onos-ovsdb" ) |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 164 | installResults = main.ONOScli1.activateApp( "org.onosproject.ovsdb" ) |
| 165 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 166 | onpass="Install onos-ovsdatabase successful", |
| 167 | onfail="Install onos-ovsdatabase failed" ) |
| 168 | |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 169 | main.step( "Install onos-app-vtn" ) |
| 170 | installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" ) |
| 171 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 172 | onpass="Install onos-app-vtn successful", |
| 173 | onfail="Install onos-app-vtn failed" ) |
| 174 | |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 175 | def CASE2( self, main ): |
| 176 | |
| 177 | """ |
| 178 | Test ovsdb connection and teardown |
| 179 | """ |
| 180 | import os,sys |
| 181 | import re |
| 182 | import time |
| 183 | |
| 184 | main.case( "Test ovsdb connection and teardown" ) |
| 185 | main.caseExplanation = "Test ovsdb connection create and delete" +\ |
| 186 | " over ovsdb node and onos node " |
| 187 | |
| 188 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 189 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 190 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 191 | |
| 192 | main.step( "Set ovsdb node manager" ) |
| 193 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 194 | stepResult = assignResult |
| 195 | utilities.assert_equals( expect=main.TRUE, |
| 196 | actual=stepResult, |
| 197 | onpass="Set ovsdb node manager sucess", |
| 198 | onfail="Set ovsdb node manager failed" ) |
| 199 | |
| 200 | main.step( "Check ovsdb node manager is " + str( ctrlip ) ) |
| 201 | response = main.OVSDB1.getManager() |
| 202 | if re.search( ctrlip, response ): |
| 203 | stepResult = main.TRUE |
| 204 | else: |
| 205 | stepResult = main.FALSE |
| 206 | utilities.assert_equals( expect=main.TRUE, |
| 207 | actual=stepResult, |
| 208 | onpass="Check ovsdb node manager is " + str( response ) , |
| 209 | onfail="Check ovsdb node manager failed" ) |
| 210 | |
| 211 | main.step( "Delete ovsdb node manager" ) |
| 212 | deleteResult = main.OVSDB1.delManager( delaytime=delaytime ) |
| 213 | stepResult = deleteResult |
| 214 | utilities.assert_equals( expect=main.TRUE, |
| 215 | actual=stepResult, |
| 216 | onpass="ovsdb node delete manager sucess", |
| 217 | onfail="ovsdb node delete manager failed" ) |
| 218 | |
| 219 | main.step( "Check ovsdb node delete manager " + str( ctrlip ) ) |
| 220 | response = main.OVSDB1.getManager() |
| 221 | if not re.search( ctrlip, response ): |
| 222 | stepResult = main.TRUE |
| 223 | else: |
| 224 | stepResult = main.FALSE |
| 225 | utilities.assert_equals( expect=main.TRUE, |
| 226 | actual=stepResult, |
| 227 | onpass="Check ovsdb node delete manager sucess", |
| 228 | onfail="Check ovsdb node delete manager failed" ) |
| 229 | |
| 230 | def CASE3( self, main ): |
| 231 | |
| 232 | """ |
| 233 | Test default br-int configuration and vxlan port |
| 234 | """ |
| 235 | import re |
| 236 | import time |
| 237 | import os,sys |
| 238 | |
| 239 | main.case( "Test default br-int configuration and vxlan port" ) |
| 240 | main.caseExplanation = "onos create default br-int bridge and" +\ |
| 241 | " vxlan port on the ovsdb node" |
| 242 | |
| 243 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 244 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 245 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 246 | |
| 247 | main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) ) |
| 248 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 249 | stepResult = assignResult |
| 250 | utilities.assert_equals( expect=main.TRUE, |
| 251 | actual=stepResult, |
| 252 | onpass="ovsdb node 1 set ovs manager to to " +\ |
| 253 | str( ctrlip ) + " sucess", |
| 254 | onfail="ovsdb node 1 set ovs manager to to " +\ |
| 255 | str( ctrlip ) + " failed" ) |
| 256 | |
| 257 | main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) ) |
| 258 | assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 259 | stepResult = assignResult |
| 260 | utilities.assert_equals( expect=main.TRUE, |
| 261 | actual=stepResult, |
| 262 | onpass="ovsdb node 2 set ovs manager to to " +\ |
| 263 | str( ctrlip ) + " sucess", |
| 264 | onfail="ovsdb node 2 set ovs manager to to " +\ |
| 265 | str( ctrlip ) + " failed" ) |
| 266 | |
| 267 | main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) ) |
| 268 | response = main.OVSDB1.getManager() |
| 269 | if re.search( ctrlip, response ): |
| 270 | stepResult = main.TRUE |
| 271 | else: |
| 272 | stepResult = main.FALSE |
| 273 | utilities.assert_equals( expect=main.TRUE, |
| 274 | actual=stepResult, |
| 275 | onpass="ovsdb node 1 manager is " + str( response ) , |
| 276 | onfail="ovsdb node 1 manager check failed" ) |
| 277 | |
| 278 | main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) ) |
| 279 | response = main.OVSDB2.getManager() |
| 280 | if re.search( ctrlip, response ): |
| 281 | stepResult = main.TRUE |
| 282 | else: |
| 283 | stepResult = main.FALSE |
| 284 | utilities.assert_equals( expect=main.TRUE, |
| 285 | actual=stepResult, |
| 286 | onpass="ovsdb node 2 manager is " + str( response ) , |
| 287 | onfail="ovsdb node 2 manager check failed" ) |
| 288 | |
| 289 | main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) ) |
| 290 | response = main.OVSDB1.listBr() |
| 291 | if re.search( "br-int", response ): |
| 292 | stepResult = main.TRUE |
| 293 | else: |
| 294 | stepResult = main.FALSE |
| 295 | utilities.assert_equals( expect=main.TRUE, |
| 296 | actual=stepResult, |
| 297 | onpass="onos add default bridge on the node 1 sucess", |
| 298 | onfail="onos add default bridge on the node 1 failed" ) |
| 299 | |
| 300 | main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB2Ip ) ) |
| 301 | response = main.OVSDB2.listBr() |
| 302 | if re.search( "br-int", response ): |
| 303 | stepResult = main.TRUE |
| 304 | else: |
| 305 | stepResult = main.FALSE |
| 306 | utilities.assert_equals( expect=main.TRUE, |
| 307 | actual=stepResult, |
| 308 | onpass="onos add default bridge on the node 2 sucess", |
| 309 | onfail="onos add default bridge on the node 2 failed" ) |
| 310 | |
| 311 | main.step( "Check default vxlan port on ovsdb node " + str( OVSDB1Ip ) ) |
| 312 | response = main.OVSDB1.listPorts( "br-int" ) |
| 313 | if re.search( "vxlan", response ) and re.search( str( OVSDB2Ip ), response ): |
| 314 | stepResult = main.TRUE |
| 315 | else: |
| 316 | stepResult = main.FALSE |
| 317 | utilities.assert_equals( expect=main.TRUE, |
| 318 | actual=stepResult, |
| 319 | onpass="onos add default vxlan port on the node 1 sucess", |
| 320 | onfail="onos add default vxlan port on the node 1 failed" ) |
| 321 | |
| 322 | main.step( "Check default vxlan port on ovsdb node " + str( OVSDB2Ip ) ) |
| 323 | response = main.OVSDB2.listPorts( "br-int" ) |
| 324 | if re.search( "vxlan", response ) and re.search( str( OVSDB1Ip ), response ): |
| 325 | stepResult = main.TRUE |
| 326 | else: |
| 327 | stepResult = main.FALSE |
| 328 | utilities.assert_equals( expect=main.TRUE, |
| 329 | actual=stepResult, |
| 330 | onpass="onos add default vxlan port on the node 2 sucess", |
| 331 | onfail="onos add default vxlan port on the node 2 failed" ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 332 | |
| 333 | def CASE4( self, main ): |
| 334 | |
| 335 | """ |
| 336 | Test default openflow configuration |
| 337 | """ |
| 338 | import re |
| 339 | import time |
| 340 | import os,sys |
| 341 | |
| 342 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 343 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 344 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 345 | |
| 346 | main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) ) |
| 347 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 348 | stepResult = assignResult |
| 349 | utilities.assert_equals( expect=main.TRUE, |
| 350 | actual=stepResult, |
| 351 | onpass="ovsdb node 1 set ovs manager to to " +\ |
| 352 | str( ctrlip ) + " sucess", |
| 353 | onfail="ovsdb node 1 set ovs manager to to " +\ |
| 354 | str( ctrlip ) + " failed" ) |
| 355 | |
| 356 | main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) ) |
| 357 | assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 358 | stepResult = assignResult |
| 359 | utilities.assert_equals( expect=main.TRUE, |
| 360 | actual=stepResult, |
| 361 | onpass="ovsdb node 2 set ovs manager to to " +\ |
| 362 | str( ctrlip ) + " sucess", |
| 363 | onfail="ovsdb node 2 set ovs manager to to " +\ |
| 364 | str( ctrlip ) + " failed" ) |
| 365 | |
| 366 | main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) ) |
| 367 | response = main.OVSDB1.getManager() |
| 368 | if re.search( ctrlip, response ): |
| 369 | stepResult = main.TRUE |
| 370 | else: |
| 371 | stepResult = main.FALSE |
| 372 | utilities.assert_equals( expect=main.TRUE, |
| 373 | actual=stepResult, |
| 374 | onpass="ovsdb node 1 manager is " + str( response ) , |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 375 | onfail="ovsdb node 1 manager check failed\n" +\ |
| 376 | str( main.OVSDB1.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 377 | |
| 378 | main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) ) |
| 379 | response = main.OVSDB2.getManager() |
| 380 | if re.search( ctrlip, response ): |
| 381 | stepResult = main.TRUE |
| 382 | else: |
| 383 | stepResult = main.FALSE |
| 384 | utilities.assert_equals( expect=main.TRUE, |
| 385 | actual=stepResult, |
| 386 | onpass="ovsdb node 2 manager is " + str( response ) , |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 387 | onfail="ovsdb node 2 manager check failed\n" +\ |
| 388 | str( main.OVSDB2.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 389 | |
| 390 | main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) ) |
| 391 | response = main.OVSDB1.getController( "br-int" ) |
| 392 | if re.search( ctrlip, response ): |
| 393 | stepResult = main.TRUE |
| 394 | else: |
| 395 | stepResult = main.FALSE |
| 396 | utilities.assert_equals( expect=main.TRUE, |
| 397 | actual=stepResult, |
| 398 | onpass="Check ovsdb node 1 bridge br-int controller set to " +\ |
| 399 | str( ctrlip ) + " sucess", |
| 400 | onfail="Check ovsdb node 1 bridge br-int controller set to " +\ |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 401 | str( ctrlip ) + " failed\n" + str( main.OVSDB1.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 402 | |
| 403 | main.step( "Check ovsdb node 2 bridge br-int controller set to " + str( ctrlip ) ) |
| 404 | response = main.OVSDB2.getController( "br-int" ) |
| 405 | if re.search( ctrlip, response ): |
| 406 | stepResult = main.TRUE |
| 407 | else: |
| 408 | stepResult = main.FALSE |
| 409 | utilities.assert_equals( expect=main.TRUE, |
| 410 | actual=stepResult, |
| 411 | onpass="Check ovsdb node 2 bridge br-int controller set to " +\ |
| 412 | str( ctrlip ) + " sucess", |
| 413 | onfail="Check ovsdb node 2 bridge br-int controller set to " +\ |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 414 | str( ctrlip ) + " failed\n" + str( main.OVSDB2.show()) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 415 | |
| 416 | main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) ) |
| 417 | response = main.ONOScli1.devices() |
| 418 | if re.search( OVSDB1Ip, response ) and not re.search( "false", response ): |
| 419 | stepResult = main.TRUE |
| 420 | else: |
| 421 | stepResult = main.FALSE |
| 422 | utilities.assert_equals( expect=main.TRUE, |
| 423 | actual=stepResult, |
| 424 | onpass="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " sucess", |
| 425 | onfail="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " failed" ) |
| 426 | |
| 427 | main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) ) |
| 428 | response = main.ONOScli1.devices() |
| 429 | if re.search( OVSDB2Ip, response ) and not re.search( "false", response ): |
| 430 | stepResult = main.TRUE |
| 431 | else: |
| 432 | stepResult = main.FALSE |
| 433 | utilities.assert_equals( expect=main.TRUE, |
| 434 | actual=stepResult, |
| 435 | onpass="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " sucess", |
| 436 | onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" ) |
| 437 | |
| 438 | def CASE5( self, main ): |
| 439 | |
| 440 | """ |
| 441 | Test default flows |
| 442 | """ |
| 443 | import re |
| 444 | import time |
| 445 | import os,sys |
| 446 | |
| 447 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 448 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 449 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 450 | |
| 451 | main.step( "ovsdb node 1 set ovs manager to onos" ) |
| 452 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 453 | stepResult = assignResult |
| 454 | utilities.assert_equals( expect=main.TRUE, |
| 455 | actual=stepResult, |
| 456 | onpass="ovsdb node 1 set ovs manager to to " +\ |
| 457 | str( ctrlip ) + " sucess", |
| 458 | onfail="ovsdb node 1 set ovs manager to to " +\ |
| 459 | str( ctrlip ) + " failed" ) |
| 460 | |
| 461 | main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) ) |
| 462 | response = main.OVSDB1.getManager() |
| 463 | if re.search( ctrlip, response ): |
| 464 | stepResult = main.TRUE |
| 465 | else: |
| 466 | stepResult = main.FALSE |
| 467 | utilities.assert_equals( expect=main.TRUE, |
| 468 | actual=stepResult, |
| 469 | onpass="ovsdb node 1 manager is " + str( response ) , |
| 470 | onfail="ovsdb node 1 manager check failed" ) |
| 471 | |
| 472 | main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) ) |
| 473 | response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" ) |
| 474 | if re.search( "actions=CONTROLLER", response ): |
| 475 | stepResult = main.TRUE |
| 476 | else: |
| 477 | stepResult = main.FALSE |
| 478 | utilities.assert_equals( expect=main.TRUE, |
| 479 | actual=stepResult, |
| 480 | onpass="Successfully set default flows " + str( ctrlip ) , |
| 481 | onfail="Failed to set default flows " + str( ctrlip ) ) |
| 482 | |
| 483 | def CASE6( self, main ): |
| 484 | """ |
| 485 | Configure Network Subnet Port |
| 486 | """ |
| 487 | import os |
| 488 | |
| 489 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 490 | from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import NetworkData |
| 491 | from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import SubnetData |
| 492 | from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 493 | except ImportError: |
| 494 | main.log.exception( "Something wrong with import file or code error." ) |
| 495 | main.log.info( "Import Error, please check!" ) |
| 496 | main.cleanup() |
| 497 | main.exit() |
| 498 | |
| 499 | main.log.info( "Configure Network Subnet Port Start" ) |
| 500 | main.case( "Configure Network Subnet Port" ) |
| 501 | main.caseExplanation = "Configure Network Subnet Port " +\ |
| 502 | "Verify post is OK" |
| 503 | |
| 504 | ctrlip = os.getenv( main.params['CTRL']['ip1'] ) |
| 505 | httpport = main.params['HTTP']['port'] |
| 506 | path = main.params['HTTP']['path'] |
| 507 | |
| 508 | main.step( "Generate Post Data" ) |
| 509 | network = NetworkData() |
| 510 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 511 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 512 | subnet = SubnetData() |
| 513 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 514 | subnet.tenant_id = network.tenant_id |
| 515 | subnet.network_id = network.id |
| 516 | subnet.start = "10.0.0.1" |
| 517 | subnet.end = "10.0.0.254" |
| 518 | subnet.cidr = "10.0.0.0/24" |
| 519 | port1 = VirtualPortData() |
| 520 | port1.id = "00000000-0000-0000-0000-000000000001" |
| 521 | port1.subnet_id = subnet.id |
| 522 | port1.tenant_id = network.tenant_id |
| 523 | port1.network_id = network.id |
| 524 | port1.macAddress = "00:00:00:00:00:01" |
| 525 | port1.ip_address = "10.0.0.1" |
| 526 | port2 = VirtualPortData() |
| 527 | port2.id = "00000000-0000-0000-0000-000000000002" |
| 528 | port2.subnet_id = subnet.id |
| 529 | port2.tenant_id = network.tenant_id |
| 530 | port2.network_id = network.id |
| 531 | port2.macAddress = "00:00:00:00:00:02" |
| 532 | port2.ip_address = "10.0.0.2" |
| 533 | |
| 534 | networkpostdata = network.DictoJson() |
| 535 | subnetpostdata = subnet.DictoJson() |
| 536 | port1postdata = port1.DictoJson() |
| 537 | port2postdata = port2.DictoJson() |
| 538 | |
| 539 | main.step( "Post Network Data via HTTP(Post port need post network)" ) |
| 540 | Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/', |
| 541 | 'POST', None, networkpostdata ) |
| 542 | utilities.assert_equals( |
| 543 | expect='200', |
| 544 | actual=Poststatus, |
| 545 | onpass="Post Network Success", |
| 546 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 547 | |
| 548 | main.step( "Post Subnet Data via HTTP(Post port need post subnet)" ) |
| 549 | Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/', |
| 550 | 'POST', None, subnetpostdata ) |
| 551 | utilities.assert_equals( |
| 552 | expect='202', |
| 553 | actual=Poststatus, |
| 554 | onpass="Post Subnet Success", |
| 555 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 556 | |
| 557 | main.step( "Post Port1 Data via HTTP" ) |
| 558 | Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/', |
| 559 | 'POST', None, port1postdata ) |
| 560 | utilities.assert_equals( |
| 561 | expect='200', |
| 562 | actual=Poststatus, |
| 563 | onpass="Post Port Success", |
| 564 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 565 | |
| 566 | main.step( "Post Port2 Data via HTTP" ) |
| 567 | Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/', |
| 568 | 'POST', None, port2postdata ) |
| 569 | utilities.assert_equals( |
| 570 | expect='200', |
| 571 | actual=Poststatus, |
| 572 | onpass="Post Port Success", |
| 573 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 574 | |
| 575 | def CASE7( self, main ): |
| 576 | |
| 577 | """ |
| 578 | Test host go online and ping each other |
| 579 | """ |
| 580 | import re |
| 581 | import time |
| 582 | import os,sys |
| 583 | |
| 584 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 585 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 586 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 587 | |
| 588 | main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) ) |
| 589 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 590 | stepResult = assignResult |
| 591 | utilities.assert_equals( expect=main.TRUE, |
| 592 | actual=stepResult, |
| 593 | onpass="ovsdb node 1 set ovs manager to to " +\ |
| 594 | str( ctrlip ) + " sucess", |
| 595 | onfail="ovsdb node 1 set ovs manager to to " +\ |
| 596 | str( ctrlip ) + " failed" ) |
| 597 | |
| 598 | main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) ) |
| 599 | assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 600 | stepResult = assignResult |
| 601 | utilities.assert_equals( expect=main.TRUE, |
| 602 | actual=stepResult, |
| 603 | onpass="ovsdb node 2 set ovs manager to " +\ |
| 604 | str( ctrlip ) + " sucess", |
| 605 | onfail="ovsdb node 2 set ovs manager to " +\ |
| 606 | str( ctrlip ) + " failed" ) |
| 607 | |
| 608 | main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) ) |
| 609 | stepResult = main.OVSDB1.createHost( hostname="host1" ) |
| 610 | utilities.assert_equals( expect=main.TRUE, |
| 611 | actual=stepResult, |
| 612 | onpass="Create host1 on node 1 " + str( OVSDB1Ip ) + " sucess", |
| 613 | onfail="Create host1 on node 1 " + str( OVSDB1Ip ) + " failed" ) |
| 614 | |
| 615 | main.step( "Create host2 on node 2 " + str( OVSDB2Ip ) ) |
| 616 | stepResult = main.OVSDB2.createHost( hostname="host2" ) |
| 617 | utilities.assert_equals( expect=main.TRUE, |
| 618 | actual=stepResult, |
| 619 | onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess", |
| 620 | onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" ) |
| 621 | |
| 622 | main.step( "Create port on host1 on the node " + str ( OVSDB1Ip ) ) |
| 623 | stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" ) |
| 624 | utilities.assert_equals( expect=main.TRUE, |
| 625 | actual=stepResult, |
| 626 | onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess", |
| 627 | onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" ) |
| 628 | |
| 629 | main.step( "Create port on host2 on the node " + str ( OVSDB2Ip ) ) |
| 630 | stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" ) |
| 631 | utilities.assert_equals( expect=main.TRUE, |
| 632 | actual=stepResult, |
| 633 | onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess", |
| 634 | onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" ) |
| 635 | |
| 636 | main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB1Ip ) ) |
| 637 | stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001", |
| 638 | attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" ) |
| 639 | utilities.assert_equals( expect=main.TRUE, |
| 640 | actual=stepResult, |
| 641 | onpass="Add port to ovs br-int and host go-online on the node " +\ |
| 642 | str( OVSDB1Ip ) + " sucess", |
| 643 | onfail="Add port to ovs br-int and host go-online on the node " +\ |
| 644 | str( OVSDB1Ip ) + " failed" ) |
| 645 | |
| 646 | main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB2Ip ) ) |
| 647 | stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002", |
| 648 | attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" ) |
| 649 | utilities.assert_equals( expect=main.TRUE, |
| 650 | actual=stepResult, |
| 651 | onpass="Add port to ovs br-int and host go-online on the node " +\ |
| 652 | str( OVSDB2Ip ) + " sucess", |
| 653 | onfail="Add port to ovs br-int and host go-online on the node " +\ |
| 654 | str( OVSDB2Ip ) + " failed" ) |
| 655 | |
| 656 | main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) ) |
| 657 | response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" ) |
| 658 | if re.search( "00:00:00:00:00:01", response ): |
| 659 | stepResult = main.TRUE |
| 660 | else: |
| 661 | stepResult = main.FALSE |
| 662 | utilities.assert_equals( expect=main.TRUE, |
| 663 | actual=stepResult, |
| 664 | onpass="Check onos set host flows on the node " +\ |
| 665 | str( OVSDB1Ip ) + " sucess", |
| 666 | onfail="Check onos set host flows on the node " +\ |
| 667 | str( OVSDB1Ip ) + " failed" ) |
| 668 | |
| 669 | main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) ) |
| 670 | response = main.OVSDB2.dumpFlows( sw="br-int", protocols="OpenFlow13" ) |
| 671 | if re.search( "00:00:00:00:00:02", response ): |
| 672 | stepResult = main.TRUE |
| 673 | else: |
| 674 | stepResult = main.FALSE |
| 675 | utilities.assert_equals( expect=main.TRUE, |
| 676 | actual=stepResult, |
| 677 | onpass="Check onos set host flows on the node " +\ |
| 678 | str( OVSDB2Ip ) + " sucess", |
| 679 | onfail="Check onos set host flows on the node " +\ |
| 680 | str( OVSDB2Ip ) + " failed" ) |
| 681 | |
| 682 | main.step( "Check hosts can ping each other" ) |
| 683 | main.OVSDB1.setHostportIp( hostname="host1", hostport1="host1-eth0", ip="10.0.0.1" ) |
| 684 | main.OVSDB2.setHostportIp( hostname="host2", hostport1="host2-eth0", ip="10.0.0.2" ) |
| 685 | pingResult1 = main.OVSDB1.hostPing( src="10.0.0.1", hostname="host1", target="10.0.0.2" ) |
| 686 | pingResult2 = main.OVSDB2.hostPing( src="10.0.0.2", hostname="host2", target="10.0.0.1" ) |
| 687 | stepResult = pingResult1 and pingResult2 |
| 688 | utilities.assert_equals( expect=main.TRUE, |
| 689 | actual=stepResult, |
| 690 | onpass="Successfully host go online and ping each other,controller is " +\ |
| 691 | str( ctrlip ), |
| 692 | onfail="Failed to host go online and ping each other,controller is " +\ |
| 693 | str( ctrlip ) ) |
| 694 | |
| 695 | def CASE8( self, main ): |
| 696 | |
| 697 | """ |
| 698 | Clear ovs configuration and host configuration |
| 699 | """ |
| 700 | import re |
| 701 | import time |
| 702 | import os,sys |
| 703 | |
| 704 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 705 | OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] ) |
| 706 | OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] ) |
| 707 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 708 | |
| 709 | main.step( "Delete ovsdb node 1 manager" ) |
| 710 | deleteResult = main.OVSDB1.delManager( delaytime=delaytime ) |
| 711 | stepResult = deleteResult |
| 712 | utilities.assert_equals( expect=main.TRUE, |
| 713 | actual=stepResult, |
| 714 | onpass="ovsdb node 1 delete manager sucess", |
| 715 | onfail="ovsdb node 1 delete manager failed" ) |
| 716 | |
| 717 | main.step( "Delete ovsdb node 2 manager" ) |
| 718 | deleteResult = main.OVSDB2.delManager( delaytime=delaytime ) |
| 719 | stepResult = deleteResult |
| 720 | utilities.assert_equals( expect=main.TRUE, |
| 721 | actual=stepResult, |
| 722 | onpass="ovsdb node 2 delete manager sucess", |
| 723 | onfail="ovsdb node 2 delete manager failed" ) |
| 724 | |
| 725 | main.step( "Delete ovsdb node 1 bridge br-int" ) |
| 726 | deleteResult = main.OVSDB1.delBr( sw="br-int" ) |
| 727 | stepResult = deleteResult |
| 728 | utilities.assert_equals( expect=main.TRUE, |
| 729 | actual=stepResult, |
| 730 | onpass="Delete ovsdb node 1 bridge br-int sucess", |
| 731 | onfail="Delete ovsdb node 1 bridge br-int failed" ) |
| 732 | |
| 733 | main.step( "Delete ovsdb node 2 bridge br-int" ) |
| 734 | deleteResult = main.OVSDB2.delBr( sw="br-int" ) |
| 735 | stepResult = deleteResult |
| 736 | utilities.assert_equals( expect=main.TRUE, |
| 737 | actual=stepResult, |
| 738 | onpass="Delete ovsdb node 2 bridge br-int sucess", |
| 739 | onfail="Delete ovsdb node 2 bridge br-int failed" ) |
| 740 | |
| 741 | main.step( "Delete ip netns host on the ovsdb node 1" ) |
| 742 | deleteResult = main.OVSDB1.delHost( hostname="host1" ) |
| 743 | stepResult = deleteResult |
| 744 | utilities.assert_equals( expect=main.TRUE, |
| 745 | actual=stepResult, |
| 746 | onpass="Delete ip netns host on the ovsdb node 1 sucess", |
| 747 | onfail="Delete ip netns host on the ovsdb node 1 failed" ) |
| 748 | |
| 749 | main.step( "Delete ip netns host on the ovsdb node 2" ) |
| 750 | deleteResult = main.OVSDB2.delHost( hostname="host2" ) |
| 751 | stepResult = deleteResult |
| 752 | utilities.assert_equals( expect=main.TRUE, |
| 753 | actual=stepResult, |
| 754 | onpass="Delete ip netns host on the ovsdb node 2 sucess", |
| 755 | onfail="Delete ip netns host on the ovsdb node 2 failed" ) |
| 756 | |
| 757 | main.step( "Check onoscli devices openflow session is false " + str( OVSDB1Ip ) ) |
| 758 | response = main.ONOScli1.devices() |
| 759 | if re.search( OVSDB1Ip, response ) and not re.search( "true", response ): |
| 760 | stepResult = main.TRUE |
| 761 | else: |
| 762 | stepResult = main.FALSE |
| 763 | utilities.assert_equals( expect=main.TRUE, |
| 764 | actual=stepResult, |
| 765 | onpass="Check openflow session is false " + str( OVSDB1Ip ) + " sucess", |
| 766 | onfail="Check openflow session is false " + str( OVSDB1Ip ) + " failed" ) |
| 767 | |
| 768 | main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) ) |
| 769 | response = main.ONOScli1.devices() |
| 770 | if re.search( OVSDB2Ip, response ) and not re.search( "true", response ): |
| 771 | stepResult = main.TRUE |
| 772 | else: |
| 773 | stepResult = main.FALSE |
| 774 | utilities.assert_equals( expect=main.TRUE, |
| 775 | actual=stepResult, |
| 776 | onpass="Check openflow session is false " + str( OVSDB2Ip ) + " sucess", |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 777 | onfail="Check openflow session is false " + str( OVSDB2Ip ) + " failed" ) |