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