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