Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
| 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 | """ |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 21 | |
| 22 | # Testing the basic intent functionality of ONOS |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 23 | # TODO: Replace the CLI calls with REST API equivalents as they become available. |
| 24 | # - May need to write functions in the onosrestdriver.py file to do this |
| 25 | # TODO: Complete implementation of case 3000, 4000, and 6000 as REST API allows |
| 26 | # -Currently there is no support in the REST API for Multi to Single and Single to Multi point intents |
| 27 | # As such, these cases are incomplete and should not be enabled in the .params file |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 28 | |
| 29 | import time |
| 30 | import json |
| 31 | |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 32 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 33 | class FUNCintentRest: |
| 34 | |
| 35 | def __init__( self ): |
| 36 | self.default = '' |
| 37 | |
| 38 | def CASE1( self, main ): |
| 39 | import time |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 40 | import imp |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 41 | import re |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 42 | """ |
| 43 | - Construct tests variables |
| 44 | - GIT ( optional ) |
| 45 | - Checkout ONOS master branch |
| 46 | - Pull latest ONOS code |
| 47 | - Building ONOS ( optional ) |
| 48 | - Install ONOS package |
| 49 | - Build ONOS package |
| 50 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 51 | try: |
| 52 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 53 | main.testSetUp = ONOSSetup() |
| 54 | except ImportError: |
| 55 | main.log.error( "ONOSSetup not found. exiting the test" ) |
| 56 | main.exit() |
| 57 | main.testSetUp.envSetupDescription() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 58 | stepResult = main.FALSE |
| 59 | |
| 60 | # Test variables |
| 61 | try: |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 62 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 63 | main.dependencyPath = main.testOnDirectory + \ |
| 64 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 65 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 66 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 67 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 68 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 69 | wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ] |
| 70 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 71 | main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] ) |
| 72 | main.removeIntentsleeo = int( main.params[ 'SLEEP' ][ 'removeintent' ] ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 73 | main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] ) |
| 74 | main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] ) |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 75 | main.addIntentSleep = int( main.params[ 'SLEEP' ][ 'addIntent' ] ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 76 | main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] ) |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 77 | main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 78 | main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] ) |
| 79 | main.numLinks = int( main.params[ 'MININET' ][ 'links' ] ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 80 | main.hostsData = {} |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 81 | main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' ) |
| 82 | main.scapyHosts = [] # List of scapy hosts for iterating |
| 83 | main.assertReturnString = '' # Assembled assert return string |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 84 | main.cycle = 0 # How many times FUNCintent has run through its tests |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 85 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 86 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 87 | |
| 88 | main.intentFunction = imp.load_source( wrapperFile2, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 89 | main.dependencyPath + |
| 90 | wrapperFile2 + |
| 91 | ".py" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 92 | |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 93 | copyResult1 = main.ONOSbench.scp( main.Mininet1, |
| 94 | main.dependencyPath + |
| 95 | main.topology, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 96 | main.Mininet1.home + "custom/", |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 97 | direction="to" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 98 | stepResult = main.testSetUp.envSetup() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 99 | except Exception as e: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 100 | main.testSetUp.envSetupException(e) |
| 101 | main.testSetUp.evnSetupConclusion( stepResult ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 102 | |
| 103 | def CASE2( self, main ): |
| 104 | """ |
| 105 | - Set up cell |
| 106 | - Create cell file |
| 107 | - Set cell file |
| 108 | - Verify cell file |
| 109 | - Kill ONOS process |
| 110 | - Uninstall ONOS cluster |
| 111 | - Verify ONOS start up |
| 112 | - Install ONOS cluster |
| 113 | - Connect to cli |
| 114 | """ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 115 | main.flowCompiler = "Flow Rules" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 116 | main.initialized = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, True ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 117 | main.intentFunction.report( main ) |
| 118 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 119 | def CASE8( self, main ): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 120 | try: |
| 121 | from tests.dependencies.topology import Topology |
| 122 | except ImportError: |
| 123 | main.log.error( "Topology not found exiting the test" ) |
| 124 | main.exit() |
| 125 | try: |
| 126 | main.topoRelated |
| 127 | except ( NameError, AttributeError ): |
| 128 | main.topoRelated = Topology() |
| 129 | main.topoRelated.compareTopos( main.Mininet1, main.checkTopoAttempts ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 130 | |
| 131 | def CASE9( self, main ): |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 132 | """ |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 133 | Report errors/warnings/exceptions |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 134 | """ |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 135 | main.log.info( "Error report: \n" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 136 | main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 137 | [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR", "Except" ], |
| 138 | "s" ) |
| 139 | #main.ONOSbench.logReport( globalONOSip[ 1 ], [ "INFO" ], "d" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 140 | |
| 141 | def CASE10( self, main ): |
| 142 | """ |
| 143 | Start Mininet topology with OF 1.0 switches |
| 144 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 145 | if main.initialized == main.FALSE: |
| 146 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 147 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 148 | main.OFProtocol = "1.0" |
| 149 | main.log.report( "Start Mininet topology with OF 1.0 switches" ) |
| 150 | main.case( "Start Mininet topology with OF 1.0 switches" ) |
| 151 | main.caseExplanation = "Start mininet topology with OF 1.0 " +\ |
| 152 | "switches to test intents, exits out if " +\ |
| 153 | "topology did not start correctly" |
| 154 | |
| 155 | main.step( "Starting Mininet topology with OF 1.0 switches" ) |
| 156 | args = "--switch ovs,protocols=OpenFlow10" |
| 157 | topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + |
| 158 | main.topology, |
| 159 | args=args ) |
| 160 | stepResult = topoResult |
| 161 | utilities.assert_equals( expect=main.TRUE, |
| 162 | actual=stepResult, |
| 163 | onpass="Successfully loaded topology", |
| 164 | onfail="Failed to load topology" ) |
| 165 | # Exit if topology did not load properly |
| 166 | if not topoResult: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 167 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 168 | |
| 169 | def CASE11( self, main ): |
| 170 | """ |
| 171 | Start Mininet topology with OF 1.3 switches |
| 172 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 173 | if main.initialized == main.FALSE: |
| 174 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 175 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 176 | main.OFProtocol = "1.3" |
| 177 | main.log.report( "Start Mininet topology with OF 1.3 switches" ) |
| 178 | main.case( "Start Mininet topology with OF 1.3 switches" ) |
| 179 | main.caseExplanation = "Start mininet topology with OF 1.3 " +\ |
| 180 | "switches to test intents, exits out if " +\ |
| 181 | "topology did not start correctly" |
| 182 | |
| 183 | main.step( "Starting Mininet topology with OF 1.3 switches" ) |
| 184 | args = "--switch ovs,protocols=OpenFlow13" |
| 185 | topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + |
| 186 | main.topology, |
| 187 | args=args ) |
| 188 | stepResult = topoResult |
| 189 | utilities.assert_equals( expect=main.TRUE, |
| 190 | actual=stepResult, |
| 191 | onpass="Successfully loaded topology", |
| 192 | onfail="Failed to load topology" ) |
| 193 | # Exit if topology did not load properly |
| 194 | if not topoResult: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 195 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 196 | |
| 197 | def CASE12( self, main ): |
| 198 | """ |
| 199 | Assign mastership to controllers |
| 200 | """ |
| 201 | import re |
| 202 | |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 203 | if main.initialized == main.FALSE: |
| 204 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 205 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 206 | main.case( "Assign switches to controllers" ) |
| 207 | main.step( "Assigning switches to controllers" ) |
| 208 | main.caseExplanation = "Assign OF " + main.OFProtocol +\ |
| 209 | " switches to ONOS nodes" |
| 210 | |
| 211 | assignResult = main.TRUE |
| 212 | switchList = [] |
| 213 | |
| 214 | # Creates a list switch name, use getSwitch() function later... |
| 215 | for i in range( 1, ( main.numSwitch + 1 ) ): |
| 216 | switchList.append( 's' + str( i ) ) |
| 217 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 218 | tempONOSip = main.Cluster.getIps() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 219 | |
| 220 | assignResult = main.Mininet1.assignSwController( sw=switchList, |
| 221 | ip=tempONOSip, |
Charles Chan | 029be65 | 2015-08-24 01:46:10 +0800 | [diff] [blame] | 222 | port='6653' ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 223 | if not assignResult: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 224 | main.log.error( "Problem assigning mastership of switches, skipping further test cases" ) |
| 225 | main.initialized = main.FALSE |
| 226 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 227 | |
| 228 | for i in range( 1, ( main.numSwitch + 1 ) ): |
| 229 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 230 | print( "Response is " + str( response ) ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 231 | if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ): |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 232 | assignResult = assignResult and main.TRUE |
| 233 | else: |
| 234 | assignResult = main.FALSE |
| 235 | stepResult = assignResult |
| 236 | utilities.assert_equals( expect=main.TRUE, |
| 237 | actual=stepResult, |
| 238 | onpass="Successfully assigned switches" + |
| 239 | "to controller", |
| 240 | onfail="Failed to assign switches to " + |
| 241 | "controller" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 242 | if not stepResult: |
| 243 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 244 | |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 245 | def CASE13( self, main ): |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 246 | """ |
| 247 | Create Scapy components |
| 248 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 249 | if main.initialized == main.FALSE: |
| 250 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 251 | main.skipCase() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 252 | main.case( "Create scapy components" ) |
| 253 | main.step( "Create scapy components" ) |
| 254 | import json |
| 255 | scapyResult = main.TRUE |
| 256 | for hostName in main.scapyHostNames: |
| 257 | main.Scapy1.createHostComponent( hostName ) |
| 258 | main.scapyHosts.append( getattr( main, hostName ) ) |
| 259 | |
| 260 | main.step( "Start scapy components" ) |
| 261 | for host in main.scapyHosts: |
| 262 | host.startHostCli() |
| 263 | host.startScapy() |
| 264 | host.updateSelf() |
| 265 | main.log.debug( host.name ) |
| 266 | main.log.debug( host.hostIp ) |
| 267 | main.log.debug( host.hostMac ) |
| 268 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 269 | utilities.assert_equals( expect=main.TRUE, |
| 270 | actual=scapyResult, |
| 271 | onpass="Successfully created Scapy Components", |
| 272 | onfail="Failed to discover Scapy Components" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 273 | if not scapyResult: |
| 274 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 275 | |
| 276 | def CASE14( self, main ): |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 277 | """ |
| 278 | Discover all hosts and store its data to a dictionary |
| 279 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 280 | if main.initialized == main.FALSE: |
| 281 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 282 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 283 | main.case( "Discover all hosts" ) |
| 284 | |
| 285 | stepResult = main.TRUE |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 286 | main.step( "Discover all ipv4 host hosts " ) |
| 287 | hostList = [] |
| 288 | # List of host with default vlan |
| 289 | defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ] |
| 290 | # Lists of host with unique vlan |
| 291 | vlanHosts1 = [ "h4", "h12", "h20" ] |
| 292 | vlanHosts2 = [ "h5", "h13", "h21" ] |
| 293 | vlanHosts3 = [ "h6", "h14", "h22" ] |
| 294 | vlanHosts4 = [ "h7", "h15", "h23" ] |
| 295 | hostList.append( defaultHosts ) |
| 296 | hostList.append( vlanHosts1 ) |
| 297 | hostList.append( vlanHosts2 ) |
| 298 | hostList.append( vlanHosts3 ) |
| 299 | hostList.append( vlanHosts4 ) |
| 300 | |
| 301 | stepResult = main.intentFunction.getHostsData( main, hostList ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 302 | utilities.assert_equals( expect=main.TRUE, |
| 303 | actual=stepResult, |
| 304 | onpass="Successfully discovered hosts", |
| 305 | onfail="Failed to discover hosts" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 306 | if not stepResult: |
| 307 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 308 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 309 | def CASE15( self, main ): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 310 | """main.topo. |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 311 | Discover all hosts with scapy arp packets and store its data to a dictionary |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 312 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 313 | if main.initialized == main.FALSE: |
| 314 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 315 | main.skipCase() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 316 | main.case( "Discover all hosts using scapy" ) |
| 317 | main.step( "Send packets from each host to the first host and confirm onos discovery" ) |
| 318 | |
| 319 | import collections |
| 320 | if len( main.scapyHosts ) < 1: |
| 321 | main.log.error( "No scapy hosts have been created" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 322 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 323 | main.skipCase() |
| 324 | |
| 325 | # Send ARP packets from each scapy host component |
| 326 | main.intentFunction.sendDiscoveryArp( main, main.scapyHosts ) |
| 327 | |
| 328 | stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery, |
| 329 | retValue=main.FALSE, args=[ main ], |
| 330 | attempts=main.checkTopoAttempts, sleep=2 ) |
| 331 | |
| 332 | utilities.assert_equals( expect=main.TRUE, |
| 333 | actual=stepResult, |
| 334 | onpass="ONOS correctly discovered all hosts", |
| 335 | onfail="ONOS incorrectly discovered hosts" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 336 | if not stepResult: |
| 337 | main.initialized = main.FALSE |
| 338 | main.skipCase() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 339 | |
| 340 | main.step( "Populate hostsData" ) |
| 341 | stepResult = main.intentFunction.populateHostData( main ) |
| 342 | utilities.assert_equals( expect=main.TRUE, |
| 343 | actual=stepResult, |
| 344 | onpass="Successfully populated hostsData", |
| 345 | onfail="Failed to populate hostsData" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 346 | if not stepResult: |
| 347 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 348 | |
| 349 | def CASE16( self, main ): |
| 350 | """ |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 351 | Balance Masters |
| 352 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 353 | if main.initialized == main.FALSE: |
| 354 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 355 | main.skipCase() |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 356 | main.case( "Balance mastership of switches" ) |
| 357 | main.step( "Balancing mastership of switches" ) |
| 358 | |
| 359 | balanceResult = main.FALSE |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 360 | balanceResult = utilities.retry( f=main.Cluster.active( 0 ).CLI.balanceMasters, retValue=main.FALSE, args=[] ) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 361 | |
| 362 | utilities.assert_equals( expect=main.TRUE, |
| 363 | actual=stepResult, |
| 364 | onpass="Successfully balanced mastership of switches", |
| 365 | onfail="Failed to balance mastership of switches" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 366 | if not stepResult: |
| 367 | main.initialized = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 368 | |
| 369 | def CASE17( self, main ): |
| 370 | """ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 371 | Use Flow Objectives |
| 372 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 373 | if main.initialized == main.FALSE: |
| 374 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 375 | main.skipCase() |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 376 | main.case( "Enable intent compilation using Flow Objectives" ) |
| 377 | main.step( "Enabling Flow Objectives" ) |
| 378 | |
| 379 | main.flowCompiler = "Flow Objectives" |
| 380 | |
| 381 | cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator" |
| 382 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 383 | stepResult = main.Cluster.active( 0 ).CLI.setCfg( component=cmd, |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 384 | propName="useFlowObjectives", value="true" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 385 | stepResult &= main.Cluster.active( 0 ).CLI.setCfg( component=cmd, |
You Wang | 106d0fa | 2017-05-15 17:22:15 -0700 | [diff] [blame] | 386 | propName="defaultFlowObjectiveCompiler", |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 387 | value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' ) |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 388 | |
| 389 | utilities.assert_equals( expect=main.TRUE, |
| 390 | actual=stepResult, |
| 391 | onpass="Successfully activated Flow Objectives", |
| 392 | onfail="Failed to activate Flow Objectives" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 393 | if not stepResult: |
| 394 | main.initialized = main.FALSE |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 395 | |
| 396 | def CASE18( self, main ): |
| 397 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 398 | Stop mininet and remove scapy hosts |
| 399 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 400 | try: |
| 401 | from tests.dependencies.utils import Utils |
| 402 | except ImportError: |
| 403 | main.log.error( "Utils not found exiting the test" ) |
| 404 | main.exit() |
| 405 | try: |
| 406 | main.Utils |
| 407 | except ( NameError, AttributeError ): |
| 408 | main.Utils = Utils() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 409 | main.log.report( "Stop Mininet and Scapy" ) |
| 410 | main.case( "Stop Mininet and Scapy" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 411 | main.caseExplanation = "Stopping the current mininet topology " +\ |
| 412 | "to start up fresh" |
| 413 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 414 | main.step( "Stopping and Removing Scapy Host Components" ) |
| 415 | scapyResult = main.TRUE |
| 416 | for host in main.scapyHosts: |
| 417 | scapyResult = scapyResult and host.stopScapy() |
| 418 | main.log.info( "Stopped Scapy Host: {0}".format( host.name ) ) |
| 419 | |
| 420 | for host in main.scapyHosts: |
| 421 | scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name ) |
| 422 | main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) ) |
| 423 | |
| 424 | main.scapyHosts = [] |
| 425 | main.scapyHostIPs = [] |
| 426 | |
| 427 | utilities.assert_equals( expect=main.TRUE, |
| 428 | actual=scapyResult, |
| 429 | onpass="Successfully stopped scapy and removed host components", |
| 430 | onfail="Failed to stop mininet and scapy" ) |
| 431 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 432 | mininetResult = main.Utils.mininetCleanup( main.Mininet1 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 433 | # Exit if topology did not load properly |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 434 | if not ( mininetResult and scapyResult ): |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 435 | main.cleanup() |
| 436 | main.exit() |
| 437 | |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 438 | def CASE19( self, main ): |
| 439 | """ |
| 440 | Copy the karaf.log files after each testcase cycle |
| 441 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 442 | try: |
| 443 | from tests.dependencies.utils import Utils |
| 444 | except ImportError: |
| 445 | main.log.error( "Utils not found exiting the test" ) |
| 446 | main.exit() |
| 447 | try: |
| 448 | main.Utils |
| 449 | except ( NameError, AttributeError ): |
| 450 | main.Utils = Utils() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 451 | main.Utils.copyKarafLog( "cycle" + str( main.cycle ) ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 452 | def CASE1000( self, main ): |
| 453 | """ |
| 454 | Add host intents between 2 host: |
| 455 | - Discover hosts |
| 456 | - Add host intents |
| 457 | - Check intents |
| 458 | - Verify flows |
| 459 | - Ping hosts |
| 460 | - Reroute |
| 461 | - Link down |
| 462 | - Verify flows |
| 463 | - Check topology |
| 464 | - Ping hosts |
| 465 | - Link up |
| 466 | - Verify flows |
| 467 | - Check topology |
| 468 | - Ping hosts |
| 469 | - Remove intents |
| 470 | """ |
| 471 | import time |
| 472 | import json |
| 473 | import re |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 474 | if main.initialized == main.FALSE: |
| 475 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 476 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 477 | # Assert variables - These variable's name|format must be followed |
| 478 | # if you want to use the wrapper function |
| 479 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 480 | try: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 481 | assert main.Mininet1 |
| 482 | except AssertionError: |
| 483 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 484 | main.initialized = main.FALSE |
| 485 | main.skipCase() |
| 486 | try: |
| 487 | assert main.numSwitch |
| 488 | except AssertionError: |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 489 | main.log.error( "Place the total number of switch topology in " + |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 490 | main.numSwitch ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 491 | main.initialized = main.FALSE |
| 492 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 493 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 494 | # Save leader candidates |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 495 | intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates() |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 496 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 497 | main.case( "Host Intents Test - " + str( main.Cluster.numCtrls ) + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 498 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 499 | main.caseExplanation = "This test case tests Host intents using " +\ |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 500 | str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\ |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 501 | "Different type of hosts will be tested in " +\ |
| 502 | "each step such as IPV4, Dual stack, VLAN " +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 503 | "etc;\nThe test will use OF " + main.OFProtocol +\ |
| 504 | " OVS running in Mininet and compile intents" +\ |
| 505 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 506 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 507 | main.step( "IPV4: Add and test host intents between h1 and h9" ) |
| 508 | main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 509 | host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" } |
| 510 | host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 511 | testResult = main.FALSE |
| 512 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 513 | name='IPV4', |
| 514 | onosNode='0', |
| 515 | host1=host1, |
| 516 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 517 | |
| 518 | if installResult: |
| 519 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 520 | name='IPV4', |
| 521 | intentId=installResult, |
| 522 | onosNode='0', |
| 523 | host1=host1, |
| 524 | host2=host2, |
| 525 | sw1='s5', |
| 526 | sw2='s2', |
| 527 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 528 | |
| 529 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 530 | actual=testResult, |
| 531 | onpass=main.assertReturnString, |
| 532 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 533 | |
| 534 | main.step( "DUALSTACK1: Add host intents between h3 and h11" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 535 | main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 536 | host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" } |
| 537 | host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 538 | testResult = main.FALSE |
| 539 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 540 | name='DUALSTACK1', |
| 541 | onosNode='0', |
| 542 | host1=host1, |
| 543 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 544 | |
| 545 | if installResult: |
| 546 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 547 | name='DUALSTACK1', |
| 548 | intentId=installResult, |
| 549 | onosNode='0', |
| 550 | host1=host1, |
| 551 | host2=host2, |
| 552 | sw1='s5', |
| 553 | sw2='s2', |
| 554 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 555 | |
| 556 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 557 | actual=testResult, |
| 558 | onpass=main.assertReturnString, |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 559 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 560 | |
| 561 | main.step( "DUALSTACK2: Add host intents between h1 and h11" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 562 | main.assertReturnString = "Assertion Result for dualstack2 host intent\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 563 | host1 = { "name": "h1" } |
| 564 | host2 = { "name": "h11" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 565 | testResult = main.FALSE |
| 566 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 567 | name='DUALSTACK2', |
| 568 | onosNode='0', |
| 569 | host1=host1, |
| 570 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 571 | |
| 572 | if installResult: |
| 573 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 574 | name='DUALSTACK2', |
| 575 | intentId=installResult, |
| 576 | onosNode='0', |
| 577 | host1=host1, |
| 578 | host2=host2, |
| 579 | sw1='s5', |
| 580 | sw2='s2', |
| 581 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 582 | |
| 583 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 584 | actual=testResult, |
| 585 | onpass=main.assertReturnString, |
| 586 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 587 | |
| 588 | main.step( "1HOP: Add host intents between h1 and h3" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 589 | main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 590 | host1 = { "name": "h1" } |
| 591 | host2 = { "name": "h3" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 592 | testResult = main.FALSE |
| 593 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 594 | name='1HOP', |
| 595 | onosNode='0', |
| 596 | host1=host1, |
| 597 | host2=host2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 598 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 599 | if installResult: |
| 600 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 601 | name='1HOP', |
| 602 | intentId=installResult, |
| 603 | onosNode='0', |
| 604 | host1=host1, |
| 605 | host2=host2, |
| 606 | sw1='s5', |
| 607 | sw2='s2', |
| 608 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 609 | |
| 610 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 611 | actual=testResult, |
| 612 | onpass=main.assertReturnString, |
| 613 | onfail=main.assertReturnString ) |
| 614 | |
| 615 | main.step( "VLAN1: Add vlan host intents between h4 and h12" ) |
| 616 | main.assertReturnString = "Assertion Result vlan IPV4\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 617 | host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" } |
| 618 | host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 619 | testResult = main.FALSE |
| 620 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 621 | name='VLAN1', |
| 622 | onosNode='0', |
| 623 | host1=host1, |
| 624 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 625 | |
| 626 | if installResult: |
| 627 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 628 | name='VLAN1', |
| 629 | intentId=installResult, |
| 630 | onosNode='0', |
| 631 | host1=host1, |
| 632 | host2=host2, |
| 633 | sw1='s5', |
| 634 | sw2='s2', |
| 635 | expectedLink=18 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 636 | |
| 637 | utilities.assert_equals( expect=main.TRUE, |
| 638 | actual=testResult, |
| 639 | onpass=main.assertReturnString, |
| 640 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 641 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 642 | # This step isn't currently possible to perform in the REST API |
| 643 | # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" ) |
| 644 | # main.assertReturnString = "Assertion Result different VLAN negative test\n" |
| 645 | # host1 = { "name":"h13" } |
| 646 | # host2 = { "name":"h20" } |
| 647 | # testResult = main.FALSE |
| 648 | # installResult = main.intentFunction.installHostIntent( main, |
| 649 | # name='VLAN2', |
| 650 | # onosNode='0', |
| 651 | # host1=host1, |
| 652 | # host2=host2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 653 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 654 | # if installResult: |
| 655 | # testResult = main.intentFunction.testHostIntent( main, |
| 656 | # name='VLAN2', |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 657 | # intentId=installResult, |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 658 | # onosNode='0', |
| 659 | # host1=host1, |
| 660 | # host2=host2, |
| 661 | # sw1='s5', |
| 662 | # sw2='s2', |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 663 | # expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 664 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 665 | # utilities.assert_equals( expect=main.TRUE, |
| 666 | # actual=testResult, |
| 667 | # onpass=main.assertReturnString, |
| 668 | # onfail=main.assertReturnString ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 669 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 670 | # Change the following to use the REST API when leader checking is |
| 671 | # supported by it |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 672 | |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 673 | main.step( "Confirm that ONOS leadership is unchanged" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 674 | intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates() |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 675 | main.intentFunction.checkLeaderChange( intentLeadersOld, |
| 676 | intentLeadersNew ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 677 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 678 | utilities.assert_equals( expect=main.TRUE, |
| 679 | actual=testResult, |
| 680 | onpass="ONOS Leaders Unchanged", |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 681 | onfail="ONOS Leader Mismatch" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 682 | |
| 683 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 684 | |
| 685 | def CASE2000( self, main ): |
| 686 | """ |
| 687 | Add point intents between 2 hosts: |
| 688 | - Get device ids | ports |
| 689 | - Add point intents |
| 690 | - Check intents |
| 691 | - Verify flows |
| 692 | - Ping hosts |
| 693 | - Reroute |
| 694 | - Link down |
| 695 | - Verify flows |
| 696 | - Check topology |
| 697 | - Ping hosts |
| 698 | - Link up |
| 699 | - Verify flows |
| 700 | - Check topology |
| 701 | - Ping hosts |
| 702 | - Remove intents |
| 703 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 704 | if main.initialized == main.FALSE: |
| 705 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 706 | main.skipCase() |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 707 | # Assert variables - These variable's name|format must be followed |
| 708 | # if you want to use the wrapper function |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 709 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 710 | try: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 711 | assert main.Mininet1 |
| 712 | except AssertionError: |
| 713 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 714 | main.initialized = main.FALSE |
| 715 | main.skipCase() |
| 716 | try: |
| 717 | assert main.numSwitch |
| 718 | except AssertionError: |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 719 | main.log.error( "Place the total number of switch topology in " + |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 720 | main.numSwitch ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 721 | main.initialized = main.FALSE |
| 722 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 723 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 724 | main.case( "Point Intents Test - " + str( main.Cluster.numCtrls ) + |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 725 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 726 | main.caseExplanation = "This test case will test point to point" + \ |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 727 | " intents using " + str( main.Cluster.numCtrls ) + \ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 728 | " node(s) cluster;\n" + \ |
| 729 | "Different type of hosts will be tested in " + \ |
| 730 | "each step such as IPV4, Dual stack, VLAN etc" + \ |
| 731 | ";\nThe test will use OF " + main.OFProtocol + \ |
| 732 | " OVS running in Mininet and compile intents" + \ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 733 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 734 | |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 735 | # No option point intent |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 736 | main.step( "NOOPTION: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 737 | main.assertReturnString = "Assertion Result for NOOPTION point intent\n" |
| 738 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 739 | { "name": "h1", "device": "of:0000000000000005/1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 740 | ] |
| 741 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 742 | { "name": "h9", "device": "of:0000000000000006/1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 743 | ] |
| 744 | testResult = main.FALSE |
| 745 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 746 | main, |
| 747 | name="NOOPTION", |
| 748 | senders=senders, |
| 749 | recipients=recipients ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 750 | |
| 751 | if installResult: |
| 752 | testResult = main.intentFunction.testPointIntent( |
| 753 | main, |
| 754 | intentId=installResult, |
| 755 | name="NOOPTION", |
| 756 | senders=senders, |
| 757 | recipients=recipients, |
| 758 | sw1="s5", |
| 759 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 760 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 761 | |
| 762 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 763 | actual=testResult, |
| 764 | onpass=main.assertReturnString, |
| 765 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 766 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 767 | main.step( "IPV4: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 768 | main.assertReturnString = "Assertion Result for IPV4 point intent\n" |
| 769 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 770 | { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 771 | ] |
| 772 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 773 | { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 774 | ] |
| 775 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 776 | main, |
| 777 | name="IPV4", |
| 778 | senders=senders, |
| 779 | recipients=recipients, |
| 780 | ethType="IPV4" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 781 | |
| 782 | if installResult: |
| 783 | testResult = main.intentFunction.testPointIntent( |
| 784 | main, |
| 785 | intentId=installResult, |
| 786 | name="IPV4", |
| 787 | senders=senders, |
| 788 | recipients=recipients, |
| 789 | sw1="s5", |
| 790 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 791 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 792 | |
| 793 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 794 | actual=testResult, |
| 795 | onpass=main.assertReturnString, |
| 796 | onfail=main.assertReturnString ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 797 | |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 798 | # main.step( "Protected: Add point intents between h1 and h9" ) |
| 799 | # main.assertReturnString = "Assertion Result for protected point intent\n" |
| 800 | # senders = [ |
| 801 | # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" } |
| 802 | # ] |
| 803 | # recipients = [ |
| 804 | # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" } |
| 805 | # ] |
| 806 | # testResult = main.FALSE |
| 807 | # installResult = main.intentFunction.installPointIntent( |
| 808 | # main, |
| 809 | # name="Protected", |
| 810 | # senders=senders, |
| 811 | # recipients=recipients, |
| 812 | # protected=True ) |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 813 | # |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 814 | # if installResult: |
| 815 | # testResult = main.intentFunction.testPointIntent( |
| 816 | # main, |
| 817 | # name="Protected", |
| 818 | # intentId=installResult, |
| 819 | # senders=senders, |
| 820 | # recipients=recipients, |
| 821 | # sw1="s5", |
| 822 | # sw2="s2", |
| 823 | # protected=True, |
| 824 | # expectedLink=18 ) |
| 825 | # |
| 826 | # utilities.assert_equals( expect=main.TRUE, |
| 827 | # actual=testResult, |
| 828 | # onpass=main.assertReturnString, |
| 829 | # onfail=main.assertReturnString ) |
| 830 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 831 | main.step( "IPV4_2: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 832 | main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n" |
| 833 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 834 | { "name": "h1", "device": "of:0000000000000005/1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 835 | ] |
| 836 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 837 | { "name": "h9", "device": "of:0000000000000006/1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 838 | ] |
| 839 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 840 | main, |
| 841 | name="IPV4_2", |
| 842 | senders=senders, |
| 843 | recipients=recipients, |
| 844 | ethType="IPV4" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 845 | |
| 846 | if installResult: |
| 847 | testResult = main.intentFunction.testPointIntent( |
| 848 | main, |
| 849 | intentId=installResult, |
| 850 | name="IPV4_2", |
| 851 | senders=senders, |
| 852 | recipients=recipients, |
| 853 | sw1="s5", |
| 854 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 855 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 856 | |
| 857 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 858 | actual=testResult, |
| 859 | onpass=main.assertReturnString, |
| 860 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 861 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 862 | main.step( "SDNIP-ICMP: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 863 | main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n" |
| 864 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 865 | { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01", |
| 866 | "ip": ( main.h1.hostIp + "/24" ) } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 867 | ] |
| 868 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 869 | { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09", |
| 870 | "ip": ( main.h9.hostIp + "/24" ) } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 871 | ] |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 872 | # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ] |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 873 | ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 874 | # Uneccessary, not including this in the selectors |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 875 | tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 876 | tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 877 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 878 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 879 | main, |
| 880 | name="SDNIP-ICMP", |
| 881 | senders=senders, |
| 882 | recipients=recipients, |
| 883 | ethType="IPV4", |
| 884 | ipProto=ipProto, |
| 885 | tcpSrc=tcpSrc, |
| 886 | tcpDst=tcpDst ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 887 | |
| 888 | if installResult: |
| 889 | testResult = main.intentFunction.testPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 890 | main, |
| 891 | intentId=installResult, |
| 892 | name="SDNIP_ICMP", |
| 893 | senders=senders, |
| 894 | recipients=recipients, |
| 895 | sw1="s5", |
| 896 | sw2="s2", |
| 897 | expectedLink=18, |
| 898 | useTCP=True ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 899 | |
| 900 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 901 | actual=testResult, |
| 902 | onpass=main.assertReturnString, |
| 903 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 904 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 905 | main.step( "SDNIP-TCP: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 906 | main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 907 | mac1 = main.hostsData[ 'h1' ][ 'mac' ] |
| 908 | mac2 = main.hostsData[ 'h9' ][ 'mac' ] |
| 909 | ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
| 910 | ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
| 911 | ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ] |
| 912 | tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 913 | tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 914 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 915 | stepResult = main.intentFunction.pointIntentTcp( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 916 | main, |
| 917 | name="SDNIP-TCP", |
| 918 | host1="h1", |
| 919 | host2="h9", |
| 920 | deviceId1="of:0000000000000005/1", |
| 921 | deviceId2="of:0000000000000006/1", |
| 922 | mac1=mac1, |
| 923 | mac2=mac2, |
| 924 | ethType="IPV4", |
| 925 | ipProto=ipProto, |
| 926 | ip1=ip1, |
| 927 | ip2=ip2, |
| 928 | tcp1=tcp1, |
| 929 | tcp2=tcp2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 930 | |
| 931 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 932 | actual=stepResult, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 933 | onpass=main.assertReturnString, |
| 934 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 935 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 936 | main.step( "DUALSTACK1: Add point intents between h3 and h11" ) |
| 937 | main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n" |
| 938 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 939 | { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 940 | ] |
| 941 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 942 | { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 943 | ] |
| 944 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 945 | main, |
| 946 | name="DUALSTACK1", |
| 947 | senders=senders, |
| 948 | recipients=recipients, |
| 949 | ethType="IPV4" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 950 | |
| 951 | if installResult: |
| 952 | testResult = main.intentFunction.testPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 953 | main, |
| 954 | intentId=installResult, |
| 955 | name="DUALSTACK1", |
| 956 | senders=senders, |
| 957 | recipients=recipients, |
| 958 | sw1="s5", |
| 959 | sw2="s2", |
| 960 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 961 | |
| 962 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 963 | actual=testResult, |
| 964 | onpass=main.assertReturnString, |
| 965 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 966 | |
| 967 | main.step( "VLAN: Add point intents between h5 and h21" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 968 | main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n" |
| 969 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 970 | { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 971 | ] |
| 972 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 973 | { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 974 | ] |
| 975 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 976 | main, |
| 977 | name="VLAN", |
| 978 | senders=senders, |
| 979 | recipients=recipients ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 980 | |
| 981 | if installResult: |
| 982 | testResult = main.intentFunction.testPointIntent( |
| 983 | main, |
| 984 | intentId=installResult, |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 985 | name="VLAN", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 986 | senders=senders, |
| 987 | recipients=recipients, |
| 988 | sw1="s5", |
| 989 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 990 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 991 | |
| 992 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 993 | actual=testResult, |
| 994 | onpass=main.assertReturnString, |
| 995 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 996 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 997 | # TODO: implement VLAN selector REST API intent test once supported |
| 998 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 999 | main.step( "1HOP: Add point intents between h1 and h3" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1000 | main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n" |
| 1001 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1002 | { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1003 | ] |
| 1004 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1005 | { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1006 | ] |
| 1007 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1008 | main, |
| 1009 | name="1HOP IPV4", |
| 1010 | senders=senders, |
| 1011 | recipients=recipients, |
| 1012 | ethType="IPV4" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1013 | |
| 1014 | if installResult: |
| 1015 | testResult = main.intentFunction.testPointIntent( |
| 1016 | main, |
| 1017 | intentId=installResult, |
| 1018 | name="1HOP IPV4", |
| 1019 | senders=senders, |
| 1020 | recipients=recipients, |
| 1021 | sw1="s5", |
| 1022 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1023 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1024 | |
| 1025 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1026 | actual=testResult, |
| 1027 | onpass=main.assertReturnString, |
| 1028 | onfail=main.assertReturnString ) |
| 1029 | |
| 1030 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1031 | |
| 1032 | def CASE3000( self, main ): |
| 1033 | """ |
| 1034 | Add single point to multi point intents |
| 1035 | - Get device ids |
| 1036 | - Add single point to multi point intents |
| 1037 | - Check intents |
| 1038 | - Verify flows |
| 1039 | - Ping hosts |
| 1040 | - Reroute |
| 1041 | - Link down |
| 1042 | - Verify flows |
| 1043 | - Check topology |
| 1044 | - Ping hosts |
| 1045 | - Link up |
| 1046 | - Verify flows |
| 1047 | - Check topology |
| 1048 | - Ping hosts |
| 1049 | - Remove intents |
| 1050 | """ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1051 | if main.initialized == main.FALSE: |
| 1052 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1053 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1054 | assert main, "There is no main" |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1055 | |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1056 | try: |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1057 | assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases" |
| 1058 | assert main.numSwitch, "Place the total number of switch topology in main.numSwitch" |
| 1059 | except AssertionError: |
| 1060 | main.initialized = main.FALSE |
| 1061 | main.skipCase() |
| 1062 | |
| 1063 | main.testName = "Single to Multi Point Intents" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1064 | main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) + |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1065 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1066 | main.caseExplanation = "This test case will test single point to" + \ |
| 1067 | " multi point intents using " + \ |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1068 | str( main.Cluster.numCtrls ) + " node(s) cluster;\n" + \ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1069 | "Different type of hosts will be tested in " + \ |
| 1070 | "each step such as IPV4, Dual stack, VLAN etc" + \ |
| 1071 | ";\nThe test will use OF " + main.OFProtocol + \ |
| 1072 | " OVS running in Mininet and compile intents" + \ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1073 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1074 | |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1075 | main.step( "NOOPTION: Install and test single point to multi point intents" ) |
| 1076 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n" |
| 1077 | senders = [ |
| 1078 | { "name": "h8", "device": "of:0000000000000005/8" } |
| 1079 | ] |
| 1080 | recipients = [ |
| 1081 | { "name": "h16", "device": "of:0000000000000006/8" }, |
| 1082 | { "name": "h24", "device": "of:0000000000000007/8" } |
| 1083 | ] |
| 1084 | badSenders = [ { "name": "h9" } ] # Senders that are not in the intent |
| 1085 | badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent |
| 1086 | testResult = main.FALSE |
| 1087 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1088 | main, |
| 1089 | name="NOOPTION", |
| 1090 | senders=senders, |
| 1091 | recipients=recipients ) |
| 1092 | |
| 1093 | if installResult: |
| 1094 | testResult = main.intentFunction.testPointIntent( |
| 1095 | main, |
| 1096 | intentId=installResult, |
| 1097 | name="NOOPTION", |
| 1098 | senders=senders, |
| 1099 | recipients=recipients, |
| 1100 | badSenders=badSenders, |
| 1101 | badRecipients=badRecipients, |
| 1102 | sw1="s5", |
| 1103 | sw2="s2", |
| 1104 | expectedLink=18 ) |
| 1105 | else: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1106 | main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1107 | |
| 1108 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1109 | actual=testResult, |
| 1110 | onpass=main.assertReturnString, |
| 1111 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1112 | |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1113 | main.step( "IPV4: Install and test single point to multi point intents" ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1114 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \ |
| 1115 | "with IPV4 type and MAC addresses\n" |
| 1116 | senders = [ |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1117 | { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" } |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1118 | ] |
| 1119 | recipients = [ |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1120 | { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" }, |
| 1121 | { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" } |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1122 | ] |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1123 | badSenders = [ { "name": "h9" } ] # Senders that are not in the intent |
| 1124 | badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1125 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1126 | main, |
| 1127 | name="IPV4", |
| 1128 | senders=senders, |
| 1129 | recipients=recipients, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1130 | ethType="IPV4" ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1131 | |
| 1132 | if installResult: |
| 1133 | testResult = main.intentFunction.testPointIntent( |
| 1134 | main, |
| 1135 | intentId=installResult, |
| 1136 | name="IPV4", |
| 1137 | senders=senders, |
| 1138 | recipients=recipients, |
| 1139 | badSenders=badSenders, |
| 1140 | badRecipients=badRecipients, |
| 1141 | sw1="s5", |
| 1142 | sw2="s2", |
| 1143 | expectedLink=18 ) |
| 1144 | else: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1145 | main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1146 | |
| 1147 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1148 | actual=testResult, |
| 1149 | onpass=main.assertReturnString, |
| 1150 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1151 | |
| 1152 | main.step( "IPV4_2: Add single point to multi point intents" ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1153 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \ |
| 1154 | "with IPV4 type and no MAC addresses\n" |
| 1155 | senders = [ |
| 1156 | { "name": "h8", "device": "of:0000000000000005/8" } |
| 1157 | ] |
| 1158 | recipients = [ |
| 1159 | { "name": "h16", "device": "of:0000000000000006/8" }, |
| 1160 | { "name": "h24", "device": "of:0000000000000007/8" } |
| 1161 | ] |
| 1162 | badSenders = [ { "name": "h9" } ] # Senders that are not in the intent |
| 1163 | badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent |
| 1164 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1165 | main, |
| 1166 | name="IPV4_2", |
| 1167 | senders=senders, |
| 1168 | recipients=recipients, |
| 1169 | ethType="IPV4" ) |
| 1170 | |
| 1171 | if installResult: |
| 1172 | testResult = main.intentFunction.testPointIntent( |
| 1173 | main, |
| 1174 | intentId=installResult, |
| 1175 | name="IPV4_2", |
| 1176 | senders=senders, |
| 1177 | recipients=recipients, |
| 1178 | badSenders=badSenders, |
| 1179 | badRecipients=badRecipients, |
| 1180 | sw1="s5", |
| 1181 | sw2="s2", |
| 1182 | expectedLink=18 ) |
| 1183 | else: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1184 | main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1185 | |
| 1186 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1187 | actual=testResult, |
| 1188 | onpass=main.assertReturnString, |
| 1189 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1190 | |
| 1191 | main.step( "VLAN: Add single point to multi point intents" ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1192 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \ |
| 1193 | "and MAC addresses in the same VLAN\n" |
| 1194 | senders = [ |
| 1195 | { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" } |
| 1196 | ] |
| 1197 | recipients = [ |
| 1198 | { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" }, |
| 1199 | { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" } |
| 1200 | ] |
| 1201 | badSenders = [ { "name": "h13" } ] # Senders that are not in the intent |
| 1202 | badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent |
| 1203 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1204 | main, |
| 1205 | name="VLAN", |
| 1206 | senders=senders, |
| 1207 | recipients=recipients, |
| 1208 | sw1="s5", |
| 1209 | sw2="s2" ) |
| 1210 | |
| 1211 | if installResult: |
| 1212 | testResult = main.intentFunction.testPointIntent( |
| 1213 | main, |
| 1214 | intentId=installResult, |
| 1215 | name="VLAN", |
| 1216 | senders=senders, |
| 1217 | recipients=recipients, |
| 1218 | badSenders=badSenders, |
| 1219 | badRecipients=badRecipients, |
| 1220 | sw1="s5", |
| 1221 | sw2="s2", |
| 1222 | expectedLink=18 ) |
| 1223 | else: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1224 | main.Cluster.active( 0 ).CLI.removeAllIntents() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1225 | |
| 1226 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1227 | actual=testResult, |
| 1228 | onpass=main.assertReturnString, |
| 1229 | onfail=main.assertReturnString ) |
| 1230 | |
| 1231 | main.step( "VLAN: Add single point to multi point intents" ) |
| 1232 | main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n" |
| 1233 | senders = [ |
| 1234 | { "name": "h5", "vlan": "200" } |
| 1235 | ] |
| 1236 | recipients = [ |
| 1237 | { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" }, |
| 1238 | { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" } |
| 1239 | ] |
| 1240 | badSenders = [ { "name": "h13" } ] # Senders that are not in the intent |
| 1241 | badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent |
| 1242 | testResult = main.FALSE |
| 1243 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1244 | main, |
| 1245 | name="VLAN2", |
| 1246 | senders=senders, |
| 1247 | recipients=recipients, |
| 1248 | sw1="s5", |
| 1249 | sw2="s2" ) |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1250 | #setVlan=100 ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1251 | |
| 1252 | if installResult: |
| 1253 | testResult = main.intentFunction.testPointIntent( |
| 1254 | main, |
| 1255 | intentId=installResult, |
| 1256 | name="VLAN2", |
| 1257 | senders=senders, |
| 1258 | recipients=recipients, |
| 1259 | badSenders=badSenders, |
| 1260 | badRecipients=badRecipients, |
| 1261 | sw1="s5", |
| 1262 | sw2="s2", |
| 1263 | expectedLink=18 ) |
| 1264 | else: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1265 | main.Cluster.active( 0 ).CLI.removeAllIntents() |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1266 | |
| 1267 | utilities.assert_equals( expect=main.TRUE, |
| 1268 | actual=testResult, |
| 1269 | onpass=main.assertReturnString, |
| 1270 | onfail=main.assertReturnString ) |
| 1271 | |
| 1272 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1273 | |
| 1274 | def CASE4000( self, main ): |
| 1275 | """ |
| 1276 | Add multi point to single point intents |
| 1277 | - Get device ids |
| 1278 | - Add multi point to single point intents |
| 1279 | - Check intents |
| 1280 | - Verify flows |
| 1281 | - Ping hosts |
| 1282 | - Reroute |
| 1283 | - Link down |
| 1284 | - Verify flows |
| 1285 | - Check topology |
| 1286 | - Ping hosts |
| 1287 | - Link up |
| 1288 | - Verify flows |
| 1289 | - Check topology |
| 1290 | - Ping hosts |
| 1291 | - Remove intents |
| 1292 | """ |
| 1293 | assert main, "There is no main" |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1294 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 1295 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 1296 | main.numSwitch" |
| 1297 | |
| 1298 | main.case( "Multi To Single Point Intents Test - " + |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1299 | str( main.Cluster.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1300 | main.caseExplanation = "This test case will test single point to" +\ |
| 1301 | " multi point intents using " +\ |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1302 | str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\ |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1303 | "Different type of hosts will be tested in " +\ |
| 1304 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1305 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1306 | " OVS running in Mininet and compile intents" +\ |
| 1307 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1308 | |
| 1309 | main.step( "NOOPTION: Add multi point to single point intents" ) |
| 1310 | stepResult = main.TRUE |
| 1311 | hostNames = [ 'h8', 'h16', 'h24' ] |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1312 | devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1313 | 'of:0000000000000007/8' ] |
| 1314 | macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] |
| 1315 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1316 | main, |
| 1317 | name="NOOPTION", |
| 1318 | hostNames=hostNames, |
| 1319 | devices=devices, |
| 1320 | sw1="s5", |
| 1321 | sw2="s2", |
| 1322 | expectedLink=18 ) |
| 1323 | |
| 1324 | utilities.assert_equals( expect=main.TRUE, |
| 1325 | actual=stepResult, |
| 1326 | onpass="NOOPTION: Successfully added multi " |
| 1327 | + " point to single point intents" + |
| 1328 | " with no match action", |
| 1329 | onfail="NOOPTION: Failed to add multi point" + |
| 1330 | " to single point intents" + |
| 1331 | " with no match action" ) |
| 1332 | |
| 1333 | main.step( "IPV4: Add multi point to single point intents" ) |
| 1334 | stepResult = main.TRUE |
| 1335 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1336 | main, |
| 1337 | name="IPV4", |
| 1338 | hostNames=hostNames, |
| 1339 | devices=devices, |
| 1340 | ports=None, |
| 1341 | ethType="IPV4", |
| 1342 | macs=macs, |
| 1343 | bandwidth="", |
| 1344 | lambdaAlloc=False, |
| 1345 | ipProto="", |
| 1346 | ipAddresses="", |
| 1347 | tcp="", |
| 1348 | sw1="s5", |
| 1349 | sw2="s2", |
| 1350 | expectedLink=18 ) |
| 1351 | |
| 1352 | utilities.assert_equals( expect=main.TRUE, |
| 1353 | actual=stepResult, |
| 1354 | onpass="IPV4: Successfully added multi point" |
| 1355 | + " to single point intents" + |
| 1356 | " with IPV4 type and MAC addresses", |
| 1357 | onfail="IPV4: Failed to add multi point" + |
| 1358 | " to single point intents" + |
| 1359 | " with IPV4 type and MAC addresses" ) |
| 1360 | |
| 1361 | main.step( "IPV4_2: Add multi point to single point intents" ) |
| 1362 | stepResult = main.TRUE |
| 1363 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1364 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1365 | main, |
| 1366 | name="IPV4", |
| 1367 | hostNames=hostNames, |
| 1368 | ethType="IPV4", |
| 1369 | lambdaAlloc=False ) |
| 1370 | |
| 1371 | utilities.assert_equals( expect=main.TRUE, |
| 1372 | actual=stepResult, |
| 1373 | onpass="IPV4_2: Successfully added multi point" |
| 1374 | + " to single point intents" + |
| 1375 | " with IPV4 type and no MAC addresses", |
| 1376 | onfail="IPV4_2: Failed to add multi point" + |
| 1377 | " to single point intents" + |
| 1378 | " with IPV4 type and no MAC addresses" ) |
| 1379 | |
| 1380 | main.step( "VLAN: Add multi point to single point intents" ) |
| 1381 | stepResult = main.TRUE |
| 1382 | hostNames = [ 'h5', 'h13', 'h21' ] |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1383 | devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1384 | 'of:0000000000000007/5' ] |
| 1385 | macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ] |
| 1386 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1387 | main, |
| 1388 | name="VLAN", |
| 1389 | hostNames=hostNames, |
| 1390 | devices=devices, |
| 1391 | ports=None, |
| 1392 | ethType="IPV4", |
| 1393 | macs=macs, |
| 1394 | bandwidth="", |
| 1395 | lambdaAlloc=False, |
| 1396 | ipProto="", |
| 1397 | ipAddresses="", |
| 1398 | tcp="", |
| 1399 | sw1="s5", |
| 1400 | sw2="s2", |
| 1401 | expectedLink=18 ) |
| 1402 | |
| 1403 | utilities.assert_equals( expect=main.TRUE, |
| 1404 | actual=stepResult, |
| 1405 | onpass="VLAN: Successfully added multi point" |
| 1406 | + " to single point intents" + |
| 1407 | " with IPV4 type and MAC addresses" + |
| 1408 | " in the same VLAN", |
| 1409 | onfail="VLAN: Failed to add multi point" + |
| 1410 | " to single point intents" ) |
| 1411 | |
| 1412 | def CASE5000( self, main ): |
| 1413 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1414 | Tests Host Mobility |
| 1415 | Modifies the topology location of h1 |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1416 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1417 | if main.initialized == main.FALSE: |
| 1418 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1419 | main.skipCase() |
| 1420 | # Assert variables - These variable's name|format must be followed |
| 1421 | # if you want to use the wrapper function |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1422 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1423 | try: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1424 | assert main.Mininet1 |
| 1425 | except AssertionError: |
| 1426 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1427 | main.initialized = main.FALSE |
| 1428 | main.skipCase() |
| 1429 | try: |
| 1430 | assert main.numSwitch |
| 1431 | except AssertionError: |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1432 | main.log.error( "Place the total number of switch topology in " + |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1433 | main.numSwitch ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1434 | main.initialized = main.FALSE |
| 1435 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1436 | main.case( "Test host mobility with host intents " ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1437 | main.step( "Testing host mobility by moving h1 from s5 to s6" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1438 | h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1439 | |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1440 | main.log.info( "Moving h1 from s5 to s6" ) |
| 1441 | main.Mininet1.moveHost( "h1", "s5", "s6" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1442 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1443 | # Send discovery ping from moved host |
| 1444 | # Moving the host brings down the default interfaces and creates a new one. |
| 1445 | # Scapy is restarted on this host to detect the new interface |
| 1446 | main.h1.stopScapy() |
| 1447 | main.h1.startScapy() |
| 1448 | |
| 1449 | # Discover new host location in ONOS and populate host data. |
| 1450 | # Host 1 IP and MAC should be unchanged |
| 1451 | main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] ) |
| 1452 | main.intentFunction.populateHostData( main ) |
| 1453 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1454 | h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1455 | |
| 1456 | utilities.assert_equals( expect="of:0000000000000006", |
| 1457 | actual=h1PostMove, |
| 1458 | onpass="Mobility: Successfully moved h1 to s6", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1459 | onfail="Mobility: Failed to move h1 to s6" + |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1460 | " to single point intents" + |
| 1461 | " with IPV4 type and MAC addresses" + |
| 1462 | " in the same VLAN" ) |
| 1463 | |
| 1464 | main.step( "IPV4: Add host intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1465 | main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1466 | host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" } |
| 1467 | host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1468 | |
| 1469 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1470 | name='IPV4 Mobility IPV4', |
| 1471 | onosNode='0', |
| 1472 | host1=host1, |
| 1473 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1474 | if installResult: |
| 1475 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1476 | name='Host Mobility IPV4', |
| 1477 | intentId=installResult, |
| 1478 | onosNode='0', |
| 1479 | host1=host1, |
| 1480 | host2=host2, |
| 1481 | sw1="s6", |
| 1482 | sw2="s2", |
| 1483 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1484 | |
| 1485 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1486 | actual=testResult, |
| 1487 | onpass=main.assertReturnString, |
| 1488 | onfail=main.assertReturnString ) |
| 1489 | |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 1490 | main.intentFunction.report( main ) |