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