blob: bd100f4640a04580ca691b83afcad13d16529c0b [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" )
Devin Lim142b5342017-07-20 15:22:39 -0700377 stepResult &= main.Cluster.active( 0 ).CLI.setCfg( component=cmd,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700378 propName="defaultFlowObjectiveCompiler",
379 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremy6e9748f2016-03-25 15:03:39 -0700380
381 utilities.assert_equals( expect=main.TRUE,
382 actual=stepResult,
383 onpass="Successfully activated Flow Objectives",
384 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700385 if not balanceResult:
386 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700387
388 def CASE18( self, main ):
389 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800390 Stop mininet and remove scapy host
391 """
Devin Lim58046fa2017-07-05 16:55:00 -0700392 try:
393 from tests.dependencies.utils import Utils
394 except ImportError:
395 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700396 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700397 try:
398 main.Utils
399 except ( NameError, AttributeError ):
400 main.Utils = Utils()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800401 main.log.report( "Stop Mininet and Scapy" )
402 main.case( "Stop Mininet and Scapy" )
403 main.caseExplanation = "Stopping the current mininet topology " +\
404 "to start up fresh"
405 main.step( "Stopping and Removing Scapy Host Components" )
406 scapyResult = main.TRUE
407 for host in main.scapyHosts:
408 scapyResult = scapyResult and host.stopScapy()
409 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
410
411 for host in main.scapyHosts:
412 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
413 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
414
415 main.scapyHosts = []
416 main.scapyHostIPs = []
417
418 utilities.assert_equals( expect=main.TRUE,
419 actual=scapyResult,
420 onpass="Successfully stopped scapy and removed host components",
421 onfail="Failed to stop mininet and scapy" )
422
Devin Lim58046fa2017-07-05 16:55:00 -0700423 mininetResult = main.Utils.mininetCleanup( main.Mininet1 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700424 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800425 if not ( mininetResult and scapyResult ):
Devin Lim44075962017-08-11 10:56:37 -0700426 main.cleanAndExit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700427
Jeremy Songster17147f22016-05-31 18:30:52 -0700428 def CASE19( self, main ):
429 """
430 Copy the karaf.log files after each testcase cycle
431 """
Devin Lim58046fa2017-07-05 16:55:00 -0700432 try:
433 from tests.dependencies.utils import Utils
434 except ImportError:
435 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700436 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700437 try:
438 main.Utils
439 except ( NameError, AttributeError ):
440 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700441 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700442
You Wang84f981d2018-01-12 16:11:50 -0800443 def CASE100( self, main):
444 """
445 Connect to a physical network, assign controllers and start scapy
446 """
447 import time
448 main.case( "Connecting to physical network" )
449 main.step( "Connecting to physical network" )
450 main.OFProtocol = "1.3"
451 topoResult = main.NetworkBench.connectToNet()
452 utilities.assert_equals( expect=main.TRUE,
453 actual=topoResult,
454 onpass="Successfully loaded topology",
455 onfail="Failed to load topology" )
456 # Exit if topology did not load properly
457 if not topoResult:
458 main.cleanAndExit()
459
460 main.step( "Assign switches to controllers." )
461 assignResult = main.TRUE
462 switchList = []
463 for i in range( 1, ( main.numSwitch + 1 ) ):
464 switchList.append( 's' + str( i ) )
465 tempONOSip = main.Cluster.getIps()
466 assignResult = main.Network.assignSwController( sw=switchList,
467 ip=tempONOSip,
468 port="6653" )
469 utilities.assert_equals( expect=main.TRUE,
470 actual=assignResult,
471 onpass="Successfully assigned switches to controller",
472 onfail="Failed to assgin switches to controller" )
473
474 main.step( "Start scapy" )
475 scapyResult = main.TRUE
476 for hostName in main.scapyHostNames:
477 main.scapyHosts.append( getattr( main, hostName ) )
478
479 for host in main.scapyHosts:
480 host.startScapy()
481 host.updateSelf()
482 main.log.debug( host.name )
483 main.log.debug( host.hostIp )
484 main.log.debug( host.hostMac )
485
486 utilities.assert_equals( expect=main.TRUE, actual=scapyResult,
487 onpass="Successfully created Scapy Components",
488 onfail="Failed to discover Scapy Components" )
489
490 def CASE101( self, main ):
491 """
492 Stop Scapy on physical hosts
493 """
494 main.case( "Stop Scapy" )
495 main.step( "Stopping Scapy Hosts" )
496 scapyResult = main.TRUE
497 for host in main.scapyHosts:
498 host.stopScapy()
499 utilities.assert_equals( expect=main.TRUE, actual=scapyResult,
500 onpass="Successfully stopped scapy",
501 onfail="Failed to stop scapy" )
502
kelvin-onlabb769f562015-07-15 17:05:10 -0700503 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700504 """
505 Add host intents between 2 host:
506 - Discover hosts
507 - Add host intents
508 - Check intents
509 - Verify flows
510 - Ping hosts
511 - Reroute
512 - Link down
513 - Verify flows
514 - Check topology
515 - Ping hosts
516 - Link up
517 - Verify flows
518 - Check topology
519 - Ping hosts
520 - Remove intents
521 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700522 if main.initialized == main.FALSE:
523 main.log.error( "Test components did not start correctly, skipping further tests" )
524 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700525 # Assert variables - These variable's name|format must be followed
526 # if you want to use the wrapper function
527 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700528 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700529 assert main.numSwitch
530 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700531 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700532 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700533 main.initialized = main.FALSE
534 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700535
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800536 # Save leader candidates
Devin Lim142b5342017-07-20 15:22:39 -0700537 intentLeadersOld = main.Cluster.active( 0 ).CLI.leaderCandidates()
acsmarse6b410f2015-07-17 14:39:34 -0700538
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700539 main.testName = "Host Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700540 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700541 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700542 main.caseExplanation = "This test case tests Host intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -0700543 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700544 "Different type of hosts will be tested in " +\
545 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700546 "etc;\nThe test will use OF " + main.OFProtocol +\
547 " OVS running in Mininet and compile intents" +\
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700548 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700549
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700550 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700551 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700552 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
553 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800554 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700555 installResult = main.intents.installHostIntent( main,
556 name="IPV4",
557 onosNode=0,
558 host1=host1,
559 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800560 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700561 testResult = main.intents.testHostIntent( main,
562 name="IPV4",
563 intentId=installResult,
564 onosNode=0,
565 host1=host1,
566 host2=host2,
567 sw1="s5",
568 sw2="s2",
569 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800570 else:
Devin Lim142b5342017-07-20 15:22:39 -0700571 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800572
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700573 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800574 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700575 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700576 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700577
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700578 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700579 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall9c888672017-05-15 18:03:54 -0700580 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
Jon Hall78be4962017-05-23 14:53:53 -0700581 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1 " }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800582 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700583 installResult = main.intents.installHostIntent( main,
584 name="DUALSTACK",
585 onosNode=0,
586 host1=host1,
587 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800588
589 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700590 testResult = main.intents.testHostIntent( main,
591 name="DUALSTACK",
592 intentId=installResult,
593 onosNode=0,
594 host1=host1,
595 host2=host2,
596 sw1="s5",
597 sw2="s2",
598 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700599
600 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800601 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700602 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700603 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700604
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700605 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700606 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700607 host1 = { "name": "h1" }
608 host2 = { "name": "h11" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800609 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700610 installResult = main.intents.installHostIntent( main,
611 name="DUALSTACK2",
612 onosNode=0,
613 host1=host1,
614 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800615
616 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700617 testResult = main.intents.testHostIntent( main,
618 name="DUALSTACK2",
619 intentId=installResult,
620 onosNode=0,
621 host1=host1,
622 host2=host2,
623 sw1="s5",
624 sw2="s2",
625 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800626 else:
Devin Lim142b5342017-07-20 15:22:39 -0700627 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700628
629 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800630 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700631 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700632 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700633
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700634 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700635 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall9c888672017-05-15 18:03:54 -0700636 host1 = { "name": "h1" }
637 host2 = { "name": "h3" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800638 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700639 installResult = main.intents.installHostIntent( main,
640 name="1HOP",
641 onosNode=0,
642 host1=host1,
643 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800644
645 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700646 testResult = main.intents.testHostIntent( main,
647 name="1HOP",
648 intentId=installResult,
649 onosNode=0,
650 host1=host1,
651 host2=host2,
652 sw1="s5",
653 sw2="s2",
654 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800655 else:
Devin Lim142b5342017-07-20 15:22:39 -0700656 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700657
658 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800659 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700660 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700661 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700662
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700663 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700664 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700665 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlan": "100" }
666 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800667 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700668 installResult = main.intents.installHostIntent( main,
669 name="VLAN1",
670 onosNode=0,
671 host1=host1,
672 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800673 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700674 testResult = main.intents.testHostIntent( main,
675 name="VLAN1",
676 intentId=installResult,
677 onosNode=0,
678 host1=host1,
679 host2=host2,
680 sw1="s5",
681 sw2="s2",
682 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800683 else:
Devin Lim142b5342017-07-20 15:22:39 -0700684 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700685
686 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800687 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700688 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700689 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700690
Jeremy Songsterff553672016-05-12 17:06:23 -0700691 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
692 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall9c888672017-05-15 18:03:54 -0700693 host1 = { "name": "h5", "vlan": "200" }
694 host2 = { "name": "h12", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -0700695 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700696 installResult = main.intents.installHostIntent( main,
697 name="VLAN2",
698 onosNode=0,
699 host1=host1,
700 host2=host2 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700701
702 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700703 testResult = main.intents.testHostIntent( main,
704 name="VLAN2",
705 intentId=installResult,
706 onosNode=0,
707 host1=host1,
708 host2=host2,
709 sw1="s5",
710 sw2="s2",
711 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700712 else:
Devin Lim142b5342017-07-20 15:22:39 -0700713 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -0700714
715 utilities.assert_equals( expect=main.TRUE,
716 actual=testResult,
717 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700718 onfail=main.assertReturnString )
Jeremy Songsterff553672016-05-12 17:06:23 -0700719
Jeremy Songsterc032f162016-08-04 17:14:49 -0700720 main.step( "Encapsulation: Add host intents between h1 and h9" )
721 main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
Jon Hall9c888672017-05-15 18:03:54 -0700722 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
723 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -0700724 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700725 installResult = main.intents.installHostIntent( main,
726 name="ENCAPSULATION",
727 onosNode=0,
728 host1=host1,
729 host2=host2,
730 encap="VLAN" )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700731 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700732 testResult = main.intents.testHostIntent( main,
733 name="ENCAPSULATION",
734 intentId=installResult,
735 onosNode=0,
736 host1=host1,
737 host2=host2,
738 sw1="s5",
739 sw2="s2",
740 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700741 else:
Devin Lim142b5342017-07-20 15:22:39 -0700742 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700743
744 utilities.assert_equals( expect=main.TRUE,
745 actual=testResult,
746 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700747 onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700748
Jon Hall78be4962017-05-23 14:53:53 -0700749 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -0700750 # main.step( "Encapsulation: Add host intents between h1 and h9" )
751 # main.assertReturnString = "Assertion Result for MPLS Encapsulated host intent\n"
752 # host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
753 # host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
754 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700755 # installResult = main.intents.installHostIntent( main,
756 # name="ENCAPSULATION",
757 # onosNode=0,
758 # host1=host1,
759 # host2=host2,
760 # encap="MPLS" )
alison52b25892016-09-19 10:53:48 -0700761 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700762 # testResult = main.intents.testHostIntent( main,
763 # name="ENCAPSULATION",
764 # intentId=installResult,
765 # onosNode=0,
766 # host1=host1,
767 # host2=host2,
768 # sw1="s5",
769 # sw2="s2",
770 # expectedLink=18 )
alison52b25892016-09-19 10:53:48 -0700771 # else:
Devin Lim142b5342017-07-20 15:22:39 -0700772 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -0700773 #
774 # utilities.assert_equals( expect=main.TRUE,
775 # actual=testResult,
776 # onpass=main.assertReturnString,
777 # onfail=main.assertReturnString )
778
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700779 main.step( "Confirm that ONOS leadership is unchanged" )
Devin Lim142b5342017-07-20 15:22:39 -0700780 intentLeadersNew = main.Cluster.active( 0 ).CLI.leaderCandidates()
Jon Hall78be4962017-05-23 14:53:53 -0700781 testResult = main.intents.checkLeaderChange( intentLeadersOld,
782 intentLeadersNew )
acsmarse6b410f2015-07-17 14:39:34 -0700783
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800784 utilities.assert_equals( expect=main.TRUE,
785 actual=testResult,
786 onpass="ONOS Leaders Unchanged",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700787 onfail="ONOS Leader Mismatch" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800788
Jon Hall78be4962017-05-23 14:53:53 -0700789 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -0700790
kelvin-onlabb769f562015-07-15 17:05:10 -0700791 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700792 """
793 Add point intents between 2 hosts:
794 - Get device ids | ports
795 - Add point intents
796 - Check intents
797 - Verify flows
798 - Ping hosts
799 - Reroute
800 - Link down
801 - Verify flows
802 - Check topology
803 - Ping hosts
804 - Link up
805 - Verify flows
806 - Check topology
807 - Ping hosts
808 - Remove intents
809 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700810 if main.initialized == main.FALSE:
811 main.log.error( "Test components did not start correctly, skipping further tests" )
812 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700813 # Assert variables - These variable's name|format must be followed
814 # if you want to use the wrapper function
815 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700816 try:
Jeremyd9e4eb12016-04-13 12:09:06 -0700817 assert main.numSwitch
818 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -0700819 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700820 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700821 main.initialized = main.FALSE
822 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700823
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700824 main.testName = "Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -0700825 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700826 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700827 main.caseExplanation = "This test case will test point to point" +\
Devin Lim142b5342017-07-20 15:22:39 -0700828 " intents using " + str( main.Cluster.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700829 " node(s) cluster;\n" +\
830 "Different type of hosts will be tested in " +\
831 "each step such as IPV4, Dual stack, VLAN etc" +\
832 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -0700833 " OVS running in Mininet and compile intents" +\
834 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700835
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700836 # No option point intents
837 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700838 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800839 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700840 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800841 ]
842 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700843 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800844 ]
Jeremy42df2e72016-02-23 16:37:46 -0800845 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700846 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700847 main,
848 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800849 senders=senders,
850 recipients=recipients )
851
852 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700853 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800854 main,
855 intentId=installResult,
856 name="NOOPTION",
857 senders=senders,
858 recipients=recipients,
859 sw1="s5",
860 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700861 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800862 else:
Devin Lim142b5342017-07-20 15:22:39 -0700863 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700864
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700865 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800866 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700867 onpass=main.assertReturnString,
868 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700869
kelvin-onlabb769f562015-07-15 17:05:10 -0700870 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700871 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800872 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700873 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800874 ]
875 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700876 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800877 ]
Jeremy42df2e72016-02-23 16:37:46 -0800878 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700879 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700880 main,
881 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800882 senders=senders,
883 recipients=recipients,
884 ethType="IPV4" )
885
886 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700887 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800888 main,
889 intentId=installResult,
890 name="IPV4",
891 senders=senders,
892 recipients=recipients,
893 sw1="s5",
894 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700895 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800896 else:
Devin Lim142b5342017-07-20 15:22:39 -0700897 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700898
899 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800900 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700901 onpass=main.assertReturnString,
902 onfail=main.assertReturnString )
alisonda157272016-12-22 01:13:21 -0800903
Jon Hall78be4962017-05-23 14:53:53 -0700904 main.step( "Protected: Add point intents between h1 and h9" )
alisonda157272016-12-22 01:13:21 -0800905 main.assertReturnString = "Assertion Result for protected point intent\n"
906 senders = [
Jon Hall78be4962017-05-23 14:53:53 -0700907 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
alisonda157272016-12-22 01:13:21 -0800908 ]
909 recipients = [
Jon Hall78be4962017-05-23 14:53:53 -0700910 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
alisonda157272016-12-22 01:13:21 -0800911 ]
912 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700913 installResult = main.intents.installPointIntent(
alisonda157272016-12-22 01:13:21 -0800914 main,
915 name="Protected",
916 senders=senders,
917 recipients=recipients,
918 protected=True )
919
920 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700921 testResult = main.intents.testPointIntent(
alisonda157272016-12-22 01:13:21 -0800922 main,
923 name="Protected",
924 intentId=installResult,
925 senders=senders,
926 recipients=recipients,
927 sw1="s5",
928 sw2="s2",
929 protected=True,
930 expectedLink=18 )
931 else:
Devin Lim142b5342017-07-20 15:22:39 -0700932 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alisonda157272016-12-22 01:13:21 -0800933
934 utilities.assert_equals( expect=main.TRUE,
935 actual=testResult,
936 onpass=main.assertReturnString,
937 onfail=main.assertReturnString )
938
kelvin-onlabb769f562015-07-15 17:05:10 -0700939 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700940 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800941 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700942 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800943 ]
944 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700945 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800946 ]
Jeremy42df2e72016-02-23 16:37:46 -0800947 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700948 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700949 main,
950 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800951 senders=senders,
952 recipients=recipients,
953 ethType="IPV4" )
954
955 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700956 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800957 main,
958 intentId=installResult,
959 name="IPV4_2",
960 senders=senders,
961 recipients=recipients,
962 sw1="s5",
963 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700964 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800965 else:
Devin Lim142b5342017-07-20 15:22:39 -0700966 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700967
968 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800969 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700970 onpass=main.assertReturnString,
971 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700972
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700973 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700974 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800975 senders = [
Jon Hall9c888672017-05-15 18:03:54 -0700976 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700977 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800978 ]
979 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -0700980 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700981 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800982 ]
Jeremy6f000c62016-02-25 17:02:28 -0800983 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700984 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800985 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
986 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -0800987 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -0700988 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800989 main,
990 name="SDNIP-ICMP",
991 senders=senders,
992 recipients=recipients,
993 ethType="IPV4",
994 ipProto=ipProto,
995 tcpSrc=tcpSrc,
996 tcpDst=tcpDst )
997
998 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -0700999 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001000 main,
1001 intentId=installResult,
1002 name="SDNIP_ICMP",
1003 senders=senders,
1004 recipients=recipients,
1005 sw1="s5",
1006 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001007 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001008 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -08001009 else:
Devin Lim142b5342017-07-20 15:22:39 -07001010 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001011
1012 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001013 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001014 onpass=main.assertReturnString,
1015 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001016
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001017 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001018 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001019 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1020 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001021 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1022 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001023 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1024 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1025 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1026
Jon Hall78be4962017-05-23 14:53:53 -07001027 stepResult = main.intents.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001028 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001029 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001030 host1="h1",
1031 host2="h9",
1032 deviceId1="of:0000000000000005/1",
1033 deviceId2="of:0000000000000006/1",
1034 mac1=mac1,
1035 mac2=mac2,
1036 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001037 ipProto=ipProto,
1038 ip1=ip1,
1039 ip2=ip2,
1040 tcp1=tcp1,
1041 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001042
1043 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001044 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001045 onpass=main.assertReturnString,
1046 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001047
acsmars5d8cc862015-09-25 09:44:50 -07001048 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1049 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001050 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001051 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001052 ]
1053 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001054 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001055 ]
Jeremy42df2e72016-02-23 16:37:46 -08001056 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001057 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001058 main,
1059 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001060 senders=senders,
1061 recipients=recipients,
1062 ethType="IPV4" )
1063
1064 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001065 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001066 main,
1067 intentId=installResult,
1068 name="DUALSTACK1",
1069 senders=senders,
1070 recipients=recipients,
1071 sw1="s5",
1072 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001073 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001074 else:
Devin Lim142b5342017-07-20 15:22:39 -07001075 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001076
1077 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001078 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001079 onpass=main.assertReturnString,
1080 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001081
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001082 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001083 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001084 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001085 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001086 ]
1087 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001088 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001089 ]
Jeremy42df2e72016-02-23 16:37:46 -08001090 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001091 installResult = main.intents.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001092 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001093 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001094 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001095 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001096
1097 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001098 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001099 main,
1100 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001101 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001102 senders=senders,
1103 recipients=recipients,
1104 sw1="s5",
1105 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001106 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001107
1108 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001109 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001110 onpass=main.assertReturnString,
1111 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001112
Jeremy Songsterff553672016-05-12 17:06:23 -07001113 main.step( "VLAN: Add point intents between h5 and h21" )
1114 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1115 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001116 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001117 ]
1118 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001119 { "name": "h21", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001120 ]
1121 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001122 installResult = main.intents.installPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001123 main,
1124 name="VLAN2",
1125 senders=senders,
1126 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001127 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001128
1129 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001130 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001131 main,
1132 intentId=installResult,
1133 name="VLAN2",
1134 senders=senders,
1135 recipients=recipients,
1136 sw1="s5",
1137 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001138 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001139
1140 utilities.assert_equals( expect=main.TRUE,
1141 actual=testResult,
1142 onpass=main.assertReturnString,
1143 onfail=main.assertReturnString )
1144
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001145 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001146 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001147 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001148 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001149 ]
1150 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001151 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001152 ]
Jeremy42df2e72016-02-23 16:37:46 -08001153 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001154 installResult = main.intents.installPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001155 main,
1156 name="1HOP IPV4",
1157 senders=senders,
1158 recipients=recipients,
1159 ethType="IPV4" )
1160
1161 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001162 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001163 main,
1164 intentId=installResult,
1165 name="1HOP IPV4",
1166 senders=senders,
1167 recipients=recipients,
1168 sw1="s5",
1169 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001170 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001171 else:
Devin Lim142b5342017-07-20 15:22:39 -07001172 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001173
1174 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001175 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001176 onpass=main.assertReturnString,
1177 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001178
Jeremy Songsterc032f162016-08-04 17:14:49 -07001179 main.step( "Add point to point intents using VLAN Encapsulation" )
1180 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1181 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001182 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001183 ]
1184 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001185 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001186 ]
1187 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001188 installResult = main.intents.installPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001189 main,
1190 name="ENCAPSULATION",
1191 senders=senders,
1192 recipients=recipients,
1193 encap="VLAN" )
1194
1195 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001196 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001197 main,
1198 intentId=installResult,
1199 name="ENCAPSULATION",
1200 senders=senders,
1201 recipients=recipients,
1202 sw1="s5",
1203 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001204 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001205 else:
Devin Lim142b5342017-07-20 15:22:39 -07001206 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001207
1208 utilities.assert_equals( expect=main.TRUE,
1209 actual=testResult,
1210 onpass=main.assertReturnString,
1211 onfail=main.assertReturnString )
1212
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001213 main.step( "BANDWIDTH ALLOCATION: Checking bandwidth allocation for point intents between h1 and h9" )
1214 main.assertReturnString = "Assertion Result for BANDWIDTH ALLOCATION for point intent\n"
1215 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001216 { "name": "h1", "device": "of:0000000000000005/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001217 ]
1218 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001219 { "name": "h9", "device": "of:0000000000000006/1" }
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001220 ]
1221 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001222 installResult = main.intents.installPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001223 main,
1224 name="NOOPTION",
1225 senders=senders,
1226 recipients=recipients,
Jon Hallf539eb92017-05-22 17:18:42 -07001227 bandwidth=100 )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001228
1229 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001230 testResult = main.intents.testPointIntent(
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001231 main,
1232 intentId=installResult,
1233 name="NOOPTION",
1234 senders=senders,
1235 recipients=recipients,
1236 sw1="s5",
1237 sw2="s2",
1238 expectedLink=18 )
1239 else:
Devin Lim142b5342017-07-20 15:22:39 -07001240 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001241
1242 utilities.assert_equals( expect=main.TRUE,
1243 actual=testResult,
1244 onpass=main.assertReturnString,
1245 onfail=main.assertReturnString )
1246
Jon Hall78be4962017-05-23 14:53:53 -07001247 # Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
alison52b25892016-09-19 10:53:48 -07001248 # main.step( "Add point to point intents using MPLS Encapsulation" )
1249 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1250 # senders = [
1251 # { "name": "h1", "device": "of:0000000000000005/1" }
1252 # ]
1253 # recipients = [
1254 # { "name": "h9", "device": "of:0000000000000006/1" }
1255 # ]
1256 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001257 # installResult = main.intents.installPointIntent(
alison52b25892016-09-19 10:53:48 -07001258 # main,
1259 # name="ENCAPSULATION",
1260 # senders=senders,
1261 # recipients=recipients,
1262 # encap="MPLS" )
1263 #
1264 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001265 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001266 # main,
1267 # intentId=installResult,
1268 # name="ENCAPSULATION",
1269 # senders=senders,
1270 # recipients=recipients,
1271 # sw1="s5",
1272 # sw2="s2",
1273 # expectedLink=18 )
1274 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001275 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001276 #
1277 # utilities.assert_equals( expect=main.TRUE,
1278 # actual=testResult,
1279 # onpass=main.assertReturnString,
1280 # onfail=main.assertReturnString )
1281
Jon Hall78be4962017-05-23 14:53:53 -07001282 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001283
kelvin-onlabb769f562015-07-15 17:05:10 -07001284 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001285 """
1286 Add single point to multi point intents
1287 - Get device ids
1288 - Add single point to multi point intents
1289 - Check intents
1290 - Verify flows
1291 - Ping hosts
1292 - Reroute
1293 - Link down
1294 - Verify flows
1295 - Check topology
1296 - Ping hosts
1297 - Link up
1298 - Verify flows
1299 - Check topology
1300 - Ping hosts
1301 - Remove intents
1302 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001303 if main.initialized == main.FALSE:
1304 main.log.error( "Test components did not start correctly, skipping further tests" )
1305 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001306 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001307 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001308 assert main.numSwitch
1309 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001310 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001311 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001312 main.initialized = main.FALSE
1313 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001314
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001315 main.testName = "Single to Multi Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001316 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001317 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001318 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001319 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001320 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001321 "Different type of hosts will be tested in " +\
1322 "each step such as IPV4, Dual stack, VLAN etc" +\
1323 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001324 " OVS running in Mininet and compile intents" +\
1325 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001326
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001327 main.step( "NOOPTION: Install and test single point to multi point intents" )
1328 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1329 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001330 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001331 ]
1332 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001333 { "name": "h16", "device": "of:0000000000000006/8" },
1334 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001335 ]
Jon Hall9c888672017-05-15 18:03:54 -07001336 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1337 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001338 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001339 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001340 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001341 name="NOOPTION",
1342 senders=senders,
1343 recipients=recipients,
1344 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001345 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001346
1347 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001348 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001349 main,
1350 intentId=installResult,
1351 name="NOOPTION",
1352 senders=senders,
1353 recipients=recipients,
1354 badSenders=badSenders,
1355 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001356 sw1="s5",
1357 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001358 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001359 else:
Devin Lim142b5342017-07-20 15:22:39 -07001360 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001361
1362 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001363 actual=testResult,
1364 onpass=main.assertReturnString,
1365 onfail=main.assertReturnString )
1366
1367 main.step( "IPV4: Install and test single point to multi point intents" )
1368 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1369 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001370 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001371 ]
1372 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001373 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1374 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001375 ]
Jon Hall9c888672017-05-15 18:03:54 -07001376 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1377 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001378 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001379 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001380 main,
1381 name="IPV4",
1382 senders=senders,
1383 recipients=recipients,
1384 ethType="IPV4",
1385 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001386 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001387
1388 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001389 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001390 main,
1391 intentId=installResult,
1392 name="IPV4",
1393 senders=senders,
1394 recipients=recipients,
1395 badSenders=badSenders,
1396 badRecipients=badRecipients,
1397 sw1="s5",
1398 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001399 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001400 else:
Devin Lim142b5342017-07-20 15:22:39 -07001401 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001402
1403 utilities.assert_equals( expect=main.TRUE,
1404 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001405 onpass=main.assertReturnString,
1406 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001407
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001408 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001409 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 -08001410 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001411 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001412 ]
1413 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001414 { "name": "h16", "device": "of:0000000000000006/8" },
1415 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001416 ]
Jon Hall9c888672017-05-15 18:03:54 -07001417 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1418 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001419 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001420 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001421 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001422 name="IPV4_2",
1423 senders=senders,
1424 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001425 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001426 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001427 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001428
1429 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001430 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001431 main,
1432 intentId=installResult,
1433 name="IPV4_2",
1434 senders=senders,
1435 recipients=recipients,
1436 badSenders=badSenders,
1437 badRecipients=badRecipients,
1438 sw1="s5",
1439 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001440 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001441 else:
Devin Lim142b5342017-07-20 15:22:39 -07001442 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001443
1444 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001445 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001446 onpass=main.assertReturnString,
1447 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001448
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001449 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001450 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 -08001451 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001452 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001453 ]
1454 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001455 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1456 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001457 ]
Jon Hall9c888672017-05-15 18:03:54 -07001458 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1459 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001460 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001461 installResult = main.intents.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001462 main,
alison52b25892016-09-19 10:53:48 -07001463 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001464 senders=senders,
1465 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001466 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001467 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001468
1469 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001470 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001471 main,
1472 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001473 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001474 senders=senders,
1475 recipients=recipients,
1476 badSenders=badSenders,
1477 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001478 sw1="s5",
1479 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001480 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001481 else:
Devin Lim142b5342017-07-20 15:22:39 -07001482 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001483
1484 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001485 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001486 onpass=main.assertReturnString,
1487 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001488
Jeremy Songsterff553672016-05-12 17:06:23 -07001489 main.step( "VLAN: Add single point to multi point intents" )
1490 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1491 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001492 { "name": "h5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001493 ]
1494 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001495 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1496 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001497 ]
Jon Hall9c888672017-05-15 18:03:54 -07001498 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1499 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001500 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001501 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001502 main,
1503 name="VLAN2",
1504 senders=senders,
1505 recipients=recipients,
1506 sw1="s5",
1507 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001508 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001509
1510 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001511 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001512 main,
1513 intentId=installResult,
1514 name="VLAN2",
1515 senders=senders,
1516 recipients=recipients,
1517 badSenders=badSenders,
1518 badRecipients=badRecipients,
1519 sw1="s5",
1520 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001521 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001522 else:
Devin Lim142b5342017-07-20 15:22:39 -07001523 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -07001524
1525 utilities.assert_equals( expect=main.TRUE,
1526 actual=testResult,
1527 onpass=main.assertReturnString,
1528 onfail=main.assertReturnString )
1529
alison52b25892016-09-19 10:53:48 -07001530 # Does not support Single point to multi point encapsulation
1531 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1532 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1533 # senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001534 # { "name": "h8", "device": "of:0000000000000005/8" }
alison52b25892016-09-19 10:53:48 -07001535 # ]
1536 # recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001537 # { "name": "h16", "device": "of:0000000000000006/8" },
1538 # { "name": "h24", "device": "of:0000000000000007/8" }
alison52b25892016-09-19 10:53:48 -07001539 # ]
Jon Hall9c888672017-05-15 18:03:54 -07001540 # badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1541 # badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
alison52b25892016-09-19 10:53:48 -07001542 # testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001543 # installResult = main.intents.installSingleToMultiIntent(
alison52b25892016-09-19 10:53:48 -07001544 # main,
1545 # name="ENCAPSULATION",
1546 # senders=senders,
1547 # recipients=recipients,
1548 # sw1="s5",
1549 # sw2="s2",
1550 # encap="VLAN" )
1551 #
1552 # if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001553 # testResult = main.intents.testPointIntent(
alison52b25892016-09-19 10:53:48 -07001554 # main,
1555 # intentId=installResult,
1556 # name="ENCAPSULATION",
1557 # senders=senders,
1558 # recipients=recipients,
1559 # badSenders=badSenders,
1560 # badRecipients=badRecipients,
1561 # sw1="s5",
1562 # sw2="s2",
1563 # expectedLink=18 )
1564 # else:
Devin Lim142b5342017-07-20 15:22:39 -07001565 # main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07001566 #
1567 # utilities.assert_equals( expect=main.TRUE,
1568 # actual=testResult,
1569 # onpass=main.assertReturnString,
1570 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001571
Jon Hall78be4962017-05-23 14:53:53 -07001572 main.intents.report( main )
kelvin-onlab016dce22015-08-10 09:54:11 -07001573
kelvin-onlabb769f562015-07-15 17:05:10 -07001574 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001575 """
1576 Add multi point to single point intents
1577 - Get device ids
1578 - Add multi point to single point intents
1579 - Check intents
1580 - Verify flows
1581 - Ping hosts
1582 - Reroute
1583 - Link down
1584 - Verify flows
1585 - Check topology
1586 - Ping hosts
1587 - Link up
1588 - Verify flows
1589 - Check topology
1590 - Ping hosts
1591 - Remove intents
1592 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001593 if main.initialized == main.FALSE:
1594 main.log.error( "Test components did not start correctly, skipping further tests" )
1595 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001596 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001597 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001598 assert main.numSwitch
1599 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001600 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001601 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001602 main.initialized = main.FALSE
1603 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001604
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001605 main.testName = "Multi To Single Point Intents"
Devin Lim142b5342017-07-20 15:22:39 -07001606 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001607 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001608 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001609 " multi point intents using " +\
Devin Lim142b5342017-07-20 15:22:39 -07001610 str( main.Cluster.numCtrls ) + " node(s) cluster;\n" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001611 "Different type of hosts will be tested in " +\
1612 "each step such as IPV4, Dual stack, VLAN etc" +\
1613 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001614 " OVS running in Mininet and compile intents" +\
1615 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001616
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001617 main.step( "NOOPTION: Add multi point to single point intents" )
1618 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1619 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001620 { "name": "h16", "device": "of:0000000000000006/8" },
1621 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001622 ]
1623 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001624 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001625 ]
Jon Hall9c888672017-05-15 18:03:54 -07001626 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1627 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001628 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001629 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001630 main,
1631 name="NOOPTION",
1632 senders=senders,
1633 recipients=recipients,
1634 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001635 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001636
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001637 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001638 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001639 main,
1640 intentId=installResult,
1641 name="NOOPTION",
1642 senders=senders,
1643 recipients=recipients,
1644 badSenders=badSenders,
1645 badRecipients=badRecipients,
1646 sw1="s5",
1647 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001648 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001649 else:
Devin Lim142b5342017-07-20 15:22:39 -07001650 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001651
1652 utilities.assert_equals( expect=main.TRUE,
1653 actual=testResult,
1654 onpass=main.assertReturnString,
1655 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001656
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001657 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001658 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 -08001659 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001660 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1661 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001662 ]
1663 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001664 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001665 ]
Jon Hall9c888672017-05-15 18:03:54 -07001666 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1667 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001668 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001669 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001670 main,
1671 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001672 senders=senders,
1673 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001674 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001675 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001676 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001677
1678 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001679 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001680 main,
1681 intentId=installResult,
1682 name="IPV4",
1683 senders=senders,
1684 recipients=recipients,
1685 badSenders=badSenders,
1686 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001687 sw1="s5",
1688 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001689 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001690 else:
Devin Lim142b5342017-07-20 15:22:39 -07001691 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001692
1693 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001694 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001695 onpass=main.assertReturnString,
1696 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001697
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001698 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001699 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 -08001700 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001701 { "name": "h16", "device": "of:0000000000000006/8" },
1702 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001703 ]
1704 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001705 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001706 ]
Jon Hall9c888672017-05-15 18:03:54 -07001707 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1708 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001709 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001710 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001711 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001712 name="IPV4_2",
1713 senders=senders,
1714 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001715 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001716 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001717 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001718
1719 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001720 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001721 main,
1722 intentId=installResult,
1723 name="IPV4_2",
1724 senders=senders,
1725 recipients=recipients,
1726 badSenders=badSenders,
1727 badRecipients=badRecipients,
1728 sw1="s5",
1729 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001730 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001731 else:
Devin Lim142b5342017-07-20 15:22:39 -07001732 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001733
1734 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001735 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001736 onpass=main.assertReturnString,
1737 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001738
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001739 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001740 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 -08001741 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001742 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1743 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001744 ]
1745 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001746 { "name": "h5", "device": "of:0000000000000005/5", "vlan": "200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001747 ]
Jon Hall9c888672017-05-15 18:03:54 -07001748 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1749 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001750 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001751 installResult = main.intents.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001752 main,
1753 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001754 senders=senders,
1755 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001756 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001757 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001758
1759 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001760 testResult = main.intents.testPointIntent(
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001761 main,
1762 intentId=installResult,
1763 name="VLAN",
1764 senders=senders,
1765 recipients=recipients,
1766 badSenders=badSenders,
1767 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001768 sw1="s5",
1769 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001770 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001771 else:
Devin Lim142b5342017-07-20 15:22:39 -07001772 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001773
1774 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001775 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001776 onpass=main.assertReturnString,
1777 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001778
Jeremy Songsterff553672016-05-12 17:06:23 -07001779 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1780 main.step( "VLAN: Add multi point to single point intents" )
1781 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1782 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001783 { "name": "h13", "device": "of:0000000000000006/5", "vlan": "200" },
1784 { "name": "h21", "device": "of:0000000000000007/5", "vlan": "200" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001785 ]
1786 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001787 { "name": "h4", "vlan": "100" }
Jeremy Songsterff553672016-05-12 17:06:23 -07001788 ]
Jon Hall9c888672017-05-15 18:03:54 -07001789 badSenders = [ { "name": "h12" } ] # Senders that are not in the intent
1790 badRecipients = [ { "name": "h20" } ] # Recipients that are not in the intent
Jeremy Songsterff553672016-05-12 17:06:23 -07001791 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001792 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001793 main,
1794 name="VLAN2",
1795 senders=senders,
1796 recipients=recipients,
1797 sw1="s5",
1798 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001799 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001800
1801 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001802 testResult = main.intents.testPointIntent(
Jeremy Songsterff553672016-05-12 17:06:23 -07001803 main,
1804 intentId=installResult,
1805 name="VLAN2",
1806 senders=senders,
1807 recipients=recipients,
1808 badSenders=badSenders,
1809 badRecipients=badRecipients,
1810 sw1="s5",
1811 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001812 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001813 else:
Devin Lim142b5342017-07-20 15:22:39 -07001814 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterff553672016-05-12 17:06:23 -07001815
1816 utilities.assert_equals( expect=main.TRUE,
1817 actual=testResult,
1818 onpass=main.assertReturnString,
1819 onfail=main.assertReturnString )
1820
Jeremy Songsterc032f162016-08-04 17:14:49 -07001821 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1822 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
1823 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07001824 { "name": "h16", "device": "of:0000000000000006/8" },
1825 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001826 ]
1827 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07001828 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songsterc032f162016-08-04 17:14:49 -07001829 ]
Jon Hall9c888672017-05-15 18:03:54 -07001830 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1831 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
Jeremy Songsterc032f162016-08-04 17:14:49 -07001832 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001833 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001834 main,
1835 name="ENCAPSULATION",
1836 senders=senders,
1837 recipients=recipients,
1838 sw1="s5",
1839 sw2="s2",
1840 encap="VLAN" )
1841
1842 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001843 testResult = main.intents.testPointIntent(
Jeremy Songsterc032f162016-08-04 17:14:49 -07001844 main,
1845 intentId=installResult,
1846 name="ENCAPSULATION",
1847 senders=senders,
1848 recipients=recipients,
1849 badSenders=badSenders,
1850 badRecipients=badRecipients,
1851 sw1="s5",
1852 sw2="s2",
1853 expectedLink=18 )
1854 else:
Devin Lim142b5342017-07-20 15:22:39 -07001855 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001856
1857 utilities.assert_equals( expect=main.TRUE,
1858 actual=testResult,
1859 onpass=main.assertReturnString,
1860 onfail=main.assertReturnString )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001861 """
1862 Testing MPLS would require kernel version of 4.1 or higher ( Current version is 3.13 )
1863 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1864 main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
1865 senders = [
1866 { "name": "h16", "device": "of:0000000000000006/8" },
1867 { "name": "h24", "device": "of:0000000000000007/8" }
1868 ]
1869 recipients = [
1870 { "name": "h8", "device": "of:0000000000000005/8" }
1871 ]
1872 badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
1873 badRecipients = [ { "name": "h9" } ] # Recipients that are not in the intent
1874 testResult = main.FALSE
1875 installResult = main.intents.installMultiToSingleIntent(
1876 main,
1877 name="ENCAPSULATION",
1878 senders=senders,
1879 recipients=recipients,
1880 sw1="s5",
1881 sw2="s2",
1882 encap="MPLS" )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001883
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001884 if installResult:
1885 testResult = main.intents.testPointIntent(
1886 main,
1887 intentId=installResult,
1888 name="ENCAPSULATION",
1889 senders=senders,
1890 recipients=recipients,
1891 badSenders=badSenders,
1892 badRecipients=badRecipients,
1893 sw1="s5",
1894 sw2="s2",
1895 expectedLink=18 )
1896 else:
1897 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
1898
1899 utilities.assert_equals( expect=main.TRUE,
1900 actual=testResult,
1901 onpass=main.assertReturnString,
1902 onfail=main.assertReturnString )
1903 """
alison52b25892016-09-19 10:53:48 -07001904
Jon Hall78be4962017-05-23 14:53:53 -07001905 main.intents.report( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001906
acsmars1ff5e052015-07-23 11:27:48 -07001907 def CASE5000( self, main ):
1908 """
acsmars5d8cc862015-09-25 09:44:50 -07001909 Tests Host Mobility
1910 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001911 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001912 if main.initialized == main.FALSE:
1913 main.log.error( "Test components did not start correctly, skipping further tests" )
1914 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001915 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001916 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001917 assert main.numSwitch
1918 except AssertionError:
Jon Hall78be4962017-05-23 14:53:53 -07001919 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001920 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001921 main.initialized = main.FALSE
1922 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001923 main.case( "Test host mobility with host intents " + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001924 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001925 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001926
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001927 main.log.info( "Moving h1 from s5 to s6" )
You Wanga0f6ff62018-01-11 15:46:30 -08001928 main.Network.moveHost( "h1", "s5", "s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001929
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001930 # Send discovery ping from moved host
1931 # Moving the host brings down the default interfaces and creates a new one.
1932 # Scapy is restarted on this host to detect the new interface
1933 main.h1.stopScapy()
1934 main.h1.startScapy()
1935
1936 # Discover new host location in ONOS and populate host data.
1937 # Host 1 IP and MAC should be unchanged
Jon Hall78be4962017-05-23 14:53:53 -07001938 main.intents.sendDiscoveryArp( main, [ main.h1 ] )
1939 main.intents.populateHostData( main )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001940
acsmars1ff5e052015-07-23 11:27:48 -07001941 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1942
1943 utilities.assert_equals( expect="of:0000000000000006",
1944 actual=h1PostMove,
1945 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001946 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001947 " to single point intents" +
1948 " with IPV4 type and MAC addresses" +
1949 " in the same VLAN" )
1950
1951 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001952 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall9c888672017-05-15 18:03:54 -07001953 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1954 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001955 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07001956 installResult = main.intents.installHostIntent( main,
1957 name="IPV4 Mobility IPV4",
1958 onosNode=0,
1959 host1=host1,
1960 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001961 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07001962 testResult = main.intents.testHostIntent( main,
1963 name="Host Mobility IPV4",
1964 intentId=installResult,
1965 onosNode=0,
1966 host1=host1,
1967 host2=host2,
1968 sw1="s6",
1969 sw2="s2",
1970 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001971 else:
Devin Lim142b5342017-07-20 15:22:39 -07001972 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001973
1974 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001975 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001976 onpass=main.assertReturnString,
1977 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001978
Jon Hall78be4962017-05-23 14:53:53 -07001979 main.intents.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001980
1981 def CASE6000( self, main ):
1982 """
1983 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1984 """
Jeremy Songster9385d412016-06-02 17:57:36 -07001985 # At some later point discussion on this behavior in MPSP and SPMP intents
1986 # will be reoppened and this test case may need to be updated to reflect
1987 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07001988 if main.initialized == main.FALSE:
1989 main.log.error( "Test components did not start correctly, skipping further tests" )
1990 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001991 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001992 try:
Jeremyd9e4eb12016-04-13 12:09:06 -07001993 assert main.numSwitch
1994 except AssertionError:
alison52b25892016-09-19 10:53:48 -07001995 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001996 main.initialized = main.FALSE
1997 main.skipCase()
Devin Lim142b5342017-07-20 15:22:39 -07001998 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.Cluster.numCtrls ) +
alison52b25892016-09-19 10:53:48 -07001999 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07002000 main.step( "Installing Multi to Single Point intents with no options set" )
2001 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2002 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002003 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002004 { "name": "h16", "device": "of:0000000000000006/8" },
2005 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002006 ]
2007 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002008 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002009 ]
2010 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07002011 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002012 ]
2013 isolatedRecipients = []
2014 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002015 installResult = main.intents.installMultiToSingleIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08002016 main,
2017 name="NOOPTION",
2018 senders=senders,
2019 recipients=recipients,
2020 sw1="s5",
2021 sw2="s2" )
2022
2023 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002024 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08002025 main,
2026 intentId=installResult,
2027 name="NOOPTION",
2028 senders=senders,
2029 recipients=recipients,
2030 isolatedSenders=isolatedSenders,
2031 isolatedRecipients=isolatedRecipients,
2032 sw1="s6",
2033 sw2="s2",
2034 sw3="s4",
2035 sw4="s1",
2036 sw5="s3",
2037 expectedLink1=16,
2038 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002039 else:
Devin Lim142b5342017-07-20 15:22:39 -07002040 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002041
2042 utilities.assert_equals( expect=main.TRUE,
2043 actual=testResult,
2044 onpass=main.assertReturnString,
2045 onfail=main.assertReturnString )
2046
Jeremy Songster9385d412016-06-02 17:57:36 -07002047 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2048
2049 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2050 "with partial failures allowed\n"
2051 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002052 { "name": "h16", "device": "of:0000000000000006/8" },
2053 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002054 ]
2055 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002056 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002057 ]
2058 isolatedSenders = [
Jon Hall9c888672017-05-15 18:03:54 -07002059 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002060 ]
2061 isolatedRecipients = []
2062 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002063 installResult = main.intents.installMultiToSingleIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002064 main,
2065 name="NOOPTION",
2066 senders=senders,
2067 recipients=recipients,
2068 sw1="s5",
2069 sw2="s2",
2070 partial=True )
2071
2072 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002073 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002074 main,
2075 intentId=installResult,
2076 name="NOOPTION",
2077 senders=senders,
2078 recipients=recipients,
2079 isolatedSenders=isolatedSenders,
2080 isolatedRecipients=isolatedRecipients,
2081 sw1="s6",
2082 sw2="s2",
2083 sw3="s4",
2084 sw4="s1",
2085 sw5="s3",
2086 expectedLink1=16,
2087 expectedLink2=14,
2088 partial=True )
2089 else:
Devin Lim142b5342017-07-20 15:22:39 -07002090 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002091
2092 utilities.assert_equals( expect=main.TRUE,
2093 actual=testResult,
2094 onpass=main.assertReturnString,
2095 onfail=main.assertReturnString )
2096
Jeremye0cb5eb2016-01-27 17:39:09 -08002097 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002098 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2099 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002100 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002101 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002102 ]
2103 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002104 { "name": "h16", "device": "of:0000000000000006/8" },
2105 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002106 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002107 isolatedSenders = []
2108 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002109 { "name": "h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002110 ]
2111 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002112 installResult = main.intents.installSingleToMultiIntent(
Jeremye0cb5eb2016-01-27 17:39:09 -08002113 main,
2114 name="NOOPTION",
2115 senders=senders,
2116 recipients=recipients,
2117 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002118 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002119
2120 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002121 testResult = main.intents.testEndPointFail(
Jeremye0cb5eb2016-01-27 17:39:09 -08002122 main,
2123 intentId=installResult,
2124 name="NOOPTION",
2125 senders=senders,
2126 recipients=recipients,
2127 isolatedSenders=isolatedSenders,
2128 isolatedRecipients=isolatedRecipients,
2129 sw1="s6",
2130 sw2="s2",
2131 sw3="s4",
2132 sw4="s1",
2133 sw5="s3",
2134 expectedLink1=16,
2135 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002136 else:
Devin Lim142b5342017-07-20 15:22:39 -07002137 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002138
2139 utilities.assert_equals( expect=main.TRUE,
2140 actual=testResult,
2141 onpass=main.assertReturnString,
2142 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002143 # Right now this functionality doesn't work properly in SPMP intents
Jon Hall78be4962017-05-23 14:53:53 -07002144 main.step( "NOOPTION: Install and test single point to multi point " +
Jeremy Songster9385d412016-06-02 17:57:36 -07002145 "intents with partial failures allowed" )
2146 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2147 "point intent with partial failures allowed\n"
2148 senders = [
Jon Hall9c888672017-05-15 18:03:54 -07002149 { "name": "h8", "device": "of:0000000000000005/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002150 ]
2151 recipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002152 { "name": "h16", "device": "of:0000000000000006/8" },
2153 { "name": "h24", "device": "of:0000000000000007/8" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002154 ]
2155 isolatedSenders = []
2156 isolatedRecipients = [
Jon Hall9c888672017-05-15 18:03:54 -07002157 { "name": "h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002158 ]
2159 testResult = main.FALSE
Jon Hall78be4962017-05-23 14:53:53 -07002160 installResult = main.intents.installSingleToMultiIntent(
Jeremy Songster9385d412016-06-02 17:57:36 -07002161 main,
2162 name="NOOPTION",
2163 senders=senders,
2164 recipients=recipients,
2165 sw1="s5",
2166 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002167 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002168
2169 if installResult:
Jon Hall78be4962017-05-23 14:53:53 -07002170 testResult = main.intents.testEndPointFail(
Jeremy Songster9385d412016-06-02 17:57:36 -07002171 main,
2172 intentId=installResult,
2173 name="NOOPTION",
2174 senders=senders,
2175 recipients=recipients,
2176 isolatedSenders=isolatedSenders,
2177 isolatedRecipients=isolatedRecipients,
2178 sw1="s6",
2179 sw2="s2",
2180 sw3="s4",
2181 sw4="s1",
2182 sw5="s3",
2183 expectedLink1=16,
2184 expectedLink2=14,
2185 partial=True )
2186 else:
Devin Lim142b5342017-07-20 15:22:39 -07002187 main.Cluster.active( 0 ).CLI.removeAllIntents( purge=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002188
2189 utilities.assert_equals( expect=main.TRUE,
2190 actual=testResult,
2191 onpass=main.assertReturnString,
2192 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002193
Jon Hall78be4962017-05-23 14:53:53 -07002194 main.intents.report( main )