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" ) |
| 142 | main.log.step( "Starting ONOS CLI sessions" ) |
| 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 | |
| 163 | main.step( "Install onos-ovsdatabase" ) |
| 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 | |
| 169 | main.step( "Install onos-app-vtnrsc" ) |
| 170 | installResults = main.ONOScli1.activateApp( "org.onosproject.vtnrsc" ) |
| 171 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 172 | onpass="Install onos-app-vtnrsc successful", |
| 173 | onfail="Install onos-app-vtnrsc failed" ) |
| 174 | |
| 175 | main.step( "Install onos-app-vtn" ) |
| 176 | installResults = main.ONOScli1.activateApp( "org.onosproject.vtn" ) |
| 177 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 178 | onpass="Install onos-app-vtn successful", |
| 179 | onfail="Install onos-app-vtn failed" ) |
| 180 | |
| 181 | main.step( "Install onos-app-vtnweb" ) |
| 182 | installResults = main.ONOScli1.activateApp( "org.onosproject.vtnweb" ) |
| 183 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 184 | onpass="Install onos-app-vtnweb successful", |
| 185 | onfail="Install onos-app-vtnweb failed" ) |
| 186 | |
| 187 | def CASE2( self, main ): |
| 188 | |
| 189 | """ |
| 190 | Test ovsdb connection and teardown |
| 191 | """ |
| 192 | import os,sys |
| 193 | import re |
| 194 | import time |
| 195 | |
| 196 | main.case( "Test ovsdb connection and teardown" ) |
| 197 | main.caseExplanation = "Test ovsdb connection create and delete" +\ |
| 198 | " over ovsdb node and onos node " |
| 199 | |
| 200 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 201 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 202 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 203 | |
| 204 | main.step( "Set ovsdb node manager" ) |
| 205 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 206 | stepResult = assignResult |
| 207 | utilities.assert_equals( expect=main.TRUE, |
| 208 | actual=stepResult, |
| 209 | onpass="Set ovsdb node manager sucess", |
| 210 | onfail="Set ovsdb node manager failed" ) |
| 211 | |
| 212 | main.step( "Check ovsdb node manager is " + str( ctrlip ) ) |
| 213 | response = main.OVSDB1.getManager() |
| 214 | if re.search( ctrlip, response ): |
| 215 | stepResult = main.TRUE |
| 216 | else: |
| 217 | stepResult = main.FALSE |
| 218 | utilities.assert_equals( expect=main.TRUE, |
| 219 | actual=stepResult, |
| 220 | onpass="Check ovsdb node manager is " + str( response ) , |
| 221 | onfail="Check ovsdb node manager failed" ) |
| 222 | |
| 223 | main.step( "Delete ovsdb node manager" ) |
| 224 | deleteResult = main.OVSDB1.delManager( delaytime=delaytime ) |
| 225 | stepResult = deleteResult |
| 226 | utilities.assert_equals( expect=main.TRUE, |
| 227 | actual=stepResult, |
| 228 | onpass="ovsdb node delete manager sucess", |
| 229 | onfail="ovsdb node delete manager failed" ) |
| 230 | |
| 231 | main.step( "Check ovsdb node delete manager " + str( ctrlip ) ) |
| 232 | response = main.OVSDB1.getManager() |
| 233 | if not re.search( ctrlip, response ): |
| 234 | stepResult = main.TRUE |
| 235 | else: |
| 236 | stepResult = main.FALSE |
| 237 | utilities.assert_equals( expect=main.TRUE, |
| 238 | actual=stepResult, |
| 239 | onpass="Check ovsdb node delete manager sucess", |
| 240 | onfail="Check ovsdb node delete manager failed" ) |
| 241 | |
| 242 | def CASE3( self, main ): |
| 243 | |
| 244 | """ |
| 245 | Test default br-int configuration and vxlan port |
| 246 | """ |
| 247 | import re |
| 248 | import time |
| 249 | import os,sys |
| 250 | |
| 251 | main.case( "Test default br-int configuration and vxlan port" ) |
| 252 | main.caseExplanation = "onos create default br-int bridge and" +\ |
| 253 | " vxlan port on the ovsdb node" |
| 254 | |
| 255 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 256 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 257 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 258 | |
| 259 | main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) ) |
| 260 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 261 | stepResult = assignResult |
| 262 | utilities.assert_equals( expect=main.TRUE, |
| 263 | actual=stepResult, |
| 264 | onpass="ovsdb node 1 set ovs manager to to " +\ |
| 265 | str( ctrlip ) + " sucess", |
| 266 | onfail="ovsdb node 1 set ovs manager to to " +\ |
| 267 | str( ctrlip ) + " failed" ) |
| 268 | |
| 269 | main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) ) |
| 270 | assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 271 | stepResult = assignResult |
| 272 | utilities.assert_equals( expect=main.TRUE, |
| 273 | actual=stepResult, |
| 274 | onpass="ovsdb node 2 set ovs manager to to " +\ |
| 275 | str( ctrlip ) + " sucess", |
| 276 | onfail="ovsdb node 2 set ovs manager to to " +\ |
| 277 | str( ctrlip ) + " failed" ) |
| 278 | |
| 279 | main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) ) |
| 280 | response = main.OVSDB1.getManager() |
| 281 | if re.search( ctrlip, response ): |
| 282 | stepResult = main.TRUE |
| 283 | else: |
| 284 | stepResult = main.FALSE |
| 285 | utilities.assert_equals( expect=main.TRUE, |
| 286 | actual=stepResult, |
| 287 | onpass="ovsdb node 1 manager is " + str( response ) , |
| 288 | onfail="ovsdb node 1 manager check failed" ) |
| 289 | |
| 290 | main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) ) |
| 291 | response = main.OVSDB2.getManager() |
| 292 | if re.search( ctrlip, response ): |
| 293 | stepResult = main.TRUE |
| 294 | else: |
| 295 | stepResult = main.FALSE |
| 296 | utilities.assert_equals( expect=main.TRUE, |
| 297 | actual=stepResult, |
| 298 | onpass="ovsdb node 2 manager is " + str( response ) , |
| 299 | onfail="ovsdb node 2 manager check failed" ) |
| 300 | |
| 301 | main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) ) |
| 302 | response = main.OVSDB1.listBr() |
| 303 | if re.search( "br-int", response ): |
| 304 | stepResult = main.TRUE |
| 305 | else: |
| 306 | stepResult = main.FALSE |
| 307 | utilities.assert_equals( expect=main.TRUE, |
| 308 | actual=stepResult, |
| 309 | onpass="onos add default bridge on the node 1 sucess", |
| 310 | onfail="onos add default bridge on the node 1 failed" ) |
| 311 | |
| 312 | main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB2Ip ) ) |
| 313 | response = main.OVSDB2.listBr() |
| 314 | if re.search( "br-int", response ): |
| 315 | stepResult = main.TRUE |
| 316 | else: |
| 317 | stepResult = main.FALSE |
| 318 | utilities.assert_equals( expect=main.TRUE, |
| 319 | actual=stepResult, |
| 320 | onpass="onos add default bridge on the node 2 sucess", |
| 321 | onfail="onos add default bridge on the node 2 failed" ) |
| 322 | |
| 323 | main.step( "Check default vxlan port on ovsdb node " + str( OVSDB1Ip ) ) |
| 324 | response = main.OVSDB1.listPorts( "br-int" ) |
| 325 | if re.search( "vxlan", response ) and re.search( str( OVSDB2Ip ), response ): |
| 326 | stepResult = main.TRUE |
| 327 | else: |
| 328 | stepResult = main.FALSE |
| 329 | utilities.assert_equals( expect=main.TRUE, |
| 330 | actual=stepResult, |
| 331 | onpass="onos add default vxlan port on the node 1 sucess", |
| 332 | onfail="onos add default vxlan port on the node 1 failed" ) |
| 333 | |
| 334 | main.step( "Check default vxlan port on ovsdb node " + str( OVSDB2Ip ) ) |
| 335 | response = main.OVSDB2.listPorts( "br-int" ) |
| 336 | if re.search( "vxlan", response ) and re.search( str( OVSDB1Ip ), response ): |
| 337 | stepResult = main.TRUE |
| 338 | else: |
| 339 | stepResult = main.FALSE |
| 340 | utilities.assert_equals( expect=main.TRUE, |
| 341 | actual=stepResult, |
| 342 | onpass="onos add default vxlan port on the node 2 sucess", |
| 343 | onfail="onos add default vxlan port on the node 2 failed" ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 344 | |
| 345 | def CASE4( self, main ): |
| 346 | |
| 347 | """ |
| 348 | Test default openflow configuration |
| 349 | """ |
| 350 | import re |
| 351 | import time |
| 352 | import os,sys |
| 353 | |
| 354 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 355 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 356 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 357 | |
| 358 | main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) ) |
| 359 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 360 | stepResult = assignResult |
| 361 | utilities.assert_equals( expect=main.TRUE, |
| 362 | actual=stepResult, |
| 363 | onpass="ovsdb node 1 set ovs manager to to " +\ |
| 364 | str( ctrlip ) + " sucess", |
| 365 | onfail="ovsdb node 1 set ovs manager to to " +\ |
| 366 | str( ctrlip ) + " failed" ) |
| 367 | |
| 368 | main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) ) |
| 369 | assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 370 | stepResult = assignResult |
| 371 | utilities.assert_equals( expect=main.TRUE, |
| 372 | actual=stepResult, |
| 373 | onpass="ovsdb node 2 set ovs manager to to " +\ |
| 374 | str( ctrlip ) + " sucess", |
| 375 | onfail="ovsdb node 2 set ovs manager to to " +\ |
| 376 | str( ctrlip ) + " failed" ) |
| 377 | |
| 378 | main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) ) |
| 379 | response = main.OVSDB1.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 1 manager is " + str( response ) , |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 387 | onfail="ovsdb node 1 manager check failed\n" +\ |
| 388 | str( main.OVSDB1.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 389 | |
| 390 | main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) ) |
| 391 | response = main.OVSDB2.getManager() |
| 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="ovsdb node 2 manager is " + str( response ) , |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 399 | onfail="ovsdb node 2 manager check failed\n" +\ |
| 400 | str( main.OVSDB2.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 401 | |
| 402 | main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) ) |
| 403 | response = main.OVSDB1.getController( "br-int" ) |
| 404 | if re.search( ctrlip, response ): |
| 405 | stepResult = main.TRUE |
| 406 | else: |
| 407 | stepResult = main.FALSE |
| 408 | utilities.assert_equals( expect=main.TRUE, |
| 409 | actual=stepResult, |
| 410 | onpass="Check ovsdb node 1 bridge br-int controller set to " +\ |
| 411 | str( ctrlip ) + " sucess", |
| 412 | onfail="Check ovsdb node 1 bridge br-int controller set to " +\ |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 413 | str( ctrlip ) + " failed\n" + str( main.OVSDB1.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 414 | |
| 415 | main.step( "Check ovsdb node 2 bridge br-int controller set to " + str( ctrlip ) ) |
| 416 | response = main.OVSDB2.getController( "br-int" ) |
| 417 | if re.search( ctrlip, response ): |
| 418 | stepResult = main.TRUE |
| 419 | else: |
| 420 | stepResult = main.FALSE |
| 421 | utilities.assert_equals( expect=main.TRUE, |
| 422 | actual=stepResult, |
| 423 | onpass="Check ovsdb node 2 bridge br-int controller set to " +\ |
| 424 | str( ctrlip ) + " sucess", |
| 425 | onfail="Check ovsdb node 2 bridge br-int controller set to " +\ |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 426 | str( ctrlip ) + " failed\n" + str( main.OVSDB2.show()) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 427 | |
| 428 | main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) ) |
| 429 | response = main.ONOScli1.devices() |
| 430 | if re.search( OVSDB1Ip, response ) and not re.search( "false", response ): |
| 431 | stepResult = main.TRUE |
| 432 | else: |
| 433 | stepResult = main.FALSE |
| 434 | utilities.assert_equals( expect=main.TRUE, |
| 435 | actual=stepResult, |
| 436 | onpass="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " sucess", |
| 437 | onfail="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " failed" ) |
| 438 | |
| 439 | main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) ) |
| 440 | response = main.ONOScli1.devices() |
| 441 | if re.search( OVSDB2Ip, response ) and not re.search( "false", response ): |
| 442 | stepResult = main.TRUE |
| 443 | else: |
| 444 | stepResult = main.FALSE |
| 445 | utilities.assert_equals( expect=main.TRUE, |
| 446 | actual=stepResult, |
| 447 | onpass="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " sucess", |
| 448 | onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" ) |
| 449 | |
| 450 | def CASE5( self, main ): |
| 451 | |
| 452 | """ |
| 453 | Test default flows |
| 454 | """ |
| 455 | import re |
| 456 | import time |
| 457 | import os,sys |
| 458 | |
| 459 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 460 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 461 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 462 | |
| 463 | main.step( "ovsdb node 1 set ovs manager to onos" ) |
| 464 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 465 | stepResult = assignResult |
| 466 | utilities.assert_equals( expect=main.TRUE, |
| 467 | actual=stepResult, |
| 468 | onpass="ovsdb node 1 set ovs manager to to " +\ |
| 469 | str( ctrlip ) + " sucess", |
| 470 | onfail="ovsdb node 1 set ovs manager to to " +\ |
| 471 | str( ctrlip ) + " failed" ) |
| 472 | |
| 473 | main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) ) |
| 474 | response = main.OVSDB1.getManager() |
| 475 | if re.search( ctrlip, response ): |
| 476 | stepResult = main.TRUE |
| 477 | else: |
| 478 | stepResult = main.FALSE |
| 479 | utilities.assert_equals( expect=main.TRUE, |
| 480 | actual=stepResult, |
| 481 | onpass="ovsdb node 1 manager is " + str( response ) , |
| 482 | onfail="ovsdb node 1 manager check failed" ) |
| 483 | |
| 484 | main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) ) |
| 485 | response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" ) |
| 486 | if re.search( "actions=CONTROLLER", response ): |
| 487 | stepResult = main.TRUE |
| 488 | else: |
| 489 | stepResult = main.FALSE |
| 490 | utilities.assert_equals( expect=main.TRUE, |
| 491 | actual=stepResult, |
| 492 | onpass="Successfully set default flows " + str( ctrlip ) , |
| 493 | onfail="Failed to set default flows " + str( ctrlip ) ) |
| 494 | |
| 495 | def CASE6( self, main ): |
| 496 | """ |
| 497 | Configure Network Subnet Port |
| 498 | """ |
| 499 | import os |
| 500 | |
| 501 | try: |
| 502 | from tests.FUNCovsdbtest.dependencies.Nbdata import NetworkData |
| 503 | from tests.FUNCovsdbtest.dependencies.Nbdata import SubnetData |
| 504 | from tests.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData |
| 505 | except ImportError: |
| 506 | main.log.exception( "Something wrong with import file or code error." ) |
| 507 | main.log.info( "Import Error, please check!" ) |
| 508 | main.cleanup() |
| 509 | main.exit() |
| 510 | |
| 511 | main.log.info( "Configure Network Subnet Port Start" ) |
| 512 | main.case( "Configure Network Subnet Port" ) |
| 513 | main.caseExplanation = "Configure Network Subnet Port " +\ |
| 514 | "Verify post is OK" |
| 515 | |
| 516 | ctrlip = os.getenv( main.params['CTRL']['ip1'] ) |
| 517 | httpport = main.params['HTTP']['port'] |
| 518 | path = main.params['HTTP']['path'] |
| 519 | |
| 520 | main.step( "Generate Post Data" ) |
| 521 | network = NetworkData() |
| 522 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 523 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 524 | subnet = SubnetData() |
| 525 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 526 | subnet.tenant_id = network.tenant_id |
| 527 | subnet.network_id = network.id |
| 528 | subnet.start = "10.0.0.1" |
| 529 | subnet.end = "10.0.0.254" |
| 530 | subnet.cidr = "10.0.0.0/24" |
| 531 | port1 = VirtualPortData() |
| 532 | port1.id = "00000000-0000-0000-0000-000000000001" |
| 533 | port1.subnet_id = subnet.id |
| 534 | port1.tenant_id = network.tenant_id |
| 535 | port1.network_id = network.id |
| 536 | port1.macAddress = "00:00:00:00:00:01" |
| 537 | port1.ip_address = "10.0.0.1" |
| 538 | port2 = VirtualPortData() |
| 539 | port2.id = "00000000-0000-0000-0000-000000000002" |
| 540 | port2.subnet_id = subnet.id |
| 541 | port2.tenant_id = network.tenant_id |
| 542 | port2.network_id = network.id |
| 543 | port2.macAddress = "00:00:00:00:00:02" |
| 544 | port2.ip_address = "10.0.0.2" |
| 545 | |
| 546 | networkpostdata = network.DictoJson() |
| 547 | subnetpostdata = subnet.DictoJson() |
| 548 | port1postdata = port1.DictoJson() |
| 549 | port2postdata = port2.DictoJson() |
| 550 | |
| 551 | main.step( "Post Network Data via HTTP(Post port need post network)" ) |
| 552 | Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/', |
| 553 | 'POST', None, networkpostdata ) |
| 554 | utilities.assert_equals( |
| 555 | expect='200', |
| 556 | actual=Poststatus, |
| 557 | onpass="Post Network Success", |
| 558 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 559 | |
| 560 | main.step( "Post Subnet Data via HTTP(Post port need post subnet)" ) |
| 561 | Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/', |
| 562 | 'POST', None, subnetpostdata ) |
| 563 | utilities.assert_equals( |
| 564 | expect='202', |
| 565 | actual=Poststatus, |
| 566 | onpass="Post Subnet Success", |
| 567 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 568 | |
| 569 | main.step( "Post Port1 Data via HTTP" ) |
| 570 | Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/', |
| 571 | 'POST', None, port1postdata ) |
| 572 | utilities.assert_equals( |
| 573 | expect='200', |
| 574 | actual=Poststatus, |
| 575 | onpass="Post Port Success", |
| 576 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 577 | |
| 578 | main.step( "Post Port2 Data via HTTP" ) |
| 579 | Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/', |
| 580 | 'POST', None, port2postdata ) |
| 581 | utilities.assert_equals( |
| 582 | expect='200', |
| 583 | actual=Poststatus, |
| 584 | onpass="Post Port Success", |
| 585 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 586 | |
| 587 | def CASE7( self, main ): |
| 588 | |
| 589 | """ |
| 590 | Test host go online and ping each other |
| 591 | """ |
| 592 | import re |
| 593 | import time |
| 594 | import os,sys |
| 595 | |
| 596 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 597 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 598 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 599 | |
| 600 | main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) ) |
| 601 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 602 | stepResult = assignResult |
| 603 | utilities.assert_equals( expect=main.TRUE, |
| 604 | actual=stepResult, |
| 605 | onpass="ovsdb node 1 set ovs manager to to " +\ |
| 606 | str( ctrlip ) + " sucess", |
| 607 | onfail="ovsdb node 1 set ovs manager to to " +\ |
| 608 | str( ctrlip ) + " failed" ) |
| 609 | |
| 610 | main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) ) |
| 611 | assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 612 | stepResult = assignResult |
| 613 | utilities.assert_equals( expect=main.TRUE, |
| 614 | actual=stepResult, |
| 615 | onpass="ovsdb node 2 set ovs manager to " +\ |
| 616 | str( ctrlip ) + " sucess", |
| 617 | onfail="ovsdb node 2 set ovs manager to " +\ |
| 618 | str( ctrlip ) + " failed" ) |
| 619 | |
| 620 | main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) ) |
| 621 | stepResult = main.OVSDB1.createHost( hostname="host1" ) |
| 622 | utilities.assert_equals( expect=main.TRUE, |
| 623 | actual=stepResult, |
| 624 | onpass="Create host1 on node 1 " + str( OVSDB1Ip ) + " sucess", |
| 625 | onfail="Create host1 on node 1 " + str( OVSDB1Ip ) + " failed" ) |
| 626 | |
| 627 | main.step( "Create host2 on node 2 " + str( OVSDB2Ip ) ) |
| 628 | stepResult = main.OVSDB2.createHost( hostname="host2" ) |
| 629 | utilities.assert_equals( expect=main.TRUE, |
| 630 | actual=stepResult, |
| 631 | onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess", |
| 632 | onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" ) |
| 633 | |
| 634 | main.step( "Create port on host1 on the node " + str ( OVSDB1Ip ) ) |
| 635 | stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" ) |
| 636 | utilities.assert_equals( expect=main.TRUE, |
| 637 | actual=stepResult, |
| 638 | onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess", |
| 639 | onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" ) |
| 640 | |
| 641 | main.step( "Create port on host2 on the node " + str ( OVSDB2Ip ) ) |
| 642 | stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" ) |
| 643 | utilities.assert_equals( expect=main.TRUE, |
| 644 | actual=stepResult, |
| 645 | onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess", |
| 646 | onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" ) |
| 647 | |
| 648 | main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB1Ip ) ) |
| 649 | stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001", |
| 650 | attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" ) |
| 651 | utilities.assert_equals( expect=main.TRUE, |
| 652 | actual=stepResult, |
| 653 | onpass="Add port to ovs br-int and host go-online on the node " +\ |
| 654 | str( OVSDB1Ip ) + " sucess", |
| 655 | onfail="Add port to ovs br-int and host go-online on the node " +\ |
| 656 | str( OVSDB1Ip ) + " failed" ) |
| 657 | |
| 658 | main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB2Ip ) ) |
| 659 | stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002", |
| 660 | attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" ) |
| 661 | utilities.assert_equals( expect=main.TRUE, |
| 662 | actual=stepResult, |
| 663 | onpass="Add port to ovs br-int and host go-online on the node " +\ |
| 664 | str( OVSDB2Ip ) + " sucess", |
| 665 | onfail="Add port to ovs br-int and host go-online on the node " +\ |
| 666 | str( OVSDB2Ip ) + " failed" ) |
| 667 | |
| 668 | main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) ) |
| 669 | response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" ) |
| 670 | if re.search( "00:00:00:00:00:01", response ): |
| 671 | stepResult = main.TRUE |
| 672 | else: |
| 673 | stepResult = main.FALSE |
| 674 | utilities.assert_equals( expect=main.TRUE, |
| 675 | actual=stepResult, |
| 676 | onpass="Check onos set host flows on the node " +\ |
| 677 | str( OVSDB1Ip ) + " sucess", |
| 678 | onfail="Check onos set host flows on the node " +\ |
| 679 | str( OVSDB1Ip ) + " failed" ) |
| 680 | |
| 681 | main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) ) |
| 682 | response = main.OVSDB2.dumpFlows( sw="br-int", protocols="OpenFlow13" ) |
| 683 | if re.search( "00:00:00:00:00:02", response ): |
| 684 | stepResult = main.TRUE |
| 685 | else: |
| 686 | stepResult = main.FALSE |
| 687 | utilities.assert_equals( expect=main.TRUE, |
| 688 | actual=stepResult, |
| 689 | onpass="Check onos set host flows on the node " +\ |
| 690 | str( OVSDB2Ip ) + " sucess", |
| 691 | onfail="Check onos set host flows on the node " +\ |
| 692 | str( OVSDB2Ip ) + " failed" ) |
| 693 | |
| 694 | main.step( "Check hosts can ping each other" ) |
| 695 | main.OVSDB1.setHostportIp( hostname="host1", hostport1="host1-eth0", ip="10.0.0.1" ) |
| 696 | main.OVSDB2.setHostportIp( hostname="host2", hostport1="host2-eth0", ip="10.0.0.2" ) |
| 697 | pingResult1 = main.OVSDB1.hostPing( src="10.0.0.1", hostname="host1", target="10.0.0.2" ) |
| 698 | pingResult2 = main.OVSDB2.hostPing( src="10.0.0.2", hostname="host2", target="10.0.0.1" ) |
| 699 | stepResult = pingResult1 and pingResult2 |
| 700 | utilities.assert_equals( expect=main.TRUE, |
| 701 | actual=stepResult, |
| 702 | onpass="Successfully host go online and ping each other,controller is " +\ |
| 703 | str( ctrlip ), |
| 704 | onfail="Failed to host go online and ping each other,controller is " +\ |
| 705 | str( ctrlip ) ) |
| 706 | |
| 707 | def CASE8( self, main ): |
| 708 | |
| 709 | """ |
| 710 | Clear ovs configuration and host configuration |
| 711 | """ |
| 712 | import re |
| 713 | import time |
| 714 | import os,sys |
| 715 | |
| 716 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 717 | OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] ) |
| 718 | OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] ) |
| 719 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 720 | |
| 721 | main.step( "Delete ovsdb node 1 manager" ) |
| 722 | deleteResult = main.OVSDB1.delManager( delaytime=delaytime ) |
| 723 | stepResult = deleteResult |
| 724 | utilities.assert_equals( expect=main.TRUE, |
| 725 | actual=stepResult, |
| 726 | onpass="ovsdb node 1 delete manager sucess", |
| 727 | onfail="ovsdb node 1 delete manager failed" ) |
| 728 | |
| 729 | main.step( "Delete ovsdb node 2 manager" ) |
| 730 | deleteResult = main.OVSDB2.delManager( delaytime=delaytime ) |
| 731 | stepResult = deleteResult |
| 732 | utilities.assert_equals( expect=main.TRUE, |
| 733 | actual=stepResult, |
| 734 | onpass="ovsdb node 2 delete manager sucess", |
| 735 | onfail="ovsdb node 2 delete manager failed" ) |
| 736 | |
| 737 | main.step( "Delete ovsdb node 1 bridge br-int" ) |
| 738 | deleteResult = main.OVSDB1.delBr( sw="br-int" ) |
| 739 | stepResult = deleteResult |
| 740 | utilities.assert_equals( expect=main.TRUE, |
| 741 | actual=stepResult, |
| 742 | onpass="Delete ovsdb node 1 bridge br-int sucess", |
| 743 | onfail="Delete ovsdb node 1 bridge br-int failed" ) |
| 744 | |
| 745 | main.step( "Delete ovsdb node 2 bridge br-int" ) |
| 746 | deleteResult = main.OVSDB2.delBr( sw="br-int" ) |
| 747 | stepResult = deleteResult |
| 748 | utilities.assert_equals( expect=main.TRUE, |
| 749 | actual=stepResult, |
| 750 | onpass="Delete ovsdb node 2 bridge br-int sucess", |
| 751 | onfail="Delete ovsdb node 2 bridge br-int failed" ) |
| 752 | |
| 753 | main.step( "Delete ip netns host on the ovsdb node 1" ) |
| 754 | deleteResult = main.OVSDB1.delHost( hostname="host1" ) |
| 755 | stepResult = deleteResult |
| 756 | utilities.assert_equals( expect=main.TRUE, |
| 757 | actual=stepResult, |
| 758 | onpass="Delete ip netns host on the ovsdb node 1 sucess", |
| 759 | onfail="Delete ip netns host on the ovsdb node 1 failed" ) |
| 760 | |
| 761 | main.step( "Delete ip netns host on the ovsdb node 2" ) |
| 762 | deleteResult = main.OVSDB2.delHost( hostname="host2" ) |
| 763 | stepResult = deleteResult |
| 764 | utilities.assert_equals( expect=main.TRUE, |
| 765 | actual=stepResult, |
| 766 | onpass="Delete ip netns host on the ovsdb node 2 sucess", |
| 767 | onfail="Delete ip netns host on the ovsdb node 2 failed" ) |
| 768 | |
| 769 | main.step( "Check onoscli devices openflow session is false " + str( OVSDB1Ip ) ) |
| 770 | response = main.ONOScli1.devices() |
| 771 | if re.search( OVSDB1Ip, response ) and not re.search( "true", response ): |
| 772 | stepResult = main.TRUE |
| 773 | else: |
| 774 | stepResult = main.FALSE |
| 775 | utilities.assert_equals( expect=main.TRUE, |
| 776 | actual=stepResult, |
| 777 | onpass="Check openflow session is false " + str( OVSDB1Ip ) + " sucess", |
| 778 | onfail="Check openflow session is false " + str( OVSDB1Ip ) + " failed" ) |
| 779 | |
| 780 | main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) ) |
| 781 | response = main.ONOScli1.devices() |
| 782 | if re.search( OVSDB2Ip, response ) and not re.search( "true", response ): |
| 783 | stepResult = main.TRUE |
| 784 | else: |
| 785 | stepResult = main.FALSE |
| 786 | utilities.assert_equals( expect=main.TRUE, |
| 787 | actual=stepResult, |
| 788 | onpass="Check openflow session is false " + str( OVSDB2Ip ) + " sucess", |
| 789 | onfail="Check openflow session is false " + str( OVSDB2Ip ) + " failed" ) |