blob: c1efd931b1d5ea48354a282a023d3a7a08e00189 [file] [log] [blame]
Flavio Castro0a05b8d2016-06-16 17:26:51 -07001import os
2import imp
3import time
Flavio Castro49c218d2016-06-21 16:55:57 -07004import json
Flavio Castro0a05b8d2016-06-16 17:26:51 -07005
6from core import utilities
7
8
9class Testcaselib:
10 @staticmethod
11 def initTest( main ):
12 """
13 - Construct tests variables
14 - GIT ( optional )
15 - Checkout ONOS master branch
16 - Pull latest ONOS code
17 - Building ONOS ( optional )
18 - Install ONOS package
19 - Build ONOS package
20 """
Flavio Castro0a05b8d2016-06-16 17:26:51 -070021 main.step( "Constructing test variables" )
22 # Test variables
23 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
24 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
25 main.diff = main.params[ 'ENV' ][ 'diffApps' ]
26 gitBranch = main.params[ 'GIT' ][ 'branch' ]
27 main.path = os.path.dirname( main.testFile )
Flavio Castro5608a392016-06-22 17:02:35 -070028 main.dependencyPath = main.path + "/../dependencies/"
Flavio Castro0a05b8d2016-06-16 17:26:51 -070029 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
30 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
Flavio Castro5608a392016-06-22 17:02:35 -070031 main.scale = (main.params[ 'SCALE' ][ 'size' ]).split( "," )
Flavio Castro0a05b8d2016-06-16 17:26:51 -070032 main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
Flavio Castro5608a392016-06-22 17:02:35 -070033 # main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
Flavio Castro0a05b8d2016-06-16 17:26:51 -070034 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
Flavio Castro5608a392016-06-22 17:02:35 -070035 main.cellData = { } # for creating cell file
36 main.CLIs = [ ]
37 main.ONOSip = [ ]
38 main.RESTs = [ ]
Flavio Castro0a05b8d2016-06-16 17:26:51 -070039
40 # Assigning ONOS cli handles to a list
Flavio Castro5608a392016-06-22 17:02:35 -070041 for i in range( 1, main.maxNodes + 1 ):
Flavio Castro0a05b8d2016-06-16 17:26:51 -070042 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
Flavio Castro49c218d2016-06-21 16:55:57 -070043 main.RESTs.append( getattr( main, 'ONOSrest' + str( i ) ) )
Flavio Castro5608a392016-06-22 17:02:35 -070044 main.ONOSip.append( main.CLIs[ i - 1 ].ip_address )
Flavio Castro0a05b8d2016-06-16 17:26:51 -070045 # -- INIT SECTION, ONLY RUNS ONCE -- #
46 main.startUp = imp.load_source( wrapperFile1,
47 main.dependencyPath +
48 wrapperFile1 +
49 ".py" )
50
51 copyResult1 = main.ONOSbench.scp( main.Mininet1,
52 main.dependencyPath +
53 main.topology,
54 main.Mininet1.home,
55 direction="to" )
56 if main.CLIs:
57 stepResult = main.TRUE
58 else:
59 main.log.error( "Did not properly created list of ONOS CLI handle" )
60 stepResult = main.FALSE
61
62 utilities.assert_equals( expect=main.TRUE,
63 actual=stepResult,
64 onpass="Successfully construct " +
65 "test variables ",
66 onfail="Failed to construct test variables" )
67
68 @staticmethod
69 def installOnos( main ):
70 """
71 - Set up cell
72 - Create cell file
73 - Set cell file
74 - Verify cell file
75 - Kill ONOS process
76 - Uninstall ONOS cluster
77 - Verify ONOS start up
78 - Install ONOS cluster
79 - Connect to cli
80 """
81 # main.scale[ 0 ] determines the current number of ONOS controller
Flavio Castro5608a392016-06-22 17:02:35 -070082 apps = main.apps
Flavio Castro0a05b8d2016-06-16 17:26:51 -070083 if main.diff:
84 apps = main.apps + "," + main.diff
Flavio Castro5608a392016-06-22 17:02:35 -070085 else:
86 main.log.error( "App list is empty" )
Flavio Castro0a05b8d2016-06-16 17:26:51 -070087 print "NODE COUNT = ", main.numCtrls
88 print main.ONOSip
Flavio Castro5608a392016-06-22 17:02:35 -070089 tempOnosIp = [ ]
Flavio Castro0a05b8d2016-06-16 17:26:51 -070090 for i in range( main.numCtrls ):
Flavio Castro5608a392016-06-22 17:02:35 -070091 tempOnosIp.append( main.ONOSip[ i ] )
Flavio Castro0a05b8d2016-06-16 17:26:51 -070092 onosUser = main.params[ 'ENV' ][ 'cellUser' ]
Flavio Castro5608a392016-06-22 17:02:35 -070093 main.step( "Create and Apply cell file" )
Flavio Castro0a05b8d2016-06-16 17:26:51 -070094 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
95 "temp",
96 main.Mininet1.ip_address,
97 apps,
98 tempOnosIp,
99 onosUser )
100 cellResult = main.ONOSbench.setCell( "temp" )
Flavio Castro5608a392016-06-22 17:02:35 -0700101 verifyResult = main.ONOSbench.verifyCell( )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700102 stepResult = cellResult and verifyResult
103 utilities.assert_equals( expect=main.TRUE,
104 actual=stepResult,
105 onpass="Successfully applied cell to " + \
106 "environment",
107 onfail="Failed to apply cell to environment " )
Flavio Castro5608a392016-06-22 17:02:35 -0700108 # kill off all onos processes
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700109 main.log.info( "Safety check, killing all ONOS processes" +
110 " before initiating environment setup" )
111 for i in range( main.maxNodes ):
112 main.ONOSbench.onosDie( main.ONOSip[ i ] )
113 main.step( "Create and Install ONOS package" )
Flavio Castro5608a392016-06-22 17:02:35 -0700114 packageResult = main.ONOSbench.onosPackage( )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700115
116 onosInstallResult = main.TRUE
117 for i in range( main.numCtrls ):
118 onosInstallResult = onosInstallResult and \
Flavio Castro5608a392016-06-22 17:02:35 -0700119 main.ONOSbench.onosInstall(
Flavio Castro519072e2016-06-23 13:30:48 -0700120 node=main.ONOSip[ i ] )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700121 stepResult = onosInstallResult
122 utilities.assert_equals( expect=main.TRUE,
123 actual=stepResult,
124 onpass="Successfully installed ONOS package",
125 onfail="Failed to install ONOS package" )
126 main.step( "Starting ONOS service" )
Flavio Castro5608a392016-06-22 17:02:35 -0700127 stopResult, startResult, onosIsUp = main.TRUE, main.TRUE, main.TRUE,
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700128 for i in range( main.numCtrls ):
129 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
130 if onosIsUp == main.TRUE:
131 main.log.report( "ONOS instance is up and ready" )
132 else:
133 main.log.report( "ONOS instance may not be up, stop and " +
134 "start ONOS again " )
135 for i in range( main.numCtrls ):
136 stopResult = stopResult and \
137 main.ONOSbench.onosStop( main.ONOSip[ i ] )
138 for i in range( main.numCtrls ):
139 startResult = startResult and \
140 main.ONOSbench.onosStart( main.ONOSip[ i ] )
141 stepResult = onosIsUp and stopResult and startResult
142
143 utilities.assert_equals( expect=main.TRUE,
144 actual=stepResult,
145 onpass="ONOS service is ready",
146 onfail="ONOS service did not start properly" )
147 main.step( "Checking if ONOS CLI is ready" )
148 for i in range( main.numCtrls ):
Flavio Castro5608a392016-06-22 17:02:35 -0700149 main.CLIs[ i ].startCellCli( )
150 cliResult = main.CLIs[ i ].startOnosCli( main.ONOSip[ i ],
151 commandlineTimeout=60,
152 onosStartTimeout=100 )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700153 utilities.assert_equals( expect=main.TRUE,
154 actual=cliResult,
155 onpass="ONOS CLI is ready",
156 onfail="ONOS CLI is not ready" )
Flavio Castro5608a392016-06-22 17:02:35 -0700157 main.active = 0
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700158 for i in range( 10 ):
159 ready = True
Flavio Castro5608a392016-06-22 17:02:35 -0700160 output = main.CLIs[ main.active ].summary( )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700161 if not output:
162 ready = False
163 if ready:
164 break
165 time.sleep( 10 )
166 utilities.assert_equals( expect=True, actual=ready,
167 onpass="ONOS summary command succeded",
168 onfail="ONOS summary command failed" )
169
Flavio Castro49c218d2016-06-21 16:55:57 -0700170 with open( main.dependencyPath + "/" + main.cfgName + ".json" ) as cfg:
Flavio Castro5608a392016-06-22 17:02:35 -0700171 main.RESTs[ main.active ].setNetCfg( json.load( cfg ) )
Flavio Castro49c218d2016-06-21 16:55:57 -0700172
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700173 if not ready:
174 main.log.error( "ONOS startup failed!" )
Flavio Castro5608a392016-06-22 17:02:35 -0700175 main.cleanup( )
176 main.exit( )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700177
178 for i in range( main.numCtrls ):
Flavio Castro5608a392016-06-22 17:02:35 -0700179 main.CLIs[ i ].logSet( "DEBUG", "org.onosproject.segmentrouting" )
180 main.CLIs[ i ].logSet( "DEBUG", "org.onosproject.driver.pipeline" )
181 main.CLIs[ i ].logSet( "DEBUG", "org.onosproject.store.group.impl" )
182 main.CLIs[ i ].logSet( "DEBUG",
183 "org.onosproject.net.flowobjective.impl" )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700184
185 @staticmethod
186 def startMininet( main, topology, args="" ):
187 main.step( "Starting Mininet Topology" )
188 arg = "--onos %d %s" % (main.numCtrls, args)
Flavio Castro5608a392016-06-22 17:02:35 -0700189 main.topology = topology
190 topoResult = main.Mininet1.startNet(
Flavio Castro519072e2016-06-23 13:30:48 -0700191 topoFile=main.dependencyPath + main.topology, args=arg )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700192 stepResult = topoResult
193 utilities.assert_equals( expect=main.TRUE,
194 actual=stepResult,
195 onpass="Successfully loaded topology",
196 onfail="Failed to load topology" )
197 # Exit if topology did not load properly
198 if not topoResult:
Flavio Castro5608a392016-06-22 17:02:35 -0700199 main.cleanup( )
200 main.exit( )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700201
202 @staticmethod
Flavio Castro5608a392016-06-22 17:02:35 -0700203 def checkFlows( main, minFlowCount ):
204 main.step(
Flavio Castro519072e2016-06-23 13:30:48 -0700205 " Check whether the flow count is bigger than %s" % minFlowCount )
Flavio Castro5608a392016-06-22 17:02:35 -0700206 count = utilities.retry( main.CLIs[ main.active ].checkFlowCount,
Flavio Castro02b43632016-06-20 17:07:27 -0700207 main.FALSE,
Flavio Castro5608a392016-06-22 17:02:35 -0700208 kwargs={ 'min': minFlowCount },
Flavio Castro02b43632016-06-20 17:07:27 -0700209 attempts=10,
Flavio Castro5608a392016-06-22 17:02:35 -0700210 sleep=10 )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700211 utilities.assertEquals( \
212 expect=True,
Flavio Castro5608a392016-06-22 17:02:35 -0700213 actual=(count > 0),
214 onpass="Flow count looks correct: " + str( count ),
215 onfail="Flow count looks wrong: " + str( count ) )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700216
217 main.step( "Check whether all flow status are ADDED" )
Flavio Castro5608a392016-06-22 17:02:35 -0700218 flowCheck = utilities.retry( main.CLIs[ main.active ].checkFlowsState,
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700219 main.FALSE,
Flavio Castro5608a392016-06-22 17:02:35 -0700220 kwargs={ 'isPENDING': False },
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700221 attempts=10,
Flavio Castro5608a392016-06-22 17:02:35 -0700222 sleep=10 )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700223 utilities.assertEquals( \
224 expect=main.TRUE,
225 actual=flowCheck,
226 onpass="Flow status is correct!",
227 onfail="Flow status is wrong!" )
Flavio Castro5608a392016-06-22 17:02:35 -0700228 main.ONOSbench.dumpFlows( main.ONOSip[ main.active ],
229 main.logdir, "flowsBefore" + main.cfgName )
230 main.ONOSbench.dumpGroups( main.ONOSip[ 0 ],
231 main.logdir, "groupsBefore" + main.cfgName )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700232
233 @staticmethod
Flavio Castro519072e2016-06-23 13:30:48 -0700234 def pingAll( main, tag="", dumpflows=True ):
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700235 main.log.report( "Check full connectivity" )
Flavio Castroe168f7f2016-06-24 15:53:12 -0700236 main.step("Check IP connectivity %s" %tag)
237 hosts = main.Mininet1.getHosts().keys()
238 vlan10 = [ '%s10' % s for s in [ 'olt', 'vsg' ] ]
239 vlan5 = [ '%s5' % s for s in [ 'olt', 'vsg' ] ]
240 IPHosts = [ host for host in hosts if host not in ( vlan10 + vlan5 ) ]
241 pa = main.Mininet1.pingallHosts(IPHosts)
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700242 utilities.assert_equals( expect=main.TRUE, actual=pa,
Flavio Castroe168f7f2016-06-24 15:53:12 -0700243 onpass="IP connectivity successfully tested",
244 onfail="IP connectivity failed" )
245 main.step("Check VLAN connectivity %s" %tag)
246 p1 = main.Mininet1.pingallHosts(vlan5)
247 p2 = main.Mininet1.pingallHosts(vlan10)
248 utilities.assert_equals( expect=main.TRUE, actual=p1&p2,
249 onpass="Vlan connectivity successfully tested",
250 onfail="Vlan connectivity failed" )
Flavio Castro519072e2016-06-23 13:30:48 -0700251 if dumpflows:
252 main.ONOSbench.dumpFlows( main.ONOSip[ main.active ],
253 main.logdir, "flowsOn" + tag )
254 main.ONOSbench.dumpGroups( main.ONOSip[ main.active ],
255 main.logdir, "groupsOn" + tag )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700256
257 @staticmethod
258 def killLink( main, end1, end2, switches, links ):
259 """
260 end1,end2: identify the switches, ex.: 'leaf1', 'spine1'
261 switches, links: number of expected switches and links after linkDown, ex.: '4', '6'
262 Kill a link and verify ONOS can see the proper link change
263 """
264 main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Flavio Castro5608a392016-06-22 17:02:35 -0700265 main.step( "Kill link between %s and %s" % (end1, end2) )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700266 LinkDown = main.Mininet1.link( END1=end1, END2=end2, OPTION="down" )
Flavio Castro5608a392016-06-22 17:02:35 -0700267 main.log.info(
Flavio Castro519072e2016-06-23 13:30:48 -0700268 "Waiting %s seconds for link down to be discovered" % main.linkSleep )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700269 time.sleep( main.linkSleep )
Flavio Castro5608a392016-06-22 17:02:35 -0700270 topology = utilities.retry( main.CLIs[ main.active ].checkStatus,
271 main.FALSE,
272 kwargs={ 'numoswitch': switches,
273 'numolink': links },
274 attempts=10,
275 sleep=main.linkSleep )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700276 result = topology & LinkDown
277 utilities.assert_equals( expect=main.TRUE, actual=result,
278 onpass="Link down successful",
279 onfail="Failed to turn off link?" )
280
281 @staticmethod
Flavio Castro5608a392016-06-22 17:02:35 -0700282 def restoreLink( main, end1, end2, dpid1, dpid2, port1, port2, switches,
283 links ):
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700284 """
285 Params:
286 end1,end2: identify the end switches, ex.: 'leaf1', 'spine1'
287 dpid1, dpid2: dpid of the end switches respectively, ex.: 'of:0000000000000002'
Flavio Castro02b43632016-06-20 17:07:27 -0700288 port1, port2: respective port of the end switches that connects to the link, ex.:'1'
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700289 switches, links: number of expected switches and links after linkDown, ex.: '4', '6'
290 Kill a link and verify ONOS can see the proper link change
291 """
Flavio Castro5608a392016-06-22 17:02:35 -0700292 main.step( "Restore link between %s and %s" % (end1, end2) )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700293 result = False
Flavio Castro5608a392016-06-22 17:02:35 -0700294 count = 0
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700295 while True:
Flavio Castrod1f36892016-07-06 11:49:11 -0700296 count += 1
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700297 main.Mininet1.link( END1=end1, END2=end2, OPTION="up" )
298 main.Mininet1.link( END2=end1, END1=end2, OPTION="up" )
Flavio Castro5608a392016-06-22 17:02:35 -0700299 main.log.info(
Flavio Castro519072e2016-06-23 13:30:48 -0700300 "Waiting %s seconds for link up to be discovered" % main.linkSleep )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700301 time.sleep( main.linkSleep )
Flavio Castro5608a392016-06-22 17:02:35 -0700302 main.CLIs[ main.active ].portstate( dpid=dpid1, port=port1 )
303 main.CLIs[ main.active ].portstate( dpid=dpid2, port=port2 )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700304 time.sleep( main.linkSleep )
305
Flavio Castro5608a392016-06-22 17:02:35 -0700306 result = main.CLIs[ main.active ].checkStatus( numoswitch=switches,
307 numolink=links )
308 if count > 5 or result:
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700309 break
310 utilities.assert_equals( expect=main.TRUE, actual=result,
311 onpass="Link up successful",
312 onfail="Failed to bring link up" )
313
314 @staticmethod
315 def killSwitch( main, switch, switches, links ):
316 """
317 Params: switches, links: number of expected switches and links after SwitchDown, ex.: '4', '6'
Flavio Castro02b43632016-06-20 17:07:27 -0700318 Completely kill a switch and verify ONOS can see the proper change
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700319 """
320 main.switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
321 main.step( "Kill " + switch )
322 main.log.info( "Stopping" + switch )
323 main.Mininet1.switch( SW=switch, OPTION="stop" )
Flavio Castro5608a392016-06-22 17:02:35 -0700324 # todo make this repeatable
325 main.log.info( "Waiting %s seconds for switch down to be discovered" % (
Flavio Castro519072e2016-06-23 13:30:48 -0700326 main.switchSleep) )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700327 time.sleep( main.switchSleep )
Flavio Castro5608a392016-06-22 17:02:35 -0700328 topology = utilities.retry( main.CLIs[ main.active ].checkStatus,
329 main.FALSE,
330 kwargs={ 'numoswitch': switches,
331 'numolink': links },
332 attempts=10,
333 sleep=main.switchSleep )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700334 utilities.assert_equals( expect=main.TRUE, actual=topology,
335 onpass="Kill switch successful",
336 onfail="Failed to kill switch?" )
337
338 @staticmethod
339 def recoverSwitch( main, switch, switches, links ):
340 """
341 Params: switches, links: number of expected switches and links after SwitchUp, ex.: '4', '6'
342 Recover a switch and verify ONOS can see the proper change
343 """
Flavio Castro5608a392016-06-22 17:02:35 -0700344 # todo make this repeatable
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700345 main.step( "Recovering " + switch )
346 main.log.info( "Starting" + switch )
Flavio Castro5608a392016-06-22 17:02:35 -0700347 main.Mininet1.switch( SW=switch, OPTION="start" )
348 main.log.info( "Waiting %s seconds for switch up to be discovered" % (
Flavio Castro519072e2016-06-23 13:30:48 -0700349 main.switchSleep) )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700350 time.sleep( main.switchSleep )
Flavio Castro5608a392016-06-22 17:02:35 -0700351 topology = utilities.retry( main.CLIs[ main.active ].checkStatus,
352 main.FALSE,
353 kwargs={ 'numoswitch': switches,
354 'numolink': links },
355 attempts=10,
356 sleep=main.switchSleep )
Flavio Castro0a05b8d2016-06-16 17:26:51 -0700357 utilities.assert_equals( expect=main.TRUE, actual=topology,
358 onpass="Switch recovery successful",
359 onfail="Failed to recover switch?" )
360
361 @staticmethod
362 def cleanup( main ):
363 """
364 Stop Onos-cluster.
365 Stops Mininet
366 Copies ONOS log
367 """
Flavio Castro5608a392016-06-22 17:02:35 -0700368 main.Mininet1.stopNet( )
Flavio Castro49c218d2016-06-21 16:55:57 -0700369 main.ONOSbench.scp( main.ONOScli1, "/opt/onos/log/karaf.log",
Flavio Castro5608a392016-06-22 17:02:35 -0700370 "/tmp/karaf.log", direction="from" )
Flavio Castro49c218d2016-06-21 16:55:57 -0700371 main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
Flavio Castro5608a392016-06-22 17:02:35 -0700372 copyFileName="karaf.log." + main.cfgName )
Flavio Castro49c218d2016-06-21 16:55:57 -0700373 for i in range( main.numCtrls ):
Flavio Castro5608a392016-06-22 17:02:35 -0700374 main.ONOSbench.onosStop( main.ONOSip[ i ] )
Flavio Castro519072e2016-06-23 13:30:48 -0700375
376 @staticmethod
377 def killOnos( main, nodes, switches, links, expNodes ):
378 """
379 Params: nodes, integer array with position of the ONOS nodes in the CLIs array
380 switches, links, nodes: number of expected switches, links and nodes after KillOnos, ex.: '4', '6'
381 Completely Kill an ONOS instance and verify the ONOS cluster can see the proper change
382 """
383 main.step( "Killing ONOS instance" )
384 for i in nodes:
385 killResult = main.ONOSbench.onosDie( main.CLIs[ i ].ip_address )
386 utilities.assert_equals( expect=main.TRUE, actual=killResult,
387 onpass="ONOS instance Killed",
388 onfail="Error killing ONOS instance" )
389 if i == main.active:
390 main.active = (i + 1) % main.numCtrls
391 time.sleep( 12 )
392 if len( nodes ) < main.numCtrls:
393 topology = utilities.retry( main.CLIs[ main.active ].checkStatus,
394 main.FALSE,
395 kwargs={ 'numoswitch': switches,
396 'numolink': links,
397 'numoctrl': expNodes },
398 attempts=10,
399 sleep=12 )
400 utilities.assert_equals( expect=main.TRUE, actual=topology,
401 onpass="ONOS Instance down successful",
402 onfail="Failed to turn off ONOS Instance" )
403 else:
404 main.active = -1
405
406 @staticmethod
407 def recoverOnos( main, nodes, switches, links, expNodes ):
408 """
409 Params: nodes, integer array with position of the ONOS nodes in the CLIs array
410 switches, links, nodes: number of expected switches, links and nodes after recoverOnos, ex.: '4', '6'
411 Recover an ONOS instance and verify the ONOS cluster can see the proper change
412 """
413 main.step( "Recovering ONOS instance" )
414 [ main.ONOSbench.onosStart( main.CLIs[ i ].ip_address ) for i in nodes ]
415 for i in nodes:
416 isUp = main.ONOSbench.isup( main.ONOSip[ i ] )
417 utilities.assert_equals( expect=main.TRUE, actual=isUp,
418 onpass="ONOS service is ready",
419 onfail="ONOS service did not start properly" )
420 for i in nodes:
421 main.step( "Checking if ONOS CLI is ready" )
422 main.CLIs[ i ].startCellCli( )
423 cliResult = main.CLIs[ i ].startOnosCli( main.ONOSip[ i ],
424 commandlineTimeout=60,
425 onosStartTimeout=100 )
426 utilities.assert_equals( expect=main.TRUE,
427 actual=cliResult,
428 onpass="ONOS CLI is ready",
429 onfail="ONOS CLI is not ready" )
430 main.active = i if main.active == -1 else main.active
431
432 topology = utilities.retry( main.CLIs[ main.active ].checkStatus,
433 main.FALSE,
434 kwargs={ 'numoswitch': switches,
435 'numolink': links,
436 'numoctrl': expNodes },
437 attempts=10,
438 sleep=12 )
439 utilities.assert_equals( expect=main.TRUE, actual=topology,
440 onpass="ONOS Instance down successful",
441 onfail="Failed to turn off ONOS Instance" )
442
443 for i in range( 10 ):
444 ready = True
445 output = main.CLIs[ main.active ].summary( )
446 if not output:
447 ready = False
448 if ready:
449 break
450 time.sleep( 10 )
451 utilities.assert_equals( expect=True, actual=ready,
452 onpass="ONOS summary command succeded",
453 onfail="ONOS summary command failed" )
454 if not ready:
455 main.log.error( "ONOS startup failed!" )
456 main.cleanup( )
457 main.exit( )