blob: 6c12a4f672111a784dba495cbec9471a1f65db9a [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
kelvin-onlabd48a68c2015-07-13 16:01:36 -070021# Testing the basic intent functionality of ONOS
22
Jon Hall78be4962017-05-23 14:53:53 -070023
kelvin-onlabd48a68c2015-07-13 16:01:36 -070024class FUNCintent:
25
26 def __init__( self ):
27 self.default = ''
28
29 def CASE1( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -070030 import imp
Jon Hallf632d202015-07-30 15:45:11 -070031 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070032 """
33 - Construct tests variables
34 - GIT ( optional )
35 - Checkout ONOS master branch
36 - Pull latest ONOS code
37 - Building ONOS ( optional )
38 - Install ONOS package
39 - Build ONOS package
40 """
Devin Lim58046fa2017-07-05 16:55:00 -070041 try:
42 from tests.dependencies.ONOSSetup import ONOSSetup
43 main.testSetUp = ONOSSetup()
44 except ImportError:
45 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070046 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070047 main.testSetUp.envSetupDescription()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070048 stepResult = main.FALSE
49
You Wanga0f6ff62018-01-11 15:46:30 -080050 from tests.dependencies.Network import Network
51 main.Network = Network()
52
kelvin-onlabd48a68c2015-07-13 16:01:36 -070053 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070054 try:
Jon Halla3e02432015-07-24 15:55:42 -070055 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Jon Halla3e02432015-07-24 15:55:42 -070056 main.dependencyPath = main.testOnDirectory + \
57 main.params[ 'DEPENDENCY' ][ 'path' ]
58 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
59 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
Devin Lim58046fa2017-07-05 16:55:00 -070060
Jon Halla3e02432015-07-24 15:55:42 -070061 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
62 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
63 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
64 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
65 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070066 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070067 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
68 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
Shreyaca8990f2017-03-16 11:43:11 -070069 main.checkConnectionSleep = int( main.params[ 'SLEEP' ][ 'checkConnection' ] )
70 main.checkFlowCountSleep = int( main.params[ 'SLEEP' ][ 'checkFlowCount' ] )
71 main.checkIntentHostSleep = int( main.params[ 'SLEEP' ][ 'checkIntentHost' ] )
72 main.checkIntentPointSleep = int( main.params[ 'SLEEP' ][ 'checkIntentPoint' ] )
acsmars59a4c552015-09-10 18:11:19 -070073 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070074 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
Devin Lima4f95bc2017-08-11 11:13:03 -070075 main.generalAttemptsNum = int( main.params[ 'RETRY' ][ 'generalAttempts' ] )
76 main.middleAttemptsNum = int( main.params[ 'RETRY' ][ 'middleAttempts' ] )
77 main.minimumAttemptsNum = int( main.params[ 'RETRY' ][ 'minimumAttempts' ] )
78 main.checkConnectionAttNum = int( main.params[ 'RETRY' ][ 'checkConnectionAtt' ] )
79 main.removeIntentAttNum = int( main.params[ 'RETRY' ][ 'removeIntentAtt' ] )
Jon Halla3e02432015-07-24 15:55:42 -070080 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
81 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
Jon Halla3e02432015-07-24 15:55:42 -070082 main.hostsData = {}
Jeremy Songster1f39bf02016-01-20 17:17:25 -080083 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
84 main.scapyHosts = [] # List of scapy hosts for iterating
acsmars5d8cc862015-09-25 09:44:50 -070085 main.assertReturnString = '' # Assembled assert return string
Jon Hall78be4962017-05-23 14:53:53 -070086 main.cycle = 0 # How many times FUNCintent has run through its tests
You Wangf6574de2018-02-09 14:43:47 -080087 main.usePortstate = True if main.params[ 'TEST' ][ 'usePortstate' ] == "True" else False
kelvin-onlabd48a68c2015-07-13 16:01:36 -070088
Jon Halla3e02432015-07-24 15:55:42 -070089 # -- INIT SECTION, ONLY RUNS ONCE -- #
kelvin-onlabd48a68c2015-07-13 16:01:36 -070090
Jon Hall78be4962017-05-23 14:53:53 -070091 main.intents = imp.load_source( wrapperFile2,
Jon Halla3e02432015-07-24 15:55:42 -070092 main.dependencyPath +
93 wrapperFile2 +
94 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070095
You Wanga0f6ff62018-01-11 15:46:30 -080096 if hasattr( main, "Mininet1" ):
97 copyResult1 = main.ONOSbench.scp( main.Mininet1,
98 main.dependencyPath +
99 main.topology,
100 main.Mininet1.home + "custom/",
101 direction="to" )
Devin Lim58046fa2017-07-05 16:55:00 -0700102
Devin Lim142b5342017-07-20 15:22:39 -0700103 stepResult = main.testSetUp.envSetup()
Jon Halla3e02432015-07-24 15:55:42 -0700104 except Exception as e:
Devin Lim58046fa2017-07-05 16:55:00 -0700105 main.testSetUp.envSetupException( e )
106 main.testSetUp.evnSetupConclusion( stepResult )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700107
108 def CASE2( self, main ):
109 """
110 - Set up cell
111 - Create cell file
112 - Set cell file
113 - Verify cell file
114 - Kill ONOS process
115 - Uninstall ONOS cluster
116 - Verify ONOS start up
117 - Install ONOS cluster
118 - Connect to cli
119 """
Jeremycd872222016-03-29 10:08:34 -0700120 main.flowCompiler = "Flow Rules"
You Wanga0f6ff62018-01-11 15:46:30 -0800121 main.initialized = main.testSetUp.ONOSSetUp( main.Cluster, True )
Jon Hall78be4962017-05-23 14:53:53 -0700122 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -0700123
Jon Halla3e02432015-07-24 15:55:42 -0700124 def CASE8( self, main ):
125 """
acsmars59a4c552015-09-10 18:11:19 -0700126 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700127 """
Devin Lim58046fa2017-07-05 16:55:00 -0700128 import time
129 try:
130 from tests.dependencies.topology import Topology
131 except ImportError:
132 main.log.error( "Topology not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700133 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700134 try:
135 main.topoRelated
136 except ( NameError, AttributeError ):
137 main.topoRelated = Topology()
138 main.topoRelated.compareTopos( main.Mininet1, main.checkTopoAttempts )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700139
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700140 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700141 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700142 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700143 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700144 if main.initialized == main.FALSE:
145 main.log.error( "Test components did not start correctly, skipping further tests" )
146 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700147 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700148 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700149 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700150 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700151 "switches to test intents, exits out if " +\
152 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700153
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700154 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700155 args = "--switch ovs,protocols=OpenFlow10"
Devin Lim29a9e3d2018-01-30 14:09:47 -0800156 topoResult = main.Mininet1.startNet( topoFile=main.Mininet1.home + "/custom/" + main.topology,
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700157 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700158 stepResult = topoResult
159 utilities.assert_equals( expect=main.TRUE,
160 actual=stepResult,
161 onpass="Successfully loaded topology",
162 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700163
164 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700165 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700166 main.initialized = main.FALSE
167 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700168
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700169 def CASE11( self, main ):
170 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700171 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700172 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700173 if main.initialized == main.FALSE:
174 main.log.error( "Test components did not start correctly, skipping further tests" )
175 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700176 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700177 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700178 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700179 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700180 "switches to test intents, exits out if " +\
181 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700182
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700183 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700184 args = "--switch ovs,protocols=OpenFlow13"
Devin Lim29a9e3d2018-01-30 14:09:47 -0800185 topoResult = main.Mininet1.startNet( topoFile=main.Mininet1.home + "/custom/" + main.topology,
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700186 args=args )
187 stepResult = topoResult
188 utilities.assert_equals( expect=main.TRUE,
189 actual=stepResult,
190 onpass="Successfully loaded topology",
191 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700192 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700193 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700194 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700195
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700196 def CASE12( self, main ):
197 """
198 Assign mastership to controllers
199 """
200 import re
201
Jeremyd9e4eb12016-04-13 12:09:06 -0700202 if main.initialized == main.FALSE:
203 main.log.error( "Test components did not start correctly, skipping further tests" )
204 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700205 main.case( "Assign switches to controllers" )
206 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700207 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700208 " switches to ONOS nodes"
209
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700210 switchList = []
211
212 # Creates a list switch name, use getSwitch() function later...
213 for i in range( 1, ( main.numSwitch + 1 ) ):
214 switchList.append( 's' + str( i ) )
215
Devin Lim142b5342017-07-20 15:22:39 -0700216 tempONOSip = main.Cluster.getIps()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700217
You Wanga0f6ff62018-01-11 15:46:30 -0800218 assignResult = main.Network.assignSwController( sw=switchList,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700219 ip=tempONOSip,
alison52b25892016-09-19 10:53:48 -0700220 port="6653" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700221 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700222 main.log.error( "Problem assigning mastership of switches" )
223 main.initialized = main.FALSE
224 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700225
226 for i in range( 1, ( main.numSwitch + 1 ) ):
You Wanga0f6ff62018-01-11 15:46:30 -0800227 response = main.Network.getSwController( "s" + str( i ) )
Jon Hall860b8152017-05-23 10:35:23 -0700228 main.log.debug( "Response is " + str( response ) )
Devin Lim142b5342017-07-20 15:22:39 -0700229 if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700230 assignResult = assignResult and main.TRUE
231 else:
232 assignResult = main.FALSE
233 stepResult = assignResult
234 utilities.assert_equals( expect=main.TRUE,
235 actual=stepResult,
236 onpass="Successfully assigned switches" +
237 "to controller",
238 onfail="Failed to assign switches to " +
239 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700240 if not stepResult:
241 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700242
Jon Hall78be4962017-05-23 14:53:53 -0700243 def CASE13( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700244 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800245 Create Scapy components
246 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700247 if main.initialized == main.FALSE:
248 main.log.error( "Test components did not start correctly, skipping further tests" )
249 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800250 main.case( "Create scapy components" )
251 main.step( "Create scapy components" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800252 scapyResult = main.TRUE
253 for hostName in main.scapyHostNames:
254 main.Scapy1.createHostComponent( hostName )
255 main.scapyHosts.append( getattr( main, hostName ) )
256
257 main.step( "Start scapy components" )
258 for host in main.scapyHosts:
259 host.startHostCli()
260 host.startScapy()
261 host.updateSelf()
262 main.log.debug( host.name )
263 main.log.debug( host.hostIp )
264 main.log.debug( host.hostMac )
265
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800266 utilities.assert_equals( expect=main.TRUE,
267 actual=scapyResult,
268 onpass="Successfully created Scapy Components",
269 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700270 if not scapyResult:
271 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800272
273 def CASE14( self, main ):
274 """
275 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700276 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700277 if main.initialized == main.FALSE:
278 main.log.error( "Test components did not start correctly, skipping further tests" )
279 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700280 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800281 main.step( "Pingall hosts and confirm ONOS discovery" )
Jon Hall78be4962017-05-23 14:53:53 -0700282 utilities.retry( f=main.intents.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700283
Jon Hall78be4962017-05-23 14:53:53 -0700284 stepResult = utilities.retry( f=main.intents.confirmHostDiscovery, retValue=main.FALSE,
285 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700286 utilities.assert_equals( expect=main.TRUE,
287 actual=stepResult,
288 onpass="Successfully discovered hosts",
289 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700290 if not stepResult:
291 main.initialized = main.FALSE
292 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700293
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800294 main.step( "Populate hostsData" )
Jon Hall78be4962017-05-23 14:53:53 -0700295 stepResult = main.intents.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700296 utilities.assert_equals( expect=main.TRUE,
297 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800298 onpass="Successfully populated hostsData",
299 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700300 if not stepResult:
301 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800302
303 def CASE15( self, main ):
304 """
305 Discover all hosts with scapy arp packets and store its data to a dictionary
306 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700307 if main.initialized == main.FALSE:
308 main.log.error( "Test components did not start correctly, skipping further tests" )
309 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800310 main.case( "Discover all hosts using scapy" )
311 main.step( "Send packets from each host to the first host and confirm onos discovery" )
312
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800313 if len( main.scapyHosts ) < 1:
314 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700315 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800316 main.skipCase()
317
318 # Send ARP packets from each scapy host component
Jon Hall78be4962017-05-23 14:53:53 -0700319 main.intents.sendDiscoveryArp( main, main.scapyHosts )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800320
Jon Hall78be4962017-05-23 14:53:53 -0700321 stepResult = utilities.retry( f=main.intents.confirmHostDiscovery,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800322 retValue=main.FALSE, args=[ main ],
323 attempts=main.checkTopoAttempts, sleep=2 )
324
325 utilities.assert_equals( expect=main.TRUE,
326 actual=stepResult,
327 onpass="ONOS correctly discovered all hosts",
328 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700329 if not stepResult:
330 main.initialized = main.FALSE
331 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800332
333 main.step( "Populate hostsData" )
Jon Hall78be4962017-05-23 14:53:53 -0700334 stepResult = main.intents.populateHostData( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800335 utilities.assert_equals( expect=main.TRUE,
336 actual=stepResult,
337 onpass="Successfully populated hostsData",
338 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700339 if not stepResult:
340 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800341
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800342 def CASE16( self, main ):
343 """
Jeremy42df2e72016-02-23 16:37:46 -0800344 Balance Masters
345 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700346 if main.initialized == main.FALSE:
347 main.log.error( "Test components did not start correctly, skipping further tests" )
348 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800349 main.case( "Balance mastership of switches" )
350 main.step( "Balancing mastership of switches" )
351
Devin Lim142b5342017-07-20 15:22:39 -0700352 balanceResult = utilities.retry( f=main.Cluster.active( 0 ).CLI.balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800353
354 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700355 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800356 onpass="Successfully balanced mastership of switches",
357 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700358 if not balanceResult:
359 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800360
361 def CASE17( self, main ):
362 """
Jeremy6e9748f2016-03-25 15:03:39 -0700363 Use Flow Objectives
364 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700365 if main.initialized == main.FALSE:
366 main.log.error( "Test components did not start correctly, skipping further tests" )
367 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700368 main.case( "Enable intent compilation using Flow Objectives" )
369 main.step( "Enabling Flow Objectives" )
370
371 main.flowCompiler = "Flow Objectives"
372
373 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
374
Devin Lim142b5342017-07-20 15:22:39 -0700375 stepResult = main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700376 propName="useFlowObjectives", value="true" )
Jeremy6e9748f2016-03-25 15:03:39 -0700377 utilities.assert_equals( expect=main.TRUE,
378 actual=stepResult,
379 onpass="Successfully activated Flow Objectives",
380 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700381 if not balanceResult:
382 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700383
384 def CASE18( self, main ):
385 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800386 Stop mininet and remove scapy host
387 """
Devin Lim58046fa2017-07-05 16:55:00 -0700388 try:
389 from tests.dependencies.utils import Utils
390 except ImportError:
391 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700392 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700393 try:
394 main.Utils
395 except ( NameError, AttributeError ):
396 main.Utils = Utils()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800397 main.log.report( "Stop Mininet and Scapy" )
398 main.case( "Stop Mininet and Scapy" )
399 main.caseExplanation = "Stopping the current mininet topology " +\
400 "to start up fresh"
401 main.step( "Stopping and Removing Scapy Host Components" )
402 scapyResult = main.TRUE
403 for host in main.scapyHosts:
404 scapyResult = scapyResult and host.stopScapy()
405 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
406
407 for host in main.scapyHosts:
408 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
409 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
410
411 main.scapyHosts = []
412 main.scapyHostIPs = []
413
414 utilities.assert_equals( expect=main.TRUE,
415 actual=scapyResult,
416 onpass="Successfully stopped scapy and removed host components",
417 onfail="Failed to stop mininet and scapy" )
418
Devin Lim58046fa2017-07-05 16:55:00 -0700419 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700420 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800421 if not ( mininetResult and scapyResult ):
Devin Lim44075962017-08-11 10:56:37 -0700422 main.cleanAndExit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700423
Jeremy Songster17147f22016-05-31 18:30:52 -0700424 def CASE19( self, main ):
425 """
426 Copy the karaf.log files after each testcase cycle
427 """
Devin Lim58046fa2017-07-05 16:55:00 -0700428 try:
429 from tests.dependencies.utils import Utils
430 except ImportError:
431 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700432 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700433 try:
434 main.Utils
435 except ( NameError, AttributeError ):
436 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700437 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700438
You Wang84f981d2018-01-12 16:11:50 -0800439 def CASE100( self, main):
440 """
441 Connect to a physical network, assign controllers and start scapy
442 """
443 import time
444 main.case( "Connecting to physical network" )
445 main.step( "Connecting to physical network" )
446 main.OFProtocol = "1.3"
447 topoResult = main.NetworkBench.connectToNet()
448 utilities.assert_equals( expect=main.TRUE,
449 actual=topoResult,
450 onpass="Successfully loaded topology",
451 onfail="Failed to load topology" )
452 # Exit if topology did not load properly
453 if not topoResult:
454 main.cleanAndExit()
455
456 main.step( "Assign switches to controllers." )
457 assignResult = main.TRUE
458 switchList = []
459 for i in range( 1, ( main.numSwitch + 1 ) ):
460 switchList.append( 's' + str( i ) )
461 tempONOSip = main.Cluster.getIps()
462 assignResult = main.Network.assignSwController( sw=switchList,
463 ip=tempONOSip,
464 port="6653" )
465 utilities.assert_equals( expect=main.TRUE,
466 actual=assignResult,
467 onpass="Successfully assigned switches to controller",
468 onfail="Failed to assgin switches to controller" )
469
470 main.step( "Start scapy" )
471 scapyResult = main.TRUE
472 for hostName in main.scapyHostNames:
473 main.scapyHosts.append( getattr( main, hostName ) )
474
475 for host in main.scapyHosts:
476 host.startScapy()
477 host.updateSelf()
478 main.log.debug( host.name )
479 main.log.debug( host.hostIp )
480 main.log.debug( host.hostMac )
481
482 utilities.assert_equals( expect=main.TRUE, actual=scapyResult,
483 onpass="Successfully created Scapy Components",
484 onfail="Failed to discover Scapy Components" )
485
486 def CASE101( self, main ):
487 """
488 Stop Scapy on physical hosts
489 """
490 main.case( "Stop Scapy" )
491 main.step( "Stopping Scapy Hosts" )
492 scapyResult = main.TRUE
493 for host in main.scapyHosts:
494 host.stopScapy()
495 utilities.assert_equals( expect=main.TRUE, actual=scapyResult,
496 onpass="Successfully stopped scapy",
497 onfail="Failed to stop scapy" )
498
kelvin-onlabb769f562015-07-15 17:05:10 -0700499 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700500 """
501 Add host intents between 2 host:
502 - Discover hosts
503 - Add host intents
504 - Check intents
505 - Verify flows
506 - Ping hosts
507 - Reroute
508 - Link down
509 - Verify flows
510 - Check topology
511 - Ping hosts
512 - Link up
513 - Verify flows
514 - Check topology
515 - Ping hosts
516 - Remove intents
517 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700518 if main.initialized == main.FALSE:
519 main.log.error( "Test components did not start correctly, skipping further tests" )
520 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700521 # Assert variables - These variable's name|format must be followed
522 # if you want to use the wrapper function
523 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700524 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700525 assert main.numSwitch
526 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700527 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700528 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700529 main.initialized = main.FALSE
530 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700531
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800532 # Save leader candidates
Devin Lim142b5342017-07-20 15:22:39 -0700533 intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates()
acsmarse6b410f2015-07-17 14:39:34 -0700534
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700535 main.testName = "Host Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700536 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700537 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700538 main.caseExplanation = "This test case tests Host intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -0700539 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700540 "Different type of hosts will be tested in " +\
541 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700542 "etc;\nThe test will use OF " + main.OFProtocol +\
543 " OVS running in Mininet and compile intents" +\
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700544 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700545
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700546 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700547 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700548 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
549 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800550 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700551 installResult = main.intents.installHostIntent( main,
552 name="IPV4",
553 onosNode=0,
554 host1=host1,
555 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800556 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700557 testResult = main.intents.testHostIntent( main,
558 name="IPV4",
559 intentId=installResult,
560 onosNode=0,
561 host1=host1,
562 host2=host2,
563 sw1="s5",
564 sw2="s2",
565 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800566 else:
Devin Lim8619b552018-04-13 00:40:43 -0700567 main.intents.removeAllExistIntents( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800568
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700569 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800570 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700571 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700572 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700573
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700574 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700575 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700576 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
Jon Hall78be4962017-05-23 14:53:53 -0700577 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1 " }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800578 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700579 installResult = main.intents.installHostIntent( main,
580 name="DUALSTACK",
581 onosNode=0,
582 host1=host1,
583 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800584
585 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700586 testResult = main.intents.testHostIntent( main,
587 name="DUALSTACK",
588 intentId=installResult,
589 onosNode=0,
590 host1=host1,
591 host2=host2,
592 sw1="s5",
593 sw2="s2",
594 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700595
596 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800597 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700598 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700599 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700600
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700601 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700602 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700603 host1 = { "name": "h1" }
604 host2 = { "name": "h11" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800605 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700606 installResult = main.intents.installHostIntent( main,
607 name="DUALSTACK2",
608 onosNode=0,
609 host1=host1,
610 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800611
612 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700613 testResult = main.intents.testHostIntent( main,
614 name="DUALSTACK2",
615 intentId=installResult,
616 onosNode=0,
617 host1=host1,
618 host2=host2,
619 sw1="s5",
620 sw2="s2",
621 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800622 else:
Devin Lim8619b552018-04-13 00:40:43 -0700623 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700624
625 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800626 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700627 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700628 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700629
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700630 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700631 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall9c888672017-05-15 18:03:54 -0700632 host1 = { "name": "h1" }
633 host2 = { "name": "h3" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800634 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700635 installResult = main.intents.installHostIntent( main,
636 name="1HOP",
637 onosNode=0,
638 host1=host1,
639 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800640
641 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700642 testResult = main.intents.testHostIntent( main,
643 name="1HOP",
644 intentId=installResult,
645 onosNode=0,
646 host1=host1,
647 host2=host2,
648 sw1="s5",
649 sw2="s2",
650 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800651 else:
Devin Lim8619b552018-04-13 00:40:43 -0700652 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700653
654 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800655 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700656 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700657 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700658
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700659 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700660 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700661 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlan": "100" }
662 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800663 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700664 installResult = main.intents.installHostIntent( main,
665 name="VLAN1",
666 onosNode=0,
667 host1=host1,
668 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800669 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700670 testResult = main.intents.testHostIntent( main,
671 name="VLAN1",
672 intentId=installResult,
673 onosNode=0,
674 host1=host1,
675 host2=host2,
676 sw1="s5",
677 sw2="s2",
678 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800679 else:
Devin Lim8619b552018-04-13 00:40:43 -0700680 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700681
682 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800683 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700684 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700685 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700686
Jeremy Songsterff553672016-05-12 17:06:23 -0700687 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
688 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700689 host1 = { "name": "h5", "vlan": "200" }
690 host2 = { "name": "h12", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -0700691 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700692 installResult = main.intents.installHostIntent( main,
693 name="VLAN2",
694 onosNode=0,
695 host1=host1,
696 host2=host2 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700697
698 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700699 testResult = main.intents.testHostIntent( main,
700 name="VLAN2",
701 intentId=installResult,
702 onosNode=0,
703 host1=host1,
704 host2=host2,
705 sw1="s5",
706 sw2="s2",
707 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700708 else:
Devin Lim8619b552018-04-13 00:40:43 -0700709 main.intents.removeAllExistIntents( main )
Jeremy Songsterff553672016-05-12 17:06:23 -0700710
711 utilities.assert_equals( expect=main.TRUE,
712 actual=testResult,
713 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700714 onfail=main.assertReturnString )
Jeremy Songsterff553672016-05-12 17:06:23 -0700715
Jeremy Songsterc032f162016-08-04 17:14:49 -0700716 main.step( "Encapsulation: Add host intents between h1 and h9" )
717 main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700718 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
719 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -0700720 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700721 installResult = main.intents.installHostIntent( main,
722 name="ENCAPSULATION",
723 onosNode=0,
724 host1=host1,
725 host2=host2,
726 encap="VLAN" )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700727 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700728 testResult = main.intents.testHostIntent( main,
729 name="ENCAPSULATION",
730 intentId=installResult,
731 onosNode=0,
732 host1=host1,
733 host2=host2,
734 sw1="s5",
735 sw2="s2",
736 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700737 else:
Devin Lim8619b552018-04-13 00:40:43 -0700738 main.intents.removeAllExistIntents( main )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700739
740 utilities.assert_equals( expect=main.TRUE,
741 actual=testResult,
742 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700743 onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700744
Jon Hall78be4962017-05-23 14:53:53 -0700745 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -0700746 # main.step( "Encapsulation: Add host intents between h1 and h9" )
747 # main.assertReturnString = "Assertion Result for MPLS Encapsulated host intent\n"
748 # host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
749 # host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
750 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700751 # installResult = main.intents.installHostIntent( main,
752 # name="ENCAPSULATION",
753 # onosNode=0,
754 # host1=host1,
755 # host2=host2,
756 # encap="MPLS" )
alison52b25892016-09-19 10:53:48 -0700757 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700758 # testResult = main.intents.testHostIntent( main,
759 # name="ENCAPSULATION",
760 # intentId=installResult,
761 # onosNode=0,
762 # host1=host1,
763 # host2=host2,
764 # sw1="s5",
765 # sw2="s2",
766 # expectedLink=18 )
alison52b25892016-09-19 10:53:48 -0700767 # else:
Devin Lim142b5342017-07-20 15:22:39 -0700768 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -0700769 #
770 # utilities.assert_equals( expect=main.TRUE,
771 # actual=testResult,
772 # onpass=main.assertReturnString,
773 # onfail=main.assertReturnString )
774
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700775 main.step( "Confirm that ONOS leadership is unchanged" )
Devin Lim142b5342017-07-20 15:22:39 -0700776 intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jon Hall78be4962017-05-23 14:53:53 -0700777 testResult = main.intents.checkLeaderChange( intentLeadersOld,
778 intentLeadersNew )
acsmarse6b410f2015-07-17 14:39:34 -0700779
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800780 utilities.assert_equals( expect=main.TRUE,
781 actual=testResult,
782 onpass="ONOS Leaders Unchanged",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700783 onfail="ONOS Leader Mismatch" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800784
Jon Hall78be4962017-05-23 14:53:53 -0700785 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -0700786
kelvin-onlabb769f562015-07-15 17:05:10 -0700787 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700788 """
789 Add point intents between 2 hosts:
790 - Get device ids | ports
791 - Add point intents
792 - Check intents
793 - Verify flows
794 - Ping hosts
795 - Reroute
796 - Link down
797 - Verify flows
798 - Check topology
799 - Ping hosts
800 - Link up
801 - Verify flows
802 - Check topology
803 - Ping hosts
804 - Remove intents
805 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700806 if main.initialized == main.FALSE:
807 main.log.error( "Test components did not start correctly, skipping further tests" )
808 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700809 # Assert variables - These variable's name|format must be followed
810 # if you want to use the wrapper function
811 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700812 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700813 assert main.numSwitch
814 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700815 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700816 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700817 main.initialized = main.FALSE
818 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700819
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700820 main.testName = "Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700821 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700822 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700823 main.caseExplanation = "This test case will test point to point" +\
Devin Lim142b5342017-07-20 15:22:39 -0700824 " intents using " + str( main.Cluster.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700825 " node(s) cluster;\n" +\
826 "Different type of hosts will be tested in " +\
827 "each step such as IPV4, Dual stack, VLAN etc" +\
828 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -0700829 " OVS running in Mininet and compile intents" +\
830 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700831
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700832 # No option point intents
833 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700834 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800835 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700836 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800837 ]
838 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700839 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800840 ]
Jeremy42df2e72016-02-23 16:37:46 -0800841 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700842 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700843 main,
844 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800845 senders=senders,
846 recipients=recipients )
847
848 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700849 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800850 main,
851 intentId=installResult,
852 name="NOOPTION",
853 senders=senders,
854 recipients=recipients,
855 sw1="s5",
856 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700857 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800858 else:
Devin Lim8619b552018-04-13 00:40:43 -0700859 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700860
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700861 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800862 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700863 onpass=main.assertReturnString,
864 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700865
kelvin-onlabb769f562015-07-15 17:05:10 -0700866 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700867 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800868 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700869 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800870 ]
871 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700872 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800873 ]
Jeremy42df2e72016-02-23 16:37:46 -0800874 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700875 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700876 main,
877 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800878 senders=senders,
879 recipients=recipients,
880 ethType="IPV4" )
881
882 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700883 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800884 main,
885 intentId=installResult,
886 name="IPV4",
887 senders=senders,
888 recipients=recipients,
889 sw1="s5",
890 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700891 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800892 else:
Devin Lim8619b552018-04-13 00:40:43 -0700893 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700894
895 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800896 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700897 onpass=main.assertReturnString,
898 onfail=main.assertReturnString )
alisonda157272016-12-22 01:13:21 -0800899
kelvin-onlabb769f562015-07-15 17:05:10 -0700900 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700901 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800902 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700903 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800904 ]
905 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700906 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800907 ]
Jeremy42df2e72016-02-23 16:37:46 -0800908 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700909 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700910 main,
911 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800912 senders=senders,
913 recipients=recipients,
914 ethType="IPV4" )
915
916 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700917 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800918 main,
919 intentId=installResult,
920 name="IPV4_2",
921 senders=senders,
922 recipients=recipients,
923 sw1="s5",
924 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700925 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800926 else:
Devin Lim8619b552018-04-13 00:40:43 -0700927 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700928
929 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800930 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700931 onpass=main.assertReturnString,
932 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700933
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700934 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700935 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800936 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700937 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700938 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800939 ]
940 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700941 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700942 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800943 ]
Jeremy6f000c62016-02-25 17:02:28 -0800944 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700945 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800946 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
947 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -0800948 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700949 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800950 main,
951 name="SDNIP-ICMP",
952 senders=senders,
953 recipients=recipients,
954 ethType="IPV4",
955 ipProto=ipProto,
956 tcpSrc=tcpSrc,
957 tcpDst=tcpDst )
958
959 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700960 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800961 main,
962 intentId=installResult,
963 name="SDNIP_ICMP",
964 senders=senders,
965 recipients=recipients,
966 sw1="s5",
967 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -0700968 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700969 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -0800970 else:
Devin Lim8619b552018-04-13 00:40:43 -0700971 main.intents.removeAllExistIntents( main )
kelvin-onlabb769f562015-07-15 17:05:10 -0700972
973 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800974 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700975 onpass=main.assertReturnString,
976 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700977
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700978 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700979 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700980 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
981 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700982 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
983 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700984 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
985 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
986 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
987
Jon Hall78be4962017-05-23 14:53:53 -0700988 stepResult = main.intents.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700989 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700990 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700991 host1="h1",
992 host2="h9",
993 deviceId1="of:0000000000000005/1",
994 deviceId2="of:0000000000000006/1",
995 mac1=mac1,
996 mac2=mac2,
997 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700998 ipProto=ipProto,
999 ip1=ip1,
1000 ip2=ip2,
1001 tcp1=tcp1,
1002 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001003
1004 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001005 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001006 onpass=main.assertReturnString,
1007 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001008
acsmars5d8cc862015-09-25 09:44:50 -07001009 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1010 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001011 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001012 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001013 ]
1014 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001015 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001016 ]
Jeremy42df2e72016-02-23 16:37:46 -08001017 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001018 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001019 main,
1020 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001021 senders=senders,
1022 recipients=recipients,
1023 ethType="IPV4" )
1024
1025 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001026 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001027 main,
1028 intentId=installResult,
1029 name="DUALSTACK1",
1030 senders=senders,
1031 recipients=recipients,
1032 sw1="s5",
1033 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001034 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001035 else:
Devin Lim8619b552018-04-13 00:40:43 -07001036 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001037
1038 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001039 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001040 onpass=main.assertReturnString,
1041 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001042
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001043 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001044 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001045 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001046 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001047 ]
1048 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001049 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001050 ]
Jeremy42df2e72016-02-23 16:37:46 -08001051 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001052 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001053 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001054 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001055 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001056 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001057
1058 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001059 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001060 main,
1061 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001062 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001063 senders=senders,
1064 recipients=recipients,
1065 sw1="s5",
1066 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001067 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001068
1069 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001070 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001071 onpass=main.assertReturnString,
1072 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001073
Jeremy Songsterff553672016-05-12 17:06:23 -07001074 main.step( "VLAN: Add point intents between h5 and h21" )
1075 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1076 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001077 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001078 ]
1079 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001080 { "name": "h21", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001081 ]
1082 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001083 installResult = main.intents.installPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001084 main,
1085 name="VLAN2",
1086 senders=senders,
1087 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001088 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001089
1090 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001091 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001092 main,
1093 intentId=installResult,
1094 name="VLAN2",
1095 senders=senders,
1096 recipients=recipients,
1097 sw1="s5",
1098 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001099 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001100
1101 utilities.assert_equals( expect=main.TRUE,
1102 actual=testResult,
1103 onpass=main.assertReturnString,
1104 onfail=main.assertReturnString )
1105
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001106 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001107 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001108 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001109 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001110 ]
1111 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001112 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001113 ]
Jeremy42df2e72016-02-23 16:37:46 -08001114 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001115 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001116 main,
1117 name="1HOP IPV4",
1118 senders=senders,
1119 recipients=recipients,
1120 ethType="IPV4" )
1121
1122 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001123 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001124 main,
1125 intentId=installResult,
1126 name="1HOP IPV4",
1127 senders=senders,
1128 recipients=recipients,
1129 sw1="s5",
1130 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001131 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001132 else:
Devin Lim8619b552018-04-13 00:40:43 -07001133 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001134
1135 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001136 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001137 onpass=main.assertReturnString,
1138 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001139
Jeremy Songsterc032f162016-08-04 17:14:49 -07001140 main.step( "Add point to point intents using VLAN Encapsulation" )
1141 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1142 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001143 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001144 ]
1145 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001146 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001147 ]
1148 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001149 installResult = main.intents.installPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001150 main,
1151 name="ENCAPSULATION",
1152 senders=senders,
1153 recipients=recipients,
1154 encap="VLAN" )
1155
1156 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001157 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001158 main,
1159 intentId=installResult,
1160 name="ENCAPSULATION",
1161 senders=senders,
1162 recipients=recipients,
1163 sw1="s5",
1164 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001165 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001166 else:
Devin Lim8619b552018-04-13 00:40:43 -07001167 main.intents.removeAllExistIntents( main )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001168
1169 utilities.assert_equals( expect=main.TRUE,
1170 actual=testResult,
1171 onpass=main.assertReturnString,
1172 onfail=main.assertReturnString )
1173
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001174 main.step( "BANDWIDTH ALLOCATION: Checking bandwidth allocation for point intents between h1 and h9" )
1175 main.assertReturnString = "Assertion Result for BANDWIDTH ALLOCATION for point intent\n"
1176 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001177 { "name": "h1", "device": "of:0000000000000005/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001178 ]
1179 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001180 { "name": "h9", "device": "of:0000000000000006/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001181 ]
1182 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001183 installResult = main.intents.installPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001184 main,
1185 name="NOOPTION",
1186 senders=senders,
1187 recipients=recipients,
Jon Hallf539eb92017-05-22 17:18:42 -07001188 bandwidth=100 )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001189
1190 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001191 testResult = main.intents.testPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001192 main,
1193 intentId=installResult,
1194 name="NOOPTION",
1195 senders=senders,
1196 recipients=recipients,
1197 sw1="s5",
1198 sw2="s2",
1199 expectedLink=18 )
1200 else:
Devin Lim8619b552018-04-13 00:40:43 -07001201 main.intents.removeAllExistIntents( main )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001202
1203 utilities.assert_equals( expect=main.TRUE,
1204 actual=testResult,
1205 onpass=main.assertReturnString,
1206 onfail=main.assertReturnString )
1207
Jon Hall78be4962017-05-23 14:53:53 -07001208 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -07001209 # main.step( "Add point to point intents using MPLS Encapsulation" )
1210 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1211 # senders = [
1212 # { "name": "h1", "device": "of:0000000000000005/1" }
1213 # ]
1214 # recipients = [
1215 # { "name": "h9", "device": "of:0000000000000006/1" }
1216 # ]
1217 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001218 # installResult = main.intents.installPointIntent(
alison52b25892016-09-19 10:53:48 -07001219 # main,
1220 # name="ENCAPSULATION",
1221 # senders=senders,
1222 # recipients=recipients,
1223 # encap="MPLS" )
1224 #
1225 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001226 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001227 # main,
1228 # intentId=installResult,
1229 # name="ENCAPSULATION",
1230 # senders=senders,
1231 # recipients=recipients,
1232 # sw1="s5",
1233 # sw2="s2",
1234 # expectedLink=18 )
1235 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001236 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001237 #
1238 # utilities.assert_equals( expect=main.TRUE,
1239 # actual=testResult,
1240 # onpass=main.assertReturnString,
1241 # onfail=main.assertReturnString )
1242
Jon Hall78be4962017-05-23 14:53:53 -07001243 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001244
kelvin-onlabb769f562015-07-15 17:05:10 -07001245 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001246 """
1247 Add single point to multi point intents
1248 - Get device ids
1249 - Add single point to multi point intents
1250 - Check intents
1251 - Verify flows
1252 - Ping hosts
1253 - Reroute
1254 - Link down
1255 - Verify flows
1256 - Check topology
1257 - Ping hosts
1258 - Link up
1259 - Verify flows
1260 - Check topology
1261 - Ping hosts
1262 - Remove intents
1263 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001264 if main.initialized == main.FALSE:
1265 main.log.error( "Test components did not start correctly, skipping further tests" )
1266 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001267 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001268 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001269 assert main.numSwitch
1270 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001271 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001272 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001273 main.initialized = main.FALSE
1274 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001275
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001276 main.testName = "Single to Multi Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001277 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001278 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001279 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001280 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001281 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001282 "Different type of hosts will be tested in " +\
1283 "each step such as IPV4, Dual stack, VLAN etc" +\
1284 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001285 " OVS running in Mininet and compile intents" +\
1286 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001287
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001288 main.step( "NOOPTION: Install and test single point to multi point intents" )
1289 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1290 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001291 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001292 ]
1293 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001294 { "name": "h16", "device": "of:0000000000000006/8" },
1295 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001296 ]
Jon Hall9c888672017-05-15 18:03:54 -07001297 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1298 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001299 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001300 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001301 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001302 name="NOOPTION",
1303 senders=senders,
1304 recipients=recipients,
1305 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001306 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001307
1308 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001309 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001310 main,
1311 intentId=installResult,
1312 name="NOOPTION",
1313 senders=senders,
1314 recipients=recipients,
1315 badSenders=badSenders,
1316 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001317 sw1="s5",
1318 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001319 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001320 else:
Devin Lim8619b552018-04-13 00:40:43 -07001321 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001322
1323 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001324 actual=testResult,
1325 onpass=main.assertReturnString,
1326 onfail=main.assertReturnString )
1327
1328 main.step( "IPV4: Install and test single point to multi point intents" )
1329 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1330 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001331 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001332 ]
1333 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001334 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1335 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001336 ]
Jon Hall9c888672017-05-15 18:03:54 -07001337 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1338 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001339 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001340 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001341 main,
1342 name="IPV4",
1343 senders=senders,
1344 recipients=recipients,
1345 ethType="IPV4",
1346 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001347 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001348
1349 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001350 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001351 main,
1352 intentId=installResult,
1353 name="IPV4",
1354 senders=senders,
1355 recipients=recipients,
1356 badSenders=badSenders,
1357 badRecipients=badRecipients,
1358 sw1="s5",
1359 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001360 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001361 else:
Devin Lim8619b552018-04-13 00:40:43 -07001362 main.intents.removeAllExistIntents( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001363
1364 utilities.assert_equals( expect=main.TRUE,
1365 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001366 onpass=main.assertReturnString,
1367 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001368
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001369 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001370 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and no MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001371 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001372 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001373 ]
1374 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001375 { "name": "h16", "device": "of:0000000000000006/8" },
1376 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001377 ]
Jon Hall9c888672017-05-15 18:03:54 -07001378 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1379 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001380 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001381 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001382 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001383 name="IPV4_2",
1384 senders=senders,
1385 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001386 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001387 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001388 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001389
1390 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001391 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001392 main,
1393 intentId=installResult,
1394 name="IPV4_2",
1395 senders=senders,
1396 recipients=recipients,
1397 badSenders=badSenders,
1398 badRecipients=badRecipients,
1399 sw1="s5",
1400 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001401 expectedLink=18 )
Devin Lim8619b552018-04-13 00:40:43 -07001402 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001403
1404 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001405 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001406 onpass=main.assertReturnString,
1407 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001408
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001409 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001410 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses in the same VLAN\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001411 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001412 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001413 ]
1414 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001415 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1416 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001417 ]
Jon Hall9c888672017-05-15 18:03:54 -07001418 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1419 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001420 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001421 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001422 main,
alison52b25892016-09-19 10:53:48 -07001423 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001424 senders=senders,
1425 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001426 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001427 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001428
1429 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001430 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001431 main,
1432 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001433 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001434 senders=senders,
1435 recipients=recipients,
1436 badSenders=badSenders,
1437 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001438 sw1="s5",
1439 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001440 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001441 else:
Devin Lim8619b552018-04-13 00:40:43 -07001442 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001443
1444 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001445 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001446 onpass=main.assertReturnString,
1447 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001448
Jeremy Songsterff553672016-05-12 17:06:23 -07001449 main.step( "VLAN: Add single point to multi point intents" )
1450 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1451 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001452 { "name": "h5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001453 ]
1454 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001455 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1456 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001457 ]
Jon Hall9c888672017-05-15 18:03:54 -07001458 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1459 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001460 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001461 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001462 main,
1463 name="VLAN2",
1464 senders=senders,
1465 recipients=recipients,
1466 sw1="s5",
1467 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001468 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001469
1470 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001471 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001472 main,
1473 intentId=installResult,
1474 name="VLAN2",
1475 senders=senders,
1476 recipients=recipients,
1477 badSenders=badSenders,
1478 badRecipients=badRecipients,
1479 sw1="s5",
1480 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001481 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001482 else:
Devin Lim8619b552018-04-13 00:40:43 -07001483 main.intents.removeAllExistIntents( main )
Jeremy Songsterff553672016-05-12 17:06:23 -07001484
1485 utilities.assert_equals( expect=main.TRUE,
1486 actual=testResult,
1487 onpass=main.assertReturnString,
1488 onfail=main.assertReturnString )
1489
alison52b25892016-09-19 10:53:48 -07001490 # Does not support Single point to multi point encapsulation
1491 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1492 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1493 # senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001494 # { "name": "h8", "device": "of:0000000000000005/8" }
alison52b25892016-09-19 10:53:48 -07001495 # ]
1496 # recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001497 # { "name": "h16", "device": "of:0000000000000006/8" },
1498 # { "name": "h24", "device": "of:0000000000000007/8" }
alison52b25892016-09-19 10:53:48 -07001499 # ]
Jon Hall9c888672017-05-15 18:03:54 -07001500 # badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1501 # badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
alison52b25892016-09-19 10:53:48 -07001502 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001503 # installResult = main.intents.installSingleToMultiIntent(
alison52b25892016-09-19 10:53:48 -07001504 # main,
1505 # name="ENCAPSULATION",
1506 # senders=senders,
1507 # recipients=recipients,
1508 # sw1="s5",
1509 # sw2="s2",
1510 # encap="VLAN" )
1511 #
1512 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001513 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001514 # main,
1515 # intentId=installResult,
1516 # name="ENCAPSULATION",
1517 # senders=senders,
1518 # recipients=recipients,
1519 # badSenders=badSenders,
1520 # badRecipients=badRecipients,
1521 # sw1="s5",
1522 # sw2="s2",
1523 # expectedLink=18 )
1524 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001525 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001526 #
1527 # utilities.assert_equals( expect=main.TRUE,
1528 # actual=testResult,
1529 # onpass=main.assertReturnString,
1530 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001531
Jon Hall78be4962017-05-23 14:53:53 -07001532 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001533
kelvin-onlabb769f562015-07-15 17:05:10 -07001534 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001535 """
1536 Add multi point to single point intents
1537 - Get device ids
1538 - Add multi point to single point intents
1539 - Check intents
1540 - Verify flows
1541 - Ping hosts
1542 - Reroute
1543 - Link down
1544 - Verify flows
1545 - Check topology
1546 - Ping hosts
1547 - Link up
1548 - Verify flows
1549 - Check topology
1550 - Ping hosts
1551 - Remove intents
1552 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001553 if main.initialized == main.FALSE:
1554 main.log.error( "Test components did not start correctly, skipping further tests" )
1555 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001556 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001557 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001558 assert main.numSwitch
1559 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001560 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001561 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001562 main.initialized = main.FALSE
1563 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001564
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001565 main.testName = "Multi To Single Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001566 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001567 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001568 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001569 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001570 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001571 "Different type of hosts will be tested in " +\
1572 "each step such as IPV4, Dual stack, VLAN etc" +\
1573 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001574 " OVS running in Mininet and compile intents" +\
1575 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001576
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001577 main.step( "NOOPTION: Add multi point to single point intents" )
1578 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1579 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001580 { "name": "h16", "device": "of:0000000000000006/8" },
1581 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001582 ]
1583 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001584 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001585 ]
Jon Hall9c888672017-05-15 18:03:54 -07001586 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1587 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001588 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001589 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001590 main,
1591 name="NOOPTION",
1592 senders=senders,
1593 recipients=recipients,
1594 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001595 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001596
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001597 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001598 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001599 main,
1600 intentId=installResult,
1601 name="NOOPTION",
1602 senders=senders,
1603 recipients=recipients,
1604 badSenders=badSenders,
1605 badRecipients=badRecipients,
1606 sw1="s5",
1607 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001608 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001609 else:
Devin Lim8619b552018-04-13 00:40:43 -07001610 main.intents.removeAllExistIntents( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001611
1612 utilities.assert_equals( expect=main.TRUE,
1613 actual=testResult,
1614 onpass=main.assertReturnString,
1615 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001616
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001617 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001618 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001619 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001620 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1621 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001622 ]
1623 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001624 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001625 ]
Jon Hall9c888672017-05-15 18:03:54 -07001626 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1627 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001628 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001629 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001630 main,
1631 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001632 senders=senders,
1633 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001634 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001635 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001636 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001637
1638 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001639 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001640 main,
1641 intentId=installResult,
1642 name="IPV4",
1643 senders=senders,
1644 recipients=recipients,
1645 badSenders=badSenders,
1646 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001647 sw1="s5",
1648 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001649 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001650 else:
Devin Lim8619b552018-04-13 00:40:43 -07001651 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001652
1653 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001654 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001655 onpass=main.assertReturnString,
1656 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001657
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001658 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001659 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001660 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001661 { "name": "h16", "device": "of:0000000000000006/8" },
1662 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001663 ]
1664 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001665 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001666 ]
Jon Hall9c888672017-05-15 18:03:54 -07001667 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1668 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001669 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001670 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001671 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001672 name="IPV4_2",
1673 senders=senders,
1674 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001675 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001676 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001677 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001678
1679 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001680 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001681 main,
1682 intentId=installResult,
1683 name="IPV4_2",
1684 senders=senders,
1685 recipients=recipients,
1686 badSenders=badSenders,
1687 badRecipients=badRecipients,
1688 sw1="s5",
1689 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001690 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001691 else:
Devin Lim8619b552018-04-13 00:40:43 -07001692 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001693
1694 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001695 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001696 onpass=main.assertReturnString,
1697 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001698
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001699 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001700 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses in the same VLAN\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001701 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001702 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1703 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001704 ]
1705 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001706 { "name": "h5", "device": "of:0000000000000005/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001707 ]
Jon Hall9c888672017-05-15 18:03:54 -07001708 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1709 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001710 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001711 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001712 main,
1713 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001714 senders=senders,
1715 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001716 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001717 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001718
1719 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001720 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001721 main,
1722 intentId=installResult,
1723 name="VLAN",
1724 senders=senders,
1725 recipients=recipients,
1726 badSenders=badSenders,
1727 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001728 sw1="s5",
1729 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001730 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001731 else:
Devin Lim8619b552018-04-13 00:40:43 -07001732 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001733
1734 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001735 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001736 onpass=main.assertReturnString,
1737 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001738
Jeremy Songsterff553672016-05-12 17:06:23 -07001739 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1740 main.step( "VLAN: Add multi point to single point intents" )
1741 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1742 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001743 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1744 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001745 ]
1746 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001747 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001748 ]
Jon Hall9c888672017-05-15 18:03:54 -07001749 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1750 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001751 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001752 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001753 main,
1754 name="VLAN2",
1755 senders=senders,
1756 recipients=recipients,
1757 sw1="s5",
1758 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001759 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001760
1761 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001762 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001763 main,
1764 intentId=installResult,
1765 name="VLAN2",
1766 senders=senders,
1767 recipients=recipients,
1768 badSenders=badSenders,
1769 badRecipients=badRecipients,
1770 sw1="s5",
1771 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001772 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001773 else:
Devin Lim8619b552018-04-13 00:40:43 -07001774 main.intents.removeAllExistIntents( main )
Jeremy Songsterff553672016-05-12 17:06:23 -07001775
1776 utilities.assert_equals( expect=main.TRUE,
1777 actual=testResult,
1778 onpass=main.assertReturnString,
1779 onfail=main.assertReturnString )
1780
Jeremy Songsterc032f162016-08-04 17:14:49 -07001781 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1782 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
1783 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001784 { "name": "h16", "device": "of:0000000000000006/8" },
1785 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001786 ]
1787 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001788 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001789 ]
Jon Hall9c888672017-05-15 18:03:54 -07001790 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1791 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songsterc032f162016-08-04 17:14:49 -07001792 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001793 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001794 main,
1795 name="ENCAPSULATION",
1796 senders=senders,
1797 recipients=recipients,
1798 sw1="s5",
1799 sw2="s2",
1800 encap="VLAN" )
1801
1802 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001803 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001804 main,
1805 intentId=installResult,
1806 name="ENCAPSULATION",
1807 senders=senders,
1808 recipients=recipients,
1809 badSenders=badSenders,
1810 badRecipients=badRecipients,
1811 sw1="s5",
1812 sw2="s2",
1813 expectedLink=18 )
1814 else:
Devin Lim8619b552018-04-13 00:40:43 -07001815 main.intents.removeAllExistIntents( main )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001816
1817 utilities.assert_equals( expect=main.TRUE,
1818 actual=testResult,
1819 onpass=main.assertReturnString,
1820 onfail=main.assertReturnString )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001821 """
1822 Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
1823 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1824 main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
1825 senders = [
1826 { "name": "h16", "device": "of:0000000000000006/8" },
1827 { "name": "h24", "device": "of:0000000000000007/8" }
1828 ]
1829 recipients = [
1830 { "name": "h8", "device": "of:0000000000000005/8" }
1831 ]
1832 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1833 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
1834 testResult = main.FALSE
1835 installResult = main.intents.installMultiToSingleIntent(
1836 main,
1837 name="ENCAPSULATION",
1838 senders=senders,
1839 recipients=recipients,
1840 sw1="s5",
1841 sw2="s2",
1842 encap="MPLS" )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001843
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001844 if installResult:
1845 testResult = main.intents.testPointIntent(
1846 main,
1847 intentId=installResult,
1848 name="ENCAPSULATION",
1849 senders=senders,
1850 recipients=recipients,
1851 badSenders=badSenders,
1852 badRecipients=badRecipients,
1853 sw1="s5",
1854 sw2="s2",
1855 expectedLink=18 )
1856 else:
1857 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
1858
1859 utilities.assert_equals( expect=main.TRUE,
1860 actual=testResult,
1861 onpass=main.assertReturnString,
1862 onfail=main.assertReturnString )
1863 """
alison52b25892016-09-19 10:53:48 -07001864
Jon Hall78be4962017-05-23 14:53:53 -07001865 main.intents.report( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001866
acsmars1ff5e052015-07-23 11:27:48 -07001867 def CASE5000( self, main ):
1868 """
acsmars5d8cc862015-09-25 09:44:50 -07001869 Tests Host Mobility
1870 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001871 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001872 if main.initialized == main.FALSE:
1873 main.log.error( "Test components did not start correctly, skipping further tests" )
1874 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001875 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001876 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001877 assert main.numSwitch
1878 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001879 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001880 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001881 main.initialized = main.FALSE
1882 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001883 main.case( "Test host mobility with host intents " + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001884 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001885 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001886
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001887 main.log.info( "Moving h1 from s5 to s6" )
You Wanga0f6ff62018-01-11 15:46:30 -08001888 main.Network.moveHost( "h1", "s5", "s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001889
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001890 # Send discovery ping from moved host
1891 # Moving the host brings down the default interfaces and creates a new one.
1892 # Scapy is restarted on this host to detect the new interface
1893 main.h1.stopScapy()
1894 main.h1.startScapy()
1895
1896 # Discover new host location in ONOS and populate host data.
1897 # Host 1 IP and MAC should be unchanged
Jon Hall78be4962017-05-23 14:53:53 -07001898 main.intents.sendDiscoveryArp( main, [ main.h1 ] )
1899 main.intents.populateHostData( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001900
acsmars1ff5e052015-07-23 11:27:48 -07001901 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1902
1903 utilities.assert_equals( expect="of:0000000000000006",
1904 actual=h1PostMove,
1905 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001906 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001907 " to single point intents" +
1908 " with IPV4 type and MAC addresses" +
1909 " in the same VLAN" )
1910
1911 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001912 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall9c888672017-05-15 18:03:54 -07001913 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1914 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001915 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001916 installResult = main.intents.installHostIntent( main,
1917 name="IPV4 Mobility IPV4",
1918 onosNode=0,
1919 host1=host1,
1920 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001921 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001922 testResult = main.intents.testHostIntent( main,
1923 name="Host Mobility IPV4",
1924 intentId=installResult,
1925 onosNode=0,
1926 host1=host1,
1927 host2=host2,
1928 sw1="s6",
1929 sw2="s2",
1930 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001931 else:
Devin Lim8619b552018-04-13 00:40:43 -07001932 main.intents.removeAllExistIntents( main )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001933
1934 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001935 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001936 onpass=main.assertReturnString,
1937 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001938
Jon Hall78be4962017-05-23 14:53:53 -07001939 main.intents.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001940
1941 def CASE6000( self, main ):
1942 """
1943 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1944 """
Jeremy Songster9385d412016-06-02 17:57:36 -07001945 # At some later point discussion on this behavior in MPSP and SPMP intents
1946 # will be reoppened and this test case may need to be updated to reflect
1947 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07001948 if main.initialized == main.FALSE:
1949 main.log.error( "Test components did not start correctly, skipping further tests" )
1950 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001951 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001952 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001953 assert main.numSwitch
1954 except AssertionError:
alison52b25892016-09-19 10:53:48 -07001955 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001956 main.initialized = main.FALSE
1957 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001958 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001959 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07001960 main.step( "Installing Multi to Single Point intents with no options set" )
1961 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
1962 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08001963 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001964 { "name": "h16", "device": "of:0000000000000006/8" },
1965 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08001966 ]
1967 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001968 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08001969 ]
1970 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07001971 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08001972 ]
1973 isolatedRecipients = []
1974 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001975 installResult = main.intents.installMultiToSingleIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08001976 main,
1977 name="NOOPTION",
1978 senders=senders,
1979 recipients=recipients,
1980 sw1="s5",
1981 sw2="s2" )
1982
1983 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001984 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08001985 main,
1986 intentId=installResult,
1987 name="NOOPTION",
1988 senders=senders,
1989 recipients=recipients,
1990 isolatedSenders=isolatedSenders,
1991 isolatedRecipients=isolatedRecipients,
1992 sw1="s6",
1993 sw2="s2",
1994 sw3="s4",
1995 sw4="s1",
1996 sw5="s3",
1997 expectedLink1=16,
1998 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001999 else:
Devin Lim8619b552018-04-13 00:40:43 -07002000 main.intents.removeAllExistIntents( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002001
2002 utilities.assert_equals( expect=main.TRUE,
2003 actual=testResult,
2004 onpass=main.assertReturnString,
2005 onfail=main.assertReturnString )
2006
Jeremy Songster9385d412016-06-02 17:57:36 -07002007 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2008
2009 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2010 "with partial failures allowed\n"
2011 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002012 { "name": "h16", "device": "of:0000000000000006/8" },
2013 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002014 ]
2015 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002016 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002017 ]
2018 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07002019 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002020 ]
2021 isolatedRecipients = []
2022 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002023 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002024 main,
2025 name="NOOPTION",
2026 senders=senders,
2027 recipients=recipients,
2028 sw1="s5",
2029 sw2="s2",
2030 partial=True )
2031
2032 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002033 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002034 main,
2035 intentId=installResult,
2036 name="NOOPTION",
2037 senders=senders,
2038 recipients=recipients,
2039 isolatedSenders=isolatedSenders,
2040 isolatedRecipients=isolatedRecipients,
2041 sw1="s6",
2042 sw2="s2",
2043 sw3="s4",
2044 sw4="s1",
2045 sw5="s3",
2046 expectedLink1=16,
2047 expectedLink2=14,
2048 partial=True )
2049 else:
Devin Lim8619b552018-04-13 00:40:43 -07002050 main.intents.removeAllExistIntents( main )
Jeremy Songster9385d412016-06-02 17:57:36 -07002051
2052 utilities.assert_equals( expect=main.TRUE,
2053 actual=testResult,
2054 onpass=main.assertReturnString,
2055 onfail=main.assertReturnString )
2056
Jeremye0cb5eb2016-01-27 17:39:09 -08002057 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002058 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2059 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002060 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002061 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002062 ]
2063 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002064 { "name": "h16", "device": "of:0000000000000006/8" },
2065 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002066 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002067 isolatedSenders = []
2068 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002069 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002070 ]
2071 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002072 installResult = main.intents.installSingleToMultiIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08002073 main,
2074 name="NOOPTION",
2075 senders=senders,
2076 recipients=recipients,
2077 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002078 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002079
2080 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002081 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08002082 main,
2083 intentId=installResult,
2084 name="NOOPTION",
2085 senders=senders,
2086 recipients=recipients,
2087 isolatedSenders=isolatedSenders,
2088 isolatedRecipients=isolatedRecipients,
2089 sw1="s6",
2090 sw2="s2",
2091 sw3="s4",
2092 sw4="s1",
2093 sw5="s3",
2094 expectedLink1=16,
2095 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002096 else:
Devin Lim8619b552018-04-13 00:40:43 -07002097 main.intents.removeAllExistIntents( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002098
2099 utilities.assert_equals( expect=main.TRUE,
2100 actual=testResult,
2101 onpass=main.assertReturnString,
2102 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002103 # Right now this functionality doesn't work properly in SPMP intents
Jon Hall78be4962017-05-23 14:53:53 -07002104 main.step( "NOOPTION: Install and test single point to multi point " +
Jeremy Songster9385d412016-06-02 17:57:36 -07002105 "intents with partial failures allowed" )
2106 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2107 "point intent with partial failures allowed\n"
2108 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002109 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002110 ]
2111 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002112 { "name": "h16", "device": "of:0000000000000006/8" },
2113 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002114 ]
2115 isolatedSenders = []
2116 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002117 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002118 ]
2119 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002120 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002121 main,
2122 name="NOOPTION",
2123 senders=senders,
2124 recipients=recipients,
2125 sw1="s5",
2126 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002127 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002128
2129 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002130 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002131 main,
2132 intentId=installResult,
2133 name="NOOPTION",
2134 senders=senders,
2135 recipients=recipients,
2136 isolatedSenders=isolatedSenders,
2137 isolatedRecipients=isolatedRecipients,
2138 sw1="s6",
2139 sw2="s2",
2140 sw3="s4",
2141 sw4="s1",
2142 sw5="s3",
2143 expectedLink1=16,
2144 expectedLink2=14,
2145 partial=True )
2146 else:
Devin Lim8619b552018-04-13 00:40:43 -07002147 main.intents.removeAllExistIntents( main )
Jeremy Songster9385d412016-06-02 17:57:36 -07002148
2149 utilities.assert_equals( expect=main.TRUE,
2150 actual=testResult,
2151 onpass=main.assertReturnString,
2152 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002153
Jon Hall78be4962017-05-23 14:53:53 -07002154 main.intents.report( main )