blob: 1f96ed1dca87d7837296b40799e630b1e6da12ed [file] [log] [blame]
Jon Hall85794ff2015-07-08 14:12:30 -07001"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002Copyright 2015 Open Networking Foundation (ONF)
3
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
11 (at your option) any later version.
12
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"""
21
22"""
Jon Hall85794ff2015-07-08 14:12:30 -070023Description: This test is to determine if a single
24 instance ONOS 'cluster' can handle a restart
25
26List of test cases:
27CASE1: Compile ONOS and push it to the test machines
28CASE2: Assign devices to controllers
29CASE21: Assign mastership to controllers
30CASE3: Assign intents
31CASE4: Ping across added host intents
32CASE5: Reading state of ONOS
33CASE6: The Failure case.
34CASE7: Check state after control plane failure
35CASE8: Compare topo
36CASE9: Link s3-s28 down
37CASE10: Link s3-s28 up
38CASE11: Switch down
39CASE12: Switch up
40CASE13: Clean up
41CASE14: start election app on all onos nodes
42CASE15: Check that Leadership Election is still functional
43CASE16: Install Distributed Primitives app
44CASE17: Check for basic functionality with distributed primitives
45"""
Jon Hall85794ff2015-07-08 14:12:30 -070046class HAsingleInstanceRestart:
47
48 def __init__( self ):
49 self.default = ''
50
51 def CASE1( self, main ):
52 """
53 CASE1 is to compile ONOS and push it to the test machines
54
55 Startup sequence:
56 cell <name>
57 onos-verify-cell
58 NOTE: temporary - onos-remove-raft-logs
59 onos-uninstall
60 start mininet
61 git pull
62 mvn clean install
63 onos-package
64 onos-install -f
65 onos-wait-for-start
66 start cli sessions
67 start tcpdump
68 """
Jon Halle1a3b752015-07-22 13:02:46 -070069 import imp
Jon Hallf3d16e72015-12-16 17:45:08 -080070 import time
Jon Halla440e872016-03-31 15:15:50 -070071 import json
Jon Hall85794ff2015-07-08 14:12:30 -070072 main.log.info( "ONOS Single node cluster restart " +
73 "HA test - initialization" )
74 main.case( "Setting up test environment" )
Jon Hall783bbf92015-07-23 14:33:19 -070075 main.caseExplanation = "Setup the test environment including " +\
Jon Hall85794ff2015-07-08 14:12:30 -070076 "installing ONOS, starting Mininet and ONOS" +\
77 "cli sessions."
Jon Hall85794ff2015-07-08 14:12:30 -070078
79 # load some variables from the params file
80 PULLCODE = False
Devin Lim58046fa2017-07-05 16:55:00 -070081 if main.params[ 'GIT' ][ 'pull' ] == 'True':
Jon Hall85794ff2015-07-08 14:12:30 -070082 PULLCODE = True
Devin Lim58046fa2017-07-05 16:55:00 -070083 gitBranch = main.params[ 'GIT' ][ 'branch' ]
Jon Hall85794ff2015-07-08 14:12:30 -070084 cellName = main.params[ 'ENV' ][ 'cellName' ]
85
Jon Halle1a3b752015-07-22 13:02:46 -070086 main.numCtrls = int( main.params[ 'num_controllers' ] )
Jon Hall5cf14d52015-07-16 12:15:19 -070087 if main.ONOSbench.maxNodes:
Jon Halle1a3b752015-07-22 13:02:46 -070088 if main.ONOSbench.maxNodes < main.numCtrls:
89 main.numCtrls = int( main.ONOSbench.maxNodes )
Devin Lim58046fa2017-07-05 16:55:00 -070090 # These are for csv plotting in jenkins
91 main.HAlabels = []
92 main.HAdata = []
Jon Halle1a3b752015-07-22 13:02:46 -070093 try:
Jon Hall53c5e662016-04-13 16:06:56 -070094 from tests.HA.dependencies.HA import HA
Jon Hall41d39f12016-04-11 22:54:35 -070095 main.HA = HA()
Devin Lim58046fa2017-07-05 16:55:00 -070096 except ImportError as e:
Jon Halle1a3b752015-07-22 13:02:46 -070097 main.log.exception( e )
98 main.cleanup()
99 main.exit()
100
101 main.CLIs = []
102 main.nodes = []
Jon Hall5cf14d52015-07-16 12:15:19 -0700103 ipList = []
104 for i in range( 1, int( main.ONOSbench.maxNodes ) + 1 ):
105 try:
Jon Halle1a3b752015-07-22 13:02:46 -0700106 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
107 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
108 ipList.append( main.nodes[ -1 ].ip_address )
Jon Hall5cf14d52015-07-16 12:15:19 -0700109 except AttributeError:
110 break
Jon Hall85794ff2015-07-08 14:12:30 -0700111
Jon Hall5cf14d52015-07-16 12:15:19 -0700112 main.step( "Create cell file" )
113 cellAppString = main.params[ 'ENV' ][ 'appString' ]
114 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
115 main.Mininet1.ip_address,
Devin Limdc78e202017-06-09 18:30:07 -0700116 cellAppString, ipList, main.ONOScli1.karafUser )
Jon Hall85794ff2015-07-08 14:12:30 -0700117 main.step( "Applying cell variable to environment" )
118 cellResult = main.ONOSbench.setCell( cellName )
119 verifyResult = main.ONOSbench.verifyCell()
120
121 # FIXME:this is short term fix
122 main.log.info( "Removing raft logs" )
123 main.ONOSbench.onosRemoveRaftLogs()
124
125 main.log.info( "Uninstalling ONOS" )
Jon Halle1a3b752015-07-22 13:02:46 -0700126 for node in main.nodes:
Jon Hall85794ff2015-07-08 14:12:30 -0700127 main.ONOSbench.onosUninstall( node.ip_address )
128
129 # Make sure ONOS is DEAD
130 main.log.info( "Killing any ONOS processes" )
131 killResults = main.TRUE
Jon Halle1a3b752015-07-22 13:02:46 -0700132 for node in main.nodes:
Jon Hall85794ff2015-07-08 14:12:30 -0700133 killed = main.ONOSbench.onosKill( node.ip_address )
134 killResults = killResults and killed
135
Jon Hall85794ff2015-07-08 14:12:30 -0700136 gitPullResult = main.TRUE
137
Devin Lim58046fa2017-07-05 16:55:00 -0700138 main.HA.startingMininet()
Jon Hall85794ff2015-07-08 14:12:30 -0700139
140 main.step( "Git checkout and pull " + gitBranch )
141 if PULLCODE:
142 main.ONOSbench.gitCheckout( gitBranch )
143 gitPullResult = main.ONOSbench.gitPull()
144 # values of 1 or 3 are good
145 utilities.assert_lesser( expect=0, actual=gitPullResult,
146 onpass="Git pull successful",
147 onfail="Git pull failed" )
148 main.ONOSbench.getVersion( report=True )
149
Devin Lim58046fa2017-07-05 16:55:00 -0700150 main.HA.generateGraph( "HAsingleInstanceRestart" )
Jon Hall85794ff2015-07-08 14:12:30 -0700151
Jon Halle1a3b752015-07-22 13:02:46 -0700152 main.CLIs = []
153 main.nodes = []
Jon Hall5cf14d52015-07-16 12:15:19 -0700154 ipList = []
Jon Halle1a3b752015-07-22 13:02:46 -0700155 for i in range( 1, main.numCtrls + 1 ):
156 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
157 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
158 ipList.append( main.nodes[ -1 ].ip_address )
Jon Hall5cf14d52015-07-16 12:15:19 -0700159
160 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, "SingleHA",
161 main.Mininet1.ip_address,
Devin Limdc78e202017-06-09 18:30:07 -0700162 cellAppString, ipList[ 0 ], main.ONOScli1.karafUser )
Jon Hall85794ff2015-07-08 14:12:30 -0700163 cellResult = main.ONOSbench.setCell( "SingleHA" )
164 verifyResult = main.ONOSbench.verifyCell()
165 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700166 packageResult = main.ONOSbench.buckBuild()
Jon Hall85794ff2015-07-08 14:12:30 -0700167 utilities.assert_equals( expect=main.TRUE, actual=packageResult,
168 onpass="ONOS package successful",
169 onfail="ONOS package failed" )
170
171 main.step( "Installing ONOS package" )
Jon Halla440e872016-03-31 15:15:50 -0700172 onosInstallResult = main.TRUE
173 for node in main.nodes:
174 tmpResult = main.ONOSbench.onosInstall( options="-f",
175 node=node.ip_address )
176 onosInstallResult = onosInstallResult and tmpResult
Jon Hall85794ff2015-07-08 14:12:30 -0700177 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
178 onpass="ONOS install successful",
179 onfail="ONOS install failed" )
180
You Wangf5de25b2017-01-06 15:13:01 -0800181 main.step( "Set up ONOS secure SSH" )
182 secureSshResult = main.TRUE
183 for node in main.nodes:
184 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
185 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
186 onpass="Test step PASS",
187 onfail="Test step FAIL" )
188
Jon Hall85794ff2015-07-08 14:12:30 -0700189 main.step( "Checking if ONOS is up yet" )
190 for i in range( 2 ):
Jon Halla440e872016-03-31 15:15:50 -0700191 onosIsupResult = main.TRUE
192 for node in main.nodes:
193 started = main.ONOSbench.isup( node.ip_address )
194 if not started:
195 main.log.error( node.name + " hasn't started" )
196 onosIsupResult = onosIsupResult and started
197 if onosIsupResult == main.TRUE:
Jon Hall85794ff2015-07-08 14:12:30 -0700198 break
Jon Halla440e872016-03-31 15:15:50 -0700199 utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult,
Jon Hall85794ff2015-07-08 14:12:30 -0700200 onpass="ONOS startup successful",
201 onfail="ONOS startup failed" )
202
Jon Hall6509dbf2016-06-21 17:01:17 -0700203 main.step( "Starting ONOS CLI sessions" )
Jon Halla440e872016-03-31 15:15:50 -0700204 cliResults = main.TRUE
205 threads = []
206 for i in range( main.numCtrls ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700207 t = main.Thread( target=main.CLIs[ i ].startOnosCli,
Jon Halla440e872016-03-31 15:15:50 -0700208 name="startOnosCli-" + str( i ),
Jon Hallf37d44d2017-05-24 10:37:30 -0700209 args=[ main.nodes[ i ].ip_address ] )
Jon Halla440e872016-03-31 15:15:50 -0700210 threads.append( t )
211 t.start()
212
213 for t in threads:
214 t.join()
215 cliResults = cliResults and t.result
Jon Hall85794ff2015-07-08 14:12:30 -0700216 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
217 onpass="ONOS cli startup successful",
218 onfail="ONOS cli startup failed" )
219
Devin Lim58046fa2017-07-05 16:55:00 -0700220 main.HA.initialSetUp()
Jon Hall9d2dcad2016-04-08 10:15:20 -0700221
Jon Hall85794ff2015-07-08 14:12:30 -0700222 def CASE2( self, main ):
223 """
224 Assign devices to controllers
225 """
Devin Lim58046fa2017-07-05 16:55:00 -0700226 main.HA.assignDevices( main )
Jon Hall85794ff2015-07-08 14:12:30 -0700227
228 def CASE21( self, main ):
229 """
230 Assign mastership to controllers
231 """
Devin Lim58046fa2017-07-05 16:55:00 -0700232 main.HA.assignMastership( main )
Jon Hall85794ff2015-07-08 14:12:30 -0700233
234 def CASE3( self, main ):
235 """
236 Assign intents
237 """
Devin Lim58046fa2017-07-05 16:55:00 -0700238 main.HA.assignIntents( main )
Jon Hall85794ff2015-07-08 14:12:30 -0700239
240 def CASE4( self, main ):
241 """
242 Ping across added host intents
243 """
Devin Lim58046fa2017-07-05 16:55:00 -0700244 main.HA.pingAcrossHostIntent( main, False, True )
Jon Hall85794ff2015-07-08 14:12:30 -0700245
246 def CASE5( self, main ):
247 """
248 Reading state of ONOS
249 """
250 import json
Jon Halle1a3b752015-07-22 13:02:46 -0700251 assert main.numCtrls, "main.numCtrls not defined"
Jon Hall85794ff2015-07-08 14:12:30 -0700252 assert main, "main not defined"
253 assert utilities.assert_equals, "utilities.assert_equals not defined"
254
255 main.case( "Setting up and gathering data for current state" )
256 # The general idea for this test case is to pull the state of
257 # ( intents,flows, topology,... ) from each ONOS node
258 # We can then compare them with each other and also with past states
259
260 main.step( "Check that each switch has a master" )
261 global mastershipState
262 mastershipState = '[]'
263
264 # Assert that each device has a master
Jon Halla440e872016-03-31 15:15:50 -0700265 rolesNotNull = main.TRUE
266 threads = []
267 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700268 t = main.Thread( target=main.CLIs[ i ].rolesNotNull,
Jon Halla440e872016-03-31 15:15:50 -0700269 name="rolesNotNull-" + str( i ),
270 args=[] )
271 threads.append( t )
272 t.start()
273
274 for t in threads:
275 t.join()
276 rolesNotNull = rolesNotNull and t.result
Jon Hall85794ff2015-07-08 14:12:30 -0700277 utilities.assert_equals(
278 expect=main.TRUE,
279 actual=rolesNotNull,
280 onpass="Each device has a master",
281 onfail="Some devices don't have a master assigned" )
282
283 main.step( "Get the Mastership of each switch" )
284 ONOS1Mastership = main.ONOScli1.roles()
285 # TODO: Make this a meaningful check
286 if "Error" in ONOS1Mastership or not ONOS1Mastership:
287 main.log.error( "Error in getting ONOS roles" )
288 main.log.warn(
289 "ONOS1 mastership response: " +
290 repr( ONOS1Mastership ) )
291 consistentMastership = main.FALSE
292 else:
293 mastershipState = ONOS1Mastership
294 consistentMastership = main.TRUE
295
296 main.step( "Get the intents from each controller" )
297 global intentState
298 intentState = []
299 ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
300 intentCheck = main.FALSE
301 if "Error" in ONOS1Intents or not ONOS1Intents:
302 main.log.error( "Error in getting ONOS intents" )
303 main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
304 else:
305 intentCheck = main.TRUE
306
307 main.step( "Get the flows from each controller" )
308 global flowState
309 flowState = []
310 flowCheck = main.FALSE
311 ONOS1Flows = main.ONOScli1.flows( jsonFormat=True )
312 if "Error" in ONOS1Flows or not ONOS1Flows:
313 main.log.error( "Error in getting ONOS flows" )
314 main.log.warn( "ONOS1 flows repsponse: " + ONOS1Flows )
315 else:
316 # TODO: Do a better check, maybe compare flows on switches?
317 flowState = ONOS1Flows
318 flowCheck = main.TRUE
319
320 main.step( "Get the OF Table entries" )
321 global flows
322 flows = []
323 for i in range( 1, 29 ):
GlennRC68467eb2015-11-16 18:01:01 -0800324 flows.append( main.Mininet1.getFlowTable( "s" + str( i ), version="1.3", debug=False ) )
Jon Hall85794ff2015-07-08 14:12:30 -0700325 if flowCheck == main.FALSE:
326 for table in flows:
327 main.log.warn( table )
328 # TODO: Compare switch flow tables with ONOS flow tables
329
330 main.step( "Collecting topology information from ONOS" )
331 devices = []
332 devices.append( main.ONOScli1.devices() )
333 hosts = []
334 hosts.append( json.loads( main.ONOScli1.hosts() ) )
335 ports = []
336 ports.append( main.ONOScli1.ports() )
337 links = []
338 links.append( main.ONOScli1.links() )
339 clusters = []
340 clusters.append( main.ONOScli1.clusters() )
341
342 main.step( "Each host has an IP address" )
343 ipResult = main.TRUE
344 for controller in range( 0, len( hosts ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700345 controllerStr = str( main.activeNodes[ controller ] + 1 )
Jon Halla440e872016-03-31 15:15:50 -0700346 if hosts[ controller ]:
347 for host in hosts[ controller ]:
Jon Hallf37d44d2017-05-24 10:37:30 -0700348 if not host.get( 'ipAddresses', [] ):
Jon Halla440e872016-03-31 15:15:50 -0700349 main.log.error( "Error with host ips on controller" +
350 controllerStr + ": " + str( host ) )
351 ipResult = main.FALSE
Jon Hall85794ff2015-07-08 14:12:30 -0700352 utilities.assert_equals(
353 expect=main.TRUE,
354 actual=ipResult,
355 onpass="The ips of the hosts aren't empty",
356 onfail="The ip of at least one host is missing" )
357
358 # there should always only be one cluster
359 main.step( "There is only one dataplane cluster" )
360 try:
361 numClusters = len( json.loads( clusters[ 0 ] ) )
362 except ( ValueError, TypeError ):
363 main.log.exception( "Error parsing clusters[0]: " +
364 repr( clusters[ 0 ] ) )
Jon Hall6e709752016-02-01 13:38:46 -0800365 numClusters = "ERROR"
Jon Hall85794ff2015-07-08 14:12:30 -0700366 clusterResults = main.FALSE
367 if numClusters == 1:
368 clusterResults = main.TRUE
369 utilities.assert_equals(
370 expect=1,
371 actual=numClusters,
372 onpass="ONOS shows 1 SCC",
373 onfail="ONOS shows " + str( numClusters ) + " SCCs" )
374
375 main.step( "Comparing ONOS topology to MN" )
376 devicesResults = main.TRUE
377 linksResults = main.TRUE
378 hostsResults = main.TRUE
379 mnSwitches = main.Mininet1.getSwitches()
380 mnLinks = main.Mininet1.getLinks()
381 mnHosts = main.Mininet1.getHosts()
Jon Halla440e872016-03-31 15:15:50 -0700382 for controller in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700383 controllerStr = str( main.activeNodes[ controller ] + 1 )
Jon Hall85794ff2015-07-08 14:12:30 -0700384 if devices[ controller ] and ports[ controller ] and\
Jon Hallf37d44d2017-05-24 10:37:30 -0700385 "Error" not in devices[ controller ] and\
386 "Error" not in ports[ controller ]:
387 currentDevicesResult = main.Mininet1.compareSwitches(
388 mnSwitches,
389 json.loads( devices[ controller ] ),
390 json.loads( ports[ controller ] ) )
Jon Hall85794ff2015-07-08 14:12:30 -0700391 else:
392 currentDevicesResult = main.FALSE
393 utilities.assert_equals( expect=main.TRUE,
394 actual=currentDevicesResult,
395 onpass="ONOS" + controllerStr +
396 " Switches view is correct",
397 onfail="ONOS" + controllerStr +
398 " Switches view is incorrect" )
399 if links[ controller ] and "Error" not in links[ controller ]:
400 currentLinksResult = main.Mininet1.compareLinks(
401 mnSwitches, mnLinks,
402 json.loads( links[ controller ] ) )
403 else:
404 currentLinksResult = main.FALSE
405 utilities.assert_equals( expect=main.TRUE,
406 actual=currentLinksResult,
407 onpass="ONOS" + controllerStr +
408 " links view is correct",
409 onfail="ONOS" + controllerStr +
410 " links view is incorrect" )
411
Jon Halla440e872016-03-31 15:15:50 -0700412 if hosts[ controller ] and "Error" not in hosts[ controller ]:
Jon Hall85794ff2015-07-08 14:12:30 -0700413 currentHostsResult = main.Mininet1.compareHosts(
414 mnHosts,
415 hosts[ controller ] )
416 else:
417 currentHostsResult = main.FALSE
418 utilities.assert_equals( expect=main.TRUE,
419 actual=currentHostsResult,
420 onpass="ONOS" + controllerStr +
421 " hosts exist in Mininet",
422 onfail="ONOS" + controllerStr +
423 " hosts don't match Mininet" )
424
425 devicesResults = devicesResults and currentDevicesResult
426 linksResults = linksResults and currentLinksResult
427 hostsResults = hostsResults and currentHostsResult
428
429 main.step( "Device information is correct" )
430 utilities.assert_equals(
431 expect=main.TRUE,
432 actual=devicesResults,
433 onpass="Device information is correct",
434 onfail="Device information is incorrect" )
435
436 main.step( "Links are correct" )
437 utilities.assert_equals(
438 expect=main.TRUE,
439 actual=linksResults,
440 onpass="Link are correct",
441 onfail="Links are incorrect" )
442
443 main.step( "Hosts are correct" )
444 utilities.assert_equals(
445 expect=main.TRUE,
446 actual=hostsResults,
447 onpass="Hosts are correct",
448 onfail="Hosts are incorrect" )
449
450 def CASE6( self, main ):
451 """
452 The Failure case.
453 """
454 import time
Jon Halle1a3b752015-07-22 13:02:46 -0700455 assert main.numCtrls, "main.numCtrls not defined"
Jon Hall85794ff2015-07-08 14:12:30 -0700456 assert main, "main not defined"
457 assert utilities.assert_equals, "utilities.assert_equals not defined"
458
459 # Reset non-persistent variables
460 try:
461 iCounterValue = 0
462 except NameError:
463 main.log.error( "iCounterValue not defined, setting to 0" )
464 iCounterValue = 0
465
466 main.case( "Restart ONOS node" )
Jon Hall783bbf92015-07-23 14:33:19 -0700467 main.caseExplanation = "Killing ONOS process and restart cli " +\
Jon Hall85794ff2015-07-08 14:12:30 -0700468 "sessions once onos is up."
Jon Hall96091e62015-09-21 17:34:17 -0700469
470 main.step( "Checking ONOS Logs for errors" )
471 for node in main.nodes:
472 main.log.debug( "Checking logs for errors on " + node.name + ":" )
473 main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) )
474
Jon Hall85794ff2015-07-08 14:12:30 -0700475 main.step( "Killing ONOS processes" )
Jon Hallf37d44d2017-05-24 10:37:30 -0700476 killResult = main.ONOSbench.onosKill( main.nodes[ 0 ].ip_address )
Jon Hall85794ff2015-07-08 14:12:30 -0700477 start = time.time()
478 utilities.assert_equals( expect=main.TRUE, actual=killResult,
479 onpass="ONOS Killed",
480 onfail="Error killing ONOS" )
481
482 main.step( "Checking if ONOS is up yet" )
483 count = 0
484 while count < 10:
Jon Hallf37d44d2017-05-24 10:37:30 -0700485 onos1Isup = main.ONOSbench.isup( main.nodes[ 0 ].ip_address )
Jon Hall85794ff2015-07-08 14:12:30 -0700486 if onos1Isup == main.TRUE:
487 elapsed = time.time() - start
488 break
489 else:
490 count = count + 1
491 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
492 onpass="ONOS is back up",
493 onfail="ONOS failed to start" )
494
Jon Hall6509dbf2016-06-21 17:01:17 -0700495 main.step( "Starting ONOS CLI sessions" )
Jon Hallf37d44d2017-05-24 10:37:30 -0700496 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
Jon Hall85794ff2015-07-08 14:12:30 -0700497 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
498 onpass="ONOS cli startup successful",
499 onfail="ONOS cli startup failed" )
500
501 if elapsed:
502 main.log.info( "ESTIMATE: ONOS took %s seconds to restart" %
503 str( elapsed ) )
504 main.restartTime = elapsed
505 else:
506 main.restartTime = -1
507 time.sleep( 5 )
508 # rerun on election apps
509 main.ONOScli1.electionTestRun()
510
511 def CASE7( self, main ):
512 """
513 Check state after ONOS failure
514 """
515 import json
Jon Halle1a3b752015-07-22 13:02:46 -0700516 assert main.numCtrls, "main.numCtrls not defined"
Jon Hall85794ff2015-07-08 14:12:30 -0700517 assert main, "main not defined"
518 assert utilities.assert_equals, "utilities.assert_equals not defined"
519 main.case( "Running ONOS Constant State Tests" )
Jon Hall6e709752016-02-01 13:38:46 -0800520
Jon Hall85794ff2015-07-08 14:12:30 -0700521 main.step( "Check that each switch has a master" )
522 # Assert that each device has a master
Jon Halla440e872016-03-31 15:15:50 -0700523 rolesNotNull = main.TRUE
524 threads = []
525 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700526 t = main.Thread( target=main.CLIs[ i ].rolesNotNull,
Jon Halla440e872016-03-31 15:15:50 -0700527 name="rolesNotNull-" + str( i ),
Jon Hallf37d44d2017-05-24 10:37:30 -0700528 args=[] )
Jon Halla440e872016-03-31 15:15:50 -0700529 threads.append( t )
530 t.start()
531
532 for t in threads:
533 t.join()
534 rolesNotNull = rolesNotNull and t.result
Jon Hall85794ff2015-07-08 14:12:30 -0700535 utilities.assert_equals(
536 expect=main.TRUE,
537 actual=rolesNotNull,
538 onpass="Each device has a master",
539 onfail="Some devices don't have a master assigned" )
540
541 main.step( "Check if switch roles are consistent across all nodes" )
542 ONOS1Mastership = main.ONOScli1.roles()
543 # FIXME: Refactor this whole case for single instance
544 if "Error" in ONOS1Mastership or not ONOS1Mastership:
545 main.log.error( "Error in getting ONOS mastership" )
546 main.log.warn( "ONOS1 mastership response: " +
547 repr( ONOS1Mastership ) )
548 consistentMastership = main.FALSE
549 else:
550 consistentMastership = main.TRUE
551 utilities.assert_equals(
552 expect=main.TRUE,
553 actual=consistentMastership,
554 onpass="Switch roles are consistent across all ONOS nodes",
555 onfail="ONOS nodes have different views of switch roles" )
556
557 description2 = "Compare switch roles from before failure"
558 main.step( description2 )
559
560 currentJson = json.loads( ONOS1Mastership )
561 oldJson = json.loads( mastershipState )
562 mastershipCheck = main.TRUE
563 for i in range( 1, 29 ):
564 switchDPID = str(
565 main.Mininet1.getSwitchDPID( switch="s" + str( i ) ) )
566
567 current = [ switch[ 'master' ] for switch in currentJson
568 if switchDPID in switch[ 'id' ] ]
569 old = [ switch[ 'master' ] for switch in oldJson
570 if switchDPID in switch[ 'id' ] ]
571 if current == old:
572 mastershipCheck = mastershipCheck and main.TRUE
573 else:
574 main.log.warn( "Mastership of switch %s changed" % switchDPID )
575 mastershipCheck = main.FALSE
576 utilities.assert_equals(
577 expect=main.TRUE,
578 actual=mastershipCheck,
579 onpass="Mastership of Switches was not changed",
580 onfail="Mastership of some switches changed" )
581 mastershipCheck = mastershipCheck and consistentMastership
582
583 main.step( "Get the intents and compare across all nodes" )
584 ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
585 intentCheck = main.FALSE
586 if "Error" in ONOS1Intents or not ONOS1Intents:
587 main.log.error( "Error in getting ONOS intents" )
588 main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
589 else:
590 intentCheck = main.TRUE
591 utilities.assert_equals(
592 expect=main.TRUE,
593 actual=intentCheck,
594 onpass="Intents are consistent across all ONOS nodes",
595 onfail="ONOS nodes have different views of intents" )
596 # Print the intent states
597 intents = []
598 intents.append( ONOS1Intents )
599 intentStates = []
600 for node in intents: # Iter through ONOS nodes
601 nodeStates = []
602 # Iter through intents of a node
603 for intent in json.loads( node ):
604 nodeStates.append( intent[ 'state' ] )
605 intentStates.append( nodeStates )
Jon Hallf37d44d2017-05-24 10:37:30 -0700606 out = [ ( i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
Jon Hall85794ff2015-07-08 14:12:30 -0700607 main.log.info( dict( out ) )
608
609 # NOTE: Store has no durability, so intents are lost across system
610 # restarts
611 """
612 main.step( "Compare current intents with intents before the failure" )
613 # NOTE: this requires case 5 to pass for intentState to be set.
614 # maybe we should stop the test if that fails?
615 sameIntents = main.FALSE
Jon Halla440e872016-03-31 15:15:50 -0700616 try:
617 intentState
618 except NameError:
619 main.log.warn( "No previous intent state was saved" )
620 else:
621 if intentState and intentState == ONOSIntents[ 0 ]:
622 sameIntents = main.TRUE
623 main.log.info( "Intents are consistent with before failure" )
624 # TODO: possibly the states have changed? we may need to figure out
625 # what the acceptable states are
626 elif len( intentState ) == len( ONOSIntents[ 0 ] ):
627 sameIntents = main.TRUE
628 try:
629 before = json.loads( intentState )
630 after = json.loads( ONOSIntents[ 0 ] )
631 for intent in before:
632 if intent not in after:
633 sameIntents = main.FALSE
634 main.log.debug( "Intent is not currently in ONOS " +
635 "(at least in the same form):" )
636 main.log.debug( json.dumps( intent ) )
637 except ( ValueError, TypeError ):
638 main.log.exception( "Exception printing intents" )
Jon Hallf37d44d2017-05-24 10:37:30 -0700639 main.log.debug( repr( ONOSIntents[ 0 ] ) )
Jon Halla440e872016-03-31 15:15:50 -0700640 main.log.debug( repr( intentState ) )
641 if sameIntents == main.FALSE:
642 try:
643 main.log.debug( "ONOS intents before: " )
644 main.log.debug( json.dumps( json.loads( intentState ),
645 sort_keys=True, indent=4,
646 separators=( ',', ': ' ) ) )
647 main.log.debug( "Current ONOS intents: " )
648 main.log.debug( json.dumps( json.loads( ONOSIntents[ 0 ] ),
649 sort_keys=True, indent=4,
650 separators=( ',', ': ' ) ) )
651 except ( ValueError, TypeError ):
652 main.log.exception( "Exception printing intents" )
Jon Hallf37d44d2017-05-24 10:37:30 -0700653 main.log.debug( repr( ONOSIntents[ 0 ] ) )
Jon Halla440e872016-03-31 15:15:50 -0700654 main.log.debug( repr( intentState ) )
655 utilities.assert_equals(
656 expect=main.TRUE,
657 actual=sameIntents,
658 onpass="Intents are consistent with before failure",
659 onfail="The Intents changed during failure" )
Jon Hall85794ff2015-07-08 14:12:30 -0700660 intentCheck = intentCheck and sameIntents
661 """
662 main.step( "Get the OF Table entries and compare to before " +
663 "component failure" )
664 FlowTables = main.TRUE
Jon Hall85794ff2015-07-08 14:12:30 -0700665 for i in range( 28 ):
666 main.log.info( "Checking flow table on s" + str( i + 1 ) )
GlennRC68467eb2015-11-16 18:01:01 -0800667 tmpFlows = main.Mininet1.getFlowTable( "s" + str( i + 1 ), version="1.3", debug=False )
Jon Hallf37d44d2017-05-24 10:37:30 -0700668 curSwitch = main.Mininet1.flowTableComp( flows[ i ], tmpFlows )
Jon Hall41d39f12016-04-11 22:54:35 -0700669 FlowTables = FlowTables and curSwitch
670 if curSwitch == main.FALSE:
GlennRC68467eb2015-11-16 18:01:01 -0800671 main.log.warn( "Differences in flow table for switch: s{}".format( i + 1 ) )
Jon Hall85794ff2015-07-08 14:12:30 -0700672 utilities.assert_equals(
673 expect=main.TRUE,
674 actual=FlowTables,
675 onpass="No changes were found in the flow tables",
676 onfail="Changes were found in the flow tables" )
677
678 main.step( "Leadership Election is still functional" )
679 # Test of LeadershipElection
680
Jon Halla440e872016-03-31 15:15:50 -0700681 leader = main.nodes[ main.activeNodes[ 0 ] ].ip_address
Jon Hall85794ff2015-07-08 14:12:30 -0700682 leaderResult = main.TRUE
Jon Halle1a3b752015-07-22 13:02:46 -0700683 for controller in range( 1, main.numCtrls + 1 ):
Jon Hall85794ff2015-07-08 14:12:30 -0700684 # loop through ONOScli handlers
685 node = getattr( main, ( 'ONOScli' + str( controller ) ) )
686 leaderN = node.electionTestLeader()
687 # verify leader is ONOS1
688 # NOTE even though we restarted ONOS, it is the only one so onos 1
689 # must be leader
690 if leaderN == leader:
691 # all is well
692 pass
693 elif leaderN == main.FALSE:
694 # error in response
695 main.log.error( "Something is wrong with " +
696 "electionTestLeader function, check the" +
697 " error logs" )
698 leaderResult = main.FALSE
699 elif leader != leaderN:
700 leaderResult = main.FALSE
701 main.log.error( "ONOS" + str( controller ) + " sees " +
702 str( leaderN ) +
703 " as the leader of the election app. " +
704 "Leader should be " + str( leader ) )
705 utilities.assert_equals(
706 expect=main.TRUE,
707 actual=leaderResult,
708 onpass="Leadership election passed",
709 onfail="Something went wrong with Leadership election" )
710
711 def CASE8( self, main ):
712 """
713 Compare topo
714 """
715 import json
716 import time
Jon Halle1a3b752015-07-22 13:02:46 -0700717 assert main.numCtrls, "main.numCtrls not defined"
Jon Hall85794ff2015-07-08 14:12:30 -0700718 assert main, "main not defined"
719 assert utilities.assert_equals, "utilities.assert_equals not defined"
720
721 main.case( "Compare ONOS Topology view to Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700722 main.caseExplanation = "Compare topology objects between Mininet" +\
Jon Hall85794ff2015-07-08 14:12:30 -0700723 " and ONOS"
Jon Hall85794ff2015-07-08 14:12:30 -0700724 topoResult = main.FALSE
725 elapsed = 0
726 count = 0
Jon Halle9b1fa32015-12-08 15:32:21 -0800727 main.step( "Comparing ONOS topology to MN topology" )
Jon Hall85794ff2015-07-08 14:12:30 -0700728 startTime = time.time()
729 # Give time for Gossip to work
Jon Halle9b1fa32015-12-08 15:32:21 -0800730 while topoResult == main.FALSE and ( elapsed < 60 or count < 3 ):
Jon Hall96091e62015-09-21 17:34:17 -0700731 devicesResults = main.TRUE
732 linksResults = main.TRUE
733 hostsResults = main.TRUE
734 hostAttachmentResults = True
Jon Hall85794ff2015-07-08 14:12:30 -0700735 count += 1
736 cliStart = time.time()
737 devices = []
738 devices.append( main.ONOScli1.devices() )
739 hosts = []
740 hosts.append( json.loads( main.ONOScli1.hosts() ) )
741 ipResult = main.TRUE
742 for controller in range( 0, len( hosts ) ):
743 controllerStr = str( controller + 1 )
744 for host in hosts[ controller ]:
745 if host is None or host.get( 'ipAddresses', [] ) == []:
746 main.log.error(
747 "DEBUG:Error with host ips on controller" +
748 controllerStr + ": " + str( host ) )
749 ipResult = main.FALSE
750 ports = []
751 ports.append( main.ONOScli1.ports() )
752 links = []
753 links.append( main.ONOScli1.links() )
754 clusters = []
755 clusters.append( main.ONOScli1.clusters() )
756
757 elapsed = time.time() - startTime
758 cliTime = time.time() - cliStart
759 print "CLI time: " + str( cliTime )
760
761 mnSwitches = main.Mininet1.getSwitches()
762 mnLinks = main.Mininet1.getLinks()
763 mnHosts = main.Mininet1.getHosts()
Jon Halle1a3b752015-07-22 13:02:46 -0700764 for controller in range( main.numCtrls ):
Jon Hall85794ff2015-07-08 14:12:30 -0700765 controllerStr = str( controller + 1 )
766 if devices[ controller ] and ports[ controller ] and\
Jon Hallf37d44d2017-05-24 10:37:30 -0700767 "Error" not in devices[ controller ] and\
768 "Error" not in ports[ controller ]:
Jon Hall85794ff2015-07-08 14:12:30 -0700769
Jon Hallc6793552016-01-19 14:18:37 -0800770 try:
771 currentDevicesResult = main.Mininet1.compareSwitches(
772 mnSwitches,
773 json.loads( devices[ controller ] ),
774 json.loads( ports[ controller ] ) )
775 except ( TypeError, ValueError ) as e:
776 main.log.exception( "Object not as expected; devices={!r}\nports={!r}".format(
777 devices[ controller ], ports[ controller ] ) )
Jon Hall85794ff2015-07-08 14:12:30 -0700778 else:
779 currentDevicesResult = main.FALSE
780 utilities.assert_equals( expect=main.TRUE,
781 actual=currentDevicesResult,
782 onpass="ONOS" + controllerStr +
783 " Switches view is correct",
784 onfail="ONOS" + controllerStr +
785 " Switches view is incorrect" )
786
787 if links[ controller ] and "Error" not in links[ controller ]:
788 currentLinksResult = main.Mininet1.compareLinks(
789 mnSwitches, mnLinks,
790 json.loads( links[ controller ] ) )
791 else:
792 currentLinksResult = main.FALSE
793 utilities.assert_equals( expect=main.TRUE,
794 actual=currentLinksResult,
795 onpass="ONOS" + controllerStr +
796 " links view is correct",
797 onfail="ONOS" + controllerStr +
798 " links view is incorrect" )
799
800 if hosts[ controller ] or "Error" not in hosts[ controller ]:
801 currentHostsResult = main.Mininet1.compareHosts(
802 mnHosts,
803 hosts[ controller ] )
804 else:
805 currentHostsResult = main.FALSE
806 utilities.assert_equals( expect=main.TRUE,
807 actual=currentHostsResult,
808 onpass="ONOS" + controllerStr +
809 " hosts exist in Mininet",
810 onfail="ONOS" + controllerStr +
811 " hosts don't match Mininet" )
812 # CHECKING HOST ATTACHMENT POINTS
813 hostAttachment = True
814 zeroHosts = False
815 # FIXME: topo-HA/obelisk specific mappings:
816 # key is mac and value is dpid
817 mappings = {}
818 for i in range( 1, 29 ): # hosts 1 through 28
819 # set up correct variables:
Jon Hallf37d44d2017-05-24 10:37:30 -0700820 macId = "00:" * 5 + hex( i ).split( "0x" )[ 1 ].upper().zfill( 2 )
Jon Hall85794ff2015-07-08 14:12:30 -0700821 if i == 1:
Jon Hallf37d44d2017-05-24 10:37:30 -0700822 deviceId = "1000".zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700823 elif i == 2:
Jon Hallf37d44d2017-05-24 10:37:30 -0700824 deviceId = "2000".zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700825 elif i == 3:
Jon Hallf37d44d2017-05-24 10:37:30 -0700826 deviceId = "3000".zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700827 elif i == 4:
Jon Hallf37d44d2017-05-24 10:37:30 -0700828 deviceId = "3004".zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700829 elif i == 5:
Jon Hallf37d44d2017-05-24 10:37:30 -0700830 deviceId = "5000".zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700831 elif i == 6:
Jon Hallf37d44d2017-05-24 10:37:30 -0700832 deviceId = "6000".zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700833 elif i == 7:
Jon Hallf37d44d2017-05-24 10:37:30 -0700834 deviceId = "6007".zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700835 elif i >= 8 and i <= 17:
836 dpid = '3' + str( i ).zfill( 3 )
Jon Hallf37d44d2017-05-24 10:37:30 -0700837 deviceId = dpid.zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700838 elif i >= 18 and i <= 27:
839 dpid = '6' + str( i ).zfill( 3 )
Jon Hallf37d44d2017-05-24 10:37:30 -0700840 deviceId = dpid.zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700841 elif i == 28:
Jon Hallf37d44d2017-05-24 10:37:30 -0700842 deviceId = "2800".zfill( 16 )
Jon Hall85794ff2015-07-08 14:12:30 -0700843 mappings[ macId ] = deviceId
844 if hosts[ controller ] or "Error" not in hosts[ controller ]:
845 if hosts[ controller ] == []:
846 main.log.warn( "There are no hosts discovered" )
847 zeroHosts = True
848 else:
849 for host in hosts[ controller ]:
850 mac = None
851 location = None
852 device = None
853 port = None
854 try:
855 mac = host.get( 'mac' )
856 assert mac, "mac field could not be found for this host object"
857
Jeremy Ronquillo0e538bc2017-06-13 15:16:09 -0700858 location = host.get( 'locations' )[ 0 ]
Jon Hall85794ff2015-07-08 14:12:30 -0700859 assert location, "location field could not be found for this host object"
860
861 # Trim the protocol identifier off deviceId
Jon Hallf37d44d2017-05-24 10:37:30 -0700862 device = str( location.get( 'elementId' ) ).split( ':' )[ 1 ]
Jon Hall85794ff2015-07-08 14:12:30 -0700863 assert device, "elementId field could not be found for this host location object"
864
865 port = location.get( 'port' )
866 assert port, "port field could not be found for this host location object"
867
868 # Now check if this matches where they should be
869 if mac and device and port:
870 if str( port ) != "1":
871 main.log.error( "The attachment port is incorrect for " +
872 "host " + str( mac ) +
Jon Hallf37d44d2017-05-24 10:37:30 -0700873 ". Expected: 1 Actual: " + str( port ) )
Jon Hall85794ff2015-07-08 14:12:30 -0700874 hostAttachment = False
875 if device != mappings[ str( mac ) ]:
876 main.log.error( "The attachment device is incorrect for " +
877 "host " + str( mac ) +
878 ". Expected: " + mappings[ str( mac ) ] +
879 " Actual: " + device )
880 hostAttachment = False
881 else:
882 hostAttachment = False
883 except AssertionError:
884 main.log.exception( "Json object not as expected" )
885 main.log.error( repr( host ) )
886 hostAttachment = False
887 else:
888 main.log.error( "No hosts json output or \"Error\"" +
889 " in output. hosts = " +
890 repr( hosts[ controller ] ) )
891 if zeroHosts is False:
892 hostAttachment = True
893
Jon Hall85794ff2015-07-08 14:12:30 -0700894 devicesResults = devicesResults and currentDevicesResult
895 linksResults = linksResults and currentLinksResult
896 hostsResults = hostsResults and currentHostsResult
897 hostAttachmentResults = hostAttachmentResults and\
898 hostAttachment
899
Jon Halla440e872016-03-31 15:15:50 -0700900 # "consistent" results don't make sense for single instance
Jon Hall85794ff2015-07-08 14:12:30 -0700901 # there should always only be one cluster
Jon Hall85794ff2015-07-08 14:12:30 -0700902 clusterResults = main.FALSE
Jon Halla440e872016-03-31 15:15:50 -0700903 try:
904 numClusters = len( json.loads( clusters[ 0 ] ) )
905 except ( ValueError, TypeError ):
906 main.log.exception( "Error parsing clusters[0]: " +
Jon Hallf37d44d2017-05-24 10:37:30 -0700907 repr( clusters[ 0 ] ) )
Jon Halla440e872016-03-31 15:15:50 -0700908 numClusters = "ERROR"
909 clusterResults = main.FALSE
Jon Hall85794ff2015-07-08 14:12:30 -0700910 if numClusters == 1:
911 clusterResults = main.TRUE
912 utilities.assert_equals(
913 expect=1,
914 actual=numClusters,
915 onpass="ONOS shows 1 SCC",
916 onfail="ONOS shows " + str( numClusters ) + " SCCs" )
917
918 topoResult = ( devicesResults and linksResults
919 and hostsResults and ipResult and clusterResults and
920 hostAttachmentResults )
921
922 topoResult = topoResult and int( count <= 2 )
923 note = "note it takes about " + str( int( cliTime ) ) + \
924 " seconds for the test to make all the cli calls to fetch " +\
925 "the topology from each ONOS instance"
926 main.log.info(
927 "Very crass estimate for topology discovery/convergence( " +
928 str( note ) + " ): " + str( elapsed ) + " seconds, " +
929 str( count ) + " tries" )
930 utilities.assert_equals( expect=main.TRUE, actual=topoResult,
931 onpass="Topology Check Test successful",
932 onfail="Topology Check Test NOT successful" )
Jon Hall41d39f12016-04-11 22:54:35 -0700933 main.step( "Checking ONOS nodes" )
934 nodeResults = utilities.retry( main.HA.nodesCheck,
935 False,
Jon Hallf37d44d2017-05-24 10:37:30 -0700936 args=[ main.activeNodes ],
Jon Hall41d39f12016-04-11 22:54:35 -0700937 attempts=5 )
938
939 utilities.assert_equals( expect=True, actual=nodeResults,
940 onpass="Nodes check successful",
941 onfail="Nodes check NOT successful" )
942 if not nodeResults:
943 for i in main.activeNodes:
944 main.log.debug( "{} components not ACTIVE: \n{}".format(
Jon Hallf37d44d2017-05-24 10:37:30 -0700945 main.CLIs[ i ].name,
946 main.CLIs[ i ].sendline( "scr:list | grep -v ACTIVE" ) ) )
Jon Hall85794ff2015-07-08 14:12:30 -0700947
Jon Halld2871c22016-07-26 11:01:14 -0700948 if not topoResult:
949 main.cleanup()
950 main.exit()
951
Jon Hall85794ff2015-07-08 14:12:30 -0700952 def CASE9( self, main ):
953 """
954 Link s3-s28 down
955 """
Devin Lim58046fa2017-07-05 16:55:00 -0700956 main.HA.linkDown( main )
Jon Hall85794ff2015-07-08 14:12:30 -0700957
958 def CASE10( self, main ):
959 """
960 Link s3-s28 up
961 """
Devin Lim58046fa2017-07-05 16:55:00 -0700962 main.HA.linkUp( main )
Jon Hall85794ff2015-07-08 14:12:30 -0700963
964 def CASE11( self, main ):
965 """
966 Switch Down
967 """
968 # NOTE: You should probably run a topology check after this
Devin Lim58046fa2017-07-05 16:55:00 -0700969 main.HA.switchDown( main )
Jon Hall85794ff2015-07-08 14:12:30 -0700970
971 def CASE12( self, main ):
972 """
973 Switch Up
974 """
975 # NOTE: You should probably run a topology check after this
Devin Lim58046fa2017-07-05 16:55:00 -0700976 main.HA.switchUp( main )
Jon Hall85794ff2015-07-08 14:12:30 -0700977
978 def CASE13( self, main ):
979 """
980 Clean up
981 """
Devin Lim58046fa2017-07-05 16:55:00 -0700982 main.HAlabels.append( "Restart" )
983 main.HAdata.append( str( main.restartTime ) )
984 main.HA.cleanUp( main )
Jon Hall85794ff2015-07-08 14:12:30 -0700985
986 def CASE14( self, main ):
987 """
988 start election app on all onos nodes
989 """
Devin Lim58046fa2017-07-05 16:55:00 -0700990 main.HA.startElectionApp( main )
Jon Hall85794ff2015-07-08 14:12:30 -0700991
992 def CASE15( self, main ):
993 """
994 Check that Leadership Election is still functional
acsmars71adceb2015-08-31 15:09:26 -0700995 15.1 Run election on each node
996 15.2 Check that each node has the same leaders and candidates
997 15.3 Find current leader and withdraw
998 15.4 Check that a new node was elected leader
999 15.5 Check that that new leader was the candidate of old leader
1000 15.6 Run for election on old leader
1001 15.7 Check that oldLeader is a candidate, and leader if only 1 node
1002 15.8 Make sure that the old leader was added to the candidate list
1003
1004 old and new variable prefixes refer to data from before vs after
1005 withdrawl and later before withdrawl vs after re-election
Jon Hall85794ff2015-07-08 14:12:30 -07001006 """
Devin Lim58046fa2017-07-05 16:55:00 -07001007 main.HA.isElectionFunctional( main )
Jon Hall85794ff2015-07-08 14:12:30 -07001008
1009 def CASE16( self, main ):
1010 """
1011 Install Distributed Primitives app
1012 """
Devin Lim58046fa2017-07-05 16:55:00 -07001013 main.HA.installDistributedPrimitiveApp( main )
Jon Hall85794ff2015-07-08 14:12:30 -07001014
1015 def CASE17( self, main ):
1016 """
1017 Check for basic functionality with distributed primitives
1018 """
Devin Lim58046fa2017-07-05 16:55:00 -07001019 main.HA.checkDistPrimitivesFunc( main )