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