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