blob: 86b9f535680a762ee415f795f15a276fd8d658c7 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
kelvin-onlabd48a68c2015-07-13 16:01:36 -070021# Testing the basic intent functionality of ONOS
22
Jon Hall78be4962017-05-23 14:53:53 -070023
kelvin-onlabd48a68c2015-07-13 16:01:36 -070024class FUNCintent:
25
26 def __init__( self ):
27 self.default = ''
28
29 def CASE1( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -070030 import imp
Jon Hallf632d202015-07-30 15:45:11 -070031 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070032 """
33 - Construct tests variables
34 - GIT ( optional )
35 - Checkout ONOS master branch
36 - Pull latest ONOS code
37 - Building ONOS ( optional )
38 - Install ONOS package
39 - Build ONOS package
40 """
Devin Lim58046fa2017-07-05 16:55:00 -070041 try:
42 from tests.dependencies.ONOSSetup import ONOSSetup
43 main.testSetUp = ONOSSetup()
44 except ImportError:
45 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070046 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070047 main.testSetUp.envSetupDescription()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070048 stepResult = main.FALSE
49
You Wanga0f6ff62018-01-11 15:46:30 -080050 from tests.dependencies.Network import Network
51 main.Network = Network()
52
kelvin-onlabd48a68c2015-07-13 16:01:36 -070053 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070054 try:
Jon Halla3e02432015-07-24 15:55:42 -070055 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Jon Halla3e02432015-07-24 15:55:42 -070056 main.dependencyPath = main.testOnDirectory + \
57 main.params[ 'DEPENDENCY' ][ 'path' ]
58 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
59 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
Devin Lim58046fa2017-07-05 16:55:00 -070060
Jon Halla3e02432015-07-24 15:55:42 -070061 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
62 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
63 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
64 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
65 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070066 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070067 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
68 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
Shreyaca8990f2017-03-16 11:43:11 -070069 main.checkConnectionSleep = int( main.params[ 'SLEEP' ][ 'checkConnection' ] )
70 main.checkFlowCountSleep = int( main.params[ 'SLEEP' ][ 'checkFlowCount' ] )
71 main.checkIntentHostSleep = int( main.params[ 'SLEEP' ][ 'checkIntentHost' ] )
72 main.checkIntentPointSleep = int( main.params[ 'SLEEP' ][ 'checkIntentPoint' ] )
acsmars59a4c552015-09-10 18:11:19 -070073 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070074 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
Devin Lima4f95bc2017-08-11 11:13:03 -070075 main.generalAttemptsNum = int( main.params[ 'RETRY' ][ 'generalAttempts' ] )
76 main.middleAttemptsNum = int( main.params[ 'RETRY' ][ 'middleAttempts' ] )
77 main.minimumAttemptsNum = int( main.params[ 'RETRY' ][ 'minimumAttempts' ] )
78 main.checkConnectionAttNum = int( main.params[ 'RETRY' ][ 'checkConnectionAtt' ] )
79 main.removeIntentAttNum = int( main.params[ 'RETRY' ][ 'removeIntentAtt' ] )
Jon Halla3e02432015-07-24 15:55:42 -070080 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
81 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
Jon Halla3e02432015-07-24 15:55:42 -070082 main.hostsData = {}
Jeremy Songster1f39bf02016-01-20 17:17:25 -080083 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
84 main.scapyHosts = [] # List of scapy hosts for iterating
acsmars5d8cc862015-09-25 09:44:50 -070085 main.assertReturnString = '' # Assembled assert return string
Jon Hall78be4962017-05-23 14:53:53 -070086 main.cycle = 0 # How many times FUNCintent has run through its tests
You Wangf6574de2018-02-09 14:43:47 -080087 main.usePortstate = True if main.params[ 'TEST' ][ 'usePortstate' ] == "True" else False
kelvin-onlabd48a68c2015-07-13 16:01:36 -070088
Jon Halla3e02432015-07-24 15:55:42 -070089 # -- INIT SECTION, ONLY RUNS ONCE -- #
kelvin-onlabd48a68c2015-07-13 16:01:36 -070090
Jon Hall78be4962017-05-23 14:53:53 -070091 main.intents = imp.load_source( wrapperFile2,
Jon Halla3e02432015-07-24 15:55:42 -070092 main.dependencyPath +
93 wrapperFile2 +
94 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070095
You Wanga0f6ff62018-01-11 15:46:30 -080096 if hasattr( main, "Mininet1" ):
97 copyResult1 = main.ONOSbench.scp( main.Mininet1,
98 main.dependencyPath +
99 main.topology,
100 main.Mininet1.home + "custom/",
101 direction="to" )
Devin Lim58046fa2017-07-05 16:55:00 -0700102
Devin Lim142b5342017-07-20 15:22:39 -0700103 stepResult = main.testSetUp.envSetup()
Jon Halla3e02432015-07-24 15:55:42 -0700104 except Exception as e:
Devin Lim58046fa2017-07-05 16:55:00 -0700105 main.testSetUp.envSetupException( e )
106 main.testSetUp.evnSetupConclusion( stepResult )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700107
108 def CASE2( self, main ):
109 """
110 - Set up cell
111 - Create cell file
112 - Set cell file
113 - Verify cell file
114 - Kill ONOS process
115 - Uninstall ONOS cluster
116 - Verify ONOS start up
117 - Install ONOS cluster
118 - Connect to cli
119 """
Jeremycd872222016-03-29 10:08:34 -0700120 main.flowCompiler = "Flow Rules"
You Wanga0f6ff62018-01-11 15:46:30 -0800121 main.initialized = main.testSetUp.ONOSSetUp( main.Cluster, True )
Jon Hall78be4962017-05-23 14:53:53 -0700122 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -0700123
Jon Halla3e02432015-07-24 15:55:42 -0700124 def CASE8( self, main ):
125 """
acsmars59a4c552015-09-10 18:11:19 -0700126 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700127 """
Devin Lim58046fa2017-07-05 16:55:00 -0700128 import time
129 try:
130 from tests.dependencies.topology import Topology
131 except ImportError:
132 main.log.error( "Topology not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700133 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700134 try:
135 main.topoRelated
136 except ( NameError, AttributeError ):
137 main.topoRelated = Topology()
138 main.topoRelated.compareTopos( main.Mininet1, main.checkTopoAttempts )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700139
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700140 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700141 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700142 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700143 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700144 if main.initialized == main.FALSE:
145 main.log.error( "Test components did not start correctly, skipping further tests" )
146 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700147 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700148 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700149 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700150 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700151 "switches to test intents, exits out if " +\
152 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700153
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700154 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700155 args = "--switch ovs,protocols=OpenFlow10"
Devin Lim29a9e3d2018-01-30 14:09:47 -0800156 topoResult = main.Mininet1.startNet( topoFile=main.Mininet1.home + "/custom/" + main.topology,
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700157 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700158 stepResult = topoResult
159 utilities.assert_equals( expect=main.TRUE,
160 actual=stepResult,
161 onpass="Successfully loaded topology",
162 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700163
164 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700165 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700166 main.initialized = main.FALSE
167 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700168
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700169 def CASE11( self, main ):
170 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700171 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700172 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700173 if main.initialized == main.FALSE:
174 main.log.error( "Test components did not start correctly, skipping further tests" )
175 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700176 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700177 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700178 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700179 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700180 "switches to test intents, exits out if " +\
181 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700182
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700183 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700184 args = "--switch ovs,protocols=OpenFlow13"
Devin Lim29a9e3d2018-01-30 14:09:47 -0800185 topoResult = main.Mininet1.startNet( topoFile=main.Mininet1.home + "/custom/" + main.topology,
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700186 args=args )
187 stepResult = topoResult
188 utilities.assert_equals( expect=main.TRUE,
189 actual=stepResult,
190 onpass="Successfully loaded topology",
191 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700192 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700193 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700194 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700195
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700196 def CASE12( self, main ):
197 """
198 Assign mastership to controllers
199 """
200 import re
201
Jeremyd9e4eb12016-04-13 12:09:06 -0700202 if main.initialized == main.FALSE:
203 main.log.error( "Test components did not start correctly, skipping further tests" )
204 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700205 main.case( "Assign switches to controllers" )
206 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700207 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700208 " switches to ONOS nodes"
209
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700210 switchList = []
211
212 # Creates a list switch name, use getSwitch() function later...
213 for i in range( 1, ( main.numSwitch + 1 ) ):
214 switchList.append( 's' + str( i ) )
215
Devin Lim142b5342017-07-20 15:22:39 -0700216 tempONOSip = main.Cluster.getIps()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700217
You Wanga0f6ff62018-01-11 15:46:30 -0800218 assignResult = main.Network.assignSwController( sw=switchList,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700219 ip=tempONOSip,
alison52b25892016-09-19 10:53:48 -0700220 port="6653" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700221 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700222 main.log.error( "Problem assigning mastership of switches" )
223 main.initialized = main.FALSE
224 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700225
226 for i in range( 1, ( main.numSwitch + 1 ) ):
You Wanga0f6ff62018-01-11 15:46:30 -0800227 response = main.Network.getSwController( "s" + str( i ) )
Jon Hall860b8152017-05-23 10:35:23 -0700228 main.log.debug( "Response is " + str( response ) )
Devin Lim142b5342017-07-20 15:22:39 -0700229 if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700230 assignResult = assignResult and main.TRUE
231 else:
232 assignResult = main.FALSE
233 stepResult = assignResult
234 utilities.assert_equals( expect=main.TRUE,
235 actual=stepResult,
236 onpass="Successfully assigned switches" +
237 "to controller",
238 onfail="Failed to assign switches to " +
239 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700240 if not stepResult:
241 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700242
Jon Hall78be4962017-05-23 14:53:53 -0700243 def CASE13( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700244 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800245 Create Scapy components
246 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700247 if main.initialized == main.FALSE:
248 main.log.error( "Test components did not start correctly, skipping further tests" )
249 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800250 main.case( "Create scapy components" )
251 main.step( "Create scapy components" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800252 scapyResult = main.TRUE
253 for hostName in main.scapyHostNames:
254 main.Scapy1.createHostComponent( hostName )
255 main.scapyHosts.append( getattr( main, hostName ) )
256
257 main.step( "Start scapy components" )
258 for host in main.scapyHosts:
259 host.startHostCli()
260 host.startScapy()
261 host.updateSelf()
262 main.log.debug( host.name )
263 main.log.debug( host.hostIp )
264 main.log.debug( host.hostMac )
265
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800266 utilities.assert_equals( expect=main.TRUE,
267 actual=scapyResult,
268 onpass="Successfully created Scapy Components",
269 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700270 if not scapyResult:
271 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800272
273 def CASE14( self, main ):
274 """
275 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700276 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700277 if main.initialized == main.FALSE:
278 main.log.error( "Test components did not start correctly, skipping further tests" )
279 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700280 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800281 main.step( "Pingall hosts and confirm ONOS discovery" )
Jon Hall78be4962017-05-23 14:53:53 -0700282 utilities.retry( f=main.intents.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700283
Jon Hall78be4962017-05-23 14:53:53 -0700284 stepResult = utilities.retry( f=main.intents.confirmHostDiscovery, retValue=main.FALSE,
285 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700286 utilities.assert_equals( expect=main.TRUE,
287 actual=stepResult,
288 onpass="Successfully discovered hosts",
289 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700290 if not stepResult:
291 main.initialized = main.FALSE
292 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700293
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800294 main.step( "Populate hostsData" )
Jon Hall78be4962017-05-23 14:53:53 -0700295 stepResult = main.intents.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700296 utilities.assert_equals( expect=main.TRUE,
297 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800298 onpass="Successfully populated hostsData",
299 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700300 if not stepResult:
301 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800302
303 def CASE15( self, main ):
304 """
305 Discover all hosts with scapy arp packets and store its data to a dictionary
306 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700307 if main.initialized == main.FALSE:
308 main.log.error( "Test components did not start correctly, skipping further tests" )
309 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800310 main.case( "Discover all hosts using scapy" )
311 main.step( "Send packets from each host to the first host and confirm onos discovery" )
312
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800313 if len( main.scapyHosts ) < 1:
314 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700315 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800316 main.skipCase()
317
318 # Send ARP packets from each scapy host component
Jon Hall78be4962017-05-23 14:53:53 -0700319 main.intents.sendDiscoveryArp( main, main.scapyHosts )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800320
Jon Hall78be4962017-05-23 14:53:53 -0700321 stepResult = utilities.retry( f=main.intents.confirmHostDiscovery,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800322 retValue=main.FALSE, args=[ main ],
323 attempts=main.checkTopoAttempts, sleep=2 )
324
325 utilities.assert_equals( expect=main.TRUE,
326 actual=stepResult,
327 onpass="ONOS correctly discovered all hosts",
328 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700329 if not stepResult:
330 main.initialized = main.FALSE
331 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800332
333 main.step( "Populate hostsData" )
Jon Hall78be4962017-05-23 14:53:53 -0700334 stepResult = main.intents.populateHostData( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800335 utilities.assert_equals( expect=main.TRUE,
336 actual=stepResult,
337 onpass="Successfully populated hostsData",
338 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700339 if not stepResult:
340 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800341
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800342 def CASE16( self, main ):
343 """
Jeremy42df2e72016-02-23 16:37:46 -0800344 Balance Masters
345 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700346 if main.initialized == main.FALSE:
347 main.log.error( "Test components did not start correctly, skipping further tests" )
348 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800349 main.case( "Balance mastership of switches" )
350 main.step( "Balancing mastership of switches" )
351
Devin Lim142b5342017-07-20 15:22:39 -0700352 balanceResult = utilities.retry( f=main.Cluster.active( 0 ).CLI.balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800353
354 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700355 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800356 onpass="Successfully balanced mastership of switches",
357 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700358 if not balanceResult:
359 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800360
361 def CASE17( self, main ):
362 """
Jeremy6e9748f2016-03-25 15:03:39 -0700363 Use Flow Objectives
364 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700365 if main.initialized == main.FALSE:
366 main.log.error( "Test components did not start correctly, skipping further tests" )
367 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700368 main.case( "Enable intent compilation using Flow Objectives" )
369 main.step( "Enabling Flow Objectives" )
370
371 main.flowCompiler = "Flow Objectives"
372
373 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
374
Devin Lim142b5342017-07-20 15:22:39 -0700375 stepResult = main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700376 propName="useFlowObjectives", value="true" )
Jeremy6e9748f2016-03-25 15:03:39 -0700377 utilities.assert_equals( expect=main.TRUE,
378 actual=stepResult,
379 onpass="Successfully activated Flow Objectives",
380 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700381 if not balanceResult:
382 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700383
384 def CASE18( self, main ):
385 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800386 Stop mininet and remove scapy host
387 """
Devin Lim58046fa2017-07-05 16:55:00 -0700388 try:
389 from tests.dependencies.utils import Utils
390 except ImportError:
391 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700392 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700393 try:
394 main.Utils
395 except ( NameError, AttributeError ):
396 main.Utils = Utils()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800397 main.log.report( "Stop Mininet and Scapy" )
398 main.case( "Stop Mininet and Scapy" )
399 main.caseExplanation = "Stopping the current mininet topology " +\
400 "to start up fresh"
401 main.step( "Stopping and Removing Scapy Host Components" )
402 scapyResult = main.TRUE
403 for host in main.scapyHosts:
404 scapyResult = scapyResult and host.stopScapy()
405 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
406
407 for host in main.scapyHosts:
408 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
409 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
410
411 main.scapyHosts = []
412 main.scapyHostIPs = []
413
414 utilities.assert_equals( expect=main.TRUE,
415 actual=scapyResult,
416 onpass="Successfully stopped scapy and removed host components",
417 onfail="Failed to stop mininet and scapy" )
418
Devin Lim58046fa2017-07-05 16:55:00 -0700419 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700420 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800421 if not ( mininetResult and scapyResult ):
Devin Lim44075962017-08-11 10:56:37 -0700422 main.cleanAndExit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700423
Jeremy Songster17147f22016-05-31 18:30:52 -0700424 def CASE19( self, main ):
425 """
426 Copy the karaf.log files after each testcase cycle
427 """
Devin Lim58046fa2017-07-05 16:55:00 -0700428 try:
429 from tests.dependencies.utils import Utils
430 except ImportError:
431 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700432 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700433 try:
434 main.Utils
435 except ( NameError, AttributeError ):
436 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700437 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700438
You Wang84f981d2018-01-12 16:11:50 -0800439 def CASE100( self, main):
440 """
441 Connect to a physical network, assign controllers and start scapy
442 """
443 import time
444 main.case( "Connecting to physical network" )
445 main.step( "Connecting to physical network" )
446 main.OFProtocol = "1.3"
447 topoResult = main.NetworkBench.connectToNet()
448 utilities.assert_equals( expect=main.TRUE,
449 actual=topoResult,
450 onpass="Successfully loaded topology",
451 onfail="Failed to load topology" )
452 # Exit if topology did not load properly
453 if not topoResult:
454 main.cleanAndExit()
455
456 main.step( "Assign switches to controllers." )
457 assignResult = main.TRUE
458 switchList = []
459 for i in range( 1, ( main.numSwitch + 1 ) ):
460 switchList.append( 's' + str( i ) )
461 tempONOSip = main.Cluster.getIps()
462 assignResult = main.Network.assignSwController( sw=switchList,
463 ip=tempONOSip,
464 port="6653" )
465 utilities.assert_equals( expect=main.TRUE,
466 actual=assignResult,
467 onpass="Successfully assigned switches to controller",
468 onfail="Failed to assgin switches to controller" )
469
470 main.step( "Start scapy" )
471 scapyResult = main.TRUE
472 for hostName in main.scapyHostNames:
473 main.scapyHosts.append( getattr( main, hostName ) )
474
475 for host in main.scapyHosts:
476 host.startScapy()
477 host.updateSelf()
478 main.log.debug( host.name )
479 main.log.debug( host.hostIp )
480 main.log.debug( host.hostMac )
481
482 utilities.assert_equals( expect=main.TRUE, actual=scapyResult,
483 onpass="Successfully created Scapy Components",
484 onfail="Failed to discover Scapy Components" )
485
486 def CASE101( self, main ):
487 """
488 Stop Scapy on physical hosts
489 """
490 main.case( "Stop Scapy" )
491 main.step( "Stopping Scapy Hosts" )
492 scapyResult = main.TRUE
493 for host in main.scapyHosts:
494 host.stopScapy()
495 utilities.assert_equals( expect=main.TRUE, actual=scapyResult,
496 onpass="Successfully stopped scapy",
497 onfail="Failed to stop scapy" )
498
kelvin-onlabb769f562015-07-15 17:05:10 -0700499 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700500 """
501 Add host intents between 2 host:
502 - Discover hosts
503 - Add host intents
504 - Check intents
505 - Verify flows
506 - Ping hosts
507 - Reroute
508 - Link down
509 - Verify flows
510 - Check topology
511 - Ping hosts
512 - Link up
513 - Verify flows
514 - Check topology
515 - Ping hosts
516 - Remove intents
517 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700518 if main.initialized == main.FALSE:
519 main.log.error( "Test components did not start correctly, skipping further tests" )
520 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700521 # Assert variables - These variable's name|format must be followed
522 # if you want to use the wrapper function
523 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700524 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700525 assert main.numSwitch
526 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700527 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700528 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700529 main.initialized = main.FALSE
530 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700531
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800532 # Save leader candidates
Devin Lim142b5342017-07-20 15:22:39 -0700533 intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates()
acsmarse6b410f2015-07-17 14:39:34 -0700534
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700535 main.testName = "Host Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700536 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700537 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700538 main.caseExplanation = "This test case tests Host intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -0700539 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700540 "Different type of hosts will be tested in " +\
541 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700542 "etc;\nThe test will use OF " + main.OFProtocol +\
543 " OVS running in Mininet and compile intents" +\
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700544 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700545
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700546 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700547 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700548 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
549 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800550 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700551 installResult = main.intents.installHostIntent( main,
552 name="IPV4",
553 onosNode=0,
554 host1=host1,
555 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800556 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700557 testResult = main.intents.testHostIntent( main,
558 name="IPV4",
559 intentId=installResult,
560 onosNode=0,
561 host1=host1,
562 host2=host2,
563 sw1="s5",
564 sw2="s2",
565 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800566 else:
Devin Lim8619b552018-04-13 00:40:43 -0700567 main.intents.removeAllExistIntents( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800568
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700569 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800570 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700571 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700572 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700573
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700574 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700575 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700576 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
Jon Hall78be4962017-05-23 14:53:53 -0700577 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1 " }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800578 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700579 installResult = main.intents.installHostIntent( main,
580 name="DUALSTACK",
581 onosNode=0,
582 host1=host1,
583 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800584
585 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700586 testResult = main.intents.testHostIntent( main,
587 name="DUALSTACK",
588 intentId=installResult,
589 onosNode=0,
590 host1=host1,
591 host2=host2,
592 sw1="s5",
593 sw2="s2",
594 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700595
596 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800597 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700598 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700599 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700600
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700601 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700602 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700603 host1 = { "name": "h1" }
604 host2 = { "name": "h11" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800605 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700606 installResult = main.intents.installHostIntent( main,
607 name="DUALSTACK2",
608 onosNode=0,
609 host1=host1,
610 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800611
612 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700613 testResult = main.intents.testHostIntent( main,
614 name="DUALSTACK2",
615 intentId=installResult,
616 onosNode=0,
617 host1=host1,
618 host2=host2,
619 sw1="s5",
620 sw2="s2",
621 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800622 else:
Devin Lim8619b552018-04-13 00:40:43 -0700623 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700624
625 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800626 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700627 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700628 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700629
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700630 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700631 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall9c888672017-05-15 18:03:54 -0700632 host1 = { "name": "h1" }
633 host2 = { "name": "h3" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800634 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700635 installResult = main.intents.installHostIntent( main,
636 name="1HOP",
637 onosNode=0,
638 host1=host1,
639 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800640
641 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700642 testResult = main.intents.testHostIntent( main,
643 name="1HOP",
644 intentId=installResult,
645 onosNode=0,
646 host1=host1,
647 host2=host2,
648 sw1="s5",
649 sw2="s2",
650 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800651 else:
Devin Lim8619b552018-04-13 00:40:43 -0700652 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700653
654 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800655 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700656 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700657 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700658
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700659 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700660 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700661 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlan": "100" }
662 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800663 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700664 installResult = main.intents.installHostIntent( main,
665 name="VLAN1",
666 onosNode=0,
667 host1=host1,
668 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800669 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700670 testResult = main.intents.testHostIntent( main,
671 name="VLAN1",
672 intentId=installResult,
673 onosNode=0,
674 host1=host1,
675 host2=host2,
676 sw1="s5",
677 sw2="s2",
678 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800679 else:
Devin Lim8619b552018-04-13 00:40:43 -0700680 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700681
682 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800683 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700684 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700685 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700686
Jeremy Songsterff553672016-05-12 17:06:23 -0700687 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
688 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700689 host1 = { "name": "h5", "vlan": "200" }
690 host2 = { "name": "h12", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -0700691 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700692 installResult = main.intents.installHostIntent( main,
693 name="VLAN2",
694 onosNode=0,
695 host1=host1,
696 host2=host2 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700697
698 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700699 testResult = main.intents.testHostIntent( main,
700 name="VLAN2",
701 intentId=installResult,
702 onosNode=0,
703 host1=host1,
704 host2=host2,
705 sw1="s5",
706 sw2="s2",
707 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700708 else:
Devin Lim8619b552018-04-13 00:40:43 -0700709 main.intents.removeAllExistIntents( main )
Jeremy Songsterff553672016-05-12 17:06:23 -0700710
711 utilities.assert_equals( expect=main.TRUE,
712 actual=testResult,
713 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700714 onfail=main.assertReturnString )
Jeremy Songsterff553672016-05-12 17:06:23 -0700715
Jeremy Songsterc032f162016-08-04 17:14:49 -0700716 main.step( "Encapsulation: Add host intents between h1 and h9" )
717 main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700718 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
719 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -0700720 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700721 installResult = main.intents.installHostIntent( main,
722 name="ENCAPSULATION",
723 onosNode=0,
724 host1=host1,
725 host2=host2,
726 encap="VLAN" )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700727 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700728 testResult = main.intents.testHostIntent( main,
729 name="ENCAPSULATION",
730 intentId=installResult,
731 onosNode=0,
732 host1=host1,
733 host2=host2,
734 sw1="s5",
735 sw2="s2",
736 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700737 else:
Devin Lim8619b552018-04-13 00:40:43 -0700738 main.intents.removeAllExistIntents( main )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700739
740 utilities.assert_equals( expect=main.TRUE,
741 actual=testResult,
742 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700743 onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700744
Jon Hall78be4962017-05-23 14:53:53 -0700745 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -0700746 # main.step( "Encapsulation: Add host intents between h1 and h9" )
747 # main.assertReturnString = "Assertion Result for MPLS Encapsulated host intent\n"
748 # host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
749 # host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
750 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700751 # installResult = main.intents.installHostIntent( main,
752 # name="ENCAPSULATION",
753 # onosNode=0,
754 # host1=host1,
755 # host2=host2,
756 # encap="MPLS" )
alison52b25892016-09-19 10:53:48 -0700757 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700758 # testResult = main.intents.testHostIntent( main,
759 # name="ENCAPSULATION",
760 # intentId=installResult,
761 # onosNode=0,
762 # host1=host1,
763 # host2=host2,
764 # sw1="s5",
765 # sw2="s2",
766 # expectedLink=18 )
alison52b25892016-09-19 10:53:48 -0700767 # else:
Devin Lim142b5342017-07-20 15:22:39 -0700768 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -0700769 #
770 # utilities.assert_equals( expect=main.TRUE,
771 # actual=testResult,
772 # onpass=main.assertReturnString,
773 # onfail=main.assertReturnString )
774
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700775 main.step( "Confirm that ONOS leadership is unchanged" )
Devin Lim142b5342017-07-20 15:22:39 -0700776 intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jon Hall78be4962017-05-23 14:53:53 -0700777 testResult = main.intents.checkLeaderChange( intentLeadersOld,
778 intentLeadersNew )
acsmarse6b410f2015-07-17 14:39:34 -0700779
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800780 utilities.assert_equals( expect=main.TRUE,
781 actual=testResult,
782 onpass="ONOS Leaders Unchanged",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700783 onfail="ONOS Leader Mismatch" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800784
Jon Hall78be4962017-05-23 14:53:53 -0700785 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -0700786
kelvin-onlabb769f562015-07-15 17:05:10 -0700787 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700788 """
789 Add point intents between 2 hosts:
790 - Get device ids | ports
791 - Add point intents
792 - Check intents
793 - Verify flows
794 - Ping hosts
795 - Reroute
796 - Link down
797 - Verify flows
798 - Check topology
799 - Ping hosts
800 - Link up
801 - Verify flows
802 - Check topology
803 - Ping hosts
804 - Remove intents
805 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700806 if main.initialized == main.FALSE:
807 main.log.error( "Test components did not start correctly, skipping further tests" )
808 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700809 # Assert variables - These variable's name|format must be followed
810 # if you want to use the wrapper function
811 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700812 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700813 assert main.numSwitch
814 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700815 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700816 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700817 main.initialized = main.FALSE
818 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700819
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700820 main.testName = "Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700821 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700822 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700823 main.caseExplanation = "This test case will test point to point" +\
Devin Lim142b5342017-07-20 15:22:39 -0700824 " intents using " + str( main.Cluster.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700825 " node(s) cluster;\n" +\
826 "Different type of hosts will be tested in " +\
827 "each step such as IPV4, Dual stack, VLAN etc" +\
828 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -0700829 " OVS running in Mininet and compile intents" +\
830 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700831
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700832 # No option point intents
833 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700834 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800835 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700836 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800837 ]
838 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700839 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800840 ]
Jeremy42df2e72016-02-23 16:37:46 -0800841 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700842 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700843 main,
844 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800845 senders=senders,
846 recipients=recipients )
847
848 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700849 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800850 main,
851 intentId=installResult,
852 name="NOOPTION",
853 senders=senders,
854 recipients=recipients,
855 sw1="s5",
856 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700857 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800858 else:
Devin Lim8619b552018-04-13 00:40:43 -0700859 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700860
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700861 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800862 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700863 onpass=main.assertReturnString,
864 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700865
kelvin-onlabb769f562015-07-15 17:05:10 -0700866 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700867 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800868 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700869 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800870 ]
871 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700872 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800873 ]
Jeremy42df2e72016-02-23 16:37:46 -0800874 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700875 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700876 main,
877 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800878 senders=senders,
879 recipients=recipients,
880 ethType="IPV4" )
881
882 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700883 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800884 main,
885 intentId=installResult,
886 name="IPV4",
887 senders=senders,
888 recipients=recipients,
889 sw1="s5",
890 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700891 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800892 else:
Devin Lim8619b552018-04-13 00:40:43 -0700893 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700894
895 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800896 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700897 onpass=main.assertReturnString,
898 onfail=main.assertReturnString )
alisonda157272016-12-22 01:13:21 -0800899
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 Lim8619b552018-04-13 00:40:43 -0700928 main.intents.removeAllExistIntents( main )
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 Lim8619b552018-04-13 00:40:43 -0700962 main.intents.removeAllExistIntents( main )
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 Lim8619b552018-04-13 00:40:43 -07001006 main.intents.removeAllExistIntents( main )
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 Lim8619b552018-04-13 00:40:43 -07001071 main.intents.removeAllExistIntents( main )
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 Lim8619b552018-04-13 00:40:43 -07001168 main.intents.removeAllExistIntents( main )
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 Lim8619b552018-04-13 00:40:43 -07001202 main.intents.removeAllExistIntents( main )
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 Lim8619b552018-04-13 00:40:43 -07001236 main.intents.removeAllExistIntents( main )
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 Lim8619b552018-04-13 00:40:43 -07001356 main.intents.removeAllExistIntents( main )
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 Lim8619b552018-04-13 00:40:43 -07001397 main.intents.removeAllExistIntents( main )
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 )
Devin Lim8619b552018-04-13 00:40:43 -07001437 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001438
1439 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001440 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001441 onpass=main.assertReturnString,
1442 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001443
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001444 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001445 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 -08001446 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001447 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001448 ]
1449 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001450 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1451 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001452 ]
Jon Hall9c888672017-05-15 18:03:54 -07001453 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1454 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001455 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001456 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001457 main,
alison52b25892016-09-19 10:53:48 -07001458 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001459 senders=senders,
1460 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001461 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001462 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001463
1464 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001465 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001466 main,
1467 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001468 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001469 senders=senders,
1470 recipients=recipients,
1471 badSenders=badSenders,
1472 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001473 sw1="s5",
1474 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001475 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001476 else:
Devin Lim8619b552018-04-13 00:40:43 -07001477 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001478
1479 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001480 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001481 onpass=main.assertReturnString,
1482 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001483
Jeremy Songsterff553672016-05-12 17:06:23 -07001484 main.step( "VLAN: Add single point to multi point intents" )
1485 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1486 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001487 { "name": "h5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001488 ]
1489 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001490 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1491 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001492 ]
Jon Hall9c888672017-05-15 18:03:54 -07001493 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1494 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001495 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001496 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001497 main,
1498 name="VLAN2",
1499 senders=senders,
1500 recipients=recipients,
1501 sw1="s5",
1502 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001503 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001504
1505 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001506 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001507 main,
1508 intentId=installResult,
1509 name="VLAN2",
1510 senders=senders,
1511 recipients=recipients,
1512 badSenders=badSenders,
1513 badRecipients=badRecipients,
1514 sw1="s5",
1515 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001516 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001517 else:
Devin Lim8619b552018-04-13 00:40:43 -07001518 main.intents.removeAllExistIntents( main )
Jeremy Songsterff553672016-05-12 17:06:23 -07001519
1520 utilities.assert_equals( expect=main.TRUE,
1521 actual=testResult,
1522 onpass=main.assertReturnString,
1523 onfail=main.assertReturnString )
1524
alison52b25892016-09-19 10:53:48 -07001525 # Does not support Single point to multi point encapsulation
1526 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1527 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1528 # senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001529 # { "name": "h8", "device": "of:0000000000000005/8" }
alison52b25892016-09-19 10:53:48 -07001530 # ]
1531 # recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001532 # { "name": "h16", "device": "of:0000000000000006/8" },
1533 # { "name": "h24", "device": "of:0000000000000007/8" }
alison52b25892016-09-19 10:53:48 -07001534 # ]
Jon Hall9c888672017-05-15 18:03:54 -07001535 # badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1536 # badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
alison52b25892016-09-19 10:53:48 -07001537 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001538 # installResult = main.intents.installSingleToMultiIntent(
alison52b25892016-09-19 10:53:48 -07001539 # main,
1540 # name="ENCAPSULATION",
1541 # senders=senders,
1542 # recipients=recipients,
1543 # sw1="s5",
1544 # sw2="s2",
1545 # encap="VLAN" )
1546 #
1547 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001548 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001549 # main,
1550 # intentId=installResult,
1551 # name="ENCAPSULATION",
1552 # senders=senders,
1553 # recipients=recipients,
1554 # badSenders=badSenders,
1555 # badRecipients=badRecipients,
1556 # sw1="s5",
1557 # sw2="s2",
1558 # expectedLink=18 )
1559 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001560 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001561 #
1562 # utilities.assert_equals( expect=main.TRUE,
1563 # actual=testResult,
1564 # onpass=main.assertReturnString,
1565 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001566
Jon Hall78be4962017-05-23 14:53:53 -07001567 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001568
kelvin-onlabb769f562015-07-15 17:05:10 -07001569 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001570 """
1571 Add multi point to single point intents
1572 - Get device ids
1573 - Add multi point to single point intents
1574 - Check intents
1575 - Verify flows
1576 - Ping hosts
1577 - Reroute
1578 - Link down
1579 - Verify flows
1580 - Check topology
1581 - Ping hosts
1582 - Link up
1583 - Verify flows
1584 - Check topology
1585 - Ping hosts
1586 - Remove intents
1587 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001588 if main.initialized == main.FALSE:
1589 main.log.error( "Test components did not start correctly, skipping further tests" )
1590 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001591 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001592 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001593 assert main.numSwitch
1594 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001595 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001596 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001597 main.initialized = main.FALSE
1598 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001599
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001600 main.testName = "Multi To Single Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001601 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001602 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001603 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001604 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001605 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001606 "Different type of hosts will be tested in " +\
1607 "each step such as IPV4, Dual stack, VLAN etc" +\
1608 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001609 " OVS running in Mininet and compile intents" +\
1610 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001611
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001612 main.step( "NOOPTION: Add multi point to single point intents" )
1613 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1614 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001615 { "name": "h16", "device": "of:0000000000000006/8" },
1616 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001617 ]
1618 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001619 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001620 ]
Jon Hall9c888672017-05-15 18:03:54 -07001621 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1622 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001623 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001624 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001625 main,
1626 name="NOOPTION",
1627 senders=senders,
1628 recipients=recipients,
1629 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001630 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001631
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001632 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001633 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001634 main,
1635 intentId=installResult,
1636 name="NOOPTION",
1637 senders=senders,
1638 recipients=recipients,
1639 badSenders=badSenders,
1640 badRecipients=badRecipients,
1641 sw1="s5",
1642 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001643 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001644 else:
Devin Lim8619b552018-04-13 00:40:43 -07001645 main.intents.removeAllExistIntents( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001646
1647 utilities.assert_equals( expect=main.TRUE,
1648 actual=testResult,
1649 onpass=main.assertReturnString,
1650 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001651
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001652 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001653 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 -08001654 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001655 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1656 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001657 ]
1658 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001659 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001660 ]
Jon Hall9c888672017-05-15 18:03:54 -07001661 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1662 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001663 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001664 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001665 main,
1666 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001667 senders=senders,
1668 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001669 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001670 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001671 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001672
1673 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001674 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001675 main,
1676 intentId=installResult,
1677 name="IPV4",
1678 senders=senders,
1679 recipients=recipients,
1680 badSenders=badSenders,
1681 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001682 sw1="s5",
1683 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001684 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001685 else:
Devin Lim8619b552018-04-13 00:40:43 -07001686 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001687
1688 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001689 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001690 onpass=main.assertReturnString,
1691 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001692
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001693 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001694 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 -08001695 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001696 { "name": "h16", "device": "of:0000000000000006/8" },
1697 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001698 ]
1699 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001700 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001701 ]
Jon Hall9c888672017-05-15 18:03:54 -07001702 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1703 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001704 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001705 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001706 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001707 name="IPV4_2",
1708 senders=senders,
1709 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001710 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001711 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001712 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001713
1714 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001715 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001716 main,
1717 intentId=installResult,
1718 name="IPV4_2",
1719 senders=senders,
1720 recipients=recipients,
1721 badSenders=badSenders,
1722 badRecipients=badRecipients,
1723 sw1="s5",
1724 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001725 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001726 else:
Devin Lim8619b552018-04-13 00:40:43 -07001727 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001728
1729 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001730 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001731 onpass=main.assertReturnString,
1732 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001733
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001734 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001735 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 -08001736 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001737 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1738 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001739 ]
1740 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001741 { "name": "h5", "device": "of:0000000000000005/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001742 ]
Jon Hall9c888672017-05-15 18:03:54 -07001743 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1744 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001745 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001746 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001747 main,
1748 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001749 senders=senders,
1750 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001751 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001752 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001753
1754 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001755 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001756 main,
1757 intentId=installResult,
1758 name="VLAN",
1759 senders=senders,
1760 recipients=recipients,
1761 badSenders=badSenders,
1762 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001763 sw1="s5",
1764 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001765 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001766 else:
Devin Lim8619b552018-04-13 00:40:43 -07001767 main.intents.removeAllExistIntents( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001768
1769 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001770 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001771 onpass=main.assertReturnString,
1772 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001773
Jeremy Songsterff553672016-05-12 17:06:23 -07001774 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1775 main.step( "VLAN: Add multi point to single point intents" )
1776 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1777 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001778 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1779 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001780 ]
1781 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001782 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001783 ]
Jon Hall9c888672017-05-15 18:03:54 -07001784 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1785 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001786 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001787 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001788 main,
1789 name="VLAN2",
1790 senders=senders,
1791 recipients=recipients,
1792 sw1="s5",
1793 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001794 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001795
1796 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001797 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001798 main,
1799 intentId=installResult,
1800 name="VLAN2",
1801 senders=senders,
1802 recipients=recipients,
1803 badSenders=badSenders,
1804 badRecipients=badRecipients,
1805 sw1="s5",
1806 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001807 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001808 else:
Devin Lim8619b552018-04-13 00:40:43 -07001809 main.intents.removeAllExistIntents( main )
Jeremy Songsterff553672016-05-12 17:06:23 -07001810
1811 utilities.assert_equals( expect=main.TRUE,
1812 actual=testResult,
1813 onpass=main.assertReturnString,
1814 onfail=main.assertReturnString )
1815
Jeremy Songsterc032f162016-08-04 17:14:49 -07001816 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1817 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
1818 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001819 { "name": "h16", "device": "of:0000000000000006/8" },
1820 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001821 ]
1822 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001823 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001824 ]
Jon Hall9c888672017-05-15 18:03:54 -07001825 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1826 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songsterc032f162016-08-04 17:14:49 -07001827 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001828 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001829 main,
1830 name="ENCAPSULATION",
1831 senders=senders,
1832 recipients=recipients,
1833 sw1="s5",
1834 sw2="s2",
1835 encap="VLAN" )
1836
1837 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001838 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001839 main,
1840 intentId=installResult,
1841 name="ENCAPSULATION",
1842 senders=senders,
1843 recipients=recipients,
1844 badSenders=badSenders,
1845 badRecipients=badRecipients,
1846 sw1="s5",
1847 sw2="s2",
1848 expectedLink=18 )
1849 else:
Devin Lim8619b552018-04-13 00:40:43 -07001850 main.intents.removeAllExistIntents( main )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001851
1852 utilities.assert_equals( expect=main.TRUE,
1853 actual=testResult,
1854 onpass=main.assertReturnString,
1855 onfail=main.assertReturnString )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001856 """
1857 Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
1858 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1859 main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
1860 senders = [
1861 { "name": "h16", "device": "of:0000000000000006/8" },
1862 { "name": "h24", "device": "of:0000000000000007/8" }
1863 ]
1864 recipients = [
1865 { "name": "h8", "device": "of:0000000000000005/8" }
1866 ]
1867 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1868 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
1869 testResult = main.FALSE
1870 installResult = main.intents.installMultiToSingleIntent(
1871 main,
1872 name="ENCAPSULATION",
1873 senders=senders,
1874 recipients=recipients,
1875 sw1="s5",
1876 sw2="s2",
1877 encap="MPLS" )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001878
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001879 if installResult:
1880 testResult = main.intents.testPointIntent(
1881 main,
1882 intentId=installResult,
1883 name="ENCAPSULATION",
1884 senders=senders,
1885 recipients=recipients,
1886 badSenders=badSenders,
1887 badRecipients=badRecipients,
1888 sw1="s5",
1889 sw2="s2",
1890 expectedLink=18 )
1891 else:
1892 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
1893
1894 utilities.assert_equals( expect=main.TRUE,
1895 actual=testResult,
1896 onpass=main.assertReturnString,
1897 onfail=main.assertReturnString )
1898 """
alison52b25892016-09-19 10:53:48 -07001899
Jon Hall78be4962017-05-23 14:53:53 -07001900 main.intents.report( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001901
acsmars1ff5e052015-07-23 11:27:48 -07001902 def CASE5000( self, main ):
1903 """
acsmars5d8cc862015-09-25 09:44:50 -07001904 Tests Host Mobility
1905 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001906 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001907 if main.initialized == main.FALSE:
1908 main.log.error( "Test components did not start correctly, skipping further tests" )
1909 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001910 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001911 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001912 assert main.numSwitch
1913 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001914 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001915 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001916 main.initialized = main.FALSE
1917 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001918 main.case( "Test host mobility with host intents " + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001919 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001920 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001921
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001922 main.log.info( "Moving h1 from s5 to s6" )
You Wanga0f6ff62018-01-11 15:46:30 -08001923 main.Network.moveHost( "h1", "s5", "s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001924
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001925 # Send discovery ping from moved host
1926 # Moving the host brings down the default interfaces and creates a new one.
1927 # Scapy is restarted on this host to detect the new interface
1928 main.h1.stopScapy()
1929 main.h1.startScapy()
1930
1931 # Discover new host location in ONOS and populate host data.
1932 # Host 1 IP and MAC should be unchanged
Jon Hall78be4962017-05-23 14:53:53 -07001933 main.intents.sendDiscoveryArp( main, [ main.h1 ] )
1934 main.intents.populateHostData( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001935
acsmars1ff5e052015-07-23 11:27:48 -07001936 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1937
1938 utilities.assert_equals( expect="of:0000000000000006",
1939 actual=h1PostMove,
1940 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001941 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001942 " to single point intents" +
1943 " with IPV4 type and MAC addresses" +
1944 " in the same VLAN" )
1945
1946 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001947 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall9c888672017-05-15 18:03:54 -07001948 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1949 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001950 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001951 installResult = main.intents.installHostIntent( main,
1952 name="IPV4 Mobility IPV4",
1953 onosNode=0,
1954 host1=host1,
1955 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001956 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001957 testResult = main.intents.testHostIntent( main,
1958 name="Host Mobility IPV4",
1959 intentId=installResult,
1960 onosNode=0,
1961 host1=host1,
1962 host2=host2,
1963 sw1="s6",
1964 sw2="s2",
1965 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001966 else:
Devin Lim8619b552018-04-13 00:40:43 -07001967 main.intents.removeAllExistIntents( main )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001968
1969 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001970 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001971 onpass=main.assertReturnString,
1972 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001973
Jon Hall78be4962017-05-23 14:53:53 -07001974 main.intents.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001975
1976 def CASE6000( self, main ):
1977 """
1978 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1979 """
Jeremy Songster9385d412016-06-02 17:57:36 -07001980 # At some later point discussion on this behavior in MPSP and SPMP intents
1981 # will be reoppened and this test case may need to be updated to reflect
1982 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07001983 if main.initialized == main.FALSE:
1984 main.log.error( "Test components did not start correctly, skipping further tests" )
1985 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001986 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001987 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001988 assert main.numSwitch
1989 except AssertionError:
alison52b25892016-09-19 10:53:48 -07001990 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001991 main.initialized = main.FALSE
1992 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001993 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001994 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07001995 main.step( "Installing Multi to Single Point intents with no options set" )
1996 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
1997 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08001998 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001999 { "name": "h16", "device": "of:0000000000000006/8" },
2000 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002001 ]
2002 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002003 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002004 ]
2005 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07002006 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002007 ]
2008 isolatedRecipients = []
2009 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002010 installResult = main.intents.installMultiToSingleIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08002011 main,
2012 name="NOOPTION",
2013 senders=senders,
2014 recipients=recipients,
2015 sw1="s5",
2016 sw2="s2" )
2017
2018 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002019 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08002020 main,
2021 intentId=installResult,
2022 name="NOOPTION",
2023 senders=senders,
2024 recipients=recipients,
2025 isolatedSenders=isolatedSenders,
2026 isolatedRecipients=isolatedRecipients,
2027 sw1="s6",
2028 sw2="s2",
2029 sw3="s4",
2030 sw4="s1",
2031 sw5="s3",
2032 expectedLink1=16,
2033 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002034 else:
Devin Lim8619b552018-04-13 00:40:43 -07002035 main.intents.removeAllExistIntents( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002036
2037 utilities.assert_equals( expect=main.TRUE,
2038 actual=testResult,
2039 onpass=main.assertReturnString,
2040 onfail=main.assertReturnString )
2041
Jeremy Songster9385d412016-06-02 17:57:36 -07002042 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2043
2044 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2045 "with partial failures allowed\n"
2046 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002047 { "name": "h16", "device": "of:0000000000000006/8" },
2048 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002049 ]
2050 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002051 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002052 ]
2053 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07002054 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002055 ]
2056 isolatedRecipients = []
2057 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002058 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002059 main,
2060 name="NOOPTION",
2061 senders=senders,
2062 recipients=recipients,
2063 sw1="s5",
2064 sw2="s2",
2065 partial=True )
2066
2067 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002068 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002069 main,
2070 intentId=installResult,
2071 name="NOOPTION",
2072 senders=senders,
2073 recipients=recipients,
2074 isolatedSenders=isolatedSenders,
2075 isolatedRecipients=isolatedRecipients,
2076 sw1="s6",
2077 sw2="s2",
2078 sw3="s4",
2079 sw4="s1",
2080 sw5="s3",
2081 expectedLink1=16,
2082 expectedLink2=14,
2083 partial=True )
2084 else:
Devin Lim8619b552018-04-13 00:40:43 -07002085 main.intents.removeAllExistIntents( main )
Jeremy Songster9385d412016-06-02 17:57:36 -07002086
2087 utilities.assert_equals( expect=main.TRUE,
2088 actual=testResult,
2089 onpass=main.assertReturnString,
2090 onfail=main.assertReturnString )
2091
Jeremye0cb5eb2016-01-27 17:39:09 -08002092 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002093 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2094 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002095 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002096 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002097 ]
2098 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002099 { "name": "h16", "device": "of:0000000000000006/8" },
2100 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002101 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002102 isolatedSenders = []
2103 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002104 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002105 ]
2106 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002107 installResult = main.intents.installSingleToMultiIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08002108 main,
2109 name="NOOPTION",
2110 senders=senders,
2111 recipients=recipients,
2112 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002113 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002114
2115 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002116 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08002117 main,
2118 intentId=installResult,
2119 name="NOOPTION",
2120 senders=senders,
2121 recipients=recipients,
2122 isolatedSenders=isolatedSenders,
2123 isolatedRecipients=isolatedRecipients,
2124 sw1="s6",
2125 sw2="s2",
2126 sw3="s4",
2127 sw4="s1",
2128 sw5="s3",
2129 expectedLink1=16,
2130 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002131 else:
Devin Lim8619b552018-04-13 00:40:43 -07002132 main.intents.removeAllExistIntents( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002133
2134 utilities.assert_equals( expect=main.TRUE,
2135 actual=testResult,
2136 onpass=main.assertReturnString,
2137 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002138 # Right now this functionality doesn't work properly in SPMP intents
Jon Hall78be4962017-05-23 14:53:53 -07002139 main.step( "NOOPTION: Install and test single point to multi point " +
Jeremy Songster9385d412016-06-02 17:57:36 -07002140 "intents with partial failures allowed" )
2141 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2142 "point intent with partial failures allowed\n"
2143 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002144 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002145 ]
2146 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002147 { "name": "h16", "device": "of:0000000000000006/8" },
2148 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002149 ]
2150 isolatedSenders = []
2151 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002152 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002153 ]
2154 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002155 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002156 main,
2157 name="NOOPTION",
2158 senders=senders,
2159 recipients=recipients,
2160 sw1="s5",
2161 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002162 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002163
2164 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002165 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002166 main,
2167 intentId=installResult,
2168 name="NOOPTION",
2169 senders=senders,
2170 recipients=recipients,
2171 isolatedSenders=isolatedSenders,
2172 isolatedRecipients=isolatedRecipients,
2173 sw1="s6",
2174 sw2="s2",
2175 sw3="s4",
2176 sw4="s1",
2177 sw5="s3",
2178 expectedLink1=16,
2179 expectedLink2=14,
2180 partial=True )
2181 else:
Devin Lim8619b552018-04-13 00:40:43 -07002182 main.intents.removeAllExistIntents( main )
Jeremy Songster9385d412016-06-02 17:57:36 -07002183
2184 utilities.assert_equals( expect=main.TRUE,
2185 actual=testResult,
2186 onpass=main.assertReturnString,
2187 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002188
Jon Hall78be4962017-05-23 14:53:53 -07002189 main.intents.report( main )