zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 2 | Copyright 2015 Open Networking Foundation (ONF) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
| 21 | |
| 22 | """ |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 23 | Description: This test is to check onos set configuration and flows with ovsdb connection. |
| 24 | |
| 25 | List of test cases: |
| 26 | CASE1: Compile ONOS and push it to the test machines |
| 27 | CASE2: Test ovsdb connection and tearDown |
| 28 | CASE3: Test default br-int configuration and vxlan port |
| 29 | CASE4: Test default openflow configuration |
| 30 | CASE5: Test default flows |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 31 | CASE6: Configure Network Subnet Port |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 32 | CASE7: Test host go online and ping each other |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 33 | CASE8: Clear ovs configuration and host configuration |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 34 | zhanghaoyu7@huawei.com |
| 35 | """ |
| 36 | import os |
| 37 | |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 38 | |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 39 | class FUNCovsdbtest: |
| 40 | |
| 41 | def __init__( self ): |
| 42 | self.default = '' |
| 43 | |
| 44 | def CASE1( self, main ): |
| 45 | """ |
| 46 | CASE1 is to compile ONOS and push it to the test machines |
| 47 | |
| 48 | Startup sequence: |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 49 | Construct test variables |
| 50 | Safety check, kill all ONOS processes before setup |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 51 | NOTE: temporary - onos-remove-raft-logs |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 52 | Create ONOS package |
| 53 | Install ONOS package |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 54 | start cli sessions |
| 55 | start ovsdb |
| 56 | start vtn apps |
| 57 | """ |
| 58 | import os |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 59 | import time |
| 60 | main.log.info( "ONOS Single node start ovsdb test - initialization" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 61 | try: |
| 62 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 63 | main.testSetUp = ONOSSetup() |
| 64 | except ImportError: |
| 65 | main.log.error( "ONOSSetup not found. exiting the test" ) |
| 66 | main.exit() |
| 67 | main.testSetUp.envSetupDescription() |
| 68 | stepResult = main.FALSE |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 69 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 70 | try: |
| 71 | # load some variables from the params file |
| 72 | main.step( "Constructing test variables" ) |
| 73 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 74 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 75 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 76 | stepResult = main.testSetUp.envSetup() |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 77 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 78 | except Exception as e: |
| 79 | main.testSetUp.envSetupException( e ) |
| 80 | main.testSetUp.evnSetupConclusion( stepResult ) |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 81 | |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 82 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 83 | cliResults = main.testSetUp.ONOSSetUp( main.OVSDB1, main.Cluster, |
| 84 | cellName=cellName, removeLog=True ) |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 85 | |
| 86 | if cliResults == main.FALSE: |
| 87 | main.log.error( "Failed to start ONOS, stopping test" ) |
| 88 | main.cleanup() |
| 89 | main.exit() |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 90 | |
| 91 | main.step( "App Ids check" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 92 | appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck() |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 93 | |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 94 | if appCheck != main.TRUE: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 95 | main.log.warn( main.Cluster.active( 0 ).CLI.apps() ) |
| 96 | main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() ) |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 97 | |
| 98 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 99 | onpass="App Ids seem to be correct", |
| 100 | onfail="Something is wrong with app Ids" ) |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 101 | |
alison | d9915ea | 2016-08-12 10:16:26 -0700 | [diff] [blame] | 102 | main.step( "Install onos-ovsdb" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 103 | installResults = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.ovsdb" ) |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 104 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 105 | onpass="Install onos-ovsdatabase successful", |
| 106 | onfail="Install onos-ovsdatabase failed" ) |
| 107 | |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 108 | main.step( "Install onos-app-vtn" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 109 | installResults = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.vtn" ) |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 110 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 111 | onpass="Install onos-app-vtn successful", |
| 112 | onfail="Install onos-app-vtn failed" ) |
| 113 | |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 114 | def CASE2( self, main ): |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 115 | """ |
| 116 | Test ovsdb connection and teardown |
| 117 | """ |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 118 | import os |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 119 | import re |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 120 | |
| 121 | main.case( "Test ovsdb connection and teardown" ) |
| 122 | main.caseExplanation = "Test ovsdb connection create and delete" +\ |
| 123 | " over ovsdb node and onos node " |
| 124 | |
| 125 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 126 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 127 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 128 | |
| 129 | main.step( "Set ovsdb node manager" ) |
| 130 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 131 | stepResult = assignResult |
| 132 | utilities.assert_equals( expect=main.TRUE, |
| 133 | actual=stepResult, |
| 134 | onpass="Set ovsdb node manager sucess", |
| 135 | onfail="Set ovsdb node manager failed" ) |
| 136 | |
| 137 | main.step( "Check ovsdb node manager is " + str( ctrlip ) ) |
| 138 | response = main.OVSDB1.getManager() |
| 139 | if re.search( ctrlip, response ): |
| 140 | stepResult = main.TRUE |
| 141 | else: |
| 142 | stepResult = main.FALSE |
| 143 | utilities.assert_equals( expect=main.TRUE, |
| 144 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 145 | onpass="Check ovsdb node manager is " + str( response ), |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 146 | onfail="Check ovsdb node manager failed" ) |
| 147 | |
| 148 | main.step( "Delete ovsdb node manager" ) |
| 149 | deleteResult = main.OVSDB1.delManager( delaytime=delaytime ) |
| 150 | stepResult = deleteResult |
| 151 | utilities.assert_equals( expect=main.TRUE, |
| 152 | actual=stepResult, |
| 153 | onpass="ovsdb node delete manager sucess", |
| 154 | onfail="ovsdb node delete manager failed" ) |
| 155 | |
| 156 | main.step( "Check ovsdb node delete manager " + str( ctrlip ) ) |
| 157 | response = main.OVSDB1.getManager() |
| 158 | if not re.search( ctrlip, response ): |
| 159 | stepResult = main.TRUE |
| 160 | else: |
| 161 | stepResult = main.FALSE |
| 162 | utilities.assert_equals( expect=main.TRUE, |
| 163 | actual=stepResult, |
| 164 | onpass="Check ovsdb node delete manager sucess", |
| 165 | onfail="Check ovsdb node delete manager failed" ) |
| 166 | |
| 167 | def CASE3( self, main ): |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 168 | """ |
| 169 | Test default br-int configuration and vxlan port |
| 170 | """ |
| 171 | import re |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 172 | import os |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 173 | |
| 174 | main.case( "Test default br-int configuration and vxlan port" ) |
| 175 | main.caseExplanation = "onos create default br-int bridge and" +\ |
| 176 | " vxlan port on the ovsdb node" |
| 177 | |
| 178 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 179 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 180 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 181 | OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] ) |
| 182 | OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] ) |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 183 | |
| 184 | main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) ) |
| 185 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 186 | stepResult = assignResult |
| 187 | utilities.assert_equals( expect=main.TRUE, |
| 188 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 189 | onpass="ovsdb node 1 set ovs manager to to " + |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 190 | str( ctrlip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 191 | onfail="ovsdb node 1 set ovs manager to to " + |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 192 | str( ctrlip ) + " failed" ) |
| 193 | |
| 194 | main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) ) |
| 195 | assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 196 | stepResult = assignResult |
| 197 | utilities.assert_equals( expect=main.TRUE, |
| 198 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 199 | onpass="ovsdb node 2 set ovs manager to to " + |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 200 | str( ctrlip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 201 | onfail="ovsdb node 2 set ovs manager to to " + |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 202 | str( ctrlip ) + " failed" ) |
| 203 | |
| 204 | main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) ) |
| 205 | response = main.OVSDB1.getManager() |
| 206 | if re.search( ctrlip, response ): |
| 207 | stepResult = main.TRUE |
| 208 | else: |
| 209 | stepResult = main.FALSE |
| 210 | utilities.assert_equals( expect=main.TRUE, |
| 211 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 212 | onpass="ovsdb node 1 manager is " + str( response ), |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 213 | onfail="ovsdb node 1 manager check failed" ) |
| 214 | |
| 215 | main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) ) |
| 216 | response = main.OVSDB2.getManager() |
| 217 | if re.search( ctrlip, response ): |
| 218 | stepResult = main.TRUE |
| 219 | else: |
| 220 | stepResult = main.FALSE |
| 221 | utilities.assert_equals( expect=main.TRUE, |
| 222 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 223 | onpass="ovsdb node 2 manager is " + str( response ), |
zhanghaoyu | 451c139 | 2015-08-07 19:21:16 +0800 | [diff] [blame] | 224 | onfail="ovsdb node 2 manager check failed" ) |
| 225 | |
| 226 | main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) ) |
| 227 | response = main.OVSDB1.listBr() |
| 228 | if re.search( "br-int", response ): |
| 229 | stepResult = main.TRUE |
| 230 | else: |
| 231 | stepResult = main.FALSE |
| 232 | utilities.assert_equals( expect=main.TRUE, |
| 233 | actual=stepResult, |
| 234 | onpass="onos add default bridge on the node 1 sucess", |
| 235 | onfail="onos add default bridge on the node 1 failed" ) |
| 236 | |
| 237 | main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB2Ip ) ) |
| 238 | response = main.OVSDB2.listBr() |
| 239 | if re.search( "br-int", response ): |
| 240 | stepResult = main.TRUE |
| 241 | else: |
| 242 | stepResult = main.FALSE |
| 243 | utilities.assert_equals( expect=main.TRUE, |
| 244 | actual=stepResult, |
| 245 | onpass="onos add default bridge on the node 2 sucess", |
| 246 | onfail="onos add default bridge on the node 2 failed" ) |
| 247 | |
| 248 | main.step( "Check default vxlan port on ovsdb node " + str( OVSDB1Ip ) ) |
| 249 | response = main.OVSDB1.listPorts( "br-int" ) |
| 250 | if re.search( "vxlan", response ) and re.search( str( OVSDB2Ip ), response ): |
| 251 | stepResult = main.TRUE |
| 252 | else: |
| 253 | stepResult = main.FALSE |
| 254 | utilities.assert_equals( expect=main.TRUE, |
| 255 | actual=stepResult, |
| 256 | onpass="onos add default vxlan port on the node 1 sucess", |
| 257 | onfail="onos add default vxlan port on the node 1 failed" ) |
| 258 | |
| 259 | main.step( "Check default vxlan port on ovsdb node " + str( OVSDB2Ip ) ) |
| 260 | response = main.OVSDB2.listPorts( "br-int" ) |
| 261 | if re.search( "vxlan", response ) and re.search( str( OVSDB1Ip ), response ): |
| 262 | stepResult = main.TRUE |
| 263 | else: |
| 264 | stepResult = main.FALSE |
| 265 | utilities.assert_equals( expect=main.TRUE, |
| 266 | actual=stepResult, |
| 267 | onpass="onos add default vxlan port on the node 2 sucess", |
| 268 | onfail="onos add default vxlan port on the node 2 failed" ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 269 | |
| 270 | def CASE4( self, main ): |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 271 | """ |
| 272 | Test default openflow configuration |
| 273 | """ |
| 274 | import re |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 275 | import os |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 276 | |
| 277 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 278 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 279 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 280 | |
| 281 | main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) ) |
| 282 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 283 | stepResult = assignResult |
| 284 | utilities.assert_equals( expect=main.TRUE, |
| 285 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 286 | onpass="ovsdb node 1 set ovs manager to to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 287 | str( ctrlip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 288 | onfail="ovsdb node 1 set ovs manager to to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 289 | str( ctrlip ) + " failed" ) |
| 290 | |
| 291 | main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) ) |
| 292 | assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 293 | stepResult = assignResult |
| 294 | utilities.assert_equals( expect=main.TRUE, |
| 295 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 296 | onpass="ovsdb node 2 set ovs manager to to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 297 | str( ctrlip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 298 | onfail="ovsdb node 2 set ovs manager to to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 299 | str( ctrlip ) + " failed" ) |
| 300 | |
| 301 | main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) ) |
| 302 | response = main.OVSDB1.getManager() |
| 303 | if re.search( ctrlip, response ): |
| 304 | stepResult = main.TRUE |
| 305 | else: |
| 306 | stepResult = main.FALSE |
| 307 | utilities.assert_equals( expect=main.TRUE, |
| 308 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 309 | onpass="ovsdb node 1 manager is " + str( response ), |
| 310 | onfail="ovsdb node 1 manager check failed\n" + |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 311 | str( main.OVSDB1.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 312 | |
| 313 | main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) ) |
| 314 | response = main.OVSDB2.getManager() |
| 315 | if re.search( ctrlip, response ): |
| 316 | stepResult = main.TRUE |
| 317 | else: |
| 318 | stepResult = main.FALSE |
| 319 | utilities.assert_equals( expect=main.TRUE, |
| 320 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 321 | onpass="ovsdb node 2 manager is " + str( response ), |
| 322 | onfail="ovsdb node 2 manager check failed\n" + |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 323 | str( main.OVSDB2.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 324 | |
| 325 | main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) ) |
| 326 | response = main.OVSDB1.getController( "br-int" ) |
| 327 | if re.search( ctrlip, response ): |
| 328 | stepResult = main.TRUE |
| 329 | else: |
| 330 | stepResult = main.FALSE |
| 331 | utilities.assert_equals( expect=main.TRUE, |
| 332 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 333 | onpass="Check ovsdb node 1 bridge br-int controller set to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 334 | str( ctrlip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 335 | onfail="Check ovsdb node 1 bridge br-int controller set to " + |
sunyulin | 916e13e | 2015-10-15 20:27:23 +0800 | [diff] [blame] | 336 | str( ctrlip ) + " failed\n" + str( main.OVSDB1.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 337 | |
| 338 | main.step( "Check ovsdb node 2 bridge br-int controller set to " + str( ctrlip ) ) |
| 339 | response = main.OVSDB2.getController( "br-int" ) |
| 340 | if re.search( ctrlip, response ): |
| 341 | stepResult = main.TRUE |
| 342 | else: |
| 343 | stepResult = main.FALSE |
| 344 | utilities.assert_equals( expect=main.TRUE, |
| 345 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 346 | onpass="Check ovsdb node 2 bridge br-int controller set to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 347 | str( ctrlip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 348 | onfail="Check ovsdb node 2 bridge br-int controller set to " + |
| 349 | str( ctrlip ) + " failed\n" + str( main.OVSDB2.show() ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 350 | |
| 351 | main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 352 | response = main.Cluster.active( 0 ).CLI.devices() |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 353 | if re.search( OVSDB1Ip, response ) and not re.search( "false", response ): |
| 354 | stepResult = main.TRUE |
| 355 | else: |
| 356 | stepResult = main.FALSE |
| 357 | utilities.assert_equals( expect=main.TRUE, |
| 358 | actual=stepResult, |
| 359 | onpass="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " sucess", |
| 360 | onfail="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " failed" ) |
| 361 | |
| 362 | main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 363 | response = main.Cluster.active( 0 ).CLI.devices() |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 364 | if re.search( OVSDB2Ip, response ) and not re.search( "false", response ): |
| 365 | stepResult = main.TRUE |
| 366 | else: |
| 367 | stepResult = main.FALSE |
| 368 | utilities.assert_equals( expect=main.TRUE, |
| 369 | actual=stepResult, |
| 370 | onpass="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " sucess", |
| 371 | onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" ) |
| 372 | |
| 373 | def CASE5( self, main ): |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 374 | """ |
| 375 | Test default flows |
| 376 | """ |
| 377 | import re |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 378 | import os |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 379 | |
| 380 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 381 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 382 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 383 | |
| 384 | main.step( "ovsdb node 1 set ovs manager to onos" ) |
| 385 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 386 | stepResult = assignResult |
| 387 | utilities.assert_equals( expect=main.TRUE, |
| 388 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 389 | onpass="ovsdb node 1 set ovs manager to to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 390 | str( ctrlip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 391 | onfail="ovsdb node 1 set ovs manager to to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 392 | str( ctrlip ) + " failed" ) |
| 393 | |
| 394 | main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) ) |
| 395 | response = main.OVSDB1.getManager() |
| 396 | if re.search( ctrlip, response ): |
| 397 | stepResult = main.TRUE |
| 398 | else: |
| 399 | stepResult = main.FALSE |
| 400 | utilities.assert_equals( expect=main.TRUE, |
| 401 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 402 | onpass="ovsdb node 1 manager is " + str( response ), |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 403 | onfail="ovsdb node 1 manager check failed" ) |
| 404 | |
| 405 | main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) ) |
| 406 | response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" ) |
| 407 | if re.search( "actions=CONTROLLER", response ): |
| 408 | stepResult = main.TRUE |
| 409 | else: |
| 410 | stepResult = main.FALSE |
| 411 | utilities.assert_equals( expect=main.TRUE, |
| 412 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 413 | onpass="Successfully set default flows " + str( ctrlip ), |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 414 | onfail="Failed to set default flows " + str( ctrlip ) ) |
| 415 | |
| 416 | def CASE6( self, main ): |
| 417 | """ |
| 418 | Configure Network Subnet Port |
| 419 | """ |
| 420 | import os |
| 421 | |
| 422 | try: |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 423 | from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import NetworkData |
| 424 | from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import SubnetData |
| 425 | from tests.FUNC.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 426 | except ImportError: |
| 427 | main.log.exception( "Something wrong with import file or code error." ) |
| 428 | main.log.info( "Import Error, please check!" ) |
| 429 | main.cleanup() |
| 430 | main.exit() |
| 431 | |
| 432 | main.log.info( "Configure Network Subnet Port Start" ) |
| 433 | main.case( "Configure Network Subnet Port" ) |
| 434 | main.caseExplanation = "Configure Network Subnet Port " +\ |
| 435 | "Verify post is OK" |
| 436 | |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 437 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 438 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 439 | path = main.params[ 'HTTP' ][ 'path' ] |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 440 | |
| 441 | main.step( "Generate Post Data" ) |
| 442 | network = NetworkData() |
| 443 | network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc' |
| 444 | network.tenant_id = '26cd996094344a0598b0a1af1d525cdc' |
| 445 | subnet = SubnetData() |
| 446 | subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178" |
| 447 | subnet.tenant_id = network.tenant_id |
| 448 | subnet.network_id = network.id |
| 449 | subnet.start = "10.0.0.1" |
| 450 | subnet.end = "10.0.0.254" |
| 451 | subnet.cidr = "10.0.0.0/24" |
| 452 | port1 = VirtualPortData() |
| 453 | port1.id = "00000000-0000-0000-0000-000000000001" |
| 454 | port1.subnet_id = subnet.id |
| 455 | port1.tenant_id = network.tenant_id |
| 456 | port1.network_id = network.id |
| 457 | port1.macAddress = "00:00:00:00:00:01" |
| 458 | port1.ip_address = "10.0.0.1" |
| 459 | port2 = VirtualPortData() |
| 460 | port2.id = "00000000-0000-0000-0000-000000000002" |
| 461 | port2.subnet_id = subnet.id |
| 462 | port2.tenant_id = network.tenant_id |
| 463 | port2.network_id = network.id |
| 464 | port2.macAddress = "00:00:00:00:00:02" |
| 465 | port2.ip_address = "10.0.0.2" |
| 466 | |
| 467 | networkpostdata = network.DictoJson() |
| 468 | subnetpostdata = subnet.DictoJson() |
| 469 | port1postdata = port1.DictoJson() |
| 470 | port2postdata = port2.DictoJson() |
| 471 | |
| 472 | main.step( "Post Network Data via HTTP(Post port need post network)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 473 | Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, httpport, '', path + 'networks/', |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 474 | 'POST', None, networkpostdata ) |
| 475 | utilities.assert_equals( |
| 476 | expect='200', |
| 477 | actual=Poststatus, |
| 478 | onpass="Post Network Success", |
| 479 | onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) ) |
| 480 | |
| 481 | main.step( "Post Subnet Data via HTTP(Post port need post subnet)" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 482 | Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, httpport, '', path + 'subnets/', |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 483 | 'POST', None, subnetpostdata ) |
| 484 | utilities.assert_equals( |
| 485 | expect='202', |
| 486 | actual=Poststatus, |
| 487 | onpass="Post Subnet Success", |
| 488 | onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) ) |
| 489 | |
| 490 | main.step( "Post Port1 Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 491 | Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, httpport, '', path + 'ports/', |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 492 | 'POST', None, port1postdata ) |
| 493 | utilities.assert_equals( |
| 494 | expect='200', |
| 495 | actual=Poststatus, |
| 496 | onpass="Post Port Success", |
| 497 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 498 | |
| 499 | main.step( "Post Port2 Data via HTTP" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 500 | Poststatus, result = main.Cluster.active( 0 ).REST.send( ctrlip, httpport, '', path + 'ports/', |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 501 | 'POST', None, port2postdata ) |
| 502 | utilities.assert_equals( |
| 503 | expect='200', |
| 504 | actual=Poststatus, |
| 505 | onpass="Post Port Success", |
| 506 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 507 | |
| 508 | def CASE7( self, main ): |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 509 | """ |
| 510 | Test host go online and ping each other |
| 511 | """ |
| 512 | import re |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 513 | import os |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 514 | |
| 515 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 516 | ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ] |
| 517 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 518 | |
| 519 | main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) ) |
| 520 | assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 521 | stepResult = assignResult |
| 522 | utilities.assert_equals( expect=main.TRUE, |
| 523 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 524 | onpass="ovsdb node 1 set ovs manager to to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 525 | str( ctrlip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 526 | onfail="ovsdb node 1 set ovs manager to to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 527 | str( ctrlip ) + " failed" ) |
| 528 | |
| 529 | main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) ) |
| 530 | assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime ) |
| 531 | stepResult = assignResult |
| 532 | utilities.assert_equals( expect=main.TRUE, |
| 533 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 534 | onpass="ovsdb node 2 set ovs manager to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 535 | str( ctrlip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 536 | onfail="ovsdb node 2 set ovs manager to " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 537 | str( ctrlip ) + " failed" ) |
| 538 | |
| 539 | main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) ) |
| 540 | stepResult = main.OVSDB1.createHost( hostname="host1" ) |
| 541 | utilities.assert_equals( expect=main.TRUE, |
| 542 | actual=stepResult, |
| 543 | onpass="Create host1 on node 1 " + str( OVSDB1Ip ) + " sucess", |
| 544 | onfail="Create host1 on node 1 " + str( OVSDB1Ip ) + " failed" ) |
| 545 | |
| 546 | main.step( "Create host2 on node 2 " + str( OVSDB2Ip ) ) |
| 547 | stepResult = main.OVSDB2.createHost( hostname="host2" ) |
| 548 | utilities.assert_equals( expect=main.TRUE, |
| 549 | actual=stepResult, |
| 550 | onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess", |
| 551 | onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" ) |
| 552 | |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 553 | main.step( "Create port on host1 on the node " + str( OVSDB1Ip ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 554 | stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" ) |
| 555 | utilities.assert_equals( expect=main.TRUE, |
| 556 | actual=stepResult, |
| 557 | onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess", |
| 558 | onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" ) |
| 559 | |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 560 | main.step( "Create port on host2 on the node " + str( OVSDB2Ip ) ) |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 561 | stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" ) |
| 562 | utilities.assert_equals( expect=main.TRUE, |
| 563 | actual=stepResult, |
| 564 | onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess", |
| 565 | onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" ) |
| 566 | |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 567 | 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] | 568 | stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001", |
| 569 | attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" ) |
| 570 | utilities.assert_equals( expect=main.TRUE, |
| 571 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 572 | 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] | 573 | str( OVSDB1Ip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 574 | 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] | 575 | str( OVSDB1Ip ) + " failed" ) |
| 576 | |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 577 | 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] | 578 | stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002", |
| 579 | attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" ) |
| 580 | utilities.assert_equals( expect=main.TRUE, |
| 581 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 582 | 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] | 583 | str( OVSDB2Ip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 584 | 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] | 585 | str( OVSDB2Ip ) + " failed" ) |
| 586 | |
| 587 | main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) ) |
| 588 | response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" ) |
| 589 | if re.search( "00:00:00:00:00:01", response ): |
| 590 | stepResult = main.TRUE |
| 591 | else: |
| 592 | stepResult = main.FALSE |
| 593 | utilities.assert_equals( expect=main.TRUE, |
| 594 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 595 | onpass="Check onos set host flows on the node " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 596 | str( OVSDB1Ip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 597 | onfail="Check onos set host flows on the node " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 598 | str( OVSDB1Ip ) + " failed" ) |
| 599 | |
| 600 | main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) ) |
| 601 | response = main.OVSDB2.dumpFlows( sw="br-int", protocols="OpenFlow13" ) |
| 602 | if re.search( "00:00:00:00:00:02", response ): |
| 603 | stepResult = main.TRUE |
| 604 | else: |
| 605 | stepResult = main.FALSE |
| 606 | utilities.assert_equals( expect=main.TRUE, |
| 607 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 608 | onpass="Check onos set host flows on the node " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 609 | str( OVSDB2Ip ) + " sucess", |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 610 | onfail="Check onos set host flows on the node " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 611 | str( OVSDB2Ip ) + " failed" ) |
| 612 | |
| 613 | main.step( "Check hosts can ping each other" ) |
| 614 | main.OVSDB1.setHostportIp( hostname="host1", hostport1="host1-eth0", ip="10.0.0.1" ) |
| 615 | main.OVSDB2.setHostportIp( hostname="host2", hostport1="host2-eth0", ip="10.0.0.2" ) |
| 616 | pingResult1 = main.OVSDB1.hostPing( src="10.0.0.1", hostname="host1", target="10.0.0.2" ) |
| 617 | pingResult2 = main.OVSDB2.hostPing( src="10.0.0.2", hostname="host2", target="10.0.0.1" ) |
| 618 | stepResult = pingResult1 and pingResult2 |
| 619 | utilities.assert_equals( expect=main.TRUE, |
| 620 | actual=stepResult, |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 621 | onpass="Successfully host go online and ping each other,controller is " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 622 | str( ctrlip ), |
Jon Hall | 8638b56 | 2017-05-24 16:39:59 -0700 | [diff] [blame] | 623 | onfail="Failed to host go online and ping each other,controller is " + |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 624 | str( ctrlip ) ) |
| 625 | |
| 626 | def CASE8( self, main ): |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 627 | """ |
| 628 | Clear ovs configuration and host configuration |
| 629 | """ |
| 630 | import re |
alison | 6acef9f | 2016-09-28 12:29:08 -0700 | [diff] [blame] | 631 | import os |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 632 | |
| 633 | ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 634 | OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] ) |
| 635 | OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] ) |
| 636 | delaytime = main.params[ 'TIMER' ][ 'delaytime' ] |
| 637 | |
| 638 | main.step( "Delete ovsdb node 1 manager" ) |
| 639 | deleteResult = main.OVSDB1.delManager( delaytime=delaytime ) |
| 640 | stepResult = deleteResult |
| 641 | utilities.assert_equals( expect=main.TRUE, |
| 642 | actual=stepResult, |
| 643 | onpass="ovsdb node 1 delete manager sucess", |
| 644 | onfail="ovsdb node 1 delete manager failed" ) |
| 645 | |
| 646 | main.step( "Delete ovsdb node 2 manager" ) |
| 647 | deleteResult = main.OVSDB2.delManager( delaytime=delaytime ) |
| 648 | stepResult = deleteResult |
| 649 | utilities.assert_equals( expect=main.TRUE, |
| 650 | actual=stepResult, |
| 651 | onpass="ovsdb node 2 delete manager sucess", |
| 652 | onfail="ovsdb node 2 delete manager failed" ) |
| 653 | |
| 654 | main.step( "Delete ovsdb node 1 bridge br-int" ) |
| 655 | deleteResult = main.OVSDB1.delBr( sw="br-int" ) |
| 656 | stepResult = deleteResult |
| 657 | utilities.assert_equals( expect=main.TRUE, |
| 658 | actual=stepResult, |
| 659 | onpass="Delete ovsdb node 1 bridge br-int sucess", |
| 660 | onfail="Delete ovsdb node 1 bridge br-int failed" ) |
| 661 | |
| 662 | main.step( "Delete ovsdb node 2 bridge br-int" ) |
| 663 | deleteResult = main.OVSDB2.delBr( sw="br-int" ) |
| 664 | stepResult = deleteResult |
| 665 | utilities.assert_equals( expect=main.TRUE, |
| 666 | actual=stepResult, |
| 667 | onpass="Delete ovsdb node 2 bridge br-int sucess", |
| 668 | onfail="Delete ovsdb node 2 bridge br-int failed" ) |
| 669 | |
| 670 | main.step( "Delete ip netns host on the ovsdb node 1" ) |
| 671 | deleteResult = main.OVSDB1.delHost( hostname="host1" ) |
| 672 | stepResult = deleteResult |
| 673 | utilities.assert_equals( expect=main.TRUE, |
| 674 | actual=stepResult, |
| 675 | onpass="Delete ip netns host on the ovsdb node 1 sucess", |
| 676 | onfail="Delete ip netns host on the ovsdb node 1 failed" ) |
| 677 | |
| 678 | main.step( "Delete ip netns host on the ovsdb node 2" ) |
| 679 | deleteResult = main.OVSDB2.delHost( hostname="host2" ) |
| 680 | stepResult = deleteResult |
| 681 | utilities.assert_equals( expect=main.TRUE, |
| 682 | actual=stepResult, |
| 683 | onpass="Delete ip netns host on the ovsdb node 2 sucess", |
| 684 | onfail="Delete ip netns host on the ovsdb node 2 failed" ) |
| 685 | |
| 686 | main.step( "Check onoscli devices openflow session is false " + str( OVSDB1Ip ) ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 687 | response = main.Cluster.active( 0 ).CLI.devices() |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 688 | if re.search( OVSDB1Ip, response ) and not re.search( "true", response ): |
| 689 | stepResult = main.TRUE |
| 690 | else: |
| 691 | stepResult = main.FALSE |
| 692 | utilities.assert_equals( expect=main.TRUE, |
| 693 | actual=stepResult, |
| 694 | onpass="Check openflow session is false " + str( OVSDB1Ip ) + " sucess", |
| 695 | onfail="Check openflow session is false " + str( OVSDB1Ip ) + " failed" ) |
| 696 | |
| 697 | main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 698 | response = main.Cluster.active( 0 ).CLI.devices() |
zhanghaoyu7 | 474d8c6 | 2015-08-26 14:53:28 +0800 | [diff] [blame] | 699 | if re.search( OVSDB2Ip, response ) and not re.search( "true", response ): |
| 700 | stepResult = main.TRUE |
| 701 | else: |
| 702 | stepResult = main.FALSE |
| 703 | utilities.assert_equals( expect=main.TRUE, |
| 704 | actual=stepResult, |
| 705 | onpass="Check openflow session is false " + str( OVSDB2Ip ) + " sucess", |
Jon Hall | 53c5e66 | 2016-04-13 16:06:56 -0700 | [diff] [blame] | 706 | onfail="Check openflow session is false " + str( OVSDB2Ip ) + " failed" ) |