blob: daa17cbabaaa0b2b99420ebc4f9edf7ce9913654 [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 Lim142b5342017-07-20 15:22:39 -0700567 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
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 Lim142b5342017-07-20 15:22:39 -0700623 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
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 Lim142b5342017-07-20 15:22:39 -0700652 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
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 Lim142b5342017-07-20 15:22:39 -0700680 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
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 Lim142b5342017-07-20 15:22:39 -0700709 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
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 Lim142b5342017-07-20 15:22:39 -0700738 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
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 Lim142b5342017-07-20 15:22:39 -0700859 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
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 Lim142b5342017-07-20 15:22:39 -0700893 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
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
Jon Hall78be4962017-05-23 14:53:53 -0700900 main.step( "Protected: Add point intents between h1 and h9" )
alisonda157272016-12-22 01:13:21 -0800901 main.assertReturnString = "Assertion Result for protected point intent\n"
902 senders = [
Jon Hall78be4962017-05-23 14:53:53 -0700903 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
alisonda157272016-12-22 01:13:21 -0800904 ]
905 recipients = [
Jon Hall78be4962017-05-23 14:53:53 -0700906 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
alisonda157272016-12-22 01:13:21 -0800907 ]
908 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700909 installResult = main.intents.installPointIntent(
alisonda157272016-12-22 01:13:21 -0800910 main,
911 name="Protected",
912 senders=senders,
913 recipients=recipients,
914 protected=True )
915
916 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700917 testResult = main.intents.testPointIntent(
alisonda157272016-12-22 01:13:21 -0800918 main,
919 name="Protected",
920 intentId=installResult,
921 senders=senders,
922 recipients=recipients,
923 sw1="s5",
924 sw2="s2",
925 protected=True,
926 expectedLink=18 )
927 else:
Devin Lim142b5342017-07-20 15:22:39 -0700928 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alisonda157272016-12-22 01:13:21 -0800929
930 utilities.assert_equals( expect=main.TRUE,
931 actual=testResult,
932 onpass=main.assertReturnString,
933 onfail=main.assertReturnString )
934
kelvin-onlabb769f562015-07-15 17:05:10 -0700935 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700936 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800937 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700938 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800939 ]
940 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700941 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800942 ]
Jeremy42df2e72016-02-23 16:37:46 -0800943 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700944 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700945 main,
946 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800947 senders=senders,
948 recipients=recipients,
949 ethType="IPV4" )
950
951 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700952 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800953 main,
954 intentId=installResult,
955 name="IPV4_2",
956 senders=senders,
957 recipients=recipients,
958 sw1="s5",
959 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700960 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800961 else:
Devin Lim142b5342017-07-20 15:22:39 -0700962 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700963
964 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800965 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700966 onpass=main.assertReturnString,
967 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700968
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700969 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700970 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800971 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700972 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700973 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800974 ]
975 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700976 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700977 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800978 ]
Jeremy6f000c62016-02-25 17:02:28 -0800979 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700980 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800981 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
982 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -0800983 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700984 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800985 main,
986 name="SDNIP-ICMP",
987 senders=senders,
988 recipients=recipients,
989 ethType="IPV4",
990 ipProto=ipProto,
991 tcpSrc=tcpSrc,
992 tcpDst=tcpDst )
993
994 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700995 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800996 main,
997 intentId=installResult,
998 name="SDNIP_ICMP",
999 senders=senders,
1000 recipients=recipients,
1001 sw1="s5",
1002 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001003 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001004 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -08001005 else:
Devin Lim142b5342017-07-20 15:22:39 -07001006 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001007
1008 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001009 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001010 onpass=main.assertReturnString,
1011 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001012
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001013 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001014 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001015 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1016 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001017 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1018 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001019 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1020 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1021 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1022
Jon Hall78be4962017-05-23 14:53:53 -07001023 stepResult = main.intents.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001024 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001025 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001026 host1="h1",
1027 host2="h9",
1028 deviceId1="of:0000000000000005/1",
1029 deviceId2="of:0000000000000006/1",
1030 mac1=mac1,
1031 mac2=mac2,
1032 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001033 ipProto=ipProto,
1034 ip1=ip1,
1035 ip2=ip2,
1036 tcp1=tcp1,
1037 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001038
1039 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001040 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001041 onpass=main.assertReturnString,
1042 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001043
acsmars5d8cc862015-09-25 09:44:50 -07001044 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1045 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001046 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001047 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001048 ]
1049 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001050 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001051 ]
Jeremy42df2e72016-02-23 16:37:46 -08001052 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001053 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001054 main,
1055 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001056 senders=senders,
1057 recipients=recipients,
1058 ethType="IPV4" )
1059
1060 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001061 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001062 main,
1063 intentId=installResult,
1064 name="DUALSTACK1",
1065 senders=senders,
1066 recipients=recipients,
1067 sw1="s5",
1068 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001069 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001070 else:
Devin Lim142b5342017-07-20 15:22:39 -07001071 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001072
1073 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001074 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001075 onpass=main.assertReturnString,
1076 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001077
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001078 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001079 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001080 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001081 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001082 ]
1083 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001084 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001085 ]
Jeremy42df2e72016-02-23 16:37:46 -08001086 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001087 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001088 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001089 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001090 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001091 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001092
1093 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001094 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001095 main,
1096 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001097 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001098 senders=senders,
1099 recipients=recipients,
1100 sw1="s5",
1101 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001102 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001103
1104 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001105 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001106 onpass=main.assertReturnString,
1107 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001108
Jeremy Songsterff553672016-05-12 17:06:23 -07001109 main.step( "VLAN: Add point intents between h5 and h21" )
1110 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1111 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001112 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001113 ]
1114 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001115 { "name": "h21", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001116 ]
1117 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001118 installResult = main.intents.installPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001119 main,
1120 name="VLAN2",
1121 senders=senders,
1122 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001123 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001124
1125 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001126 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001127 main,
1128 intentId=installResult,
1129 name="VLAN2",
1130 senders=senders,
1131 recipients=recipients,
1132 sw1="s5",
1133 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001134 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001135
1136 utilities.assert_equals( expect=main.TRUE,
1137 actual=testResult,
1138 onpass=main.assertReturnString,
1139 onfail=main.assertReturnString )
1140
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001141 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001142 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001143 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001144 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001145 ]
1146 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001147 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001148 ]
Jeremy42df2e72016-02-23 16:37:46 -08001149 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001150 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001151 main,
1152 name="1HOP IPV4",
1153 senders=senders,
1154 recipients=recipients,
1155 ethType="IPV4" )
1156
1157 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001158 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001159 main,
1160 intentId=installResult,
1161 name="1HOP IPV4",
1162 senders=senders,
1163 recipients=recipients,
1164 sw1="s5",
1165 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001166 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001167 else:
Devin Lim142b5342017-07-20 15:22:39 -07001168 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001169
1170 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001171 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001172 onpass=main.assertReturnString,
1173 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001174
Jeremy Songsterc032f162016-08-04 17:14:49 -07001175 main.step( "Add point to point intents using VLAN Encapsulation" )
1176 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1177 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001178 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001179 ]
1180 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001181 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001182 ]
1183 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001184 installResult = main.intents.installPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001185 main,
1186 name="ENCAPSULATION",
1187 senders=senders,
1188 recipients=recipients,
1189 encap="VLAN" )
1190
1191 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001192 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001193 main,
1194 intentId=installResult,
1195 name="ENCAPSULATION",
1196 senders=senders,
1197 recipients=recipients,
1198 sw1="s5",
1199 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001200 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001201 else:
Devin Lim142b5342017-07-20 15:22:39 -07001202 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001203
1204 utilities.assert_equals( expect=main.TRUE,
1205 actual=testResult,
1206 onpass=main.assertReturnString,
1207 onfail=main.assertReturnString )
1208
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001209 main.step( "BANDWIDTH ALLOCATION: Checking bandwidth allocation for point intents between h1 and h9" )
1210 main.assertReturnString = "Assertion Result for BANDWIDTH ALLOCATION for point intent\n"
1211 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001212 { "name": "h1", "device": "of:0000000000000005/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001213 ]
1214 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001215 { "name": "h9", "device": "of:0000000000000006/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001216 ]
1217 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001218 installResult = main.intents.installPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001219 main,
1220 name="NOOPTION",
1221 senders=senders,
1222 recipients=recipients,
Jon Hallf539eb92017-05-22 17:18:42 -07001223 bandwidth=100 )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001224
1225 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001226 testResult = main.intents.testPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001227 main,
1228 intentId=installResult,
1229 name="NOOPTION",
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 )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -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 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -07001244 # main.step( "Add point to point intents using MPLS Encapsulation" )
1245 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1246 # senders = [
1247 # { "name": "h1", "device": "of:0000000000000005/1" }
1248 # ]
1249 # recipients = [
1250 # { "name": "h9", "device": "of:0000000000000006/1" }
1251 # ]
1252 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001253 # installResult = main.intents.installPointIntent(
alison52b25892016-09-19 10:53:48 -07001254 # main,
1255 # name="ENCAPSULATION",
1256 # senders=senders,
1257 # recipients=recipients,
1258 # encap="MPLS" )
1259 #
1260 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001261 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001262 # main,
1263 # intentId=installResult,
1264 # name="ENCAPSULATION",
1265 # senders=senders,
1266 # recipients=recipients,
1267 # sw1="s5",
1268 # sw2="s2",
1269 # expectedLink=18 )
1270 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001271 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001272 #
1273 # utilities.assert_equals( expect=main.TRUE,
1274 # actual=testResult,
1275 # onpass=main.assertReturnString,
1276 # onfail=main.assertReturnString )
1277
Jon Hall78be4962017-05-23 14:53:53 -07001278 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001279
kelvin-onlabb769f562015-07-15 17:05:10 -07001280 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001281 """
1282 Add single point to multi point intents
1283 - Get device ids
1284 - Add single point to multi point intents
1285 - Check intents
1286 - Verify flows
1287 - Ping hosts
1288 - Reroute
1289 - Link down
1290 - Verify flows
1291 - Check topology
1292 - Ping hosts
1293 - Link up
1294 - Verify flows
1295 - Check topology
1296 - Ping hosts
1297 - Remove intents
1298 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001299 if main.initialized == main.FALSE:
1300 main.log.error( "Test components did not start correctly, skipping further tests" )
1301 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001302 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001303 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001304 assert main.numSwitch
1305 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001306 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001307 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001308 main.initialized = main.FALSE
1309 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001310
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001311 main.testName = "Single to Multi Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001312 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001313 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001314 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001315 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001316 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001317 "Different type of hosts will be tested in " +\
1318 "each step such as IPV4, Dual stack, VLAN etc" +\
1319 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001320 " OVS running in Mininet and compile intents" +\
1321 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001322
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001323 main.step( "NOOPTION: Install and test single point to multi point intents" )
1324 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1325 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001326 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001327 ]
1328 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001329 { "name": "h16", "device": "of:0000000000000006/8" },
1330 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001331 ]
Jon Hall9c888672017-05-15 18:03:54 -07001332 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1333 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001334 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001335 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001336 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001337 name="NOOPTION",
1338 senders=senders,
1339 recipients=recipients,
1340 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001341 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001342
1343 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001344 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001345 main,
1346 intentId=installResult,
1347 name="NOOPTION",
1348 senders=senders,
1349 recipients=recipients,
1350 badSenders=badSenders,
1351 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001352 sw1="s5",
1353 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001354 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001355 else:
Devin Lim142b5342017-07-20 15:22:39 -07001356 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001357
1358 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001359 actual=testResult,
1360 onpass=main.assertReturnString,
1361 onfail=main.assertReturnString )
1362
1363 main.step( "IPV4: Install and test single point to multi point intents" )
1364 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1365 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001366 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001367 ]
1368 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001369 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1370 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001371 ]
Jon Hall9c888672017-05-15 18:03:54 -07001372 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1373 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001374 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001375 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001376 main,
1377 name="IPV4",
1378 senders=senders,
1379 recipients=recipients,
1380 ethType="IPV4",
1381 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001382 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001383
1384 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001385 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001386 main,
1387 intentId=installResult,
1388 name="IPV4",
1389 senders=senders,
1390 recipients=recipients,
1391 badSenders=badSenders,
1392 badRecipients=badRecipients,
1393 sw1="s5",
1394 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001395 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001396 else:
Devin Lim142b5342017-07-20 15:22:39 -07001397 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001398
1399 utilities.assert_equals( expect=main.TRUE,
1400 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001401 onpass=main.assertReturnString,
1402 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001403
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001404 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001405 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 -08001406 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001407 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001408 ]
1409 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001410 { "name": "h16", "device": "of:0000000000000006/8" },
1411 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001412 ]
Jon Hall9c888672017-05-15 18:03:54 -07001413 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1414 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001415 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001416 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001417 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001418 name="IPV4_2",
1419 senders=senders,
1420 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001421 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001422 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001423 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001424
1425 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001426 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001427 main,
1428 intentId=installResult,
1429 name="IPV4_2",
1430 senders=senders,
1431 recipients=recipients,
1432 badSenders=badSenders,
1433 badRecipients=badRecipients,
1434 sw1="s5",
1435 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001436 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001437 else:
Devin Lim142b5342017-07-20 15:22:39 -07001438 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001439
1440 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001441 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001442 onpass=main.assertReturnString,
1443 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001444
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001445 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001446 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 -08001447 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001448 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001449 ]
1450 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001451 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1452 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001453 ]
Jon Hall9c888672017-05-15 18:03:54 -07001454 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1455 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001456 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001457 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001458 main,
alison52b25892016-09-19 10:53:48 -07001459 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001460 senders=senders,
1461 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001462 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001463 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001464
1465 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001466 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001467 main,
1468 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001469 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001470 senders=senders,
1471 recipients=recipients,
1472 badSenders=badSenders,
1473 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001474 sw1="s5",
1475 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001476 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001477 else:
Devin Lim142b5342017-07-20 15:22:39 -07001478 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001479
1480 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001481 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001482 onpass=main.assertReturnString,
1483 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001484
Jeremy Songsterff553672016-05-12 17:06:23 -07001485 main.step( "VLAN: Add single point to multi point intents" )
1486 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1487 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001488 { "name": "h5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001489 ]
1490 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001491 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1492 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001493 ]
Jon Hall9c888672017-05-15 18:03:54 -07001494 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1495 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001496 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001497 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001498 main,
1499 name="VLAN2",
1500 senders=senders,
1501 recipients=recipients,
1502 sw1="s5",
1503 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001504 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001505
1506 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001507 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001508 main,
1509 intentId=installResult,
1510 name="VLAN2",
1511 senders=senders,
1512 recipients=recipients,
1513 badSenders=badSenders,
1514 badRecipients=badRecipients,
1515 sw1="s5",
1516 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001517 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001518 else:
Devin Lim142b5342017-07-20 15:22:39 -07001519 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -07001520
1521 utilities.assert_equals( expect=main.TRUE,
1522 actual=testResult,
1523 onpass=main.assertReturnString,
1524 onfail=main.assertReturnString )
1525
alison52b25892016-09-19 10:53:48 -07001526 # Does not support Single point to multi point encapsulation
1527 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1528 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1529 # senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001530 # { "name": "h8", "device": "of:0000000000000005/8" }
alison52b25892016-09-19 10:53:48 -07001531 # ]
1532 # recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001533 # { "name": "h16", "device": "of:0000000000000006/8" },
1534 # { "name": "h24", "device": "of:0000000000000007/8" }
alison52b25892016-09-19 10:53:48 -07001535 # ]
Jon Hall9c888672017-05-15 18:03:54 -07001536 # badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1537 # badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
alison52b25892016-09-19 10:53:48 -07001538 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001539 # installResult = main.intents.installSingleToMultiIntent(
alison52b25892016-09-19 10:53:48 -07001540 # main,
1541 # name="ENCAPSULATION",
1542 # senders=senders,
1543 # recipients=recipients,
1544 # sw1="s5",
1545 # sw2="s2",
1546 # encap="VLAN" )
1547 #
1548 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001549 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001550 # main,
1551 # intentId=installResult,
1552 # name="ENCAPSULATION",
1553 # senders=senders,
1554 # recipients=recipients,
1555 # badSenders=badSenders,
1556 # badRecipients=badRecipients,
1557 # sw1="s5",
1558 # sw2="s2",
1559 # expectedLink=18 )
1560 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001561 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001562 #
1563 # utilities.assert_equals( expect=main.TRUE,
1564 # actual=testResult,
1565 # onpass=main.assertReturnString,
1566 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001567
Jon Hall78be4962017-05-23 14:53:53 -07001568 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001569
kelvin-onlabb769f562015-07-15 17:05:10 -07001570 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001571 """
1572 Add multi point to single point intents
1573 - Get device ids
1574 - Add multi point to single point intents
1575 - Check intents
1576 - Verify flows
1577 - Ping hosts
1578 - Reroute
1579 - Link down
1580 - Verify flows
1581 - Check topology
1582 - Ping hosts
1583 - Link up
1584 - Verify flows
1585 - Check topology
1586 - Ping hosts
1587 - Remove intents
1588 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001589 if main.initialized == main.FALSE:
1590 main.log.error( "Test components did not start correctly, skipping further tests" )
1591 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001592 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001593 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001594 assert main.numSwitch
1595 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001596 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001597 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001598 main.initialized = main.FALSE
1599 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001600
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001601 main.testName = "Multi To Single Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001602 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001603 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001604 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001605 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001606 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001607 "Different type of hosts will be tested in " +\
1608 "each step such as IPV4, Dual stack, VLAN etc" +\
1609 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001610 " OVS running in Mininet and compile intents" +\
1611 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001612
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001613 main.step( "NOOPTION: Add multi point to single point intents" )
1614 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1615 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001616 { "name": "h16", "device": "of:0000000000000006/8" },
1617 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001618 ]
1619 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001620 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001621 ]
Jon Hall9c888672017-05-15 18:03:54 -07001622 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1623 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001624 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001625 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001626 main,
1627 name="NOOPTION",
1628 senders=senders,
1629 recipients=recipients,
1630 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001631 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001632
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001633 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001634 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001635 main,
1636 intentId=installResult,
1637 name="NOOPTION",
1638 senders=senders,
1639 recipients=recipients,
1640 badSenders=badSenders,
1641 badRecipients=badRecipients,
1642 sw1="s5",
1643 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001644 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001645 else:
Devin Lim142b5342017-07-20 15:22:39 -07001646 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001647
1648 utilities.assert_equals( expect=main.TRUE,
1649 actual=testResult,
1650 onpass=main.assertReturnString,
1651 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001652
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001653 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001654 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 -08001655 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001656 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1657 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001658 ]
1659 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001660 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001661 ]
Jon Hall9c888672017-05-15 18:03:54 -07001662 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1663 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001664 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001665 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001666 main,
1667 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001668 senders=senders,
1669 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001670 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001671 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001672 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001673
1674 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001675 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001676 main,
1677 intentId=installResult,
1678 name="IPV4",
1679 senders=senders,
1680 recipients=recipients,
1681 badSenders=badSenders,
1682 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001683 sw1="s5",
1684 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001685 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001686 else:
Devin Lim142b5342017-07-20 15:22:39 -07001687 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001688
1689 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001690 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001691 onpass=main.assertReturnString,
1692 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001693
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001694 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001695 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 -08001696 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001697 { "name": "h16", "device": "of:0000000000000006/8" },
1698 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001699 ]
1700 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001701 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001702 ]
Jon Hall9c888672017-05-15 18:03:54 -07001703 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1704 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001705 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001706 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001707 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001708 name="IPV4_2",
1709 senders=senders,
1710 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001711 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001712 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001713 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001714
1715 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001716 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001717 main,
1718 intentId=installResult,
1719 name="IPV4_2",
1720 senders=senders,
1721 recipients=recipients,
1722 badSenders=badSenders,
1723 badRecipients=badRecipients,
1724 sw1="s5",
1725 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001726 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001727 else:
Devin Lim142b5342017-07-20 15:22:39 -07001728 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001729
1730 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001731 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001732 onpass=main.assertReturnString,
1733 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001734
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001735 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001736 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 -08001737 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001738 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1739 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001740 ]
1741 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001742 { "name": "h5", "device": "of:0000000000000005/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001743 ]
Jon Hall9c888672017-05-15 18:03:54 -07001744 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1745 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001746 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001747 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001748 main,
1749 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001750 senders=senders,
1751 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001752 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001753 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001754
1755 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001756 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001757 main,
1758 intentId=installResult,
1759 name="VLAN",
1760 senders=senders,
1761 recipients=recipients,
1762 badSenders=badSenders,
1763 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001764 sw1="s5",
1765 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001766 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001767 else:
Devin Lim142b5342017-07-20 15:22:39 -07001768 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001769
1770 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001771 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001772 onpass=main.assertReturnString,
1773 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001774
Jeremy Songsterff553672016-05-12 17:06:23 -07001775 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1776 main.step( "VLAN: Add multi point to single point intents" )
1777 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1778 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001779 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1780 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001781 ]
1782 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001783 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001784 ]
Jon Hall9c888672017-05-15 18:03:54 -07001785 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1786 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001787 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001788 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001789 main,
1790 name="VLAN2",
1791 senders=senders,
1792 recipients=recipients,
1793 sw1="s5",
1794 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001795 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001796
1797 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001798 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001799 main,
1800 intentId=installResult,
1801 name="VLAN2",
1802 senders=senders,
1803 recipients=recipients,
1804 badSenders=badSenders,
1805 badRecipients=badRecipients,
1806 sw1="s5",
1807 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001808 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001809 else:
Devin Lim142b5342017-07-20 15:22:39 -07001810 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -07001811
1812 utilities.assert_equals( expect=main.TRUE,
1813 actual=testResult,
1814 onpass=main.assertReturnString,
1815 onfail=main.assertReturnString )
1816
Jeremy Songsterc032f162016-08-04 17:14:49 -07001817 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1818 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
1819 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001820 { "name": "h16", "device": "of:0000000000000006/8" },
1821 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001822 ]
1823 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001824 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001825 ]
Jon Hall9c888672017-05-15 18:03:54 -07001826 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1827 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songsterc032f162016-08-04 17:14:49 -07001828 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001829 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001830 main,
1831 name="ENCAPSULATION",
1832 senders=senders,
1833 recipients=recipients,
1834 sw1="s5",
1835 sw2="s2",
1836 encap="VLAN" )
1837
1838 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001839 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001840 main,
1841 intentId=installResult,
1842 name="ENCAPSULATION",
1843 senders=senders,
1844 recipients=recipients,
1845 badSenders=badSenders,
1846 badRecipients=badRecipients,
1847 sw1="s5",
1848 sw2="s2",
1849 expectedLink=18 )
1850 else:
Devin Lim142b5342017-07-20 15:22:39 -07001851 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001852
1853 utilities.assert_equals( expect=main.TRUE,
1854 actual=testResult,
1855 onpass=main.assertReturnString,
1856 onfail=main.assertReturnString )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001857 """
1858 Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
1859 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1860 main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
1861 senders = [
1862 { "name": "h16", "device": "of:0000000000000006/8" },
1863 { "name": "h24", "device": "of:0000000000000007/8" }
1864 ]
1865 recipients = [
1866 { "name": "h8", "device": "of:0000000000000005/8" }
1867 ]
1868 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1869 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
1870 testResult = main.FALSE
1871 installResult = main.intents.installMultiToSingleIntent(
1872 main,
1873 name="ENCAPSULATION",
1874 senders=senders,
1875 recipients=recipients,
1876 sw1="s5",
1877 sw2="s2",
1878 encap="MPLS" )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001879
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001880 if installResult:
1881 testResult = main.intents.testPointIntent(
1882 main,
1883 intentId=installResult,
1884 name="ENCAPSULATION",
1885 senders=senders,
1886 recipients=recipients,
1887 badSenders=badSenders,
1888 badRecipients=badRecipients,
1889 sw1="s5",
1890 sw2="s2",
1891 expectedLink=18 )
1892 else:
1893 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
1894
1895 utilities.assert_equals( expect=main.TRUE,
1896 actual=testResult,
1897 onpass=main.assertReturnString,
1898 onfail=main.assertReturnString )
1899 """
alison52b25892016-09-19 10:53:48 -07001900
Jon Hall78be4962017-05-23 14:53:53 -07001901 main.intents.report( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001902
acsmars1ff5e052015-07-23 11:27:48 -07001903 def CASE5000( self, main ):
1904 """
acsmars5d8cc862015-09-25 09:44:50 -07001905 Tests Host Mobility
1906 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001907 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001908 if main.initialized == main.FALSE:
1909 main.log.error( "Test components did not start correctly, skipping further tests" )
1910 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001911 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001912 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001913 assert main.numSwitch
1914 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001915 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001916 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001917 main.initialized = main.FALSE
1918 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001919 main.case( "Test host mobility with host intents " + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001920 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001921 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001922
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001923 main.log.info( "Moving h1 from s5 to s6" )
You Wanga0f6ff62018-01-11 15:46:30 -08001924 main.Network.moveHost( "h1", "s5", "s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001925
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001926 # Send discovery ping from moved host
1927 # Moving the host brings down the default interfaces and creates a new one.
1928 # Scapy is restarted on this host to detect the new interface
1929 main.h1.stopScapy()
1930 main.h1.startScapy()
1931
1932 # Discover new host location in ONOS and populate host data.
1933 # Host 1 IP and MAC should be unchanged
Jon Hall78be4962017-05-23 14:53:53 -07001934 main.intents.sendDiscoveryArp( main, [ main.h1 ] )
1935 main.intents.populateHostData( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001936
acsmars1ff5e052015-07-23 11:27:48 -07001937 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1938
1939 utilities.assert_equals( expect="of:0000000000000006",
1940 actual=h1PostMove,
1941 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001942 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001943 " to single point intents" +
1944 " with IPV4 type and MAC addresses" +
1945 " in the same VLAN" )
1946
1947 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001948 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall9c888672017-05-15 18:03:54 -07001949 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1950 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001951 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001952 installResult = main.intents.installHostIntent( main,
1953 name="IPV4 Mobility IPV4",
1954 onosNode=0,
1955 host1=host1,
1956 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001957 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001958 testResult = main.intents.testHostIntent( main,
1959 name="Host Mobility IPV4",
1960 intentId=installResult,
1961 onosNode=0,
1962 host1=host1,
1963 host2=host2,
1964 sw1="s6",
1965 sw2="s2",
1966 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001967 else:
Devin Lim142b5342017-07-20 15:22:39 -07001968 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001969
1970 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001971 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001972 onpass=main.assertReturnString,
1973 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001974
Jon Hall78be4962017-05-23 14:53:53 -07001975 main.intents.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001976
1977 def CASE6000( self, main ):
1978 """
1979 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1980 """
Jeremy Songster9385d412016-06-02 17:57:36 -07001981 # At some later point discussion on this behavior in MPSP and SPMP intents
1982 # will be reoppened and this test case may need to be updated to reflect
1983 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07001984 if main.initialized == main.FALSE:
1985 main.log.error( "Test components did not start correctly, skipping further tests" )
1986 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001987 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001988 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001989 assert main.numSwitch
1990 except AssertionError:
alison52b25892016-09-19 10:53:48 -07001991 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001992 main.initialized = main.FALSE
1993 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001994 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001995 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07001996 main.step( "Installing Multi to Single Point intents with no options set" )
1997 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
1998 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08001999 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002000 { "name": "h16", "device": "of:0000000000000006/8" },
2001 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002002 ]
2003 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002004 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002005 ]
2006 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07002007 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002008 ]
2009 isolatedRecipients = []
2010 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002011 installResult = main.intents.installMultiToSingleIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08002012 main,
2013 name="NOOPTION",
2014 senders=senders,
2015 recipients=recipients,
2016 sw1="s5",
2017 sw2="s2" )
2018
2019 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002020 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08002021 main,
2022 intentId=installResult,
2023 name="NOOPTION",
2024 senders=senders,
2025 recipients=recipients,
2026 isolatedSenders=isolatedSenders,
2027 isolatedRecipients=isolatedRecipients,
2028 sw1="s6",
2029 sw2="s2",
2030 sw3="s4",
2031 sw4="s1",
2032 sw5="s3",
2033 expectedLink1=16,
2034 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002035 else:
Devin Lim142b5342017-07-20 15:22:39 -07002036 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002037
2038 utilities.assert_equals( expect=main.TRUE,
2039 actual=testResult,
2040 onpass=main.assertReturnString,
2041 onfail=main.assertReturnString )
2042
Jeremy Songster9385d412016-06-02 17:57:36 -07002043 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2044
2045 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2046 "with partial failures allowed\n"
2047 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002048 { "name": "h16", "device": "of:0000000000000006/8" },
2049 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002050 ]
2051 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002052 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002053 ]
2054 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07002055 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002056 ]
2057 isolatedRecipients = []
2058 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002059 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002060 main,
2061 name="NOOPTION",
2062 senders=senders,
2063 recipients=recipients,
2064 sw1="s5",
2065 sw2="s2",
2066 partial=True )
2067
2068 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002069 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002070 main,
2071 intentId=installResult,
2072 name="NOOPTION",
2073 senders=senders,
2074 recipients=recipients,
2075 isolatedSenders=isolatedSenders,
2076 isolatedRecipients=isolatedRecipients,
2077 sw1="s6",
2078 sw2="s2",
2079 sw3="s4",
2080 sw4="s1",
2081 sw5="s3",
2082 expectedLink1=16,
2083 expectedLink2=14,
2084 partial=True )
2085 else:
Devin Lim142b5342017-07-20 15:22:39 -07002086 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002087
2088 utilities.assert_equals( expect=main.TRUE,
2089 actual=testResult,
2090 onpass=main.assertReturnString,
2091 onfail=main.assertReturnString )
2092
Jeremye0cb5eb2016-01-27 17:39:09 -08002093 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002094 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2095 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002096 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002097 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002098 ]
2099 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002100 { "name": "h16", "device": "of:0000000000000006/8" },
2101 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002102 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002103 isolatedSenders = []
2104 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002105 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002106 ]
2107 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002108 installResult = main.intents.installSingleToMultiIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08002109 main,
2110 name="NOOPTION",
2111 senders=senders,
2112 recipients=recipients,
2113 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002114 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002115
2116 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002117 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08002118 main,
2119 intentId=installResult,
2120 name="NOOPTION",
2121 senders=senders,
2122 recipients=recipients,
2123 isolatedSenders=isolatedSenders,
2124 isolatedRecipients=isolatedRecipients,
2125 sw1="s6",
2126 sw2="s2",
2127 sw3="s4",
2128 sw4="s1",
2129 sw5="s3",
2130 expectedLink1=16,
2131 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002132 else:
Devin Lim142b5342017-07-20 15:22:39 -07002133 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002134
2135 utilities.assert_equals( expect=main.TRUE,
2136 actual=testResult,
2137 onpass=main.assertReturnString,
2138 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002139 # Right now this functionality doesn't work properly in SPMP intents
Jon Hall78be4962017-05-23 14:53:53 -07002140 main.step( "NOOPTION: Install and test single point to multi point " +
Jeremy Songster9385d412016-06-02 17:57:36 -07002141 "intents with partial failures allowed" )
2142 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2143 "point intent with partial failures allowed\n"
2144 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002145 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002146 ]
2147 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002148 { "name": "h16", "device": "of:0000000000000006/8" },
2149 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002150 ]
2151 isolatedSenders = []
2152 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002153 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002154 ]
2155 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002156 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002157 main,
2158 name="NOOPTION",
2159 senders=senders,
2160 recipients=recipients,
2161 sw1="s5",
2162 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002163 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002164
2165 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002166 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002167 main,
2168 intentId=installResult,
2169 name="NOOPTION",
2170 senders=senders,
2171 recipients=recipients,
2172 isolatedSenders=isolatedSenders,
2173 isolatedRecipients=isolatedRecipients,
2174 sw1="s6",
2175 sw2="s2",
2176 sw3="s4",
2177 sw4="s1",
2178 sw5="s3",
2179 expectedLink1=16,
2180 expectedLink2=14,
2181 partial=True )
2182 else:
Devin Lim142b5342017-07-20 15:22:39 -07002183 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002184
2185 utilities.assert_equals( expect=main.TRUE,
2186 actual=testResult,
2187 onpass=main.assertReturnString,
2188 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002189
Jon Hall78be4962017-05-23 14:53:53 -07002190 main.intents.report( main )