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