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