Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2015 Open Networking Foundation (ONF) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
| 21 | |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 22 | class FUNCflow: |
| 23 | |
| 24 | def __init__( self ): |
| 25 | self.default = '' |
| 26 | |
| 27 | def CASE1( self, main ): |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 28 | import os |
| 29 | import imp |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 30 | try: |
| 31 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 32 | except ImportError: |
| 33 | main.log.error( "SetUp not found exiting the test" ) |
| 34 | main.exit() |
| 35 | try: |
| 36 | main.testSetUp |
| 37 | except ( NameError, AttributeError ): |
| 38 | main.testSetUp = ONOSSetup() |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 39 | """ |
| 40 | - Construct tests variables |
| 41 | - GIT ( optional ) |
| 42 | - Checkout ONOS master branch |
| 43 | - Pull latest ONOS code |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 44 | """ |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 45 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 46 | main.testSetUp.envSetupDescription() |
| 47 | stepResult = main.FALSE |
| 48 | try: |
| 49 | # Test variables |
| 50 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 51 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 52 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 53 | main.dependencyPath = main.testOnDirectory + \ |
| 54 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 55 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 56 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 57 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 58 | main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] ) |
| 59 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 60 | main.startMNSleep = int( main.params[ 'SLEEP' ][ 'startMN' ] ) |
| 61 | main.addFlowSleep = int( main.params[ 'SLEEP' ][ 'addFlow' ] ) |
| 62 | main.delFlowSleep = int( main.params[ 'SLEEP' ][ 'delFlow' ] ) |
| 63 | main.debug = main.params[ 'DEBUG' ] |
| 64 | main.swDPID = main.params[ 'TEST' ][ 'swDPID' ] |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 65 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 66 | main.debug = True if "on" in main.debug else False |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 67 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 68 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 69 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 70 | try: |
| 71 | from tests.FUNC.FUNCflow.dependencies.checkingFlow import CheckingFlow |
| 72 | main.checkingFlow = CheckingFlow() |
| 73 | except ImportError as e: |
| 74 | print e |
| 75 | main.log.error("CheckingFlow not found exiting the test") |
| 76 | main.exit() |
| 77 | copyResult = main.ONOSbench.scp( main.Mininet1, |
| 78 | main.dependencyPath + main.topology, |
| 79 | main.Mininet1.home + '/custom/', |
| 80 | direction="to" ) |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 81 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 82 | utilities.assert_equals( expect=main.TRUE, |
| 83 | actual=copyResult, |
| 84 | onpass="Successfully copy " + "test variables ", |
| 85 | onfail="Failed to copy test variables" ) |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 86 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 87 | stepResult = main.testSetUp.envSetup() |
GlennRC | 1704d07 | 2015-10-07 18:40:45 -0700 | [diff] [blame] | 88 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 89 | except Exception as e: |
| 90 | main.testSetUp.envSetupException( e ) |
| 91 | main.testSetUp.evnSetupConclusion( stepResult ) |
Devin Lim | 8d7c778 | 2017-06-07 16:21:20 -0700 | [diff] [blame] | 92 | |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 93 | |
| 94 | def CASE2( self, main ): |
| 95 | """ |
| 96 | - Set up cell |
| 97 | - Create cell file |
| 98 | - Set cell file |
| 99 | - Verify cell file |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 100 | - Building ONOS |
| 101 | - Install ONOS package |
| 102 | - Build ONOS package |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 103 | - Kill ONOS process |
| 104 | - Uninstall ONOS cluster |
| 105 | - Verify ONOS start up |
| 106 | - Install ONOS cluster |
| 107 | - Connect to cli |
| 108 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 109 | main.testSetUp.ONOSSetUp( main.Mininet1 ) |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 110 | |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 111 | def CASE10( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 112 | """ |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 113 | Start Mininet |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 114 | """ |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 115 | import json |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 116 | import time |
| 117 | try: |
| 118 | from tests.dependencies.topology import Topology |
| 119 | except ImportError: |
| 120 | main.log.error( "Topology not found exiting the test" ) |
| 121 | main.exit() |
| 122 | try: |
| 123 | main.topoRelated |
| 124 | except ( NameError, AttributeError ): |
| 125 | main.topoRelated = Topology() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 126 | |
| 127 | main.case( "Setup mininet and compare ONOS topology view to Mininet topology" ) |
| 128 | main.caseExplanation = "Start mininet with custom topology and compare topology " +\ |
| 129 | "elements between Mininet and ONOS" |
| 130 | |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 131 | main.step( "Setup Mininet Topology" ) |
| 132 | topology = main.Mininet1.home + '/custom/' + main.topology |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 133 | stepResult = main.Mininet1.startNet( topoFile=topology ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 134 | |
| 135 | utilities.assert_equals( expect=main.TRUE, |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 136 | actual=stepResult, |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 137 | onpass="Successfully loaded topology", |
| 138 | onfail="Failed to load topology" ) |
| 139 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 140 | main.step( "Assign switch to controller" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 141 | stepResult = main.Mininet1.assignSwController( "s1", main.ONOSip[ 0 ] ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 142 | |
| 143 | utilities.assert_equals( expect=main.TRUE, |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 144 | actual=stepResult, |
| 145 | onpass="Successfully assigned switch to controller", |
| 146 | onfail="Failed to assign switch to controller" ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 147 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 148 | time.sleep( main.startMNSleep ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 149 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 150 | main.topoRelated.compareTopos( main.Mininet1 ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 151 | |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 152 | def CASE66( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 153 | """ |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 154 | Testing scapy |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 155 | """ |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 156 | main.case( "Testing scapy" ) |
| 157 | main.step( "Creating Host1 component" ) |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 158 | main.Scapy.createHostComponent( "h1" ) |
| 159 | main.Scapy.createHostComponent( "h2" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 160 | hosts = [ main.h1, main.h2 ] |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 161 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 162 | host.startHostCli() |
| 163 | host.startScapy() |
| 164 | host.updateSelf() |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 165 | main.log.debug( host.name ) |
| 166 | main.log.debug( host.hostIp ) |
| 167 | main.log.debug( host.hostMac ) |
| 168 | |
| 169 | main.step( "Sending/Receiving Test packet - Filter doesn't match" ) |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 170 | main.log.info( "Starting Filter..." ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 171 | main.h2.startFilter() |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 172 | main.log.info( "Building Ether frame..." ) |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 173 | main.h1.buildEther( dst=main.h2.hostMac ) |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 174 | main.log.info( "Sending Packet..." ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 175 | main.h1.sendPacket() |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 176 | main.log.info( "Checking Filter..." ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 177 | finished = main.h2.checkFilter() |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 178 | main.log.debug( finished ) |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 179 | i = "" |
| 180 | if finished: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 181 | a = main.h2.readPackets() |
| 182 | for i in a.splitlines(): |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 183 | main.log.info( i ) |
| 184 | else: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 185 | kill = main.h2.killFilter() |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 186 | main.log.debug( kill ) |
| 187 | main.h2.handle.sendline( "" ) |
| 188 | main.h2.handle.expect( main.h2.scapyPrompt ) |
| 189 | main.log.debug( main.h2.handle.before ) |
| 190 | utilities.assert_equals( expect=True, |
| 191 | actual="dst=00:00:00:00:00:02 src=00:00:00:00:00:01" in i, |
| 192 | onpass="Pass", |
| 193 | onfail="Fail" ) |
| 194 | |
| 195 | main.step( "Sending/Receiving Test packet - Filter matches" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 196 | main.h2.startFilter() |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 197 | main.h1.buildEther( dst=main.h2.hostMac ) |
| 198 | main.h1.buildIP( dst=main.h2.hostIp ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 199 | main.h1.sendPacket() |
| 200 | finished = main.h2.checkFilter() |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 201 | i = "" |
| 202 | if finished: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 203 | a = main.h2.readPackets() |
| 204 | for i in a.splitlines(): |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 205 | main.log.info( i ) |
| 206 | else: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 207 | kill = main.h2.killFilter() |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 208 | main.log.debug( kill ) |
| 209 | main.h2.handle.sendline( "" ) |
| 210 | main.h2.handle.expect( main.h2.scapyPrompt ) |
| 211 | main.log.debug( main.h2.handle.before ) |
| 212 | utilities.assert_equals( expect=True, |
| 213 | actual="dst=00:00:00:00:00:02 src=00:00:00:00:00:01" in i, |
| 214 | onpass="Pass", |
| 215 | onfail="Fail" ) |
| 216 | |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 217 | main.step( "Clean up host components" ) |
| 218 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 219 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 220 | main.Mininet1.removeHostComponent( "h1" ) |
| 221 | main.Mininet1.removeHostComponent( "h2" ) |
Jon Hall | 892818c | 2015-10-20 17:58:34 -0700 | [diff] [blame] | 222 | |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 223 | def CASE1000( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 224 | """ |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 225 | Add flows with MAC selectors and verify the flows |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 226 | """ |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 227 | import json |
| 228 | import time |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 229 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 230 | main.case( "Verify flow MAC selectors are correctly compiled" ) |
| 231 | main.caseExplanation = "Install two flows with only MAC selectors " +\ |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 232 | "specified, then verify flows are added in ONOS, finally " +\ |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 233 | "send a packet that only specifies the MAC src and dst." |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 234 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 235 | main.step( "Add flows with MAC addresses as the only selectors" ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 236 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 237 | main.log.info( "Creating host components" ) |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 238 | main.Scapy.createHostComponent( "h1" ) |
| 239 | main.Scapy.createHostComponent( "h2" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 240 | hosts = [ main.h1, main.h2 ] |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 241 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 242 | host.startHostCli() |
| 243 | host.startScapy() |
| 244 | host.updateSelf() |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 245 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 246 | # Add a flow that connects host1 on port1 to host2 on port2 |
| 247 | # send output on port2 |
| 248 | # recieve input on port1 |
| 249 | egress = 2 |
| 250 | ingress = 1 |
| 251 | |
| 252 | # Add flows that sends packets from port1 to port2 with correct |
| 253 | # MAC src and dst addresses |
| 254 | main.log.info( "Adding flow with MAC selectors" ) |
| 255 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 256 | egressPort=egress, |
| 257 | ingressPort=ingress, |
| 258 | ethSrc=main.h1.hostMac, |
| 259 | ethDst=main.h2.hostMac, |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 260 | debug=main.debug ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 261 | |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame] | 262 | utilities.assert_equals( expect=main.TRUE, |
| 263 | actual=stepResult, |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 264 | onpass="Successfully added flows", |
| 265 | onfail="Failed add flows" ) |
GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame] | 266 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 267 | # Giving ONOS time to add the flows |
| 268 | time.sleep( main.addFlowSleep ) |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 269 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 270 | main.step( "Check flows are in the ADDED state" ) |
| 271 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 272 | main.log.info( "Get the flows from ONOS" ) |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 273 | try: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 274 | flows = json.loads( main.ONOSrest.flows() ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 275 | |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 276 | stepResult = main.TRUE |
| 277 | for f in flows: |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 278 | if "rest" in f.get( "appId" ): |
| 279 | if "ADDED" not in f.get( "state" ): |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 280 | stepResult = main.FALSE |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 281 | main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) ) |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 282 | except TypeError: |
| 283 | main.log.error( "No Flows found by the REST API" ) |
| 284 | stepResult = main.FALSE |
| 285 | except ValueError: |
| 286 | main.log.error( "Problem getting Flows state from REST API. Exiting test" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 287 | main.cleanup() |
| 288 | main.exit() |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 289 | |
| 290 | utilities.assert_equals( expect=main.TRUE, |
| 291 | actual=stepResult, |
| 292 | onpass="All flows are in the ADDED state", |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 293 | onfail="All flows are NOT in the ADDED state" ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 294 | |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 295 | main.step( "Check flows are in Mininet's flow table" ) |
| 296 | |
| 297 | # get the flow IDs that were added through rest |
| 298 | main.log.info( "Getting the flow IDs from ONOS" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 299 | flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ] |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 300 | # convert the flowIDs to ints then hex and finally back to strings |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 301 | flowIds = [ str( hex( int( x ) ) ) for x in flowIds ] |
| 302 | main.log.info( "ONOS flow IDs: {}".format( flowIds ) ) |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 303 | |
| 304 | stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False ) |
| 305 | |
| 306 | utilities.assert_equals( expect=main.TRUE, |
| 307 | actual=stepResult, |
| 308 | onpass="All flows are in mininet", |
| 309 | onfail="All flows are NOT in mininet" ) |
| 310 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 311 | main.step( "Send a packet to verify the flows are correct" ) |
| 312 | |
| 313 | # Specify the src and dst MAC addr |
| 314 | main.log.info( "Constructing packet" ) |
| 315 | main.h1.buildEther( src=main.h1.hostMac, dst=main.h2.hostMac ) |
| 316 | |
| 317 | # Filter for packets with the correct host name. Otherwise, |
| 318 | # the filter we catch any packet that is sent to host2 |
| 319 | # NOTE: I believe it doesn't matter which host name it is, |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 320 | # as long as the src and dst are both specified |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 321 | main.log.info( "Starting filter on host2" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 322 | main.h2.startFilter( pktFilter="ether host %s" % main.h1.hostMac ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 323 | |
| 324 | main.log.info( "Sending packet to host2" ) |
| 325 | main.h1.sendPacket() |
| 326 | |
| 327 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 328 | stepResult = main.h2.checkFilter() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 329 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 330 | main.log.info( "Packet: %s" % main.h2.readPackets() ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 331 | else: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 332 | main.h2.killFilter() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 333 | |
| 334 | main.log.info( "Clean up host components" ) |
| 335 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 336 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 337 | main.Mininet1.removeHostComponent( "h1" ) |
| 338 | main.Mininet1.removeHostComponent( "h2" ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 339 | |
| 340 | utilities.assert_equals( expect=main.TRUE, |
| 341 | actual=stepResult, |
| 342 | onpass="Successfully sent a packet", |
| 343 | onfail="Failed to send a packet" ) |
| 344 | |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 345 | def CASE1400( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 346 | """ |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 347 | Add flows with IPv4 selectors and verify the flows |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 348 | """ |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 349 | import json |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 350 | import time |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 351 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 352 | main.case( "Verify flow IP selectors are correctly compiled" ) |
| 353 | main.caseExplanation = "Install two flows with only IP selectors " +\ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 354 | "specified, then verify flows are added in ONOS, finally " +\ |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 355 | "send a packet that only specifies the IP src and dst." |
| 356 | |
| 357 | main.step( "Add flows with IPv4 addresses as the only selectors" ) |
| 358 | |
| 359 | main.log.info( "Creating host components" ) |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 360 | main.Scapy.createHostComponent( "h1" ) |
| 361 | main.Scapy.createHostComponent( "h2" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 362 | hosts = [ main.h1, main.h2 ] |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 363 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 364 | host.startHostCli() |
| 365 | host.startScapy() |
| 366 | host.updateSelf() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 367 | |
| 368 | # Add a flow that connects host1 on port1 to host2 on port2 |
| 369 | # send output on port2 |
| 370 | # recieve input on port1 |
| 371 | egress = 2 |
| 372 | ingress = 1 |
| 373 | # IPv4 etherType = 0x800 |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 374 | ethType = main.params[ 'TEST' ][ 'ip4Type' ] |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 375 | |
| 376 | # Add flows that connects host1 to host2 |
| 377 | main.log.info( "Add flow with port ingress 1 to port egress 2" ) |
| 378 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 379 | egressPort=egress, |
| 380 | ingressPort=ingress, |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 381 | ethType=ethType, |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 382 | ipSrc=( "IPV4_SRC", main.h1.hostIp + "/32" ), |
| 383 | ipDst=( "IPV4_DST", main.h2.hostIp + "/32" ), |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 384 | debug=main.debug ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 385 | |
| 386 | utilities.assert_equals( expect=main.TRUE, |
| 387 | actual=stepResult, |
| 388 | onpass="Successfully added flows", |
| 389 | onfail="Failed add flows" ) |
| 390 | |
| 391 | # Giving ONOS time to add the flow |
| 392 | time.sleep( main.addFlowSleep ) |
| 393 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 394 | main.checkingFlow.checkFlow() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 395 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 396 | main.step( "Send a packet to verify the flow is correct" ) |
| 397 | |
| 398 | main.log.info( "Constructing packet" ) |
| 399 | # No need for the MAC src dst |
| 400 | main.h1.buildEther( dst=main.h2.hostMac ) |
| 401 | main.h1.buildIP( src=main.h1.hostIp, dst=main.h2.hostIp ) |
| 402 | |
| 403 | main.log.info( "Starting filter on host2" ) |
| 404 | # Defaults to ip |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 405 | main.h2.startFilter() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 406 | |
| 407 | main.log.info( "Sending packet to host2" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 408 | main.h1.sendPacket() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 409 | |
| 410 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 411 | stepResult = main.h2.checkFilter() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 412 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 413 | main.log.info( "Packet: %s" % main.h2.readPackets() ) |
| 414 | else: |
| 415 | main.h2.killFilter() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 416 | |
| 417 | main.log.info( "Clean up host components" ) |
| 418 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 419 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 420 | main.Mininet1.removeHostComponent( "h1" ) |
| 421 | main.Mininet1.removeHostComponent( "h2" ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 422 | |
| 423 | utilities.assert_equals( expect=main.TRUE, |
| 424 | actual=stepResult, |
| 425 | onpass="Successfully sent a packet", |
| 426 | onfail="Failed to send a packet" ) |
| 427 | |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 428 | def CASE1500( self, main ): |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 429 | """ |
| 430 | Add flow with IPv6 selector and verify the flow |
| 431 | """ |
| 432 | import json |
| 433 | import time |
| 434 | main.case( "Verify IPv6 selector is correctly compiled" ) |
| 435 | main.caseExplanation = "Install two flows with only IP selectors " + \ |
| 436 | "specified, then verify flows are added in ONOS, finally " + \ |
| 437 | "send a packet that only specifies the IP src and dst." |
| 438 | |
| 439 | main.step( "Add flows with IPv6 addresses as the only selectors" ) |
| 440 | |
| 441 | main.log.info( "Creating host components" ) |
| 442 | main.Scapy.createHostComponent( "h5" ) |
| 443 | main.Scapy.createHostComponent( "h6" ) |
| 444 | hosts = [ main.h5, main.h6 ] |
| 445 | |
| 446 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 447 | host.startHostCli() |
| 448 | host.startScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 449 | host.updateSelf( IPv6=True ) |
| 450 | |
| 451 | # Add a flow that connects host1 on port1 to host2 on port2 |
| 452 | # send output on port2 |
| 453 | # recieve input on port1 |
| 454 | egress = 6 |
| 455 | ingress = 5 |
| 456 | # IPv6 etherType = 0x86DD |
| 457 | ethType = main.params[ 'TEST' ][ 'ip6Type' ] |
| 458 | |
| 459 | # Add flows that connects host1 to host2 |
| 460 | main.log.info( "Add flow with port ingress 5 to port egress 6" ) |
| 461 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 462 | egressPort=egress, |
| 463 | ingressPort=ingress, |
| 464 | ethType=ethType, |
| 465 | ipSrc=( "IPV6_SRC", main.h5.hostIp + "/128" ), |
| 466 | ipDst=( "IPV6_DST", main.h6.hostIp + "/128" ), |
| 467 | debug=main.debug ) |
| 468 | |
| 469 | utilities.assert_equals( expect=main.TRUE, |
| 470 | actual=stepResult, |
| 471 | onpass="Successfully added flows", |
| 472 | onfail="Failed add flows" ) |
| 473 | |
| 474 | # Giving ONOS time to add the flow |
| 475 | time.sleep( main.addFlowSleep ) |
| 476 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 477 | main.checkingFlow.checkFlow() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 478 | |
| 479 | main.step( "Send a packet to verify the flow is correct" ) |
| 480 | |
| 481 | main.log.info( "Constructing packet" ) |
| 482 | # No need for the MAC src dst |
| 483 | main.h5.buildEther( dst=main.h6.hostMac ) |
| 484 | main.h5.buildIPv6( src=main.h5.hostIp, dst=main.h6.hostIp ) |
| 485 | |
| 486 | main.log.info( "Starting filter on host6" ) |
| 487 | # Defaults to ip |
| 488 | main.h6.startFilter( pktFilter="ip6" ) |
| 489 | main.log.info( "Sending packet to host6" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 490 | main.h5.sendPacket() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 491 | |
| 492 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 493 | stepResult = main.h6.checkFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 494 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 495 | main.log.info( "Packet: %s" % main.h6.readPackets() ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 496 | else: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 497 | main.h6.killFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 498 | |
| 499 | main.log.info( "Clean up host components" ) |
| 500 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 501 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 502 | main.Mininet1.removeHostComponent( "h5" ) |
| 503 | main.Mininet1.removeHostComponent( "h6" ) |
| 504 | |
| 505 | utilities.assert_equals( expect=main.TRUE, |
| 506 | actual=stepResult, |
| 507 | onpass="Successfully sent a packet", |
| 508 | onfail="Failed to send a packet" ) |
| 509 | |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 510 | def CASE1100( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 511 | """ |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 512 | Add flow with VLAN selector and verify the flow |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 513 | """ |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 514 | import json |
| 515 | import time |
| 516 | |
| 517 | main.case( "Verify VLAN selector is correctly compiled" ) |
| 518 | main.caseExplanation = "Install one flow with only the VLAN selector " +\ |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 519 | "specified, then verify the flow is added in ONOS, and finally " +\ |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 520 | "broadcast a packet with the correct VLAN tag." |
| 521 | |
| 522 | # We do this here to utilize the hosts information |
| 523 | main.log.info( "Creating host components" ) |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 524 | main.Scapy.createHostComponent( "h3" ) |
| 525 | main.Scapy.createHostComponent( "h4" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 526 | hosts = [ main.h3, main.h4 ] |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 527 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 528 | host.startHostCli() |
| 529 | host.startScapy() |
| 530 | host.updateSelf() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 531 | |
| 532 | main.step( "Add a flow with the VLAN tag as the only selector" ) |
| 533 | |
| 534 | # Add flows that connects the two vlan hosts h3 and h4 |
| 535 | # Host 3 is on port 3 and host 4 is on port 4 |
| 536 | vlan = main.params[ 'TEST' ][ 'vlan' ] |
| 537 | egress = 4 |
| 538 | ingress = 3 |
| 539 | # VLAN ethType = 0x8100 |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 540 | ethType = main.params[ 'TEST' ][ 'vlanType' ] |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 541 | |
| 542 | # Add only one flow because we don't need a response |
| 543 | main.log.info( "Add flow with port ingress 1 to port egress 2" ) |
| 544 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 545 | egressPort=egress, |
| 546 | ingressPort=ingress, |
| 547 | ethType=ethType, |
| 548 | vlan=vlan, |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 549 | debug=main.debug ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 550 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 551 | utilities.assert_equals( expect=main.TRUE, |
| 552 | actual=stepResult, |
| 553 | onpass="Successfully added flow", |
| 554 | onfail="Failed add flows" ) |
| 555 | |
| 556 | # Giving ONOS time to add the flows |
| 557 | time.sleep( main.addFlowSleep ) |
| 558 | |
| 559 | main.step( "Check flows are in the ADDED state" ) |
| 560 | |
| 561 | main.log.info( "Get the flows from ONOS" ) |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 562 | try: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 563 | flows = json.loads( main.ONOSrest.flows() ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 564 | |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 565 | stepResult = main.TRUE |
| 566 | for f in flows: |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 567 | if "rest" in f.get( "appId" ): |
| 568 | if "ADDED" not in f.get( "state" ): |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 569 | stepResult = main.FALSE |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 570 | main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) ) |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 571 | except TypeError: |
| 572 | main.log.error( "No Flows found by the REST API" ) |
| 573 | stepResult = main.FALSE |
| 574 | except ValueError: |
| 575 | main.log.error( "Problem getting Flows state from REST API. Exiting test" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 576 | main.cleanup() |
| 577 | main.exit() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 578 | |
| 579 | utilities.assert_equals( expect=main.TRUE, |
| 580 | actual=stepResult, |
| 581 | onpass="All flows are in the ADDED state", |
| 582 | onfail="All flows are NOT in the ADDED state" ) |
| 583 | |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 584 | main.step( "Check flows are in Mininet's flow table" ) |
| 585 | |
| 586 | # get the flow IDs that were added through rest |
| 587 | main.log.info( "Getting the flow IDs from ONOS" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 588 | flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ] |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 589 | # convert the flowIDs to ints then hex and finally back to strings |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 590 | flowIds = [ str( hex( int( x ) ) ) for x in flowIds ] |
| 591 | main.log.info( "ONOS flow IDs: {}".format( flowIds ) ) |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 592 | |
| 593 | stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False ) |
| 594 | |
| 595 | utilities.assert_equals( expect=main.TRUE, |
| 596 | actual=stepResult, |
| 597 | onpass="All flows are in mininet", |
| 598 | onfail="All flows are NOT in mininet" ) |
| 599 | |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 600 | main.step( "Send a packet to verify the flow are correct" ) |
| 601 | |
| 602 | # The receiving interface |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 603 | recIface = "{}-eth0.{}".format( main.h4.name, vlan ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 604 | main.log.info( "Starting filter on host2" ) |
| 605 | # Filter is setup to catch any packet on the vlan interface with the correct vlan tag |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 606 | main.h4.startFilter( ifaceName=recIface, pktFilter="" ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 607 | |
| 608 | # Broadcast the packet on the vlan interface. We only care if the flow forwards |
| 609 | # the packet with the correct vlan tag, not if the mac addr is correct |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 610 | sendIface = "{}-eth0.{}".format( main.h3.name, vlan ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 611 | main.log.info( "Broadcasting the packet with a vlan tag" ) |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 612 | main.h3.sendPacket( iface=sendIface, |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 613 | packet="Ether()/Dot1Q(vlan={})".format( vlan ) ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 614 | |
| 615 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 616 | stepResult = main.h4.checkFilter() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 617 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 618 | main.log.info( "Packet: %s" % main.h4.readPackets() ) |
| 619 | else: |
| 620 | main.h4.killFilter() |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 621 | |
| 622 | main.log.info( "Clean up host components" ) |
| 623 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 624 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 625 | main.Mininet1.removeHostComponent( "h3" ) |
| 626 | main.Mininet1.removeHostComponent( "h4" ) |
GlennRC | 073e8bc | 2015-10-27 17:11:28 -0700 | [diff] [blame] | 627 | |
| 628 | utilities.assert_equals( expect=main.TRUE, |
| 629 | actual=stepResult, |
| 630 | onpass="Successfully sent a packet", |
| 631 | onfail="Failed to send a packet" ) |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 632 | |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 633 | def CASE1300( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 634 | """ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 635 | Add flows with MPLS selector and verify the flows |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 636 | """ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 637 | import json |
| 638 | import time |
| 639 | |
| 640 | main.case( "Verify the MPLS selector is correctly compiled on the flow." ) |
| 641 | main.caseExplanation = "Install one flow with an MPLS selector, " +\ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 642 | "verify the flow is added in ONOS, and finally " +\ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 643 | "send a packet via scapy that has a MPLS label." |
| 644 | |
| 645 | main.step( "Add a flow with a MPLS selector" ) |
| 646 | |
| 647 | main.log.info( "Creating host components" ) |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 648 | main.Scapy.createHostComponent( "h1" ) |
| 649 | main.Scapy.createHostComponent( "h2" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 650 | hosts = [ main.h1, main.h2 ] |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 651 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 652 | host.startHostCli() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 653 | host.startScapy( main.dependencyPath ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 654 | host.updateSelf() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 655 | |
| 656 | # ports |
| 657 | egress = 2 |
| 658 | ingress = 1 |
| 659 | # MPLS etherType |
| 660 | ethType = main.params[ 'TEST' ][ 'mplsType' ] |
| 661 | # MPLS label |
| 662 | mplsLabel = main.params[ 'TEST' ][ 'mpls' ] |
| 663 | |
| 664 | # Add a flow that connects host1 on port1 to host2 on port2 |
| 665 | main.log.info( "Adding flow with MPLS selector" ) |
| 666 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 667 | egressPort=egress, |
| 668 | ingressPort=ingress, |
| 669 | ethType=ethType, |
| 670 | mpls=mplsLabel, |
| 671 | debug=main.debug ) |
| 672 | |
| 673 | utilities.assert_equals( expect=main.TRUE, |
| 674 | actual=stepResult, |
| 675 | onpass="Successfully added flow", |
| 676 | onfail="Failed add flow" ) |
| 677 | |
| 678 | # Giving ONOS time to add the flow |
| 679 | time.sleep( main.addFlowSleep ) |
| 680 | |
| 681 | main.step( "Check flow is in the ADDED state" ) |
| 682 | |
| 683 | main.log.info( "Get the flows from ONOS" ) |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 684 | try: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 685 | flows = json.loads( main.ONOSrest.flows() ) |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 686 | |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 687 | stepResult = main.TRUE |
| 688 | for f in flows: |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 689 | if "rest" in f.get( "appId" ): |
| 690 | if "ADDED" not in f.get( "state" ): |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 691 | stepResult = main.FALSE |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 692 | main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) ) |
Jeremy | 8616099 | 2016-04-11 10:05:53 -0700 | [diff] [blame] | 693 | except TypeError: |
| 694 | main.log.error( "No Flows found by the REST API" ) |
| 695 | stepResult = main.FALSE |
| 696 | except ValueError: |
| 697 | main.log.error( "Problem getting Flows state from REST API. Exiting test" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 698 | main.cleanup() |
| 699 | main.exit() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 700 | |
| 701 | utilities.assert_equals( expect=main.TRUE, |
| 702 | actual=stepResult, |
| 703 | onpass="All flows are in the ADDED state", |
| 704 | onfail="All flows are NOT in the ADDED state" ) |
| 705 | |
| 706 | main.step( "Check flows are in Mininet's flow table" ) |
| 707 | |
| 708 | # get the flow IDs that were added through rest |
| 709 | main.log.info( "Getting the flow IDs from ONOS" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 710 | flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ] |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 711 | # convert the flowIDs to ints then hex and finally back to strings |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 712 | flowIds = [ str( hex( int( x ) ) ) for x in flowIds ] |
| 713 | main.log.info( "ONOS flow IDs: {}".format( flowIds ) ) |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 714 | |
| 715 | stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=True ) |
| 716 | |
| 717 | utilities.assert_equals( expect=main.TRUE, |
| 718 | actual=stepResult, |
| 719 | onpass="All flows are in mininet", |
| 720 | onfail="All flows are NOT in mininet" ) |
| 721 | |
| 722 | main.step( "Send a packet to verify the flow is correct" ) |
| 723 | |
| 724 | main.log.info( "Starting filter on host2" ) |
| 725 | main.h2.startFilter( pktFilter="mpls" ) |
| 726 | |
| 727 | main.log.info( "Constructing packet" ) |
| 728 | main.log.info( "Sending packet to host2" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 729 | main.h1.sendPacket( packet='Ether()/MPLS(label={})'.format( mplsLabel ) ) |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 730 | |
| 731 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 732 | stepResult = main.h2.checkFilter() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 733 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 734 | main.log.info( "Packet: %s" % main.h2.readPackets() ) |
| 735 | else: |
| 736 | main.h2.killFilter() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 737 | |
| 738 | main.log.info( "Clean up host components" ) |
| 739 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 740 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 741 | main.Mininet1.removeHostComponent( "h1" ) |
| 742 | main.Mininet1.removeHostComponent( "h2" ) |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 743 | |
| 744 | utilities.assert_equals( expect=main.TRUE, |
| 745 | actual=stepResult, |
| 746 | onpass="Successfully sent a packet", |
| 747 | onfail="Failed to send a packet" ) |
| 748 | |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 749 | def CASE1700( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 750 | """ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 751 | Add flows with a TCP selector and verify the flow |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 752 | """ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 753 | import json |
| 754 | import time |
| 755 | |
| 756 | main.case( "Verify the TCP selector is correctly compiled on the flow" ) |
| 757 | main.caseExplanation = "Install a flow with only the TCP selector " +\ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 758 | "specified, verify the flow is added in ONOS, and finally " +\ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 759 | "send a TCP packet to verify the TCP selector is compiled correctly." |
| 760 | |
| 761 | main.step( "Add a flow with a TCP selector" ) |
| 762 | |
| 763 | main.log.info( "Creating host components" ) |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 764 | main.Scapy.createHostComponent( "h1" ) |
| 765 | main.Scapy.createHostComponent( "h2" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 766 | hosts = [ main.h1, main.h2 ] |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 767 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 768 | host.startHostCli() |
| 769 | host.startScapy() |
| 770 | host.updateSelf() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 771 | |
| 772 | # Add a flow that connects host1 on port1 to host2 on port2 |
| 773 | egress = 2 |
| 774 | ingress = 1 |
| 775 | # IPv4 etherType |
| 776 | ethType = main.params[ 'TEST' ][ 'ip4Type' ] |
| 777 | # IP protocol |
| 778 | ipProto = main.params[ 'TEST' ][ 'tcpProto' ] |
| 779 | # TCP port destination |
| 780 | tcpDst = main.params[ 'TEST' ][ 'tcpDst' ] |
| 781 | |
| 782 | main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" ) |
| 783 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 784 | egressPort=egress, |
| 785 | ingressPort=ingress, |
| 786 | ethType=ethType, |
| 787 | ipProto=ipProto, |
| 788 | tcpDst=tcpDst, |
| 789 | debug=main.debug ) |
| 790 | |
| 791 | utilities.assert_equals( expect=main.TRUE, |
| 792 | actual=stepResult, |
| 793 | onpass="Successfully added flows", |
| 794 | onfail="Failed add flows" ) |
| 795 | |
| 796 | # Giving ONOS time to add the flow |
| 797 | time.sleep( main.addFlowSleep ) |
| 798 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 799 | main.checkingFlow.checkFlow() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 800 | |
| 801 | main.step( "Send a packet to verify the flow is correct" ) |
| 802 | |
| 803 | main.log.info( "Constructing packet" ) |
| 804 | # No need for the MAC src dst |
| 805 | main.h1.buildEther( dst=main.h2.hostMac ) |
| 806 | main.h1.buildIP( dst=main.h2.hostIp ) |
| 807 | main.h1.buildTCP( dport=tcpDst ) |
| 808 | |
| 809 | main.log.info( "Starting filter on host2" ) |
| 810 | # Defaults to ip |
| 811 | main.h2.startFilter( pktFilter="tcp" ) |
| 812 | |
| 813 | main.log.info( "Sending packet to host2" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 814 | main.h1.sendPacket() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 815 | |
| 816 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 817 | stepResult = main.h2.checkFilter() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 818 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 819 | main.log.info( "Packet: %s" % main.h2.readPackets() ) |
| 820 | else: |
| 821 | main.h2.killFilter() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 822 | |
| 823 | main.log.info( "Clean up host components" ) |
| 824 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 825 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 826 | main.Mininet1.removeHostComponent( "h1" ) |
| 827 | main.Mininet1.removeHostComponent( "h2" ) |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 828 | |
| 829 | utilities.assert_equals( expect=main.TRUE, |
| 830 | actual=stepResult, |
| 831 | onpass="Successfully sent a packet", |
| 832 | onfail="Failed to send a packet" ) |
| 833 | |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 834 | def CASE1600( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 835 | """ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 836 | Add flows with a UDP selector and verify the flow |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 837 | """ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 838 | import json |
| 839 | import time |
| 840 | |
| 841 | main.case( "Verify the UDP selector is correctly compiled on the flow" ) |
| 842 | main.caseExplanation = "Install a flow with only the UDP selector " +\ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 843 | "specified, verify the flow is added in ONOS, and finally " +\ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 844 | "send a UDP packet to verify the UDP selector is compiled correctly." |
| 845 | |
| 846 | main.step( "Add a flow with a UDP selector" ) |
| 847 | |
| 848 | main.log.info( "Creating host components" ) |
Jon Hall | a510a8a | 2016-05-04 15:09:28 -0700 | [diff] [blame] | 849 | main.Scapy.createHostComponent( "h1" ) |
| 850 | main.Scapy.createHostComponent( "h2" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 851 | hosts = [ main.h1, main.h2 ] |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 852 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 853 | host.startHostCli() |
| 854 | host.startScapy() |
| 855 | host.updateSelf() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 856 | |
| 857 | # Add a flow that connects host1 on port1 to host2 on port2 |
| 858 | egress = 2 |
| 859 | ingress = 1 |
| 860 | # IPv4 etherType |
| 861 | ethType = main.params[ 'TEST' ][ 'ip4Type' ] |
| 862 | # IP protocol |
| 863 | ipProto = main.params[ 'TEST' ][ 'udpProto' ] |
| 864 | # UDP port destination |
| 865 | udpDst = main.params[ 'TEST' ][ 'udpDst' ] |
| 866 | |
| 867 | main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" ) |
| 868 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 869 | egressPort=egress, |
| 870 | ingressPort=ingress, |
| 871 | ethType=ethType, |
| 872 | ipProto=ipProto, |
| 873 | udpDst=udpDst, |
| 874 | debug=main.debug ) |
| 875 | |
| 876 | utilities.assert_equals( expect=main.TRUE, |
| 877 | actual=stepResult, |
| 878 | onpass="Successfully added flows", |
| 879 | onfail="Failed add flows" ) |
| 880 | |
| 881 | # Giving ONOS time to add the flow |
| 882 | time.sleep( main.addFlowSleep ) |
| 883 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 884 | main.checkingFlow.checkFlow() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 885 | |
| 886 | main.step( "Send a packet to verify the flow is correct" ) |
| 887 | |
| 888 | main.log.info( "Constructing packet" ) |
| 889 | # No need for the MAC src dst |
| 890 | main.h1.buildEther( dst=main.h2.hostMac ) |
| 891 | main.h1.buildIP( dst=main.h2.hostIp ) |
| 892 | main.h1.buildUDP( dport=udpDst ) |
| 893 | |
| 894 | main.log.info( "Starting filter on host2" ) |
| 895 | # Defaults to ip |
| 896 | main.h2.startFilter( pktFilter="udp" ) |
| 897 | |
| 898 | main.log.info( "Sending packet to host2" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 899 | main.h1.sendPacket() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 900 | |
| 901 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 902 | stepResult = main.h2.checkFilter() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 903 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 904 | main.log.info( "Packet: %s" % main.h2.readPackets() ) |
| 905 | else: |
| 906 | main.h2.killFilter() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 907 | |
| 908 | main.log.info( "Clean up host components" ) |
| 909 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 910 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 911 | main.Mininet1.removeHostComponent( "h1" ) |
| 912 | main.Mininet1.removeHostComponent( "h2" ) |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 913 | |
| 914 | utilities.assert_equals( expect=main.TRUE, |
| 915 | actual=stepResult, |
| 916 | onpass="Successfully sent a packet", |
| 917 | onfail="Failed to send a packet" ) |
| 918 | |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 919 | def CASE1900( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 920 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 921 | Add flows with a ICMPv4 selector and verify the flow |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 922 | """ |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 923 | import json |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 924 | import time |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 925 | |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 926 | main.case( "Verify the ICMPv4 selector is correctly compiled on the flow" ) |
| 927 | main.caseExplanation = "Install a flow with only the ICMPv4 selector " +\ |
| 928 | "specified, verify the flow is added in ONOS, and finally " +\ |
| 929 | "send a IMCPv4 packet to verify the ICMPv4 selector is compiled correctly." |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 930 | |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 931 | main.step( "Add a flow with a ICMPv4 selector" ) |
| 932 | |
| 933 | main.log.info( "Creating host components" ) |
| 934 | main.Scapy.createHostComponent( "h1" ) |
| 935 | main.Scapy.createHostComponent( "h2" ) |
| 936 | hosts = [ main.h1, main.h2 ] |
| 937 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 938 | host.startHostCli() |
| 939 | host.startScapy() |
| 940 | host.updateSelf() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 941 | |
| 942 | # Add a flow that connects host1 on port1 to host2 on port2 |
| 943 | egress = 2 |
| 944 | ingress = 1 |
| 945 | # IPv4 etherType |
| 946 | ethType = main.params[ 'TEST' ][ 'ip4Type' ] |
| 947 | # IP protocol |
| 948 | ipProto = main.params[ 'TEST' ][ 'icmpProto' ] |
| 949 | |
| 950 | main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" ) |
| 951 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 952 | egressPort=egress, |
| 953 | ingressPort=ingress, |
| 954 | ethType=ethType, |
| 955 | ipProto=ipProto, |
| 956 | debug=main.debug ) |
| 957 | |
| 958 | utilities.assert_equals( expect=main.TRUE, |
| 959 | actual=stepResult, |
| 960 | onpass="Successfully added flows", |
| 961 | onfail="Failed add flows" ) |
| 962 | |
| 963 | # Giving ONOS time to add the flow |
| 964 | time.sleep( main.addFlowSleep ) |
| 965 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 966 | main.checkingFlow.checkFlow() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 967 | |
| 968 | main.step( "Send a packet to verify the flow is correct" ) |
| 969 | |
| 970 | main.log.info( "Constructing packet" ) |
| 971 | # No need for the MAC src dst |
| 972 | main.h1.buildEther( dst=main.h2.hostMac ) |
| 973 | main.h1.buildIP( dst=main.h2.hostIp ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 974 | main.h1.buildICMP() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 975 | |
| 976 | main.log.info( "Starting filter on host2" ) |
| 977 | # Defaults to ip |
| 978 | main.h2.startFilter( pktFilter="icmp" ) |
| 979 | |
| 980 | main.log.info( "Sending packet to host2" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 981 | main.h1.sendPacket() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 982 | |
| 983 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 984 | stepResult = main.h2.checkFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 985 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 986 | main.log.info( "Packet: %s" % main.h2.readPackets() ) |
| 987 | else: |
| 988 | main.h2.killFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 989 | |
| 990 | main.log.info( "Clean up host components" ) |
| 991 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 992 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 993 | main.Mininet1.removeHostComponent( "h1" ) |
| 994 | main.Mininet1.removeHostComponent( "h2" ) |
| 995 | |
| 996 | utilities.assert_equals( expect=main.TRUE, |
| 997 | actual=stepResult, |
| 998 | onpass="Successfully sent a packet", |
| 999 | onfail="Failed to send a packet" ) |
| 1000 | |
| 1001 | def CASE2000( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1002 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1003 | Add flows with a ICMPv6 selector and verify the flow |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1004 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1005 | import json |
| 1006 | import time |
| 1007 | |
| 1008 | main.case( "Verify the ICMPv6 selector is correctly compiled on the flow" ) |
| 1009 | main.caseExplanation = "Install a flow with only the ICMPv6 selector " +\ |
| 1010 | "specified, verify the flow is added in ONOS, and finally " +\ |
| 1011 | "send a IMCPv6 packet to verify the ICMPv6 selector is compiled correctly." |
| 1012 | |
| 1013 | main.step( "Add a flow with a ICMPv6 selector" ) |
| 1014 | |
| 1015 | main.log.info( "Creating host components" ) |
| 1016 | main.Scapy.createHostComponent( "h5" ) |
| 1017 | main.Scapy.createHostComponent( "h6" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1018 | hosts = [ main.h5, main.h6 ] |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1019 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1020 | host.startHostCli() |
| 1021 | host.startScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1022 | host.updateSelf( IPv6=True ) |
| 1023 | |
| 1024 | # Add a flow that connects host1 on port1 to host2 on port2 |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1025 | egress = 6 |
| 1026 | ingress = 5 |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1027 | # IPv6 etherType |
| 1028 | ethType = main.params[ 'TEST' ][ 'ip6Type' ] |
| 1029 | # IP protocol |
| 1030 | ipProto = main.params[ 'TEST' ][ 'icmp6Proto' ] |
| 1031 | |
| 1032 | main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" ) |
| 1033 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 1034 | egressPort=egress, |
| 1035 | ingressPort=ingress, |
| 1036 | ethType=ethType, |
| 1037 | ipProto=ipProto, |
| 1038 | debug=main.debug ) |
| 1039 | |
| 1040 | utilities.assert_equals( expect=main.TRUE, |
| 1041 | actual=stepResult, |
| 1042 | onpass="Successfully added flows", |
| 1043 | onfail="Failed add flows" ) |
| 1044 | |
| 1045 | # Giving ONOS time to add the flow |
| 1046 | time.sleep( main.addFlowSleep ) |
| 1047 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 1048 | main.checkingFlow.checkFlow() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1049 | |
| 1050 | main.step( "Send a packet to verify the flow is correct" ) |
| 1051 | |
| 1052 | main.log.info( "Constructing packet" ) |
| 1053 | # No need for the MAC src dst |
| 1054 | main.h5.buildEther( dst=main.h6.hostMac ) |
| 1055 | main.h5.buildIPv6( dst=main.h6.hostIp ) |
| 1056 | main.h5.buildICMP( ipVersion=6 ) |
| 1057 | |
| 1058 | main.log.info( "Starting filter on host2" ) |
| 1059 | # Defaults to ip |
| 1060 | main.h6.startFilter( pktFilter="icmp6" ) |
| 1061 | |
| 1062 | main.log.info( "Sending packet to host2" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1063 | main.h5.sendPacket() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1064 | |
| 1065 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1066 | stepResult = main.h6.checkFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1067 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1068 | main.log.info( "Packet: %s" % main.h6.readPackets() ) |
| 1069 | else: |
| 1070 | main.h6.killFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1071 | |
| 1072 | main.log.info( "Clean up host components" ) |
| 1073 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1074 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1075 | main.Mininet1.removeHostComponent( "h5" ) |
| 1076 | main.Mininet1.removeHostComponent( "h6" ) |
| 1077 | |
| 1078 | utilities.assert_equals( expect=main.TRUE, |
| 1079 | actual=stepResult, |
| 1080 | onpass="Successfully sent a packet", |
| 1081 | onfail="Failed to send a packet" ) |
| 1082 | |
| 1083 | def CASE3000( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1084 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1085 | Delete flow |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1086 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1087 | import json |
| 1088 | |
| 1089 | main.case( "Delete flows that were added through rest" ) |
| 1090 | main.step( "Deleting flows" ) |
| 1091 | |
| 1092 | main.log.info( "Getting flows" ) |
| 1093 | try: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1094 | flows = json.loads( main.ONOSrest.flows() ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1095 | |
| 1096 | stepResult = main.TRUE |
| 1097 | for f in flows: |
| 1098 | if "rest" in f.get( "appId" ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1099 | if main.debug: |
| 1100 | main.log.debug( "Flow to be deleted:\n{}".format( main.ONOSrest.pprint( f ) ) ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1101 | stepResult = stepResult and main.ONOSrest.removeFlow( f.get( "deviceId" ), f.get( "id" ) ) |
| 1102 | except TypeError: |
| 1103 | main.log.error( "No Flows found by the REST API" ) |
| 1104 | stepResult = main.FALSE |
| 1105 | except ValueError: |
| 1106 | main.log.error( "Problem getting Flows state from REST API. Exiting test" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1107 | main.cleanup() |
| 1108 | main.exit() |
GlennRC | 956ea74 | 2015-11-05 16:14:15 -0800 | [diff] [blame] | 1109 | |
| 1110 | utilities.assert_equals( expect=main.TRUE, |
| 1111 | actual=stepResult, |
| 1112 | onpass="Successfully deleting flows", |
| 1113 | onfail="Failed to delete flows" ) |
| 1114 | |
| 1115 | time.sleep( main.delFlowSleep ) |
| 1116 | |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1117 | def CASE1200( self, main ): |
| 1118 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1119 | Add flows with a ARP selector and verify the flow |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1120 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1121 | import json |
| 1122 | import time |
| 1123 | |
| 1124 | main.case( "Verify flow IP selectors are correctly compiled" ) |
| 1125 | main.caseExplanation = "Install two flows with only IP selectors " + \ |
| 1126 | "specified, then verify flows are added in ONOS, finally " + \ |
| 1127 | "send a packet that only specifies the IP src and dst." |
| 1128 | |
| 1129 | main.step( "Add flows with ARP addresses as the only selectors" ) |
| 1130 | |
| 1131 | main.log.info( "Creating host components" ) |
| 1132 | main.Scapy.createHostComponent( "h1" ) |
| 1133 | main.Scapy.createHostComponent( "h2" ) |
| 1134 | hosts = [ main.h1, main.h2 ] |
| 1135 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1136 | host.startHostCli() |
| 1137 | host.startScapy() |
| 1138 | host.updateSelf() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1139 | |
| 1140 | # Add a flow that connects host1 on port1 to host2 on port2 |
| 1141 | # send output on port2 |
| 1142 | # recieve input on port1 |
| 1143 | egress = 2 |
| 1144 | ingress = 1 |
| 1145 | # ARP etherType = 0x0806 |
| 1146 | ethType = main.params[ 'TEST' ][ 'arpType' ] |
| 1147 | |
| 1148 | # Add flows that connects host1 to host2 |
| 1149 | main.log.info( "Add flow with port ingress 1 to port egress 2" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1150 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 1151 | egressPort=egress, |
| 1152 | ingressPort=ingress, |
| 1153 | ethType=ethType, |
| 1154 | priority=40001, |
| 1155 | debug=main.debug ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1156 | |
| 1157 | utilities.assert_equals( expect=main.TRUE, |
| 1158 | actual=stepResult, |
| 1159 | onpass="Successfully added flows", |
| 1160 | onfail="Failed add flows" ) |
| 1161 | |
| 1162 | # Giving ONOS time to add the flow |
| 1163 | time.sleep( main.addFlowSleep ) |
| 1164 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 1165 | main.checkingFlow.checkFlow() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1166 | |
| 1167 | main.step( "Send a packet to verify the flow is correct" ) |
| 1168 | |
| 1169 | main.log.info( "Constructing packet" ) |
| 1170 | # No need for the MAC src dst |
| 1171 | main.h1.buildEther( src=main.h1.hostMac, dst=main.h2.hostMac ) |
| 1172 | main.h1.buildARP( pdst=main.h2.hostIp ) |
| 1173 | |
| 1174 | main.log.info( "Starting filter on host2" ) |
| 1175 | # Defaults to ip |
| 1176 | main.h2.startFilter( pktFilter="arp" ) |
| 1177 | |
| 1178 | main.log.info( "Sending packet to host2" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1179 | main.h1.sendPacket() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1180 | |
| 1181 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1182 | stepResult = main.h2.checkFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1183 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1184 | main.log.info( "Packet: %s" % main.h2.readPackets() ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1185 | else: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1186 | main.h2.killFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1187 | |
| 1188 | main.log.info( "Clean up host components" ) |
| 1189 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1190 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1191 | main.Mininet1.removeHostComponent( "h1" ) |
| 1192 | main.Mininet1.removeHostComponent( "h2" ) |
| 1193 | |
| 1194 | utilities.assert_equals( expect=main.TRUE, |
| 1195 | actual=stepResult, |
| 1196 | onpass="Successfully sent a packet", |
| 1197 | onfail="Failed to send a packet" ) |
| 1198 | |
| 1199 | def CASE1800( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1200 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1201 | Add flows with a SCTP selector and verify the flow |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1202 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1203 | import json |
| 1204 | import time |
| 1205 | |
| 1206 | main.case( "Verify the UDP selector is correctly compiled on the flow" ) |
| 1207 | main.caseExplanation = "Install a flow with only the UDP selector " + \ |
| 1208 | "specified, verify the flow is added in ONOS, and finally " + \ |
| 1209 | "send a UDP packet to verify the UDP selector is compiled correctly." |
| 1210 | |
| 1211 | main.step( "Add a flow with a SCTP selector" ) |
| 1212 | |
| 1213 | main.log.info( "Creating host components" ) |
| 1214 | main.Scapy.createHostComponent( "h1" ) |
| 1215 | main.Scapy.createHostComponent( "h2" ) |
| 1216 | hosts = [ main.h1, main.h2 ] |
| 1217 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1218 | host.startHostCli() |
| 1219 | host.startScapy() |
| 1220 | host.updateSelf() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1221 | |
| 1222 | # Add a flow that connects host1 on port1 to host2 on port2 |
| 1223 | egress = 2 |
| 1224 | ingress = 1 |
| 1225 | # IPv4 etherType |
| 1226 | ethType = main.params[ 'TEST' ][ 'ip4Type' ] |
| 1227 | # IP protocol |
| 1228 | ipProto = main.params[ 'TEST' ][ 'sctpProto' ] |
| 1229 | |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1230 | main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1231 | stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID, |
| 1232 | egressPort=egress, |
| 1233 | ingressPort=ingress, |
| 1234 | ethType=ethType, |
| 1235 | ipProto=ipProto, |
| 1236 | debug=main.debug ) |
| 1237 | |
| 1238 | utilities.assert_equals( expect=main.TRUE, |
| 1239 | actual=stepResult, |
| 1240 | onpass="Successfully added flows", |
| 1241 | onfail="Failed add flows" ) |
| 1242 | |
| 1243 | # Giving ONOS time to add the flow |
| 1244 | time.sleep( main.addFlowSleep ) |
| 1245 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 1246 | main.checkingFlow.checkFlow() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1247 | |
| 1248 | main.step( "Send a packet to verify the flow is correct" ) |
| 1249 | |
| 1250 | main.log.info( "Constructing packet" ) |
| 1251 | # No need for the MAC src dst |
| 1252 | main.h1.buildEther( dst=main.h2.hostMac ) |
| 1253 | main.h1.buildIP( dst=main.h2.hostIp ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1254 | main.h1.buildSCTP() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1255 | |
| 1256 | main.log.info( "Starting filter on host2" ) |
| 1257 | # Defaults to ip |
| 1258 | main.h2.startFilter( pktFilter="sctp" ) |
| 1259 | |
| 1260 | main.log.info( "Sending packet to host2" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1261 | main.h1.sendPacket() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1262 | |
| 1263 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1264 | stepResult = main.h2.checkFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1265 | if stepResult: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1266 | main.log.info( "Packet: %s" % main.h2.readPackets() ) |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1267 | else: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1268 | main.h2.killFilter() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1269 | |
| 1270 | main.log.info( "Clean up host components" ) |
| 1271 | for host in hosts: |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1272 | host.stopScapy() |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1273 | main.Mininet1.removeHostComponent( "h1" ) |
| 1274 | main.Mininet1.removeHostComponent( "h2" ) |
| 1275 | |
| 1276 | utilities.assert_equals( expect=main.TRUE, |
| 1277 | actual=stepResult, |
| 1278 | onpass="Successfully sent a packet", |
| 1279 | onfail="Failed to send a packet" ) |
| 1280 | |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 1281 | def CASE100( self, main ): |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1282 | """ |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 1283 | Report errors/warnings/exceptions |
Jon Hall | fc95107 | 2017-05-24 15:55:34 -0700 | [diff] [blame] | 1284 | """ |
alison | e14d7b0 | 2016-07-06 10:31:51 -0700 | [diff] [blame] | 1285 | main.log.info( "Error report: \n" ) |
GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 1286 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 1287 | [ "INFO", |
| 1288 | "FOLLOWER", |
| 1289 | "WARN", |
| 1290 | "flow", |
| 1291 | "ERROR", |
| 1292 | "Except" ], |
GlennRC | 6844994 | 2015-10-16 16:03:12 -0700 | [diff] [blame] | 1293 | "s" ) |