blob: 0daf07466baaf54e47aac3336ea95525571ca34b [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 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"""
Jon Hall1efcb3f2016-08-23 13:42:15 -070021import os
22import imp
23import time
24import json
25import urllib
26from core import utilities
27
28
29class Testcaselib:
Pierfb719b12016-09-19 14:51:44 -070030
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070031 useSSH = True
Pierfb719b12016-09-19 14:51:44 -070032
Jon Hall1efcb3f2016-08-23 13:42:15 -070033 @staticmethod
34 def initTest( main ):
35 """
36 - Construct tests variables
37 - GIT ( optional )
38 - Checkout ONOS master branch
39 - Pull latest ONOS code
40 - Building ONOS ( optional )
41 - Install ONOS package
42 - Build ONOS package
43 """
Devin Lim58046fa2017-07-05 16:55:00 -070044 try:
45 from tests.dependencies.ONOSSetup import ONOSSetup
46 main.testSetUp = ONOSSetup()
47 except ImportError:
48 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070049 main.cleanAndExit()
You Wangd5873482018-01-24 12:30:00 -080050 from tests.dependencies.Network import Network
51 main.Network = Network()
Devin Lim0c972b72018-02-08 14:53:59 -080052 main.testSetUp.envSetupDescription( False )
Devin Lim58046fa2017-07-05 16:55:00 -070053 stepResult = main.FALSE
54 try:
55 main.step( "Constructing test variables" )
56 # Test variables
57 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
58 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Devin Lim58046fa2017-07-05 16:55:00 -070059 main.path = os.path.dirname( main.testFile )
Devin Lim57221b02018-02-14 15:45:36 -080060 main.useCommonTopo = main.params[ 'DEPENDENCY' ][ 'useCommonTopo' ] == 'True'
61 main.topoPath = main.path + ( "/.." if main.useCommonTopo else "" ) + "/dependencies/"
62 main.useCommonConf = main.params[ 'DEPENDENCY' ][ 'useCommonConf' ] == 'True'
63 main.configPath = main.path + ( "/.." if main.useCommonConf else "" ) + "/dependencies/"
64 main.forJson = "json/"
65 main.forChart = "chart/"
66 main.forConfig = "conf/"
67 main.forHost = "host/"
You Wang27317572018-03-06 12:13:11 -080068 main.forSwitchFailure = "switchFailure/"
Andreas Pantelopoulosfab6bf32018-03-06 18:56:35 -080069 main.forLinkFailure = "linkFailure/"
You Wange24d6272018-03-27 21:18:50 -070070 main.forMulticast = "multicast/"
Devin Lim58046fa2017-07-05 16:55:00 -070071 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
You Wangd87b2312018-01-30 12:47:17 -080072 main.topologyLib = main.params[ 'DEPENDENCY' ][ 'lib' ] if 'lib' in main.params[ 'DEPENDENCY' ] else None
73 main.topologyConf = main.params[ 'DEPENDENCY' ][ 'conf' ] if 'conf' in main.params[ 'DEPENDENCY' ] else None
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070074 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
Devin Lim58046fa2017-07-05 16:55:00 -070075 main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
Jon Hall1efcb3f2016-08-23 13:42:15 -070076
Devin Lim0c972b72018-02-08 14:53:59 -080077 stepResult = main.testSetUp.envSetup( False )
Devin Lim58046fa2017-07-05 16:55:00 -070078 except Exception as e:
79 main.testSetUp.envSetupException( e )
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070080
Devin Lim58046fa2017-07-05 16:55:00 -070081 main.testSetUp.evnSetupConclusion( stepResult )
Jon Hall1efcb3f2016-08-23 13:42:15 -070082
Jon Hall1efcb3f2016-08-23 13:42:15 -070083 @staticmethod
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080084 def installOnos( main, vlanCfg=True, skipPackage=False, cliSleep=10,
85 parallel=True ):
Jon Hall1efcb3f2016-08-23 13:42:15 -070086 """
87 - Set up cell
88 - Create cell file
89 - Set cell file
90 - Verify cell file
91 - Kill ONOS process
92 - Uninstall ONOS cluster
93 - Verify ONOS start up
94 - Install ONOS cluster
95 - Connect to cli
96 """
97 # main.scale[ 0 ] determines the current number of ONOS controller
You Wangd87b2312018-01-30 12:47:17 -080098 if not main.apps:
Jon Hall1efcb3f2016-08-23 13:42:15 -070099 main.log.error( "App list is empty" )
Jon Hall3c910162018-03-07 14:42:16 -0800100 main.log.info( "Cluster size: " + str( main.Cluster.numCtrls ) )
101 main.log.info( "Cluster ips: " + ', '.join( main.Cluster.getIps() ) )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700102 main.dynamicHosts = [ 'in1', 'out1' ]
You Wanga0f6ff62018-01-11 15:46:30 -0800103 main.testSetUp.ONOSSetUp( main.Cluster, newCell=True, cellName=main.cellName,
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -0800104 skipPack=skipPackage,
105 useSSH=Testcaselib.useSSH,
Devin Lim0c972b72018-02-08 14:53:59 -0800106 installParallel=parallel, includeCaseDesc=False )
Devin Lim142b5342017-07-20 15:22:39 -0700107 ready = utilities.retry( main.Cluster.active( 0 ).CLI.summary,
108 main.FALSE,
You Wang1cdc5f52017-12-19 16:47:51 -0800109 sleep=cliSleep,
Devin Lim142b5342017-07-20 15:22:39 -0700110 attempts=10 )
111 if ready:
112 ready = main.TRUE
113 utilities.assert_equals( expect=main.TRUE, actual=ready,
Jon Hall1efcb3f2016-08-23 13:42:15 -0700114 onpass="ONOS summary command succeded",
115 onfail="ONOS summary command failed" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700116 if not ready:
117 main.log.error( "ONOS startup failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700118 main.cleanAndExit()
Jon Hall1efcb3f2016-08-23 13:42:15 -0700119
Devin Lim142b5342017-07-20 15:22:39 -0700120 for ctrl in main.Cluster.active():
121 ctrl.CLI.logSet( "DEBUG", "org.onosproject.segmentrouting" )
You Wangf5f104f2018-03-30 17:09:10 -0700122 ctrl.CLI.logSet( "DEBUG", "org.onosproject.driver" )
Devin Lim142b5342017-07-20 15:22:39 -0700123 ctrl.CLI.logSet( "DEBUG", "org.onosproject.net.flowobjective.impl" )
You Wangf5f104f2018-03-30 17:09:10 -0700124 ctrl.CLI.logSet( "DEBUG", "org.onosproject.routeservice.impl" )
125 ctrl.CLI.logSet( "DEBUG", "org.onosproject.routeservice.store" )
126 ctrl.CLI.logSet( "DEBUG", "org.onosproject.routing.fpm" )
Jon Hall9677ed32018-04-24 11:16:23 -0700127 ctrl.CLI.logSet( "TRACE", "org.onosproject.events" )
128 ctrl.CLI.logSet( "DEBUG", "org.onosproject.mcast" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700129
130 @staticmethod
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800131 def loadCount( main ):
132 with open("%s/count/%s.count" % (main.configPath, main.cfgName)) as count:
You Wang5df1c6d2018-04-06 18:02:02 -0700133 main.count = json.load(count)
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800134
135 @staticmethod
Devin Lim57221b02018-02-14 15:45:36 -0800136 def loadJson( main ):
137 with open( "%s%s.json" % ( main.configPath + main.forJson,
138 main.cfgName ) ) as cfg:
139 main.Cluster.active( 0 ).REST.setNetCfg( json.load( cfg ) )
140
141 @staticmethod
142 def loadChart( main ):
143 try:
144 with open( "%s%s.chart" % ( main.configPath + main.forChart,
145 main.cfgName ) ) as chart:
146 main.pingChart = json.load(chart)
147 except IOError:
148 main.log.warn( "No chart file found." )
149
150 @staticmethod
151 def loadHost( main ):
152 with open( "%s%s.host" % ( main.configPath + main.forHost,
153 main.cfgName ) ) as host:
154 main.expectedHosts = json.load( host )
155
156 @staticmethod
You Wang27317572018-03-06 12:13:11 -0800157 def loadSwitchFailureChart( main ):
158 with open( "%s%s.switchFailureChart" % ( main.configPath + main.forSwitchFailure,
159 main.cfgName ) ) as sfc:
160 main.switchFailureChart = json.load( sfc )
161
162 @staticmethod
Andreas Pantelopoulosfab6bf32018-03-06 18:56:35 -0800163 def loadLinkFailureChart( main ):
164 with open( "%s%s.linkFailureChart" % ( main.configPath + main.forLinkFailure,
You Wange24d6272018-03-27 21:18:50 -0700165 main.cfgName ) ) as lfc:
166 main.linkFailureChart = json.load( lfc )
167
168 @staticmethod
169 def loadMulticastConfig( main ):
170 with open( "%s%s.multicastConfig" % ( main.configPath + main.forMulticast,
171 main.cfgName ) ) as cfg:
172 main.multicastConfig = json.load( cfg )
Andreas Pantelopoulosfab6bf32018-03-06 18:56:35 -0800173
174 @staticmethod
Jon Hall1efcb3f2016-08-23 13:42:15 -0700175 def startMininet( main, topology, args="" ):
You Wangd87b2312018-01-30 12:47:17 -0800176 copyResult = main.ONOSbench.scp( main.Mininet1,
177 main.topoPath + main.topology,
You Wang5da39c82018-04-26 22:55:08 -0700178 main.Mininet1.home + "custom",
You Wangd87b2312018-01-30 12:47:17 -0800179 direction="to" )
180 if main.topologyLib:
181 for lib in main.topologyLib.split(","):
182 copyResult = copyResult and main.ONOSbench.scp( main.Mininet1,
183 main.topoPath + lib,
You Wang5da39c82018-04-26 22:55:08 -0700184 main.Mininet1.home + "custom",
You Wangd87b2312018-01-30 12:47:17 -0800185 direction="to" )
186 if main.topologyConf:
You Wanga877ea42018-04-05 15:27:40 -0700187 import re
188 controllerIPs = [ ctrl.ipAddress for ctrl in main.Cluster.runningNodes ]
189 index = 0
You Wangd87b2312018-01-30 12:47:17 -0800190 for conf in main.topologyConf.split(","):
You Wanga877ea42018-04-05 15:27:40 -0700191 # Update zebra configurations with correct ONOS instance IP
192 if conf in [ "zebradbgp1.conf", "zebradbgp2.conf" ]:
193 ip = controllerIPs[ index ]
194 index = ( index + 1 ) % len( controllerIPs )
195 with open( main.configPath + main.forConfig + conf ) as f:
196 s = f.read()
197 s = re.sub( r"(fpm connection ip).*(port 2620)", r"\1 " + ip + r" \2", s )
198 with open( main.configPath + main.forConfig + conf, "w" ) as f:
199 f.write( s )
You Wangd87b2312018-01-30 12:47:17 -0800200 copyResult = copyResult and main.ONOSbench.scp( main.Mininet1,
Devin Lim57221b02018-02-14 15:45:36 -0800201 main.configPath + main.forConfig + conf,
You Wangd87b2312018-01-30 12:47:17 -0800202 "~/",
203 direction="to" )
204 stepResult = copyResult
205 utilities.assert_equals( expect=main.TRUE,
206 actual=stepResult,
207 onpass="Successfully copied topo files",
208 onfail="Failed to copy topo files" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700209 main.step( "Starting Mininet Topology" )
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -0700210 arg = "--onos-ip=%s %s" % (",".join([ctrl.ipAddress for ctrl in main.Cluster.runningNodes]), args)
Jon Hall1efcb3f2016-08-23 13:42:15 -0700211 main.topology = topology
212 topoResult = main.Mininet1.startNet(
You Wang5da39c82018-04-26 22:55:08 -0700213 topoFile=main.Mininet1.home + "custom/" + main.topology, args=arg )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700214 stepResult = topoResult
215 utilities.assert_equals( expect=main.TRUE,
216 actual=stepResult,
217 onpass="Successfully loaded topology",
218 onfail="Failed to load topology" )
219 # Exit if topology did not load properly
220 if not topoResult:
Devin Lim44075962017-08-11 10:56:37 -0700221 main.cleanAndExit()
Jon Hall1efcb3f2016-08-23 13:42:15 -0700222
223 @staticmethod
You Wang84f981d2018-01-12 16:11:50 -0800224 def connectToPhysicalNetwork( main, switchNames ):
225 main.step( "Connecting to physical netowrk" )
226 topoResult = main.NetworkBench.connectToNet()
227 stepResult = topoResult
228 utilities.assert_equals( expect=main.TRUE,
229 actual=stepResult,
230 onpass="Successfully loaded topology",
231 onfail="Failed to load topology" )
232 # Exit if topology did not load properly
233 if not topoResult:
234 main.cleanAndExit()
235
236 main.step( "Assign switches to controllers." )
237 assignResult = main.TRUE
238 for name in switchNames:
239 assignResult = assignResult & main.NetworkBench.assignSwController( sw=name,
240 ip=main.Cluster.getIps(),
241 port='6653' )
242 utilities.assert_equals( expect=main.TRUE,
243 actual=stepResult,
244 onpass="Successfully assign switches to controllers",
245 onfail="Failed to assign switches to controllers" )
246
247 @staticmethod
You Wang5df1c6d2018-04-06 18:02:02 -0700248 def saveOnosDiagnostics( main ):
249 """
250 Get onos-diags.tar.gz and save it to the log directory.
251 suffix: suffix string of the file name. E.g. onos-diags-case1.tar.gz
252 """
253 main.log.info( "Collecting onos-diags..." )
254 main.ONOSbench.onosDiagnostics( [ctrl.ipAddress for ctrl in main.Cluster.runningNodes],
255 main.logdir,
256 "-CASE%d" % main.CurrentTestCaseNumber )
257
258 @staticmethod
Devin Lim142b5342017-07-20 15:22:39 -0700259 def config( main, cfgName ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700260 main.spines = []
Piera2a7e1b2016-10-04 11:51:43 -0700261
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700262 main.failures = int( main.params[ 'failures' ] )
263 main.cfgName = cfgName
Piera2a7e1b2016-10-04 11:51:43 -0700264
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700265 if main.cfgName == '2x2':
266 spine = {}
267 spine[ 'name' ] = main.params[ 'switches' ][ 'spine1' ]
268 spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid1' ]
269 main.spines.append( spine )
Piera2a7e1b2016-10-04 11:51:43 -0700270
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700271 spine = {}
272 spine[ 'name' ] = main.params[ 'switches' ][ 'spine2' ]
273 spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid2' ]
274 main.spines.append( spine )
Piera2a7e1b2016-10-04 11:51:43 -0700275
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700276 elif main.cfgName == '4x4':
277 spine = {}
278 spine[ 'name' ] = main.params[ 'switches' ][ 'spine1' ]
279 spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid1' ]
280 main.spines.append( spine )
Piera2a7e1b2016-10-04 11:51:43 -0700281
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700282 spine = {}
283 spine[ 'name' ] = main.params[ 'switches' ][ 'spine2' ]
284 spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid2' ]
285 main.spines.append( spine )
Piera2a7e1b2016-10-04 11:51:43 -0700286
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700287 spine = {}
288 spine[ 'name' ] = main.params[ 'switches' ][ 'spine3' ]
289 spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid3' ]
290 main.spines.append( spine )
Piera2a7e1b2016-10-04 11:51:43 -0700291
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700292 spine = {}
293 spine[ 'name' ] = main.params[ 'switches' ][ 'spine4' ]
294 spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid4' ]
295 main.spines.append( spine )
Piera2a7e1b2016-10-04 11:51:43 -0700296
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700297 else:
Piera2a7e1b2016-10-04 11:51:43 -0700298 main.log.error( "Configuration failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700299 main.cleanAndExit()
You Wang27317572018-03-06 12:13:11 -0800300
Andreas Pantelopoulos2eae3242018-03-06 13:47:20 -0800301 @staticmethod
302 def addStaticOnosRoute( main, subnet, intf):
303 """
304 Adds an ONOS static route with the use route-add command.
305 """
306 main.step("Add static route for subnet {0} towards router interface {1}".format(subnet, intf))
307 routeResult = main.Cluster.active( 0 ).addStaticRoute(subnet, intf)
308
309 utilities.assert_equals( expect=True, actual=( not routeResult ),
310 onpass="route-add command succeeded",
311 onfail="route-add command failed")
Piera2a7e1b2016-10-04 11:51:43 -0700312
313 @staticmethod
Jonghwan Hyun76a02b72018-01-30 16:40:48 +0900314 def checkFlows( main, minFlowCount, tag="", dumpflows=True, sleep=10 ):
Jon Hall1efcb3f2016-08-23 13:42:15 -0700315 main.step(
Jon Hall3c910162018-03-07 14:42:16 -0800316 "Check whether the flow count is bigger than %s" % minFlowCount )
Jonghwan Hyun76a02b72018-01-30 16:40:48 +0900317 if tag == "":
318 tag = 'CASE%d' % main.CurrentTestCaseNumber
Devin Lim142b5342017-07-20 15:22:39 -0700319 count = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowCount,
Jon Hall1efcb3f2016-08-23 13:42:15 -0700320 main.FALSE,
321 kwargs={ 'min': minFlowCount },
322 attempts=10,
You Wang1cdc5f52017-12-19 16:47:51 -0800323 sleep=sleep )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700324 utilities.assertEquals(
Jon Hall1efcb3f2016-08-23 13:42:15 -0700325 expect=True,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700326 actual=( count > 0 ),
Jon Hall1efcb3f2016-08-23 13:42:15 -0700327 onpass="Flow count looks correct: " + str( count ),
328 onfail="Flow count looks wrong: " + str( count ) )
329
330 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700331 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall1efcb3f2016-08-23 13:42:15 -0700332 main.FALSE,
333 kwargs={ 'isPENDING': False },
Jonghwan Hyun98fb40a2018-01-04 16:16:28 -0800334 attempts=5,
You Wang1cdc5f52017-12-19 16:47:51 -0800335 sleep=sleep )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700336 utilities.assertEquals(
Jon Hall1efcb3f2016-08-23 13:42:15 -0700337 expect=main.TRUE,
338 actual=flowCheck,
339 onpass="Flow status is correct!",
340 onfail="Flow status is wrong!" )
341 if dumpflows:
Devin Lim142b5342017-07-20 15:22:39 -0700342 main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress,
Pier50f0bc62016-09-07 17:53:40 -0700343 "flows",
344 main.logdir,
Jonghwan Hyun76a02b72018-01-30 16:40:48 +0900345 tag + "_FlowsBefore" )
Devin Lim142b5342017-07-20 15:22:39 -0700346 main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress,
Pier50f0bc62016-09-07 17:53:40 -0700347 "groups",
348 main.logdir,
Jonghwan Hyun76a02b72018-01-30 16:40:48 +0900349 tag + "_GroupsBefore" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700350
351 @staticmethod
Pier6a0c4de2018-03-18 16:01:30 -0700352 def checkDevices( main, switches, tag="", sleep=10 ):
353 main.step(
354 "Check whether the switches count is equal to %s" % switches )
355 if tag == "":
356 tag = 'CASE%d' % main.CurrentTestCaseNumber
357 result = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
358 main.FALSE,
359 kwargs={ 'numoswitch': switches},
360 attempts=10,
361 sleep=sleep )
362 utilities.assert_equals( expect=main.TRUE, actual=result,
363 onpass="Device up successful",
364 onfail="Failed to boot up devices?" )
365
366 @staticmethod
Jonghwan Hyun98fb40a2018-01-04 16:16:28 -0800367 def checkFlowsByDpid( main, dpid, minFlowCount, sleep=10 ):
368 main.step(
Jonghwan Hyuncf2345c2018-02-26 11:07:54 -0800369 " Check whether the flow count of device %s is bigger than %s" % ( dpid, minFlowCount ) )
370 count = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowAddedCount,
371 main.FALSE,
372 args=( dpid, minFlowCount ),
Jonghwan Hyun98fb40a2018-01-04 16:16:28 -0800373 attempts=5,
374 sleep=sleep )
375 utilities.assertEquals(
Jonghwan Hyuncf2345c2018-02-26 11:07:54 -0800376 expect=True,
377 actual=( count > minFlowCount ),
378 onpass="Flow count looks correct: " + str( count ),
379 onfail="Flow count looks wrong. " )
Jonghwan Hyun98fb40a2018-01-04 16:16:28 -0800380
381 @staticmethod
Jon Hall9677ed32018-04-24 11:16:23 -0700382 def checkFlowEqualityByDpid( main, dpid, flowCount, sleep=10 ):
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800383 main.step(
384 " Check whether the flow count of device %s is equal to %s" % ( dpid, flowCount ) )
385 count = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowAddedCount,
386 main.FALSE,
Jon Hall9677ed32018-04-24 11:16:23 -0700387 args=( dpid, flowCount, False, 1 ),
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800388 attempts=5,
389 sleep=sleep )
390
391 utilities.assertEquals(
392 expect=True,
393 actual=( int( count ) == flowCount ),
Jon Hall9677ed32018-04-24 11:16:23 -0700394 onpass="Flow count looks correct: " + str( count ) ,
395 onfail="Flow count looks wrong. found {}, should be {}.".format( count, flowCount ) )
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800396
397 @staticmethod
398 def checkGroupEqualityByDpid( main, dpid, groupCount, sleep=10):
399 main.step(
400 " Check whether the group count of device %s is equal to %s" % ( dpid, groupCount ) )
401 count = utilities.retry( main.Cluster.active( 0 ).CLI.checkGroupAddedCount,
402 main.FALSE,
403 args=( dpid, groupCount, False, 1),
404 attempts=5,
405 sleep=sleep )
406
407 utilities.assertEquals(
408 expect=True,
409 actual=( count == groupCount ),
Jon Hall9677ed32018-04-24 11:16:23 -0700410 onpass="Group count looks correct: " + str( count ) ,
411 onfail="Group count looks wrong. found {}, should be {}.".format( count, groupCount ) )
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800412
413 @staticmethod
Jon Hall9677ed32018-04-24 11:16:23 -0700414 def checkFlowsGroupsFromFile( main ):
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800415
416 for dpid, values in main.count.items():
417 flowCount = values["flows"]
418 groupCount = values["groups"]
Jon Hall9677ed32018-04-24 11:16:23 -0700419 main.log.report( "Check flow count for dpid " + str( dpid ) +
420 ", should be " + str( flowCount ) )
421 Testcaselib.checkFlowEqualityByDpid( main, dpid, flowCount )
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800422
Jon Hall9677ed32018-04-24 11:16:23 -0700423 main.log.report( "Check group count for dpid " + str( dpid ) +
424 ", should be " + str( groupCount ) )
425 Testcaselib.checkGroupEqualityByDpid( main, dpid, groupCount )
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800426
427 return
428
429 @staticmethod
You Wang5df1c6d2018-04-06 18:02:02 -0700430 def pingAll( main, tag="", dumpflows=True, acceptableFailed=0, basedOnIp=False, sleep=10, retryAttempts=1, skipOnFail=False ):
You Wangf19d9f42018-02-23 16:34:19 -0800431 '''
You Wangba231e72018-03-01 13:18:21 -0800432 Verify connectivity between hosts according to the ping chart
433 acceptableFailed: max number of acceptable failed pings.
You Wangf19d9f42018-02-23 16:34:19 -0800434 basedOnIp: if True, run ping or ping6 based on suffix of host names
Jonghwan Hyun812c70f2018-02-16 16:33:16 -0800435 retryAttempts: the number of retry ping. Only works for IPv4 hosts.
You Wangf19d9f42018-02-23 16:34:19 -0800436 '''
You Wangba231e72018-03-01 13:18:21 -0800437 main.log.report( "Check host connectivity" )
438 main.log.debug( "Ping chart: %s" % main.pingChart )
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -0800439 if tag == "":
440 tag = 'CASE%d' % main.CurrentTestCaseNumber
441 for entry in main.pingChart.itervalues():
You Wangba231e72018-03-01 13:18:21 -0800442 main.log.debug( "Entry in ping chart: %s" % entry )
443 expect = entry[ 'expect' ]
444 if expect == "Unidirectional":
445 # Verify ping from each src host to each dst host
446 src = entry[ 'src' ]
447 dst = entry[ 'dst' ]
448 expect = main.TRUE
449 main.step( "Verify unidirectional connectivity from %s to %s with tag %s" % ( str( src ), str( dst ), tag ) )
450 if basedOnIp:
451 if ("v4" in src[0]):
452 pa = main.Network.pingallHostsUnidirectional( src, dst, acceptableFailed=acceptableFailed )
453 utilities.assert_equals( expect=expect, actual=pa,
454 onpass="IPv4 connectivity successfully tested",
455 onfail="IPv4 connectivity failed" )
456 if ("v6" in src[0]):
457 pa = main.Network.pingallHostsUnidirectional( src, dst, ipv6=True, acceptableFailed=acceptableFailed )
458 utilities.assert_equals( expect=expect, actual=pa,
459 onpass="IPv6 connectivity successfully tested",
460 onfail="IPv6 connectivity failed" )
461 else:
462 pa = main.Network.pingallHostsUnidirectional( src, dst, acceptableFailed=acceptableFailed )
463 utilities.assert_equals( expect=expect, actual=pa,
464 onpass="IP connectivity successfully tested",
465 onfail="IP connectivity failed" )
466 else:
467 # Verify ping between each host pair
468 hosts = entry[ 'hosts' ]
469 try:
470 expect = main.TRUE if str(expect).lower() == 'true' else main.FALSE
471 except:
472 expect = main.FALSE
473 main.step( "Verify full connectivity for %s with tag %s" % ( str( hosts ), tag ) )
474 if basedOnIp:
475 if ("v4" in hosts[0]):
Jonghwan Hyun812c70f2018-02-16 16:33:16 -0800476 pa = utilities.retry( main.Network.pingallHosts,
477 main.FALSE if expect else main.TRUE,
478 args=(hosts,),
479 attempts=retryAttempts,
480 sleep=sleep )
You Wangba231e72018-03-01 13:18:21 -0800481 utilities.assert_equals( expect=expect, actual=pa,
482 onpass="IPv4 connectivity successfully tested",
483 onfail="IPv4 connectivity failed" )
484 if ("v6" in hosts[0]):
485 pa = main.Network.pingIpv6Hosts( hosts, acceptableFailed=acceptableFailed )
486 utilities.assert_equals( expect=expect, actual=pa,
487 onpass="IPv6 connectivity successfully tested",
488 onfail="IPv6 connectivity failed" )
489 else:
You Wangf19d9f42018-02-23 16:34:19 -0800490 pa = main.Network.pingallHosts( hosts )
491 utilities.assert_equals( expect=expect, actual=pa,
You Wangba231e72018-03-01 13:18:21 -0800492 onpass="IP connectivity successfully tested",
493 onfail="IP connectivity failed" )
You Wang5df1c6d2018-04-06 18:02:02 -0700494 if skipOnFail and pa != expect:
495 Testcaselib.saveOnosDiagnostics( main )
You Wang24ad2f52018-04-10 10:47:12 -0700496 Testcaselib.cleanup( main, copyKarafLog=False )
You Wang5df1c6d2018-04-06 18:02:02 -0700497 main.skipCase()
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -0800498
499 if dumpflows:
500 main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress,
501 "flows",
502 main.logdir,
503 tag + "_FlowsOn" )
504 main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress,
505 "groups",
506 main.logdir,
507 tag + "_GroupsOn" )
508
509 @staticmethod
Jon Hall1efcb3f2016-08-23 13:42:15 -0700510 def killLink( main, end1, end2, switches, links ):
511 """
512 end1,end2: identify the switches, ex.: 'leaf1', 'spine1'
513 switches, links: number of expected switches and links after linkDown, ex.: '4', '6'
514 Kill a link and verify ONOS can see the proper link change
515 """
516 main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700517 main.step( "Kill link between %s and %s" % ( end1, end2 ) )
You Wangd5873482018-01-24 12:30:00 -0800518 LinkDown = main.Network.link( END1=end1, END2=end2, OPTION="down" )
519 LinkDown = main.Network.link( END2=end1, END1=end2, OPTION="down" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700520 main.log.info(
521 "Waiting %s seconds for link down to be discovered" % main.linkSleep )
522 time.sleep( main.linkSleep )
Devin Lim142b5342017-07-20 15:22:39 -0700523 topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
Jon Hall1efcb3f2016-08-23 13:42:15 -0700524 main.FALSE,
525 kwargs={ 'numoswitch': switches,
526 'numolink': links },
527 attempts=10,
528 sleep=main.linkSleep )
529 result = topology & LinkDown
530 utilities.assert_equals( expect=main.TRUE, actual=result,
531 onpass="Link down successful",
532 onfail="Failed to turn off link?" )
533
534 @staticmethod
You Wangeb717bc2018-04-05 17:36:11 -0700535 def killLinkBatch( main, links, linksAfter, switches ):
Andreas Pantelopoulosfab6bf32018-03-06 18:56:35 -0800536 """
537 links = list of links (src, dst) to bring down.
538 """
539
540 main.step("Killing a batch of links {0}".format(links))
541
542 for end1, end2 in links:
543 main.Network.link( END1=end1, END2=end2, OPTION="down")
544 main.Network.link( END1=end2, END2=end1, OPTION="down")
545
546 main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
547 main.log.info(
548 "Waiting %s seconds for links down to be discovered" % main.linkSleep )
549 time.sleep( main.linkSleep )
550
551 topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
552 main.FALSE,
553 kwargs={ 'numoswitch': switches,
554 'numolink': linksAfter },
555 attempts=10,
556 sleep=main.linkSleep )
557
You Wang2854bce2018-03-30 10:15:32 -0700558 utilities.assert_equals( expect=main.TRUE, actual=topology,
559 onpass="Link batch down successful",
560 onfail="Link batch down failed" )
561
Andreas Pantelopoulosfab6bf32018-03-06 18:56:35 -0800562 @staticmethod
You Wangeb717bc2018-04-05 17:36:11 -0700563 def restoreLinkBatch( main, links, linksAfter, switches ):
Andreas Pantelopoulosfab6bf32018-03-06 18:56:35 -0800564 """
565 links = list of link (src, dst) to bring up again.
566 """
567
568 main.step("Restoring a batch of links {0}".format(links))
569
570 for end1, end2 in links:
571 main.Network.link( END1=end1, END2=end2, OPTION="up")
572 main.Network.link( END1=end2, END2=end1, OPTION="up")
573
574 main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
575 main.log.info(
You Wang547893e2018-05-08 13:34:59 -0700576 "Waiting %s seconds for links up to be discovered" % main.linkSleep )
Andreas Pantelopoulosfab6bf32018-03-06 18:56:35 -0800577 time.sleep( main.linkSleep )
578
579 topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
580 main.FALSE,
581 kwargs={ 'numoswitch': switches,
582 'numolink': linksAfter },
583 attempts=10,
584 sleep=main.linkSleep )
585
You Wang2854bce2018-03-30 10:15:32 -0700586 utilities.assert_equals( expect=main.TRUE, actual=topology,
587 onpass="Link batch up successful",
588 onfail="Link batch up failed" )
589
Andreas Pantelopoulosfab6bf32018-03-06 18:56:35 -0800590 @staticmethod
You Wang85747762018-05-11 15:51:50 -0700591 def disablePortBatch( main, ports, switches=None, links=None, sleep=None ):
592 """
593 Disable a list of switch ports using 'portstate' and verify ONOS can see the proper link change
594 ports: a list of ports to disable ex. [ [ "of:0000000000000001", 1 ] ]
595 switches, links: number of expected switches and links after link change, ex.: '4', '6'
596 """
597 if sleep is None:
598 sleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
599 else:
600 sleep = float( sleep )
601 main.step( "Disable a batch of ports" )
602 for dpid, port in ports:
603 main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="disable" )
604 main.log.info( "Waiting {} seconds for port down to be discovered".format( sleep ) )
605 time.sleep( sleep )
606 if switches and links:
607 result = main.Cluster.active( 0 ).CLI.checkStatus( numoswitch=switches,
608 numolink=links )
609 utilities.assert_equals( expect=main.TRUE, actual=result,
610 onpass="Port down successful",
611 onfail="Port down failed" )
612
613 @staticmethod
614 def enablePortBatch( main, ports, switches, links, sleep=None ):
615 """
616 Enable a list of switch ports using 'portstate' and verify ONOS can see the proper link change
617 ports: a list of ports to enable ex. [ [ "of:0000000000000001", 1 ] ]
618 switches, links: number of expected switches and links after link change, ex.: '4', '6'
619 """
620 if sleep is None:
621 sleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
622 else:
623 sleep = float( sleep )
624 main.step( "Enable a batch of ports" )
625 for dpid, port in ports:
626 main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="enable" )
627 main.log.info( "Waiting {} seconds for port up to be discovered".format( sleep ) )
628 time.sleep( sleep )
629 if switches and links:
630 result = main.Cluster.active( 0 ).CLI.checkStatus( numoswitch=switches,
631 numolink=links )
632 utilities.assert_equals( expect=main.TRUE, actual=result,
633 onpass="Port up successful",
634 onfail="Port up failed" )
635
636 @staticmethod
You Wangc02d8352018-04-17 16:42:10 -0700637 def restoreLink( main, end1, end2, switches, links,
638 portUp=False, dpid1='', dpid2='', port1='', port2='' ):
Jon Hall1efcb3f2016-08-23 13:42:15 -0700639 """
640 Params:
641 end1,end2: identify the end switches, ex.: 'leaf1', 'spine1'
You Wangc02d8352018-04-17 16:42:10 -0700642 portUp: enable portstate after restoring link
Jon Hall1efcb3f2016-08-23 13:42:15 -0700643 dpid1, dpid2: dpid of the end switches respectively, ex.: 'of:0000000000000002'
644 port1, port2: respective port of the end switches that connects to the link, ex.:'1'
645 switches, links: number of expected switches and links after linkDown, ex.: '4', '6'
646 Kill a link and verify ONOS can see the proper link change
647 """
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700648 main.step( "Restore link between %s and %s" % ( end1, end2 ) )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700649 result = False
650 count = 0
651 while True:
652 count += 1
You Wangd5873482018-01-24 12:30:00 -0800653 main.Network.link( END1=end1, END2=end2, OPTION="up" )
654 main.Network.link( END2=end1, END1=end2, OPTION="up" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700655 main.log.info(
656 "Waiting %s seconds for link up to be discovered" % main.linkSleep )
657 time.sleep( main.linkSleep )
Pierfb719b12016-09-19 14:51:44 -0700658
You Wangc02d8352018-04-17 16:42:10 -0700659 if portUp:
660 ctrl.CLI.portstate( dpid=dpid1, port=port1, state='Enable' )
661 ctrl.CLI.portstate( dpid=dpid2, port=port2, state='Enable' )
662 time.sleep( main.linkSleep )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700663
Devin Lim142b5342017-07-20 15:22:39 -0700664 result = main.Cluster.active( 0 ).CLI.checkStatus( numoswitch=switches,
665 numolink=links )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700666 if count > 5 or result:
667 break
668 utilities.assert_equals( expect=main.TRUE, actual=result,
669 onpass="Link up successful",
670 onfail="Failed to bring link up" )
671
672 @staticmethod
673 def killSwitch( main, switch, switches, links ):
674 """
675 Params: switches, links: number of expected switches and links after SwitchDown, ex.: '4', '6'
676 Completely kill a switch and verify ONOS can see the proper change
677 """
678 main.switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
You Wangc02d8352018-04-17 16:42:10 -0700679 switch = switch if isinstance( switch, list ) else [ switch ]
680 main.step( "Kill " + str( switch ) )
681 for s in switch:
682 main.log.info( "Stopping " + s )
683 main.Network.switch( SW=s, OPTION="stop" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700684 # todo make this repeatable
685 main.log.info( "Waiting %s seconds for switch down to be discovered" % (
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700686 main.switchSleep ) )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700687 time.sleep( main.switchSleep )
Devin Lim142b5342017-07-20 15:22:39 -0700688 topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
Jon Hall1efcb3f2016-08-23 13:42:15 -0700689 main.FALSE,
690 kwargs={ 'numoswitch': switches,
691 'numolink': links },
692 attempts=10,
693 sleep=main.switchSleep )
694 utilities.assert_equals( expect=main.TRUE, actual=topology,
695 onpass="Kill switch successful",
696 onfail="Failed to kill switch?" )
697
698 @staticmethod
You Wang48381752018-05-07 13:50:57 -0700699 def recoverSwitch( main, switch, switches, links, rediscoverHosts=False, hostsToDiscover=[] ):
Jon Hall1efcb3f2016-08-23 13:42:15 -0700700 """
701 Params: switches, links: number of expected switches and links after SwitchUp, ex.: '4', '6'
702 Recover a switch and verify ONOS can see the proper change
703 """
704 # todo make this repeatable
You Wangc02d8352018-04-17 16:42:10 -0700705 switch = switch if isinstance( switch, list ) else [ switch ]
706 main.step( "Recovering " + str( switch ) )
707 for s in switch:
708 main.log.info( "Starting " + s )
709 main.Network.switch( SW=s, OPTION="start" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700710 main.log.info( "Waiting %s seconds for switch up to be discovered" % (
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700711 main.switchSleep ) )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700712 time.sleep( main.switchSleep )
Andreas Pantelopoulos74c7ff22018-05-01 15:42:02 -0700713 if rediscoverHosts:
You Wang48381752018-05-07 13:50:57 -0700714 main.Network.discoverHosts( hostList=hostsToDiscover )
Andreas Pantelopoulos74c7ff22018-05-01 15:42:02 -0700715 main.log.info( "Waiting %s seconds for hosts to get re-discovered" % (
716 main.switchSleep ) )
717 time.sleep( main.switchSleep )
718
Devin Lim142b5342017-07-20 15:22:39 -0700719 topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
Jon Hall1efcb3f2016-08-23 13:42:15 -0700720 main.FALSE,
721 kwargs={ 'numoswitch': switches,
722 'numolink': links },
723 attempts=10,
724 sleep=main.switchSleep )
725 utilities.assert_equals( expect=main.TRUE, actual=topology,
726 onpass="Switch recovery successful",
727 onfail="Failed to recover switch?" )
728
Jonghwan Hyun25c98a62018-05-04 13:59:09 -0700729 @staticmethod
You Wang5da39c82018-04-26 22:55:08 -0700730 def cleanup( main, copyKarafLog=True, removeHostComponent=False ):
Jon Hall1efcb3f2016-08-23 13:42:15 -0700731 """
732 Stop Onos-cluster.
733 Stops Mininet
734 Copies ONOS log
735 """
Devin Lim58046fa2017-07-05 16:55:00 -0700736 try:
737 from tests.dependencies.utils import Utils
738 except ImportError:
739 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700740 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700741 try:
Devin Lim142b5342017-07-20 15:22:39 -0700742 main.utils
Devin Lim58046fa2017-07-05 16:55:00 -0700743 except ( NameError, AttributeError ):
Devin Lim142b5342017-07-20 15:22:39 -0700744 main.utils = Utils()
Devin Lim58046fa2017-07-05 16:55:00 -0700745
You Wange24d6272018-03-27 21:18:50 -0700746 if hasattr( main, "scapyHosts" ):
747 scapyResult = main.TRUE
748 for host in main.scapyHosts:
749 scapyResult = host.stopScapy() and scapyResult
750 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
751 for host in main.scapyHosts:
752 scapyResult = main.Scapy.removeHostComponent( host.name ) and scapyResult
753 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
754 main.scapyHosts = []
755
You Wang5da39c82018-04-26 22:55:08 -0700756 if removeHostComponent:
757 for host in main.internalIpv4Hosts + main.internalIpv6Hosts + main.externalIpv4Hosts + main.externalIpv6Hosts:
758 if hasattr( main, host ):
759 main.Network.removeHostComponent( host )
760
You Wang5df1c6d2018-04-06 18:02:02 -0700761 if hasattr( main, 'Mininet1' ):
Pier6a0c4de2018-03-18 16:01:30 -0700762 main.utils.mininetCleanup( main.Mininet1 )
Devin Lim58046fa2017-07-05 16:55:00 -0700763
You Wang5df1c6d2018-04-06 18:02:02 -0700764 if copyKarafLog:
765 main.utils.copyKarafLog( "CASE%d" % main.CurrentTestCaseNumber, before=True, includeCaseDesc=False )
Devin Lim58046fa2017-07-05 16:55:00 -0700766
Devin Lim142b5342017-07-20 15:22:39 -0700767 for ctrl in main.Cluster.active():
768 main.ONOSbench.onosStop( ctrl.ipAddress )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700769
770 @staticmethod
771 def killOnos( main, nodes, switches, links, expNodes ):
772 """
773 Params: nodes, integer array with position of the ONOS nodes in the CLIs array
774 switches, links, nodes: number of expected switches, links and nodes after KillOnos, ex.: '4', '6'
775 Completely Kill an ONOS instance and verify the ONOS cluster can see the proper change
776 """
Jon Hall3c910162018-03-07 14:42:16 -0800777 main.step( "Killing ONOS instances with index(es): {}".format( nodes ) )
You Wang5df1c6d2018-04-06 18:02:02 -0700778 main.onosSleep = float( main.params[ 'timers' ][ 'OnosDiscovery' ] )
Pier3b58c652016-09-26 12:03:31 -0700779
Jon Hall1efcb3f2016-08-23 13:42:15 -0700780 for i in nodes:
Devin Lim142b5342017-07-20 15:22:39 -0700781 killResult = main.ONOSbench.onosDie( main.Cluster.runningNodes[ i ].ipAddress )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700782 utilities.assert_equals( expect=main.TRUE, actual=killResult,
783 onpass="ONOS instance Killed",
784 onfail="Error killing ONOS instance" )
Devin Lim142b5342017-07-20 15:22:39 -0700785 main.Cluster.runningNodes[ i ].active = False
You Wang5df1c6d2018-04-06 18:02:02 -0700786 time.sleep( main.onosSleep )
Pier3b58c652016-09-26 12:03:31 -0700787
Devin Lim142b5342017-07-20 15:22:39 -0700788 if len( nodes ) < main.Cluster.numCtrls:
Pier3b58c652016-09-26 12:03:31 -0700789
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -0700790 nodeResults = utilities.retry( main.Cluster.nodesCheck,
Pier3b58c652016-09-26 12:03:31 -0700791 False,
Jon Hall9677ed32018-04-24 11:16:23 -0700792 attempts=10,
Pier3b58c652016-09-26 12:03:31 -0700793 sleep=10 )
794 utilities.assert_equals( expect=True, actual=nodeResults,
795 onpass="Nodes check successful",
796 onfail="Nodes check NOT successful" )
797
798 if not nodeResults:
799 for i in nodes:
Devin Lim142b5342017-07-20 15:22:39 -0700800 ctrl = main.Cluster.runningNodes[ i ]
Pier3b58c652016-09-26 12:03:31 -0700801 main.log.debug( "{} components not ACTIVE: \n{}".format(
Devin Lim142b5342017-07-20 15:22:39 -0700802 ctrl.name,
803 ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
Pier3b58c652016-09-26 12:03:31 -0700804 main.log.error( "Failed to kill ONOS, stopping test" )
Devin Lim44075962017-08-11 10:56:37 -0700805 main.cleanAndExit()
Pier3b58c652016-09-26 12:03:31 -0700806
Jonghwan Hyun76a02b72018-01-30 16:40:48 +0900807 topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
Jon Hall1efcb3f2016-08-23 13:42:15 -0700808 main.FALSE,
809 kwargs={ 'numoswitch': switches,
810 'numolink': links,
811 'numoctrl': expNodes },
812 attempts=10,
813 sleep=12 )
814 utilities.assert_equals( expect=main.TRUE, actual=topology,
815 onpass="ONOS Instance down successful",
816 onfail="Failed to turn off ONOS Instance" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700817
818 @staticmethod
819 def recoverOnos( main, nodes, switches, links, expNodes ):
820 """
821 Params: nodes, integer array with position of the ONOS nodes in the CLIs array
822 switches, links, nodes: number of expected switches, links and nodes after recoverOnos, ex.: '4', '6'
823 Recover an ONOS instance and verify the ONOS cluster can see the proper change
824 """
Jon Hall3c910162018-03-07 14:42:16 -0800825 main.step( "Recovering ONOS instances with index(es): {}".format( nodes ) )
Devin Lim142b5342017-07-20 15:22:39 -0700826 [ main.ONOSbench.onosStart( main.Cluster.runningNodes[ i ].ipAddress ) for i in nodes ]
You Wang5df1c6d2018-04-06 18:02:02 -0700827 time.sleep( main.onosSleep )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700828 for i in nodes:
Devin Lim142b5342017-07-20 15:22:39 -0700829 isUp = main.ONOSbench.isup( main.Cluster.runningNodes[ i ].ipAddress )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700830 utilities.assert_equals( expect=main.TRUE, actual=isUp,
831 onpass="ONOS service is ready",
832 onfail="ONOS service did not start properly" )
833 for i in nodes:
834 main.step( "Checking if ONOS CLI is ready" )
Devin Lim142b5342017-07-20 15:22:39 -0700835 ctrl = main.Cluster.runningNodes[ i ]
Jonghwan Hyun76a02b72018-01-30 16:40:48 +0900836 # ctrl.CLI.startCellCli()
Devin Lim142b5342017-07-20 15:22:39 -0700837 cliResult = ctrl.CLI.startOnosCli( ctrl.ipAddress,
838 commandlineTimeout=60,
839 onosStartTimeout=100 )
840 ctrl.active = True
Jon Hall1efcb3f2016-08-23 13:42:15 -0700841 utilities.assert_equals( expect=main.TRUE,
842 actual=cliResult,
843 onpass="ONOS CLI is ready",
844 onfail="ONOS CLI is not ready" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700845
Pier3b58c652016-09-26 12:03:31 -0700846 main.step( "Checking ONOS nodes" )
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -0700847 nodeResults = utilities.retry( main.Cluster.nodesCheck,
Pier3b58c652016-09-26 12:03:31 -0700848 False,
Pier3b58c652016-09-26 12:03:31 -0700849 attempts=5,
850 sleep=10 )
851 utilities.assert_equals( expect=True, actual=nodeResults,
852 onpass="Nodes check successful",
853 onfail="Nodes check NOT successful" )
854
855 if not nodeResults:
856 for i in nodes:
Devin Lim142b5342017-07-20 15:22:39 -0700857 ctrl = main.Cluster.runningNodes[ i ]
Pier3b58c652016-09-26 12:03:31 -0700858 main.log.debug( "{} components not ACTIVE: \n{}".format(
Devin Lim142b5342017-07-20 15:22:39 -0700859 ctrl.name,
860 ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
Pier3b58c652016-09-26 12:03:31 -0700861 main.log.error( "Failed to start ONOS, stopping test" )
Devin Lim44075962017-08-11 10:56:37 -0700862 main.cleanAndExit()
Pier3b58c652016-09-26 12:03:31 -0700863
Devin Lim142b5342017-07-20 15:22:39 -0700864 topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
Jon Hall1efcb3f2016-08-23 13:42:15 -0700865 main.FALSE,
866 kwargs={ 'numoswitch': switches,
867 'numolink': links,
868 'numoctrl': expNodes },
869 attempts=10,
870 sleep=12 )
871 utilities.assert_equals( expect=main.TRUE, actual=topology,
872 onpass="ONOS Instance down successful",
873 onfail="Failed to turn off ONOS Instance" )
Devin Lim142b5342017-07-20 15:22:39 -0700874 ready = utilities.retry( main.Cluster.active( 0 ).CLI.summary,
875 main.FALSE,
876 attempts=10,
877 sleep=12 )
878 if ready:
879 ready = main.TRUE
880 utilities.assert_equals( expect=main.TRUE, actual=ready,
Jon Hall1efcb3f2016-08-23 13:42:15 -0700881 onpass="ONOS summary command succeded",
882 onfail="ONOS summary command failed" )
883 if not ready:
884 main.log.error( "ONOS startup failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700885 main.cleanAndExit()
Jon Hall1efcb3f2016-08-23 13:42:15 -0700886
887 @staticmethod
888 def addHostCfg( main ):
889 """
890 Adds Host Configuration to ONOS
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700891 Updates expected state of the network ( pingChart )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700892 """
893 import json
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700894 hostCfg = {}
Devin Lim57221b02018-02-14 15:45:36 -0800895 with open( main.configPath + main.forJson + "extra.json" ) as template:
Jon Hall1efcb3f2016-08-23 13:42:15 -0700896 hostCfg = json.load( template )
897 main.pingChart[ 'ip' ][ 'hosts' ] += [ 'in1' ]
898 main.step( "Pushing new configuration" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700899 mac, cfg = hostCfg[ 'hosts' ].popitem()
Devin Lim142b5342017-07-20 15:22:39 -0700900 main.Cluster.active( 0 ).REST.setNetCfg( cfg[ 'basic' ],
901 subjectClass="hosts",
902 subjectKey=urllib.quote( mac,
903 safe='' ),
904 configKey="basic" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700905 main.pingChart[ 'ip' ][ 'hosts' ] += [ 'out1' ]
906 main.step( "Pushing new configuration" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700907 mac, cfg = hostCfg[ 'hosts' ].popitem()
Devin Lim142b5342017-07-20 15:22:39 -0700908 main.Cluster.active( 0 ).REST.setNetCfg( cfg[ 'basic' ],
909 subjectClass="hosts",
910 subjectKey=urllib.quote( mac,
911 safe='' ),
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700912 configKey="basic" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700913 main.pingChart.update( { 'vlan1': { "expect": "True",
914 "hosts": [ "olt1", "vsg1" ] } } )
915 main.pingChart[ 'vlan5' ][ 'expect' ] = 0
916 main.pingChart[ 'vlan10' ][ 'expect' ] = 0
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700917 ports = "[%s,%s]" % ( 5, 6 )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700918 cfg = '{"of:0000000000000001":[{"vlan":1,"ports":%s,"name":"OLT 1"}]}' % ports
Devin Lim142b5342017-07-20 15:22:39 -0700919 main.Cluster.active( 0 ).REST.setNetCfg( json.loads( cfg ),
920 subjectClass="apps",
921 subjectKey="org.onosproject.segmentrouting",
922 configKey="xconnect" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700923
924 @staticmethod
925 def delHostCfg( main ):
926 """
927 Removest Host Configuration from ONOS
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700928 Updates expected state of the network ( pingChart )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700929 """
930 import json
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700931 hostCfg = {}
Devin Lim57221b02018-02-14 15:45:36 -0800932 with open( main.configPath + main.forJson + "extra.json" ) as template:
Jon Hall1efcb3f2016-08-23 13:42:15 -0700933 hostCfg = json.load( template )
934 main.step( "Removing host configuration" )
935 main.pingChart[ 'ip' ][ 'expect' ] = 0
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700936 mac, cfg = hostCfg[ 'hosts' ].popitem()
Devin Lim142b5342017-07-20 15:22:39 -0700937 main.Cluster.active( 0 ).REST.removeNetCfg( subjectClass="hosts",
938 subjectKey=urllib.quote(
939 mac,
940 safe='' ),
941 configKey="basic" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700942 main.step( "Removing configuration" )
943 main.pingChart[ 'ip' ][ 'expect' ] = 0
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700944 mac, cfg = hostCfg[ 'hosts' ].popitem()
Devin Lim142b5342017-07-20 15:22:39 -0700945 main.Cluster.active( 0 ).REST.removeNetCfg( subjectClass="hosts",
946 subjectKey=urllib.quote(
947 mac,
948 safe='' ),
949 configKey="basic" )
Jon Hall1efcb3f2016-08-23 13:42:15 -0700950 main.step( "Removing vlan configuration" )
951 main.pingChart[ 'vlan1' ][ 'expect' ] = 0
Devin Lim142b5342017-07-20 15:22:39 -0700952 main.Cluster.active( 0 ).REST.removeNetCfg( subjectClass="apps",
953 subjectKey="org.onosproject.segmentrouting",
954 configKey="xconnect" )
You Wang53dba1e2018-02-02 17:45:44 -0800955
956 @staticmethod
957 def verifyNetworkHostIp( main, attempts=10, sleep=10 ):
958 """
959 Verifies IP address assignment from the hosts
960 """
961 main.step( "Verify IP address assignment from hosts" )
962 ipResult = main.TRUE
You Wangd66de192018-04-30 17:30:12 -0700963 main.Network.update()
You Wang6acb7a42018-05-04 15:12:25 -0700964 # Find out names of disconnected hosts
965 disconnectedHosts = []
966 if hasattr( main, "disconnectedIpv4Hosts" ):
967 for host in main.disconnectedIpv4Hosts:
968 disconnectedHosts.append( host )
969 if hasattr( main, "disconnectedIpv6Hosts" ):
970 for host in main.disconnectedIpv6Hosts:
971 disconnectedHosts.append( host )
You Wang53dba1e2018-02-02 17:45:44 -0800972 for hostName, ip in main.expectedHosts[ "network" ].items():
You Wang6acb7a42018-05-04 15:12:25 -0700973 # Exclude disconnected hosts
974 if hostName in disconnectedHosts:
975 main.log.debug( "Skip verifying IP for {} as it's disconnected".format( hostName ) )
976 continue
You Wang53dba1e2018-02-02 17:45:44 -0800977 ipResult = ipResult and utilities.retry( main.Network.verifyHostIp,
978 main.FALSE,
979 kwargs={ 'hostList': [ hostName ],
You Wangd66de192018-04-30 17:30:12 -0700980 'prefix': ip,
981 'update': False },
You Wang53dba1e2018-02-02 17:45:44 -0800982 attempts=attempts,
983 sleep=sleep )
984 utilities.assert_equals( expect=main.TRUE, actual=ipResult,
985 onpass="Verify network host IP succeded",
986 onfail="Verify network host IP failed" )
987
988 @staticmethod
989 def verifyOnosHostIp( main, attempts=10, sleep=10 ):
990 """
991 Verifies host IP address assignment from ONOS
992 """
993 main.step( "Verify host IP address assignment in ONOS" )
994 ipResult = main.TRUE
You Wang6acb7a42018-05-04 15:12:25 -0700995 # Find out IPs of disconnected hosts
996 disconnectedIps = []
997 if hasattr( main, "disconnectedIpv4Hosts" ):
998 for host in main.disconnectedIpv4Hosts:
999 disconnectedIps.append( main.expectedHosts[ "network" ][ host ] )
1000 if hasattr( main, "disconnectedIpv6Hosts" ):
1001 for host in main.disconnectedIpv6Hosts:
1002 disconnectedIps.append( main.expectedHosts[ "network" ][ host ] )
You Wang53dba1e2018-02-02 17:45:44 -08001003 for hostName, ip in main.expectedHosts[ "onos" ].items():
You Wang6acb7a42018-05-04 15:12:25 -07001004 # Exclude disconnected hosts
1005 if ip in disconnectedIps:
1006 main.log.debug( "Skip verifying IP for {} as it's disconnected".format( ip ) )
1007 continue
You Wang53dba1e2018-02-02 17:45:44 -08001008 ipResult = ipResult and utilities.retry( main.Cluster.active( 0 ).verifyHostIp,
1009 main.FALSE,
1010 kwargs={ 'hostList': [ hostName ],
1011 'prefix': ip },
1012 attempts=attempts,
1013 sleep=sleep )
1014 utilities.assert_equals( expect=main.TRUE, actual=ipResult,
1015 onpass="Verify ONOS host IP succeded",
1016 onfail="Verify ONOS host IP failed" )
Andreas Pantelopoulos2eae3242018-03-06 13:47:20 -08001017
Jonghwan Hyun812c70f2018-02-16 16:33:16 -08001018 @staticmethod
1019 def updateIntfCfg( main, connectPoint, ips=[], untagged=0, tagged=[], native=0 ):
1020 """
1021 Description:
1022 Updates interface configuration in ONOS, with given IP and vlan parameters
1023 Required:
1024 * connectPoint: connect point to update configuration
1025 Optional:
1026 * ips: list of IP addresses, combined with '/xx' subnet representation,
1027 corresponding to 'ips' field in the configuration
1028 * untagged: vlan ID as an integer, corresponding to 'vlan-untagged' field in the configuration
1029 * tagged: integer list of vlan IDs, corresponding to 'vlan-tagged' field in the configuration
1030 * native: vlan ID as an integer, corresponding to 'vlan-native' field in the configuration
1031 """
1032 cfg = dict()
1033 cfg[ "ports" ] = dict()
1034 cfg[ "ports" ][ connectPoint ] = dict()
1035 cfg[ "ports" ][ connectPoint ][ "interfaces" ] = [ dict() ]
1036 cfg[ "ports" ][ connectPoint ][ "interfaces" ][ 0 ][ "ips" ] = ips
1037 if untagged > 0:
1038 cfg[ "ports" ][ connectPoint ][ "interfaces" ][ 0 ][ "vlan-untagged" ] = untagged
1039 else:
1040 cfg[ "ports" ][ connectPoint ][ "interfaces" ][ 0 ][ "vlan-tagged" ] = tagged
1041 if native > 0:
1042 cfg[ "ports" ][ connectPoint ][ "interfaces" ][ 0 ][ "vlan-native" ] = native
1043
1044 main.Cluster.active( 0 ).REST.setNetCfg( json.loads( json.dumps( cfg ) ) )
You Wange24d6272018-03-27 21:18:50 -07001045
1046 @staticmethod
1047 def startScapyHosts( main ):
1048 """
1049 Create host components and start Scapy CLIs
1050 """
1051 main.step( "Start Scapy CLIs" )
1052 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
1053 main.scapyHosts = []
1054 for hostName in main.scapyHostNames:
1055 main.Scapy.createHostComponent( hostName )
1056 main.scapyHosts.append( getattr( main, hostName ) )
1057 for host in main.scapyHosts:
1058 host.startHostCli()
1059 host.startScapy()
1060 host.updateSelf()
1061 main.log.debug( host.name )
1062 main.log.debug( host.hostIp )
1063 main.log.debug( host.hostMac )
1064
1065 @staticmethod
You Wang547893e2018-05-08 13:34:59 -07001066 def verifyMulticastTraffic( main, routeName, expect, skipOnFail=True, maxRetry=1 ):
You Wange24d6272018-03-27 21:18:50 -07001067 """
1068 Verify multicast traffic using scapy
1069 """
You Wangc564c6f2018-05-01 15:24:57 -07001070 from tests.dependencies.topology import Topology
1071 try:
1072 main.topo
1073 except ( NameError, AttributeError ):
1074 main.topo = Topology()
You Wang85747762018-05-11 15:51:50 -07001075 main.step( "Verify {} multicast traffic".format( routeName ) )
You Wangc02d8352018-04-17 16:42:10 -07001076 routeData = main.multicastConfig[ routeName ]
1077 srcs = main.mcastRoutes[ routeName ][ "src" ]
1078 dsts = main.mcastRoutes[ routeName ][ "dst" ]
1079 main.log.info( "Sending multicast traffic from {} to {}".format( [ routeData[ "src" ][ i ][ "host" ] for i in srcs ],
1080 [ routeData[ "dst" ][ i ][ "host" ] for i in dsts ] ) )
You Wang85747762018-05-11 15:51:50 -07001081 result = main.TRUE
You Wangc02d8352018-04-17 16:42:10 -07001082 for src in srcs:
1083 srcEntry = routeData[ "src" ][ src ]
1084 for dst in dsts:
1085 dstEntry = routeData[ "dst" ][ dst ]
1086 sender = getattr( main, srcEntry[ "host" ] )
1087 receiver = getattr( main, dstEntry[ "host" ] )
1088 main.Network.addRoute( str( srcEntry[ "host" ] ),
1089 str( routeData[ "group" ] ),
1090 str( srcEntry[ "interface" ] ),
1091 True if routeData[ "ipVersion" ] == 6 else False )
1092 # Build the packet
1093 sender.buildEther( dst=str( srcEntry[ "Ether" ] ) )
1094 if routeData[ "ipVersion" ] == 4:
1095 sender.buildIP( dst=str( routeData[ "group" ] ) )
1096 elif routeData[ "ipVersion" ] == 6:
1097 sender.buildIPv6( dst=str( routeData[ "group" ] ) )
1098 sender.buildUDP( ipVersion=routeData[ "ipVersion" ], dport=srcEntry[ "UDP" ] )
1099 sIface = srcEntry[ "interface" ]
1100 dIface = dstEntry[ "interface" ] if "interface" in dstEntry.keys() else None
1101 pktFilter = srcEntry[ "filter" ]
1102 pkt = srcEntry[ "packet" ]
1103 # Send packet and check received packet
1104 expectedResult = expect.pop( 0 ) if isinstance( expect, list ) else expect
You Wangc564c6f2018-05-01 15:24:57 -07001105 t3Cmd = "t3-troubleshoot -vv -sp {} -et ipv{} -d {} -dm {}".format( srcEntry[ "port" ], routeData[ "ipVersion" ],
1106 routeData[ "group" ], srcEntry[ "Ether" ] )
1107 trafficResult = main.topo.sendScapyPackets( sender, receiver, pktFilter, pkt, sIface, dIface,
1108 expectedResult, maxRetry, True, t3Cmd )
You Wang85747762018-05-11 15:51:50 -07001109 if not trafficResult:
1110 result = main.FALSE
1111 main.log.warn( "Scapy result from {} to {} is not as expected".format( srcEntry[ "host" ],
1112 dstEntry[ "host" ] ) )
1113 utilities.assert_equals( expect=main.TRUE,
1114 actual=result,
1115 onpass="Verify {} multicast traffic: Pass".format( routeName ),
1116 onfail="Verify {} multicast traffic: Fail".format( routeName ) )
1117 if skipOnFail and trafficResult != main.TRUE:
1118 Testcaselib.saveOnosDiagnostics( main )
1119 Testcaselib.cleanup( main, copyKarafLog=False )
1120 main.skipCase()
You Wangc02d8352018-04-17 16:42:10 -07001121
1122 @staticmethod
You Wang85747762018-05-11 15:51:50 -07001123 def verifyPing( main, srcList, dstList, ipv6=False, expect=True, wait=1,
1124 acceptableFailed=0, skipOnFail=True, stepMsg="Verify Ping" ):
You Wang5da39c82018-04-26 22:55:08 -07001125 """
1126 Verify reachability from each host in srcList to each host in dstList
1127 """
1128 from tests.dependencies.topology import Topology
1129 try:
1130 main.topo
1131 except ( NameError, AttributeError ):
1132 main.topo = Topology()
You Wang85747762018-05-11 15:51:50 -07001133 main.step( stepMsg )
You Wang5da39c82018-04-26 22:55:08 -07001134 pingResult = main.topo.ping( srcList, dstList, ipv6, expect, wait, acceptableFailed, skipOnFail )
You Wang85747762018-05-11 15:51:50 -07001135 utilities.assert_equals( expect=main.TRUE,
1136 actual=pingResult,
1137 onpass="{}: Pass".format( stepMsg ),
1138 onfail="{}: Fail".format( stepMsg ) )
You Wang5da39c82018-04-26 22:55:08 -07001139 if not pingResult and skipOnFail:
1140 Testcaselib.saveOnosDiagnostics( main )
1141 Testcaselib.cleanup( main, copyKarafLog=False, removeHostComponent=True )
1142 main.skipCase()
You Wangbc898b82018-05-03 16:22:34 -07001143
1144 @staticmethod
You Wang85747762018-05-11 15:51:50 -07001145 def verifyHostLocations( main, locationDict, retry=2 ):
You Wangbc898b82018-05-03 16:22:34 -07001146 """
1147 Verify if the specified host is discovered by ONOS on the given locations
1148 Required:
You Wang85747762018-05-11 15:51:50 -07001149 locationDict: a dictionary that maps host names to expected locations.
1150 locations could be a string or a list.
1151 ex. { "h1v4": ["of:0000000000000005/8"] }
You Wangbc898b82018-05-03 16:22:34 -07001152 Returns:
1153 main.TRUE if host is discovered on all locations provided, otherwise main.FALSE
1154 """
You Wang85747762018-05-11 15:51:50 -07001155 main.step( "Verify locations of hosts {}".format( locationDict.keys() ) )
1156 result = main.TRUE
1157 for hostName, locations in locationDict.items():
1158 main.log.info( "Verify host {} is discovered at {}".format( hostName, locations ) )
1159 hostIp = main.Network.getIPAddress( hostName, proto='IPV4' )
1160 if not hostIp:
1161 hostIp = main.Network.getIPAddress( hostName, proto='IPV6' )
1162 if not hostIp:
1163 main.log.warn( "Failed to find IP address for host {}, skipping location verification".format( hostName ) )
1164 result = main.FALSE
1165 continue
1166 locationResult = utilities.retry( main.Cluster.active( 0 ).CLI.verifyHostLocation,
1167 main.FALSE,
1168 args=( hostIp, locations ),
1169 attempts=retry + 1,
1170 sleep=10 )
1171 if not locationResult:
1172 result = main.FALSE
1173 main.log.warn( "location verification for host {} failed".format( hostName ) )
You Wang547893e2018-05-08 13:34:59 -07001174 utilities.assert_equals( expect=main.TRUE, actual=result,
You Wang85747762018-05-11 15:51:50 -07001175 onpass="Location verification passed",
1176 onfail="Location verification failed" )