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