blob: 791d55c6cedaad7b51209f4e365a562ad1f3400c [file] [log] [blame]
Jon Hall6aec96b2015-01-19 14:49:31 -08001"""
Jon Hall73cf9cc2014-11-20 22:28:38 -08002Description: This test is to determine if ONOS can handle
3 all of it's nodes restarting
4
5List of test cases:
6CASE1: Compile ONOS and push it to the test machines
7CASE2: Assign mastership to controllers
8CASE3: Assign intents
9CASE4: Ping across added host intents
10CASE5: Reading state of ONOS
11CASE6: The Failure case.
12CASE7: Check state after control plane failure
13CASE8: Compare topo
14CASE9: Link s3-s28 down
15CASE10: Link s3-s28 up
16CASE11: Switch down
17CASE12: Switch up
18CASE13: Clean up
Jon Hall669173b2014-12-17 11:36:30 -080019CASE14: start election app on all onos nodes
20CASE15: Check that Leadership Election is still functional
Jon Hall6aec96b2015-01-19 14:49:31 -080021"""
Jon Hall8f89dda2015-01-22 16:03:33 -080022
23
Jon Hall73cf9cc2014-11-20 22:28:38 -080024class HATestClusterRestart:
25
Jon Hall6aec96b2015-01-19 14:49:31 -080026 def __init__( self ):
Jon Hall73cf9cc2014-11-20 22:28:38 -080027 self.default = ''
28
Jon Hall6aec96b2015-01-19 14:49:31 -080029 def CASE1( self, main ):
30 """
Jon Hall73cf9cc2014-11-20 22:28:38 -080031 CASE1 is to compile ONOS and push it to the test machines
32
33 Startup sequence:
34 git pull
35 mvn clean install
36 onos-package
37 cell <name>
38 onos-verify-cell
39 NOTE: temporary - onos-remove-raft-logs
40 onos-install -f
41 onos-wait-for-start
Jon Hall6aec96b2015-01-19 14:49:31 -080042 """
43 main.log.report( "ONOS HA test: Restart all ONOS nodes - " +
44 "initialization" )
45 main.case( "Setting up test environment" )
46 # TODO: save all the timers and output them for plotting
Jon Hall73cf9cc2014-11-20 22:28:38 -080047
48 # load some vairables from the params file
Jon Hall8f89dda2015-01-22 16:03:33 -080049 PULLCODE = False
Jon Hall6aec96b2015-01-19 14:49:31 -080050 if main.params[ 'Git' ] == 'True':
Jon Hall8f89dda2015-01-22 16:03:33 -080051 PULLCODE = True
Jon Hall529a37f2015-01-28 10:02:00 -080052 gitBranch = main.params[ 'branch' ]
Jon Hall8f89dda2015-01-22 16:03:33 -080053 cellName = main.params[ 'ENV' ][ 'cellName' ]
Jon Hall6aec96b2015-01-19 14:49:31 -080054
55 # set global variables
Jon Hall8f89dda2015-01-22 16:03:33 -080056 global ONOS1Ip
57 global ONOS1Port
58 global ONOS2Ip
59 global ONOS2Port
60 global ONOS3Ip
61 global ONOS3Port
62 global ONOS4Ip
63 global ONOS4Port
64 global ONOS5Ip
65 global ONOS5Port
66 global ONOS6Ip
67 global ONOS6Port
68 global ONOS7Ip
69 global ONOS7Port
70 global numControllers
Jon Hall73cf9cc2014-11-20 22:28:38 -080071
Jon Hall8f89dda2015-01-22 16:03:33 -080072 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
73 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
74 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
75 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
76 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
77 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
78 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
79 ONOS4Port = main.params[ 'CTRL' ][ 'port4' ]
80 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
81 ONOS5Port = main.params[ 'CTRL' ][ 'port5' ]
82 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
83 ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
84 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
85 ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
86 numControllers = int( main.params[ 'num_controllers' ] )
Jon Hall73cf9cc2014-11-20 22:28:38 -080087
Jon Hall6aec96b2015-01-19 14:49:31 -080088 main.step( "Applying cell variable to environment" )
Jon Hall8f89dda2015-01-22 16:03:33 -080089 cellResult = main.ONOSbench.setCell( cellName )
90 verifyResult = main.ONOSbench.verifyCell()
Jon Hall73cf9cc2014-11-20 22:28:38 -080091
Jon Hall6aec96b2015-01-19 14:49:31 -080092 # FIXME:this is short term fix
93 main.log.report( "Removing raft logs" )
Jon Hall8f89dda2015-01-22 16:03:33 -080094 main.ONOSbench.onosRemoveRaftLogs()
Jon Hall6aec96b2015-01-19 14:49:31 -080095 main.log.report( "Uninstalling ONOS" )
Jon Hall8f89dda2015-01-22 16:03:33 -080096 main.ONOSbench.onosUninstall( ONOS1Ip )
97 main.ONOSbench.onosUninstall( ONOS2Ip )
98 main.ONOSbench.onosUninstall( ONOS3Ip )
99 main.ONOSbench.onosUninstall( ONOS4Ip )
100 main.ONOSbench.onosUninstall( ONOS5Ip )
101 main.ONOSbench.onosUninstall( ONOS6Ip )
102 main.ONOSbench.onosUninstall( ONOS7Ip )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800103
Jon Hall8f89dda2015-01-22 16:03:33 -0800104 cleanInstallResult = main.TRUE
105 gitPullResult = main.TRUE
Jon Hall73cf9cc2014-11-20 22:28:38 -0800106
Jon Hall6aec96b2015-01-19 14:49:31 -0800107 main.step( "Compiling the latest version of ONOS" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800108 if PULLCODE:
Jon Hall6aec96b2015-01-19 14:49:31 -0800109 # TODO Configure branch in params
110 main.step( "Git checkout and pull master" )
Jon Hall529a37f2015-01-28 10:02:00 -0800111 main.ONOSbench.gitCheckout( gitBranch )
Jon Hall8f89dda2015-01-22 16:03:33 -0800112 gitPullResult = main.ONOSbench.gitPull()
Jon Hall73cf9cc2014-11-20 22:28:38 -0800113
Jon Hall6aec96b2015-01-19 14:49:31 -0800114 main.step( "Using mvn clean & install" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800115 cleanInstallResult = main.ONOSbench.cleanInstall()
Jon Hall6aec96b2015-01-19 14:49:31 -0800116 else:
117 main.log.warn( "Did not pull new code so skipping mvn " +
118 "clean install" )
Jon Hall529a37f2015-01-28 10:02:00 -0800119 main.ONOSbench.getVersion( report=True )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800120
Jon Hall6aec96b2015-01-19 14:49:31 -0800121 main.step( "Creating ONOS package" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800122 packageResult = main.ONOSbench.onosPackage()
Jon Hall73cf9cc2014-11-20 22:28:38 -0800123
Jon Hall6aec96b2015-01-19 14:49:31 -0800124 main.step( "Installing ONOS package" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800125 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
126 node=ONOS1Ip )
127 onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
128 node=ONOS2Ip )
129 onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
130 node=ONOS3Ip )
131 onos4InstallResult = main.ONOSbench.onosInstall( options="-f",
132 node=ONOS4Ip )
133 onos5InstallResult = main.ONOSbench.onosInstall( options="-f",
134 node=ONOS5Ip )
135 onos6InstallResult = main.ONOSbench.onosInstall( options="-f",
136 node=ONOS6Ip )
137 onos7InstallResult = main.ONOSbench.onosInstall( options="-f",
138 node=ONOS7Ip )
139 onosInstallResult = onos1InstallResult and onos2InstallResult\
140 and onos3InstallResult and onos4InstallResult\
141 and onos5InstallResult and onos6InstallResult\
142 and onos7InstallResult
Jon Hall73cf9cc2014-11-20 22:28:38 -0800143
Jon Hall6aec96b2015-01-19 14:49:31 -0800144 main.step( "Checking if ONOS is up yet" )
145 # TODO check bundle:list?
146 for i in range( 2 ):
Jon Hall8f89dda2015-01-22 16:03:33 -0800147 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
148 if not onos1Isup:
Jon Hall6aec96b2015-01-19 14:49:31 -0800149 main.log.report( "ONOS1 didn't start!" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800150 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
151 if not onos2Isup:
Jon Hall6aec96b2015-01-19 14:49:31 -0800152 main.log.report( "ONOS2 didn't start!" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800153 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
154 if not onos3Isup:
Jon Hall6aec96b2015-01-19 14:49:31 -0800155 main.log.report( "ONOS3 didn't start!" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800156 onos4Isup = main.ONOSbench.isup( ONOS4Ip )
157 if not onos4Isup:
Jon Hall6aec96b2015-01-19 14:49:31 -0800158 main.log.report( "ONOS4 didn't start!" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800159 onos5Isup = main.ONOSbench.isup( ONOS5Ip )
160 if not onos5Isup:
Jon Hall6aec96b2015-01-19 14:49:31 -0800161 main.log.report( "ONOS5 didn't start!" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800162 onos6Isup = main.ONOSbench.isup( ONOS6Ip )
163 if not onos6Isup:
Jon Hall6aec96b2015-01-19 14:49:31 -0800164 main.log.report( "ONOS6 didn't start!" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800165 onos7Isup = main.ONOSbench.isup( ONOS7Ip )
166 if not onos7Isup:
Jon Hall6aec96b2015-01-19 14:49:31 -0800167 main.log.report( "ONOS7 didn't start!" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800168 onosIsupResult = onos1Isup and onos2Isup and onos3Isup\
169 and onos4Isup and onos5Isup and onos6Isup and onos7Isup
170 if onosIsupResult == main.TRUE:
Jon Hall94fd0472014-12-08 11:52:42 -0800171 break
Jon Hall73cf9cc2014-11-20 22:28:38 -0800172
Jon Hall8f89dda2015-01-22 16:03:33 -0800173 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip )
174 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip )
175 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip )
176 cliResult4 = main.ONOScli4.startOnosCli( ONOS4Ip )
177 cliResult5 = main.ONOScli5.startOnosCli( ONOS5Ip )
178 cliResult6 = main.ONOScli6.startOnosCli( ONOS6Ip )
179 cliResult7 = main.ONOScli7.startOnosCli( ONOS7Ip )
180 cliResults = cliResult1 and cliResult2 and cliResult3 and\
181 cliResult4 and cliResult5 and cliResult6 and cliResult7
Jon Hall73cf9cc2014-11-20 22:28:38 -0800182
Jon Hall6aec96b2015-01-19 14:49:31 -0800183 main.step( "Start Packet Capture MN" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800184 main.Mininet2.startTcpdump(
Jon Hall6aec96b2015-01-19 14:49:31 -0800185 str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST )
186 + "-MN.pcap",
187 intf=main.params[ 'MNtcpdump' ][ 'intf' ],
188 port=main.params[ 'MNtcpdump' ][ 'port' ] )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800189
Jon Hall8f89dda2015-01-22 16:03:33 -0800190 case1Result = ( cleanInstallResult and packageResult and
191 cellResult and verifyResult and onosInstallResult
192 and onosIsupResult and cliResults )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800193
Jon Hall8f89dda2015-01-22 16:03:33 -0800194 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
195 onpass="Test startup successful",
196 onfail="Test startup NOT successful" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800197
Jon Hall8f89dda2015-01-22 16:03:33 -0800198 if case1Result == main.FALSE:
Jon Hall94fd0472014-12-08 11:52:42 -0800199 main.cleanup()
200 main.exit()
Jon Hall73cf9cc2014-11-20 22:28:38 -0800201
Jon Hall6aec96b2015-01-19 14:49:31 -0800202 def CASE2( self, main ):
203 """
Jon Hall73cf9cc2014-11-20 22:28:38 -0800204 Assign mastership to controllers
Jon Hall6aec96b2015-01-19 14:49:31 -0800205 """
Jon Hall73cf9cc2014-11-20 22:28:38 -0800206 import re
207
Jon Hall6aec96b2015-01-19 14:49:31 -0800208 main.log.report( "Assigning switches to controllers" )
209 main.case( "Assigning Controllers" )
210 main.step( "Assign switches to controllers" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800211
Jon Hall6aec96b2015-01-19 14:49:31 -0800212 for i in range( 1, 29 ):
Jon Hall8f89dda2015-01-22 16:03:33 -0800213 main.Mininet1.assignSwController(
Jon Hall6aec96b2015-01-19 14:49:31 -0800214 sw=str( i ),
Jon Hall8f89dda2015-01-22 16:03:33 -0800215 count=numControllers,
216 ip1=ONOS1Ip, port1=ONOS1Port,
217 ip2=ONOS2Ip, port2=ONOS2Port,
218 ip3=ONOS3Ip, port3=ONOS3Port,
219 ip4=ONOS4Ip, port4=ONOS4Port,
220 ip5=ONOS5Ip, port5=ONOS5Port,
221 ip6=ONOS6Ip, port6=ONOS6Port,
222 ip7=ONOS7Ip, port7=ONOS7Port )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800223
Jon Hall8f89dda2015-01-22 16:03:33 -0800224 mastershipCheck = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -0800225 for i in range( 1, 29 ):
Jon Hall8f89dda2015-01-22 16:03:33 -0800226 response = main.Mininet1.getSwController( "s" + str( i ) )
Jon Hallffb386d2014-11-21 13:43:38 -0800227 try:
Jon Hall6aec96b2015-01-19 14:49:31 -0800228 main.log.info( str( response ) )
Jon Hallffb386d2014-11-21 13:43:38 -0800229 except:
Jon Hall6aec96b2015-01-19 14:49:31 -0800230 main.log.info( repr( response ) )
Jon Hall8f89dda2015-01-22 16:03:33 -0800231 if re.search( "tcp:" + ONOS1Ip, response )\
232 and re.search( "tcp:" + ONOS2Ip, response )\
233 and re.search( "tcp:" + ONOS3Ip, response )\
234 and re.search( "tcp:" + ONOS4Ip, response )\
235 and re.search( "tcp:" + ONOS5Ip, response )\
236 and re.search( "tcp:" + ONOS6Ip, response )\
237 and re.search( "tcp:" + ONOS7Ip, response ):
238 mastershipCheck = mastershipCheck and main.TRUE
Jon Hall73cf9cc2014-11-20 22:28:38 -0800239 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800240 mastershipCheck = main.FALSE
241 if mastershipCheck == main.TRUE:
Jon Hall6aec96b2015-01-19 14:49:31 -0800242 main.log.report( "Switch mastership assigned correctly" )
243 utilities.assert_equals(
244 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800245 actual=mastershipCheck,
Jon Hall6aec96b2015-01-19 14:49:31 -0800246 onpass="Switch mastership assigned correctly",
247 onfail="Switches not assigned correctly to controllers" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800248
Jon Hall6aec96b2015-01-19 14:49:31 -0800249 # Manually assign mastership to the controller we want
Jon Hall8f89dda2015-01-22 16:03:33 -0800250 roleCall = main.TRUE
251 roleCheck = main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800252
Jon Hall6aec96b2015-01-19 14:49:31 -0800253 # Assign switch
Jon Hall8f89dda2015-01-22 16:03:33 -0800254 deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
255 roleCall = roleCall and main.ONOScli1.deviceRole(
256 deviceId,
257 ONOS1Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800258 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800259 if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
260 roleCheck = roleCheck and main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800261 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800262 roleCheck = roleCheck and main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800263
Jon Hall6aec96b2015-01-19 14:49:31 -0800264 # Assign switch
Jon Hall8f89dda2015-01-22 16:03:33 -0800265 deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
266 roleCall = roleCall and main.ONOScli1.deviceRole(
267 deviceId,
268 ONOS1Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800269 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800270 if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
271 roleCheck = roleCheck and main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800272 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800273 roleCheck = roleCheck and main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800274
Jon Hall6aec96b2015-01-19 14:49:31 -0800275 # Assign switch
Jon Hall8f89dda2015-01-22 16:03:33 -0800276 deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
277 roleCall = roleCall and main.ONOScli1.deviceRole(
278 deviceId,
279 ONOS2Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800280 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800281 if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
282 roleCheck = roleCheck and main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800283 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800284 roleCheck = roleCheck and main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800285
Jon Hall6aec96b2015-01-19 14:49:31 -0800286 # Assign switch
Jon Hall8f89dda2015-01-22 16:03:33 -0800287 deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
288 roleCall = roleCall and main.ONOScli1.deviceRole(
289 deviceId,
290 ONOS2Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800291 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800292 if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
293 roleCheck = roleCheck and main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800294 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800295 roleCheck = roleCheck and main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800296
Jon Hall6aec96b2015-01-19 14:49:31 -0800297 # Assign switch
Jon Hall8f89dda2015-01-22 16:03:33 -0800298 deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
299 roleCall = roleCall and main.ONOScli1.deviceRole(
300 deviceId,
301 ONOS3Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800302 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800303 if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
304 roleCheck = roleCheck and main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800305 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800306 roleCheck = roleCheck and main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800307
Jon Hall6aec96b2015-01-19 14:49:31 -0800308 # Assign switch
Jon Hall8f89dda2015-01-22 16:03:33 -0800309 deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
310 roleCall = roleCall and main.ONOScli1.deviceRole(
311 deviceId,
312 ONOS3Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800313 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800314 if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
315 roleCheck = roleCheck and main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800316 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800317 roleCheck = roleCheck and main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800318
Jon Hall6aec96b2015-01-19 14:49:31 -0800319 # Assign switch
Jon Hall8f89dda2015-01-22 16:03:33 -0800320 deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
321 roleCall = roleCall and main.ONOScli1.deviceRole(
322 deviceId,
323 ONOS4Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800324 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800325 if ONOS4Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
326 roleCheck = roleCheck and main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800327 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800328 roleCheck = roleCheck and main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800329
Jon Hall6aec96b2015-01-19 14:49:31 -0800330 for i in range( 8, 18 ):
331 dpid = '3' + str( i ).zfill( 3 )
Jon Hall8f89dda2015-01-22 16:03:33 -0800332 deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
333 roleCall = roleCall and main.ONOScli1.deviceRole(
334 deviceId,
335 ONOS5Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800336 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800337 if ONOS5Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
338 roleCheck = roleCheck and main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -0800339 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800340 roleCheck = roleCheck and main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -0800341
Jon Hall8f89dda2015-01-22 16:03:33 -0800342 deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
343 roleCall = roleCall and main.ONOScli1.deviceRole(
344 deviceId,
345 ONOS6Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800346 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800347 if ONOS6Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
348 roleCheck = roleCheck and main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800349 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800350 roleCheck = roleCheck and main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800351
Jon Hall6aec96b2015-01-19 14:49:31 -0800352 for i in range( 18, 28 ):
353 dpid = '6' + str( i ).zfill( 3 )
Jon Hall8f89dda2015-01-22 16:03:33 -0800354 deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
355 roleCall = roleCall and main.ONOScli1.deviceRole(
356 deviceId,
357 ONOS7Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -0800358 # Check assignment
Jon Hall8f89dda2015-01-22 16:03:33 -0800359 if ONOS7Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ):
360 roleCheck = roleCheck and main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -0800361 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800362 roleCheck = roleCheck and main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800363
Jon Hall6aec96b2015-01-19 14:49:31 -0800364 utilities.assert_equals(
365 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800366 actual=roleCall,
Jon Hall6aec96b2015-01-19 14:49:31 -0800367 onpass="Re-assigned switch mastership to designated controller",
Jon Hall8f89dda2015-01-22 16:03:33 -0800368 onfail="Something wrong with deviceRole calls" )
Jon Hall94fd0472014-12-08 11:52:42 -0800369
Jon Hall6aec96b2015-01-19 14:49:31 -0800370 utilities.assert_equals(
371 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800372 actual=roleCheck,
Jon Hall6aec96b2015-01-19 14:49:31 -0800373 onpass="Switches were successfully reassigned to designated " +
374 "controller",
375 onfail="Switches were not successfully reassigned" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800376 mastershipCheck = mastershipCheck and roleCall and roleCheck
377 utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck,
378 onpass="Switch mastership correctly assigned",
379 onfail="Error in ( re )assigning switch" +
380 " mastership" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800381
Jon Hall6aec96b2015-01-19 14:49:31 -0800382 def CASE3( self, main ):
Jon Hall73cf9cc2014-11-20 22:28:38 -0800383 """
384 Assign intents
Jon Hall73cf9cc2014-11-20 22:28:38 -0800385 """
Jon Hall6aec96b2015-01-19 14:49:31 -0800386 # FIXME: we must reinstall intents until we have a persistant
387 # datastore!
Jon Hall73cf9cc2014-11-20 22:28:38 -0800388 import time
Jon Hall6aec96b2015-01-19 14:49:31 -0800389 main.log.report( "Adding host intents" )
390 main.case( "Adding host Intents" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800391
Jon Hall8f89dda2015-01-22 16:03:33 -0800392 main.step( "Discovering Hosts( Via pingall for now )" )
Jon Hall6aec96b2015-01-19 14:49:31 -0800393 # FIXME: Once we have a host discovery mechanism, use that instead
Jon Hall73cf9cc2014-11-20 22:28:38 -0800394
Jon Hall6aec96b2015-01-19 14:49:31 -0800395 # install onos-app-fwd
396 main.log.info( "Install reactive forwarding app" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800397 main.ONOScli1.featureInstall( "onos-app-fwd" )
398 main.ONOScli2.featureInstall( "onos-app-fwd" )
399 main.ONOScli3.featureInstall( "onos-app-fwd" )
400 main.ONOScli4.featureInstall( "onos-app-fwd" )
401 main.ONOScli5.featureInstall( "onos-app-fwd" )
402 main.ONOScli6.featureInstall( "onos-app-fwd" )
403 main.ONOScli7.featureInstall( "onos-app-fwd" )
Jon Hall94fd0472014-12-08 11:52:42 -0800404
Jon Hall6aec96b2015-01-19 14:49:31 -0800405 # REACTIVE FWD test
Jon Hall8f89dda2015-01-22 16:03:33 -0800406 pingResult = main.FALSE
Jon Hall73cf9cc2014-11-20 22:28:38 -0800407 time1 = time.time()
Jon Hall8f89dda2015-01-22 16:03:33 -0800408 pingResult = main.Mininet1.pingall()
Jon Hall529a37f2015-01-28 10:02:00 -0800409 utilities.assert_equals(
410 expect=main.TRUE,
411 actual=pingResult,
412 onpass="Reactive Pingall test passed",
413 onfail="Reactive Pingall failed, one or more ping pairs failed" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800414 time2 = time.time()
Jon Hall6aec96b2015-01-19 14:49:31 -0800415 main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800416
Jon Hall6aec96b2015-01-19 14:49:31 -0800417 # uninstall onos-app-fwd
418 main.log.info( "Uninstall reactive forwarding app" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800419 main.ONOScli1.featureUninstall( "onos-app-fwd" )
420 main.ONOScli2.featureUninstall( "onos-app-fwd" )
421 main.ONOScli3.featureUninstall( "onos-app-fwd" )
422 main.ONOScli4.featureUninstall( "onos-app-fwd" )
423 main.ONOScli5.featureUninstall( "onos-app-fwd" )
424 main.ONOScli6.featureUninstall( "onos-app-fwd" )
425 main.ONOScli7.featureUninstall( "onos-app-fwd" )
Jon Hall6aec96b2015-01-19 14:49:31 -0800426 # timeout for fwd flows
427 time.sleep( 10 )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800428
Jon Hall6aec96b2015-01-19 14:49:31 -0800429 main.step( "Add host intents" )
430 # TODO: move the host numbers to params
Jon Hall8f89dda2015-01-22 16:03:33 -0800431 intentAddResult = True
Jon Hall6aec96b2015-01-19 14:49:31 -0800432 for i in range( 8, 18 ):
433 main.log.info( "Adding host intent between h" + str( i ) +
434 " and h" + str( i + 10 ) )
435 host1 = "00:00:00:00:00:" + \
436 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
437 host2 = "00:00:00:00:00:" + \
438 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
Jon Hall8f89dda2015-01-22 16:03:33 -0800439 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
440 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
Jon Hall6aec96b2015-01-19 14:49:31 -0800441 # NOTE: get host can return None
Jon Hall8f89dda2015-01-22 16:03:33 -0800442 if host1Id and host2Id:
443 tmpResult = main.ONOScli1.addHostIntent(
444 host1Id,
445 host2Id )
Jon Hall669173b2014-12-17 11:36:30 -0800446 else:
Jon Hall8f89dda2015-01-22 16:03:33 -0800447 main.log.error( "Error, getHost() failed" )
448 tmpResult = main.FALSE
449 intentAddResult = bool( pingResult and intentAddResult
450 and tmpResult )
Jon Hall529a37f2015-01-28 10:02:00 -0800451 # TODO Check that intents were added?
Jon Hall6aec96b2015-01-19 14:49:31 -0800452 utilities.assert_equals(
453 expect=True,
Jon Hall8f89dda2015-01-22 16:03:33 -0800454 actual=intentAddResult,
Jon Hall529a37f2015-01-28 10:02:00 -0800455 onpass="Pushed host intents to ONOS",
456 onfail="Error in pushing host intents to ONOS" )
Jon Hall6aec96b2015-01-19 14:49:31 -0800457 # TODO Check if intents all exist in datastore
Jon Hall73cf9cc2014-11-20 22:28:38 -0800458
Jon Hall6aec96b2015-01-19 14:49:31 -0800459 def CASE4( self, main ):
Jon Hall73cf9cc2014-11-20 22:28:38 -0800460 """
461 Ping across added host intents
462 """
463 description = " Ping across added host intents"
Jon Hall6aec96b2015-01-19 14:49:31 -0800464 main.log.report( description )
465 main.case( description )
Jon Hall8f89dda2015-01-22 16:03:33 -0800466 PingResult = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -0800467 for i in range( 8, 18 ):
468 ping = main.Mininet1.pingHost(
469 src="h" + str( i ), target="h" + str( i + 10 ) )
Jon Hall8f89dda2015-01-22 16:03:33 -0800470 PingResult = PingResult and ping
Jon Hall6aec96b2015-01-19 14:49:31 -0800471 if ping == main.FALSE:
472 main.log.warn( "Ping failed between h" + str( i ) +
473 " and h" + str( i + 10 ) )
474 elif ping == main.TRUE:
475 main.log.info( "Ping test passed!" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800476 PingResult = main.TRUE
477 if PingResult == main.FALSE:
Jon Hall6aec96b2015-01-19 14:49:31 -0800478 main.log.report(
479 "Intents have not been installed correctly, pings failed." )
Jon Hall529a37f2015-01-28 10:02:00 -0800480 #TODO: pretty print
481 main.log.warn( "ONSO1 intents: " )
482 main.log.warn( json.dumps( json.loads( main.ONOScli1.intents() ),
483 sort_keys=True,
484 indent=4,
485 separators=( ',', ': ' ) ) )
Jon Hall8f89dda2015-01-22 16:03:33 -0800486 if PingResult == main.TRUE:
Jon Hall6aec96b2015-01-19 14:49:31 -0800487 main.log.report(
488 "Intents have been installed correctly and verified by pings" )
489 utilities.assert_equals(
490 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800491 actual=PingResult,
Jon Hall6aec96b2015-01-19 14:49:31 -0800492 onpass="Intents have been installed correctly and pings work",
493 onfail="Intents have not been installed correctly, pings failed." )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800494
Jon Hall6aec96b2015-01-19 14:49:31 -0800495 def CASE5( self, main ):
496 """
Jon Hall73cf9cc2014-11-20 22:28:38 -0800497 Reading state of ONOS
Jon Hall6aec96b2015-01-19 14:49:31 -0800498 """
Jon Hall73cf9cc2014-11-20 22:28:38 -0800499 import json
Jon Hall6aec96b2015-01-19 14:49:31 -0800500 # assumes that sts is already in you PYTHONPATH
501 from sts.topology.teston_topology import TestONTopology
Jon Hall73cf9cc2014-11-20 22:28:38 -0800502
Jon Hall6aec96b2015-01-19 14:49:31 -0800503 main.log.report( "Setting up and gathering data for current state" )
504 main.case( "Setting up and gathering data for current state" )
505 # The general idea for this test case is to pull the state of
506 # ( intents,flows, topology,... ) from each ONOS node
507 # We can then compare them with eachother and also with past states
Jon Hall73cf9cc2014-11-20 22:28:38 -0800508
Jon Hall6aec96b2015-01-19 14:49:31 -0800509 main.step( "Get the Mastership of each switch from each controller" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800510 global mastershipState
511 mastershipState = []
Jon Hall94fd0472014-12-08 11:52:42 -0800512
Jon Hall6aec96b2015-01-19 14:49:31 -0800513 # Assert that each device has a master
Jon Hall8f89dda2015-01-22 16:03:33 -0800514 ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
515 ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
516 ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
517 ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
518 ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
519 ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
520 ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
521 rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
522 ONOS3MasterNotNull and ONOS4MasterNotNull and\
523 ONOS5MasterNotNull and ONOS6MasterNotNull and\
524 ONOS7MasterNotNull
Jon Hall6aec96b2015-01-19 14:49:31 -0800525 utilities.assert_equals(
526 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800527 actual=rolesNotNull,
Jon Hall6aec96b2015-01-19 14:49:31 -0800528 onpass="Each device has a master",
529 onfail="Some devices don't have a master assigned" )
Jon Hall94fd0472014-12-08 11:52:42 -0800530
Jon Hall8f89dda2015-01-22 16:03:33 -0800531 ONOS1Mastership = main.ONOScli1.roles()
532 ONOS2Mastership = main.ONOScli2.roles()
533 ONOS3Mastership = main.ONOScli3.roles()
534 ONOS4Mastership = main.ONOScli4.roles()
535 ONOS5Mastership = main.ONOScli5.roles()
536 ONOS6Mastership = main.ONOScli6.roles()
537 ONOS7Mastership = main.ONOScli7.roles()
538 if "Error" in ONOS1Mastership or not ONOS1Mastership\
539 or "Error" in ONOS2Mastership or not ONOS2Mastership\
540 or "Error" in ONOS3Mastership or not ONOS3Mastership\
541 or "Error" in ONOS4Mastership or not ONOS4Mastership\
542 or "Error" in ONOS5Mastership or not ONOS5Mastership\
543 or "Error" in ONOS6Mastership or not ONOS6Mastership\
544 or "Error" in ONOS7Mastership or not ONOS7Mastership:
Jon Hall6aec96b2015-01-19 14:49:31 -0800545 main.log.report( "Error in getting ONOS roles" )
546 main.log.warn(
547 "ONOS1 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800548 repr( ONOS1Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -0800549 main.log.warn(
550 "ONOS2 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800551 repr( ONOS2Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -0800552 main.log.warn(
553 "ONOS3 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800554 repr( ONOS3Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -0800555 main.log.warn(
556 "ONOS4 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800557 repr( ONOS4Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -0800558 main.log.warn(
559 "ONOS5 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800560 repr( ONOS5Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -0800561 main.log.warn(
562 "ONOS6 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800563 repr( ONOS6Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -0800564 main.log.warn(
565 "ONOS7 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800566 repr( ONOS7Mastership ) )
567 consistentMastership = main.FALSE
568 elif ONOS1Mastership == ONOS2Mastership\
569 and ONOS1Mastership == ONOS3Mastership\
570 and ONOS1Mastership == ONOS4Mastership\
571 and ONOS1Mastership == ONOS5Mastership\
572 and ONOS1Mastership == ONOS6Mastership\
573 and ONOS1Mastership == ONOS7Mastership:
574 mastershipState = ONOS1Mastership
575 consistentMastership = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -0800576 main.log.report(
577 "Switch roles are consistent across all ONOS nodes" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800578 else:
Jon Hall6aec96b2015-01-19 14:49:31 -0800579 main.log.warn(
580 "ONOS1 roles: ",
581 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800582 json.loads( ONOS1Mastership ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800583 sort_keys=True,
584 indent=4,
585 separators=(
586 ',',
587 ': ' ) ) )
588 main.log.warn(
589 "ONOS2 roles: ",
590 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800591 json.loads( ONOS2Mastership ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800592 sort_keys=True,
593 indent=4,
594 separators=(
595 ',',
596 ': ' ) ) )
597 main.log.warn(
598 "ONOS3 roles: ",
599 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800600 json.loads( ONOS3Mastership ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800601 sort_keys=True,
602 indent=4,
603 separators=(
604 ',',
605 ': ' ) ) )
606 main.log.warn(
607 "ONOS4 roles: ",
608 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800609 json.loads( ONOS4Mastership ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800610 sort_keys=True,
611 indent=4,
612 separators=(
613 ',',
614 ': ' ) ) )
615 main.log.warn(
616 "ONOS5 roles: ",
617 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800618 json.loads( ONOS5Mastership ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800619 sort_keys=True,
620 indent=4,
621 separators=(
622 ',',
623 ': ' ) ) )
624 main.log.warn(
625 "ONOS6 roles: ",
626 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800627 json.loads( ONOS6Mastership ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800628 sort_keys=True,
629 indent=4,
630 separators=(
631 ',',
632 ': ' ) ) )
633 main.log.warn(
634 "ONOS7 roles: ",
635 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800636 json.loads( ONOS7Mastership ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800637 sort_keys=True,
638 indent=4,
639 separators=(
640 ',',
641 ': ' ) ) )
Jon Hall8f89dda2015-01-22 16:03:33 -0800642 consistentMastership = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -0800643 utilities.assert_equals(
644 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800645 actual=consistentMastership,
Jon Hall6aec96b2015-01-19 14:49:31 -0800646 onpass="Switch roles are consistent across all ONOS nodes",
647 onfail="ONOS nodes have different views of switch roles" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800648
Jon Hall6aec96b2015-01-19 14:49:31 -0800649 main.step( "Get the intents from each controller" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800650 global intentState
651 intentState = []
652 ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
653 ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
654 ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
655 ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
656 ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
657 ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
658 ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
659 intentCheck = main.FALSE
660 if "Error" in ONOS1Intents or not ONOS1Intents\
661 or "Error" in ONOS2Intents or not ONOS2Intents\
662 or "Error" in ONOS3Intents or not ONOS3Intents\
663 or "Error" in ONOS4Intents or not ONOS4Intents\
664 or "Error" in ONOS5Intents or not ONOS5Intents\
665 or "Error" in ONOS6Intents or not ONOS6Intents\
666 or "Error" in ONOS7Intents or not ONOS7Intents:
Jon Hall6aec96b2015-01-19 14:49:31 -0800667 main.log.report( "Error in getting ONOS intents" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800668 main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
669 main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) )
670 main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) )
671 main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) )
672 main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) )
673 main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) )
674 main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) )
675 elif ONOS1Intents == ONOS2Intents\
676 and ONOS1Intents == ONOS3Intents\
677 and ONOS1Intents == ONOS4Intents\
678 and ONOS1Intents == ONOS5Intents\
679 and ONOS1Intents == ONOS6Intents\
680 and ONOS1Intents == ONOS7Intents:
681 intentState = ONOS1Intents
682 intentCheck = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -0800683 main.log.report( "Intents are consistent across all ONOS nodes" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800684 else:
Jon Hall6aec96b2015-01-19 14:49:31 -0800685 main.log.warn(
686 "ONOS1 intents: ",
687 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800688 json.loads( ONOS1Intents ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800689 sort_keys=True,
690 indent=4,
691 separators=(
692 ',',
693 ': ' ) ) )
694 main.log.warn(
695 "ONOS2 intents: ",
696 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800697 json.loads( ONOS2Intents ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800698 sort_keys=True,
699 indent=4,
700 separators=(
701 ',',
702 ': ' ) ) )
703 main.log.warn(
704 "ONOS3 intents: ",
705 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800706 json.loads( ONOS3Intents ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800707 sort_keys=True,
708 indent=4,
709 separators=(
710 ',',
711 ': ' ) ) )
712 main.log.warn(
713 "ONOS4 intents: ",
714 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800715 json.loads( ONOS4Intents ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800716 sort_keys=True,
717 indent=4,
718 separators=(
719 ',',
720 ': ' ) ) )
721 main.log.warn(
722 "ONOS5 intents: ",
723 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800724 json.loads( ONOS5Intents ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800725 sort_keys=True,
726 indent=4,
727 separators=(
728 ',',
729 ': ' ) ) )
730 main.log.warn(
731 "ONOS6 intents: ",
732 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800733 json.loads( ONOS6Intents ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800734 sort_keys=True,
735 indent=4,
736 separators=(
737 ',',
738 ': ' ) ) )
739 main.log.warn(
740 "ONOS7 intents: ",
741 json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -0800742 json.loads( ONOS7Intents ),
Jon Hall6aec96b2015-01-19 14:49:31 -0800743 sort_keys=True,
744 indent=4,
745 separators=(
746 ',',
747 ': ' ) ) )
748 utilities.assert_equals(
749 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800750 actual=intentCheck,
Jon Hall6aec96b2015-01-19 14:49:31 -0800751 onpass="Intents are consistent across all ONOS nodes",
752 onfail="ONOS nodes have different views of intents" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800753
Jon Hall6aec96b2015-01-19 14:49:31 -0800754 main.step( "Get the flows from each controller" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800755 global flowState
756 flowState = []
757 ONOS1Flows = main.ONOScli1.flows( jsonFormat=True )
758 ONOS2Flows = main.ONOScli2.flows( jsonFormat=True )
759 ONOS3Flows = main.ONOScli3.flows( jsonFormat=True )
760 ONOS4Flows = main.ONOScli4.flows( jsonFormat=True )
761 ONOS5Flows = main.ONOScli5.flows( jsonFormat=True )
762 ONOS6Flows = main.ONOScli6.flows( jsonFormat=True )
763 ONOS7Flows = main.ONOScli7.flows( jsonFormat=True )
764 ONOS1FlowsJson = json.loads( ONOS1Flows )
765 ONOS2FlowsJson = json.loads( ONOS2Flows )
766 ONOS3FlowsJson = json.loads( ONOS3Flows )
767 ONOS4FlowsJson = json.loads( ONOS4Flows )
768 ONOS5FlowsJson = json.loads( ONOS5Flows )
769 ONOS6FlowsJson = json.loads( ONOS6Flows )
770 ONOS7FlowsJson = json.loads( ONOS7Flows )
771 flowCheck = main.FALSE
772 if "Error" in ONOS1Flows or not ONOS1Flows\
773 or "Error" in ONOS2Flows or not ONOS2Flows\
774 or "Error" in ONOS3Flows or not ONOS3Flows\
775 or "Error" in ONOS4Flows or not ONOS4Flows\
776 or "Error" in ONOS5Flows or not ONOS5Flows\
777 or "Error" in ONOS6Flows or not ONOS6Flows\
778 or "Error" in ONOS7Flows or not ONOS7Flows:
Jon Hall6aec96b2015-01-19 14:49:31 -0800779 main.log.report( "Error in getting ONOS intents" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800780 main.log.warn( "ONOS1 flows repsponse: " + ONOS1Flows )
781 main.log.warn( "ONOS2 flows repsponse: " + ONOS2Flows )
782 main.log.warn( "ONOS3 flows repsponse: " + ONOS3Flows )
783 main.log.warn( "ONOS4 flows repsponse: " + ONOS4Flows )
784 main.log.warn( "ONOS5 flows repsponse: " + ONOS5Flows )
785 main.log.warn( "ONOS6 flows repsponse: " + ONOS6Flows )
786 main.log.warn( "ONOS7 flows repsponse: " + ONOS7Flows )
787 elif len( ONOS1FlowsJson ) == len( ONOS2FlowsJson )\
788 and len( ONOS1FlowsJson ) == len( ONOS3FlowsJson )\
789 and len( ONOS1FlowsJson ) == len( ONOS4FlowsJson )\
790 and len( ONOS1FlowsJson ) == len( ONOS5FlowsJson )\
791 and len( ONOS1FlowsJson ) == len( ONOS6FlowsJson )\
792 and len( ONOS1FlowsJson ) == len( ONOS7FlowsJson ):
Jon Hall6aec96b2015-01-19 14:49:31 -0800793 # TODO: Do a better check, maybe compare flows on switches?
Jon Hall8f89dda2015-01-22 16:03:33 -0800794 flowState = ONOS1Flows
795 flowCheck = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -0800796 main.log.report( "Flow count is consistent across all ONOS nodes" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800797 else:
Jon Hall6aec96b2015-01-19 14:49:31 -0800798 main.log.warn( "ONOS1 flows: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800799 json.dumps( ONOS1FlowsJson, sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -0800800 indent=4, separators=( ',', ': ' ) ) )
801 main.log.warn( "ONOS2 flows: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800802 json.dumps( ONOS2FlowsJson, sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -0800803 indent=4, separators=( ',', ': ' ) ) )
804 main.log.warn( "ONOS3 flows: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800805 json.dumps( ONOS3FlowsJson, sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -0800806 indent=4, separators=( ',', ': ' ) ) )
807 main.log.warn( "ONOS4 flows: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800808 json.dumps( ONOS4FlowsJson, sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -0800809 indent=4, separators=( ',', ': ' ) ) )
810 main.log.warn( "ONOS5 flows: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800811 json.dumps( ONOS5FlowsJson, sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -0800812 indent=4, separators=( ',', ': ' ) ) )
813 main.log.warn( "ONOS6 flows: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800814 json.dumps( ONOS6FlowsJson, sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -0800815 indent=4, separators=( ',', ': ' ) ) )
816 main.log.warn( "ONOS7 flows: " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800817 json.dumps( ONOS7FlowsJson, sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -0800818 indent=4, separators=( ',', ': ' ) ) )
819 utilities.assert_equals(
820 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800821 actual=flowCheck,
Jon Hall6aec96b2015-01-19 14:49:31 -0800822 onpass="The flow count is consistent across all ONOS nodes",
823 onfail="ONOS nodes have different flow counts" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800824
Jon Hall6aec96b2015-01-19 14:49:31 -0800825 main.step( "Get the OF Table entries" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800826 global flows
Jon Hall6aec96b2015-01-19 14:49:31 -0800827 flows = []
828 for i in range( 1, 29 ):
Jon Hall8f89dda2015-01-22 16:03:33 -0800829 flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800830
Jon Hall6aec96b2015-01-19 14:49:31 -0800831 # TODO: Compare switch flow tables with ONOS flow tables
Jon Hall73cf9cc2014-11-20 22:28:38 -0800832
Jon Hall6aec96b2015-01-19 14:49:31 -0800833 main.step( "Start continuous pings" )
834 main.Mininet2.pingLong(
835 src=main.params[ 'PING' ][ 'source1' ],
836 target=main.params[ 'PING' ][ 'target1' ],
837 pingTime=500 )
838 main.Mininet2.pingLong(
839 src=main.params[ 'PING' ][ 'source2' ],
840 target=main.params[ 'PING' ][ 'target2' ],
841 pingTime=500 )
842 main.Mininet2.pingLong(
843 src=main.params[ 'PING' ][ 'source3' ],
844 target=main.params[ 'PING' ][ 'target3' ],
845 pingTime=500 )
846 main.Mininet2.pingLong(
847 src=main.params[ 'PING' ][ 'source4' ],
848 target=main.params[ 'PING' ][ 'target4' ],
849 pingTime=500 )
850 main.Mininet2.pingLong(
851 src=main.params[ 'PING' ][ 'source5' ],
852 target=main.params[ 'PING' ][ 'target5' ],
853 pingTime=500 )
854 main.Mininet2.pingLong(
855 src=main.params[ 'PING' ][ 'source6' ],
856 target=main.params[ 'PING' ][ 'target6' ],
857 pingTime=500 )
858 main.Mininet2.pingLong(
859 src=main.params[ 'PING' ][ 'source7' ],
860 target=main.params[ 'PING' ][ 'target7' ],
861 pingTime=500 )
862 main.Mininet2.pingLong(
863 src=main.params[ 'PING' ][ 'source8' ],
864 target=main.params[ 'PING' ][ 'target8' ],
865 pingTime=500 )
866 main.Mininet2.pingLong(
867 src=main.params[ 'PING' ][ 'source9' ],
868 target=main.params[ 'PING' ][ 'target9' ],
869 pingTime=500 )
870 main.Mininet2.pingLong(
871 src=main.params[ 'PING' ][ 'source10' ],
872 target=main.params[ 'PING' ][ 'target10' ],
873 pingTime=500 )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800874
Jon Hall6aec96b2015-01-19 14:49:31 -0800875 main.step( "Create TestONTopology object" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800876 ctrls = []
877 count = 1
878 while True:
879 temp = ()
Jon Hall6aec96b2015-01-19 14:49:31 -0800880 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
881 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
882 temp = temp + ( "ONOS" + str( count ), )
883 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
884 temp = temp + \
885 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
886 ctrls.append( temp )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800887 count = count + 1
888 else:
889 break
Jon Hall6aec96b2015-01-19 14:49:31 -0800890 MNTopo = TestONTopology(
891 main.Mininet1,
892 ctrls ) # can also add Intent API info for intent operations
Jon Hall73cf9cc2014-11-20 22:28:38 -0800893
Jon Hall6aec96b2015-01-19 14:49:31 -0800894 main.step( "Collecting topology information from ONOS" )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800895 devices = []
896 devices.append( main.ONOScli1.devices() )
897 devices.append( main.ONOScli2.devices() )
898 devices.append( main.ONOScli3.devices() )
899 devices.append( main.ONOScli4.devices() )
900 devices.append( main.ONOScli5.devices() )
901 devices.append( main.ONOScli6.devices() )
902 devices.append( main.ONOScli7.devices() )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800903 hosts = []
904 hosts.append( main.ONOScli1.hosts() )
905 hosts.append( main.ONOScli2.hosts() )
906 hosts.append( main.ONOScli3.hosts() )
907 hosts.append( main.ONOScli4.hosts() )
908 hosts.append( main.ONOScli5.hosts() )
909 hosts.append( main.ONOScli6.hosts() )
910 hosts.append( main.ONOScli7.hosts() )
Jon Hall73cf9cc2014-11-20 22:28:38 -0800911 ports = []
912 ports.append( main.ONOScli1.ports() )
913 ports.append( main.ONOScli2.ports() )
914 ports.append( main.ONOScli3.ports() )
915 ports.append( main.ONOScli4.ports() )
916 ports.append( main.ONOScli5.ports() )
917 ports.append( main.ONOScli6.ports() )
918 ports.append( main.ONOScli7.ports() )
919 links = []
920 links.append( main.ONOScli1.links() )
921 links.append( main.ONOScli2.links() )
922 links.append( main.ONOScli3.links() )
923 links.append( main.ONOScli4.links() )
924 links.append( main.ONOScli5.links() )
925 links.append( main.ONOScli6.links() )
926 links.append( main.ONOScli7.links() )
Jon Hall94fd0472014-12-08 11:52:42 -0800927 clusters = []
928 clusters.append( main.ONOScli1.clusters() )
929 clusters.append( main.ONOScli2.clusters() )
930 clusters.append( main.ONOScli3.clusters() )
931 clusters.append( main.ONOScli4.clusters() )
932 clusters.append( main.ONOScli5.clusters() )
933 clusters.append( main.ONOScli6.clusters() )
934 clusters.append( main.ONOScli7.clusters() )
Jon Hall529a37f2015-01-28 10:02:00 -0800935 # Compare json objects for hosts and dataplane clusters
Jon Hall94fd0472014-12-08 11:52:42 -0800936
Jon Hall6aec96b2015-01-19 14:49:31 -0800937 # hosts
Jon Hall8f89dda2015-01-22 16:03:33 -0800938 consistentHostsResult = main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800939 for controller in range( len( hosts ) ):
Jon Hall8f89dda2015-01-22 16:03:33 -0800940 controllerStr = str( controller + 1 )
Jon Hall6aec96b2015-01-19 14:49:31 -0800941 if "Error" not in hosts[ controller ]:
942 if hosts[ controller ] == hosts[ 0 ]:
Jon Hall94fd0472014-12-08 11:52:42 -0800943 continue
Jon Hall6aec96b2015-01-19 14:49:31 -0800944 else: # hosts not consistent
945 main.log.report( "hosts from ONOS" +
Jon Hall8f89dda2015-01-22 16:03:33 -0800946 controllerStr +
Jon Hall6aec96b2015-01-19 14:49:31 -0800947 " is inconsistent with ONOS1" )
948 main.log.warn( repr( hosts[ controller ] ) )
Jon Hall8f89dda2015-01-22 16:03:33 -0800949 consistentHostsResult = main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800950
951 else:
Jon Hall6aec96b2015-01-19 14:49:31 -0800952 main.log.report( "Error in getting ONOS hosts from ONOS" +
Jon Hall8f89dda2015-01-22 16:03:33 -0800953 controllerStr )
954 consistentHostsResult = main.FALSE
955 main.log.warn( "ONOS" + controllerStr +
Jon Hall6aec96b2015-01-19 14:49:31 -0800956 " hosts response: " +
957 repr( hosts[ controller ] ) )
958 utilities.assert_equals(
959 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800960 actual=consistentHostsResult,
Jon Hall6aec96b2015-01-19 14:49:31 -0800961 onpass="Hosts view is consistent across all ONOS nodes",
962 onfail="ONOS nodes have different views of hosts" )
Jon Hall94fd0472014-12-08 11:52:42 -0800963
Jon Hall6aec96b2015-01-19 14:49:31 -0800964 # Strongly connected clusters of devices
Jon Hall8f89dda2015-01-22 16:03:33 -0800965 consistentClustersResult = main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -0800966 for controller in range( len( clusters ) ):
Jon Hall6aec96b2015-01-19 14:49:31 -0800967 if "Error" not in clusters[ controller ]:
968 if clusters[ controller ] == clusters[ 0 ]:
Jon Hall94fd0472014-12-08 11:52:42 -0800969 continue
Jon Hall6aec96b2015-01-19 14:49:31 -0800970 else: # clusters not consistent
971 main.log.report( "clusters from ONOS" +
Jon Hall8f89dda2015-01-22 16:03:33 -0800972 controllerStr +
Jon Hall6aec96b2015-01-19 14:49:31 -0800973 " is inconsistent with ONOS1" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800974 consistentClustersResult = main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -0800975
976 else:
Jon Hall6aec96b2015-01-19 14:49:31 -0800977 main.log.report( "Error in getting dataplane clusters " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800978 "from ONOS" + controllerStr )
979 consistentClustersResult = main.FALSE
980 main.log.warn( "ONOS" + controllerStr +
Jon Hall6aec96b2015-01-19 14:49:31 -0800981 " clusters response: " +
982 repr( clusters[ controller ] ) )
983 utilities.assert_equals(
984 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -0800985 actual=consistentClustersResult,
Jon Hall6aec96b2015-01-19 14:49:31 -0800986 onpass="Clusters view is consistent across all ONOS nodes",
987 onfail="ONOS nodes have different views of clusters" )
988 # there should always only be one cluster
Jon Hall8f89dda2015-01-22 16:03:33 -0800989 numClusters = len( json.loads( clusters[ 0 ] ) )
Jon Hall6aec96b2015-01-19 14:49:31 -0800990 utilities.assert_equals(
991 expect=1,
Jon Hall8f89dda2015-01-22 16:03:33 -0800992 actual=numClusters,
Jon Hall6aec96b2015-01-19 14:49:31 -0800993 onpass="ONOS shows 1 SCC",
994 onfail="ONOS shows " +
Jon Hall8f89dda2015-01-22 16:03:33 -0800995 str( numClusters ) +
Jon Hall6aec96b2015-01-19 14:49:31 -0800996 " SCCs" )
Jon Hall94fd0472014-12-08 11:52:42 -0800997
Jon Hall6aec96b2015-01-19 14:49:31 -0800998 main.step( "Comparing ONOS topology to MN" )
Jon Hall8f89dda2015-01-22 16:03:33 -0800999 devicesResults = main.TRUE
1000 portsResults = main.TRUE
1001 linksResults = main.TRUE
1002 for controller in range( numControllers ):
1003 controllerStr = str( controller + 1 )
Jon Hall6aec96b2015-01-19 14:49:31 -08001004 if devices[ controller ] or "Error" not in devices[ controller ]:
Jon Hall8f89dda2015-01-22 16:03:33 -08001005 currentDevicesResult = main.Mininet1.compareSwitches(
Jon Hall6aec96b2015-01-19 14:49:31 -08001006 MNTopo,
1007 json.loads(
1008 devices[ controller ] ) )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001009 else:
Jon Hall8f89dda2015-01-22 16:03:33 -08001010 currentDevicesResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001011 utilities.assert_equals( expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001012 actual=currentDevicesResult,
1013 onpass="ONOS" + controllerStr +
1014 " Switches view is correct",
1015 onfail="ONOS" + controllerStr +
1016 " Switches view is incorrect" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001017
Jon Hall6aec96b2015-01-19 14:49:31 -08001018 if ports[ controller ] or "Error" not in ports[ controller ]:
Jon Hall8f89dda2015-01-22 16:03:33 -08001019 currentPortsResult = main.Mininet1.comparePorts(
Jon Hall6aec96b2015-01-19 14:49:31 -08001020 MNTopo,
1021 json.loads(
1022 ports[ controller ] ) )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001023 else:
Jon Hall8f89dda2015-01-22 16:03:33 -08001024 currentPortsResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001025 utilities.assert_equals( expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001026 actual=currentPortsResult,
1027 onpass="ONOS" + controllerStr +
1028 " ports view is correct",
1029 onfail="ONOS" + controllerStr +
1030 " ports view is incorrect" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001031
Jon Hall6aec96b2015-01-19 14:49:31 -08001032 if links[ controller ] or "Error" not in links[ controller ]:
Jon Hall8f89dda2015-01-22 16:03:33 -08001033 currentLinksResult = main.Mininet1.compareLinks(
Jon Hall6aec96b2015-01-19 14:49:31 -08001034 MNTopo,
1035 json.loads(
1036 links[ controller ] ) )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001037 else:
Jon Hall8f89dda2015-01-22 16:03:33 -08001038 currentLinksResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001039 utilities.assert_equals( expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001040 actual=currentLinksResult,
1041 onpass="ONOS" + controllerStr +
1042 " links view is correct",
1043 onfail="ONOS" + controllerStr +
1044 " links view is incorrect" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001045
Jon Hall8f89dda2015-01-22 16:03:33 -08001046 devicesResults = devicesResults and currentDevicesResult
1047 portsResults = portsResults and currentPortsResult
1048 linksResults = linksResults and currentLinksResult
Jon Hall73cf9cc2014-11-20 22:28:38 -08001049
Jon Hall8f89dda2015-01-22 16:03:33 -08001050 topoResult = devicesResults and portsResults and linksResults\
Jon Hall529a37f2015-01-28 10:02:00 -08001051 and consistentHostsResult and consistentClustersResult
Jon Hall8f89dda2015-01-22 16:03:33 -08001052 utilities.assert_equals( expect=main.TRUE, actual=topoResult,
1053 onpass="Topology Check Test successful",
1054 onfail="Topology Check Test NOT successful" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001055
Jon Hall8f89dda2015-01-22 16:03:33 -08001056 finalAssert = main.TRUE
1057 finalAssert = finalAssert and topoResult and flowCheck \
1058 and intentCheck and consistentMastership and rolesNotNull
1059 utilities.assert_equals( expect=main.TRUE, actual=finalAssert,
1060 onpass="State check successful",
1061 onfail="State check NOT successful" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001062
Jon Hall6aec96b2015-01-19 14:49:31 -08001063 def CASE6( self, main ):
1064 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001065 The Failure case.
Jon Hall6aec96b2015-01-19 14:49:31 -08001066 """
1067 main.log.report( "Restart entire ONOS cluster" )
1068 main.log.case( "Restart entire ONOS cluster" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001069 main.ONOSbench.onosKill( ONOS1Ip )
1070 main.ONOSbench.onosKill( ONOS2Ip )
1071 main.ONOSbench.onosKill( ONOS3Ip )
1072 main.ONOSbench.onosKill( ONOS4Ip )
1073 main.ONOSbench.onosKill( ONOS5Ip )
1074 main.ONOSbench.onosKill( ONOS6Ip )
1075 main.ONOSbench.onosKill( ONOS7Ip )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001076
Jon Hall6aec96b2015-01-19 14:49:31 -08001077 main.step( "Checking if ONOS is up yet" )
Jon Hallffb386d2014-11-21 13:43:38 -08001078 count = 0
Jon Hall8f89dda2015-01-22 16:03:33 -08001079 onosIsupResult = main.FALSE
1080 while onosIsupResult == main.FALSE and count < 10:
1081 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1082 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
1083 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
1084 onos4Isup = main.ONOSbench.isup( ONOS4Ip )
1085 onos5Isup = main.ONOSbench.isup( ONOS5Ip )
1086 onos6Isup = main.ONOSbench.isup( ONOS6Ip )
1087 onos7Isup = main.ONOSbench.isup( ONOS7Ip )
1088 onosIsupResult = onos1Isup and onos2Isup and onos3Isup\
1089 and onos4Isup and onos5Isup and onos6Isup and onos7Isup
Jon Hallffb386d2014-11-21 13:43:38 -08001090 count = count + 1
Jon Hall73cf9cc2014-11-20 22:28:38 -08001091 # TODO: if it becomes an issue, we can retry this step a few times
1092
Jon Hall8f89dda2015-01-22 16:03:33 -08001093 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip )
1094 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip )
1095 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip )
1096 cliResult4 = main.ONOScli4.startOnosCli( ONOS4Ip )
1097 cliResult5 = main.ONOScli5.startOnosCli( ONOS5Ip )
1098 cliResult6 = main.ONOScli6.startOnosCli( ONOS6Ip )
1099 cliResult7 = main.ONOScli7.startOnosCli( ONOS7Ip )
1100 cliResults = cliResult1 and cliResult2 and cliResult3\
1101 and cliResult4 and cliResult5 and cliResult6\
1102 and cliResult7
Jon Hall73cf9cc2014-11-20 22:28:38 -08001103
Jon Hall8f89dda2015-01-22 16:03:33 -08001104 caseResults = main.TRUE and onosIsupResult and cliResults
1105 utilities.assert_equals( expect=main.TRUE, actual=caseResults,
1106 onpass="ONOS restart successful",
1107 onfail="ONOS restart NOT successful" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001108
Jon Hall6aec96b2015-01-19 14:49:31 -08001109 def CASE7( self, main ):
1110 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001111 Check state after ONOS failure
Jon Hall6aec96b2015-01-19 14:49:31 -08001112 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001113 import json
Jon Hall6aec96b2015-01-19 14:49:31 -08001114 main.case( "Running ONOS Constant State Tests" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001115
Jon Hall6aec96b2015-01-19 14:49:31 -08001116 # Assert that each device has a master
Jon Hall8f89dda2015-01-22 16:03:33 -08001117 ONOS1MasterNotNull = main.ONOScli1.rolesNotNull()
1118 ONOS2MasterNotNull = main.ONOScli2.rolesNotNull()
1119 ONOS3MasterNotNull = main.ONOScli3.rolesNotNull()
1120 ONOS4MasterNotNull = main.ONOScli4.rolesNotNull()
1121 ONOS5MasterNotNull = main.ONOScli5.rolesNotNull()
1122 ONOS6MasterNotNull = main.ONOScli6.rolesNotNull()
1123 ONOS7MasterNotNull = main.ONOScli7.rolesNotNull()
1124 rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\
1125 ONOS3MasterNotNull and ONOS4MasterNotNull and\
1126 ONOS5MasterNotNull and ONOS6MasterNotNull and\
1127 ONOS7MasterNotNull
Jon Hall6aec96b2015-01-19 14:49:31 -08001128 utilities.assert_equals(
1129 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001130 actual=rolesNotNull,
Jon Hall6aec96b2015-01-19 14:49:31 -08001131 onpass="Each device has a master",
1132 onfail="Some devices don't have a master assigned" )
Jon Hall94fd0472014-12-08 11:52:42 -08001133
Jon Hall6aec96b2015-01-19 14:49:31 -08001134 main.step( "Check if switch roles are consistent across all nodes" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001135 ONOS1Mastership = main.ONOScli1.roles()
1136 ONOS2Mastership = main.ONOScli2.roles()
1137 ONOS3Mastership = main.ONOScli3.roles()
1138 ONOS4Mastership = main.ONOScli4.roles()
1139 ONOS5Mastership = main.ONOScli5.roles()
1140 ONOS6Mastership = main.ONOScli6.roles()
1141 ONOS7Mastership = main.ONOScli7.roles()
1142 if "Error" in ONOS1Mastership or not ONOS1Mastership\
1143 or "Error" in ONOS2Mastership or not ONOS2Mastership\
1144 or "Error" in ONOS3Mastership or not ONOS3Mastership\
1145 or "Error" in ONOS4Mastership or not ONOS4Mastership\
1146 or "Error" in ONOS5Mastership or not ONOS5Mastership\
1147 or "Error" in ONOS6Mastership or not ONOS6Mastership\
1148 or "Error" in ONOS7Mastership or not ONOS7Mastership:
Jon Hall6aec96b2015-01-19 14:49:31 -08001149 main.log.error( "Error in getting ONOS mastership" )
1150 main.log.warn( "ONOS1 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001151 repr( ONOS1Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -08001152 main.log.warn( "ONOS2 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001153 repr( ONOS2Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -08001154 main.log.warn( "ONOS3 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001155 repr( ONOS3Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -08001156 main.log.warn( "ONOS4 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001157 repr( ONOS4Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -08001158 main.log.warn( "ONOS5 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001159 repr( ONOS5Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -08001160 main.log.warn( "ONOS6 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001161 repr( ONOS6Mastership ) )
Jon Hall6aec96b2015-01-19 14:49:31 -08001162 main.log.warn( "ONOS7 mastership response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001163 repr( ONOS7Mastership ) )
1164 consistentMastership = main.FALSE
1165 elif ONOS1Mastership == ONOS2Mastership\
1166 and ONOS1Mastership == ONOS3Mastership\
1167 and ONOS1Mastership == ONOS4Mastership\
1168 and ONOS1Mastership == ONOS5Mastership\
1169 and ONOS1Mastership == ONOS6Mastership\
1170 and ONOS1Mastership == ONOS7Mastership:
1171 consistentMastership = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -08001172 main.log.report(
1173 "Switch roles are consistent across all ONOS nodes" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001174 else:
Jon Hall6aec96b2015-01-19 14:49:31 -08001175 main.log.warn( "ONOS1 roles: ", json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -08001176 json.loads( ONOS1Mastership ), sort_keys=True, indent=4,
Jon Hall6aec96b2015-01-19 14:49:31 -08001177 separators=( ',', ': ' ) ) )
1178 main.log.warn( "ONOS2 roles: ", json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -08001179 json.loads( ONOS2Mastership ), sort_keys=True, indent=4,
Jon Hall6aec96b2015-01-19 14:49:31 -08001180 separators=( ',', ': ' ) ) )
1181 main.log.warn( "ONOS3 roles: ", json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -08001182 json.loads( ONOS3Mastership ), sort_keys=True, indent=4,
Jon Hall6aec96b2015-01-19 14:49:31 -08001183 separators=( ',', ': ' ) ) )
1184 main.log.warn( "ONOS4 roles: ", json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -08001185 json.loads( ONOS4Mastership ), sort_keys=True, indent=4,
Jon Hall6aec96b2015-01-19 14:49:31 -08001186 separators=( ',', ': ' ) ) )
1187 main.log.warn( "ONOS5 roles: ", json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -08001188 json.loads( ONOS5Mastership ), sort_keys=True, indent=4,
Jon Hall6aec96b2015-01-19 14:49:31 -08001189 separators=( ',', ': ' ) ) )
1190 main.log.warn( "ONOS6 roles: ", json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -08001191 json.loads( ONOS6Mastership ), sort_keys=True, indent=4,
Jon Hall6aec96b2015-01-19 14:49:31 -08001192 separators=( ',', ': ' ) ) )
1193 main.log.warn( "ONOS7 roles: ", json.dumps(
Jon Hall8f89dda2015-01-22 16:03:33 -08001194 json.loads( ONOS7Mastership ), sort_keys=True, indent=4,
Jon Hall6aec96b2015-01-19 14:49:31 -08001195 separators=( ',', ': ' ) ) )
Jon Hall8f89dda2015-01-22 16:03:33 -08001196 consistentMastership = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001197 utilities.assert_equals(
1198 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001199 actual=consistentMastership,
Jon Hall6aec96b2015-01-19 14:49:31 -08001200 onpass="Switch roles are consistent across all ONOS nodes",
1201 onfail="ONOS nodes have different views of switch roles" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001202
1203 description2 = "Compare switch roles from before failure"
Jon Hall6aec96b2015-01-19 14:49:31 -08001204 main.step( description2 )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001205
Jon Hall8f89dda2015-01-22 16:03:33 -08001206 currentJson = json.loads( ONOS1Mastership )
1207 oldJson = json.loads( mastershipState )
1208 mastershipCheck = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -08001209 for i in range( 1, 29 ):
1210 switchDPID = str(
1211 main.Mininet1.getSwitchDPID(
1212 switch="s" +
1213 str( i ) ) )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001214
Jon Hall8f89dda2015-01-22 16:03:33 -08001215 current = [ switch[ 'master' ] for switch in currentJson
Jon Hall6aec96b2015-01-19 14:49:31 -08001216 if switchDPID in switch[ 'id' ] ]
Jon Hall8f89dda2015-01-22 16:03:33 -08001217 old = [ switch[ 'master' ] for switch in oldJson
Jon Hall6aec96b2015-01-19 14:49:31 -08001218 if switchDPID in switch[ 'id' ] ]
Jon Hall73cf9cc2014-11-20 22:28:38 -08001219 if current == old:
Jon Hall8f89dda2015-01-22 16:03:33 -08001220 mastershipCheck = mastershipCheck and main.TRUE
Jon Hall73cf9cc2014-11-20 22:28:38 -08001221 else:
Jon Hall6aec96b2015-01-19 14:49:31 -08001222 main.log.warn( "Mastership of switch %s changed" % switchDPID )
Jon Hall8f89dda2015-01-22 16:03:33 -08001223 mastershipCheck = main.FALSE
1224 if mastershipCheck == main.TRUE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001225 main.log.report( "Mastership of Switches was not changed" )
1226 utilities.assert_equals(
1227 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001228 actual=mastershipCheck,
Jon Hall6aec96b2015-01-19 14:49:31 -08001229 onpass="Mastership of Switches was not changed",
1230 onfail="Mastership of some switches changed" )
1231 # NOTE: we expect mastership to change on controller failure
Jon Hall8f89dda2015-01-22 16:03:33 -08001232 mastershipCheck = mastershipCheck and consistentMastership
Jon Hall73cf9cc2014-11-20 22:28:38 -08001233
Jon Hall6aec96b2015-01-19 14:49:31 -08001234 main.step( "Get the intents and compare across all nodes" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001235 ONOS1Intents = main.ONOScli1.intents( jsonFormat=True )
1236 ONOS2Intents = main.ONOScli2.intents( jsonFormat=True )
1237 ONOS3Intents = main.ONOScli3.intents( jsonFormat=True )
1238 ONOS4Intents = main.ONOScli4.intents( jsonFormat=True )
1239 ONOS5Intents = main.ONOScli5.intents( jsonFormat=True )
1240 ONOS6Intents = main.ONOScli6.intents( jsonFormat=True )
1241 ONOS7Intents = main.ONOScli7.intents( jsonFormat=True )
1242 intentCheck = main.FALSE
1243 if "Error" in ONOS1Intents or not ONOS1Intents\
1244 or "Error" in ONOS2Intents or not ONOS2Intents\
1245 or "Error" in ONOS3Intents or not ONOS3Intents\
1246 or "Error" in ONOS4Intents or not ONOS4Intents\
1247 or "Error" in ONOS5Intents or not ONOS5Intents\
1248 or "Error" in ONOS6Intents or not ONOS6Intents\
1249 or "Error" in ONOS7Intents or not ONOS7Intents:
Jon Hall6aec96b2015-01-19 14:49:31 -08001250 main.log.report( "Error in getting ONOS intents" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001251 main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) )
1252 main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) )
1253 main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) )
1254 main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) )
1255 main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) )
1256 main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) )
1257 main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) )
1258 elif ONOS1Intents == ONOS2Intents\
1259 and ONOS1Intents == ONOS3Intents\
1260 and ONOS1Intents == ONOS4Intents\
1261 and ONOS1Intents == ONOS5Intents\
1262 and ONOS1Intents == ONOS6Intents\
1263 and ONOS1Intents == ONOS7Intents:
1264 intentCheck = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -08001265 main.log.report( "Intents are consistent across all ONOS nodes" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001266 else:
Jon Hall6aec96b2015-01-19 14:49:31 -08001267 main.log.warn( "ONOS1 intents: " )
Jon Hall8f89dda2015-01-22 16:03:33 -08001268 print json.dumps( json.loads( ONOS1Intents ), sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -08001269 indent=4, separators=( ',', ': ' ) )
1270 main.log.warn( "ONOS2 intents: " )
Jon Hall8f89dda2015-01-22 16:03:33 -08001271 print json.dumps( json.loads( ONOS2Intents ), sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -08001272 indent=4, separators=( ',', ': ' ) )
1273 main.log.warn( "ONOS3 intents: " )
Jon Hall8f89dda2015-01-22 16:03:33 -08001274 print json.dumps( json.loads( ONOS3Intents ), sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -08001275 indent=4, separators=( ',', ': ' ) )
1276 main.log.warn( "ONOS4 intents: " )
Jon Hall8f89dda2015-01-22 16:03:33 -08001277 print json.dumps( json.loads( ONOS4Intents ), sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -08001278 indent=4, separators=( ',', ': ' ) )
1279 main.log.warn( "ONOS5 intents: " )
Jon Hall8f89dda2015-01-22 16:03:33 -08001280 print json.dumps( json.loads( ONOS5Intents ), sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -08001281 indent=4, separators=( ',', ': ' ) )
1282 main.log.warn( "ONOS6 intents: " )
Jon Hall8f89dda2015-01-22 16:03:33 -08001283 print json.dumps( json.loads( ONOS6Intents ), sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -08001284 indent=4, separators=( ',', ': ' ) )
1285 main.log.warn( "ONOS7 intents: " )
Jon Hall8f89dda2015-01-22 16:03:33 -08001286 print json.dumps( json.loads( ONOS7Intents ), sort_keys=True,
Jon Hall6aec96b2015-01-19 14:49:31 -08001287 indent=4, separators=( ',', ': ' ) )
1288 utilities.assert_equals(
1289 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001290 actual=intentCheck,
Jon Hall6aec96b2015-01-19 14:49:31 -08001291 onpass="Intents are consistent across all ONOS nodes",
1292 onfail="ONOS nodes have different views of intents" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001293
Jon Hall6aec96b2015-01-19 14:49:31 -08001294 # NOTE: Hazelcast has no durability, so intents are lost across system
1295 # restarts
1296 """
1297 main.step( "Compare current intents with intents before the failure" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001298 # NOTE: this requires case 5 to pass for intentState to be set.
Jon Hall94fd0472014-12-08 11:52:42 -08001299 # maybe we should stop the test if that fails?
Jon Hall8f89dda2015-01-22 16:03:33 -08001300 if intentState == ONOS1Intents:
1301 sameIntents = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -08001302 main.log.report( "Intents are consistent with before failure" )
1303 # TODO: possibly the states have changed? we may need to figure out
1304 # what the aceptable states are
Jon Hall73cf9cc2014-11-20 22:28:38 -08001305 else:
Jon Hall669173b2014-12-17 11:36:30 -08001306 try:
Jon Hall6aec96b2015-01-19 14:49:31 -08001307 main.log.warn( "ONOS1 intents: " )
Jon Hall8f89dda2015-01-22 16:03:33 -08001308 print json.dumps( json.loads( ONOS1Intents ),
Jon Hall6aec96b2015-01-19 14:49:31 -08001309 sort_keys=True, indent=4,
1310 separators=( ',', ': ' ) )
Jon Hall669173b2014-12-17 11:36:30 -08001311 except:
1312 pass
Jon Hall8f89dda2015-01-22 16:03:33 -08001313 sameIntents = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001314 utilities.assert_equals(
1315 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001316 actual=sameIntents,
Jon Hall6aec96b2015-01-19 14:49:31 -08001317 onpass="Intents are consistent with before failure",
1318 onfail="The Intents changed during failure" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001319 intentCheck = intentCheck and sameIntents
Jon Hall6aec96b2015-01-19 14:49:31 -08001320 """
1321 main.step( "Get the OF Table entries and compare to before " +
1322 "component failure" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001323 FlowTables = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -08001324 flows2 = []
1325 for i in range( 28 ):
1326 main.log.info( "Checking flow table on s" + str( i + 1 ) )
Jon Hall8f89dda2015-01-22 16:03:33 -08001327 tmpFlows = main.Mininet2.getFlowTable( 1.3, "s" + str( i + 1 ) )
1328 flows2.append( tmpFlows )
1329 tempResult = main.Mininet2.flowComp(
Jon Hall6aec96b2015-01-19 14:49:31 -08001330 flow1=flows[ i ],
Jon Hall8f89dda2015-01-22 16:03:33 -08001331 flow2=tmpFlows )
1332 FlowTables = FlowTables and tempResult
1333 if FlowTables == main.FALSE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001334 main.log.info( "Differences in flow table for switch: s" +
1335 str( i + 1 ) )
Jon Hall8f89dda2015-01-22 16:03:33 -08001336 if FlowTables == main.TRUE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001337 main.log.report( "No changes were found in the flow tables" )
1338 utilities.assert_equals(
1339 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001340 actual=FlowTables,
Jon Hall6aec96b2015-01-19 14:49:31 -08001341 onpass="No changes were found in the flow tables",
1342 onfail="Changes were found in the flow tables" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001343
Jon Hall6aec96b2015-01-19 14:49:31 -08001344 main.step( "Check the continuous pings to ensure that no packets " +
1345 "were dropped during component failure" )
1346 # FIXME: This check is always failing. Investigate cause
1347 # NOTE: this may be something to do with file permsissions
Jon Hall73cf9cc2014-11-20 22:28:38 -08001348 # or slight change in format
Jon Hall6aec96b2015-01-19 14:49:31 -08001349 main.Mininet2.pingKill(
1350 main.params[ 'TESTONUSER' ],
1351 main.params[ 'TESTONIP' ] )
Jon Hall8f89dda2015-01-22 16:03:33 -08001352 LossInPings = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001353 # NOTE: checkForLoss returns main.FALSE with 0% packet loss
1354 for i in range( 8, 18 ):
1355 main.log.info(
1356 "Checking for a loss in pings along flow from s" +
1357 str( i ) )
Jon Hall8f89dda2015-01-22 16:03:33 -08001358 LossInPings = main.Mininet2.checkForLoss(
Jon Hall6aec96b2015-01-19 14:49:31 -08001359 "/tmp/ping.h" +
Jon Hall8f89dda2015-01-22 16:03:33 -08001360 str( i ) ) or LossInPings
1361 if LossInPings == main.TRUE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001362 main.log.info( "Loss in ping detected" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001363 elif LossInPings == main.ERROR:
Jon Hall6aec96b2015-01-19 14:49:31 -08001364 main.log.info( "There are multiple mininet process running" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001365 elif LossInPings == main.FALSE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001366 main.log.info( "No Loss in the pings" )
1367 main.log.report( "No loss of dataplane connectivity" )
1368 utilities.assert_equals(
1369 expect=main.FALSE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001370 actual=LossInPings,
Jon Hall6aec96b2015-01-19 14:49:31 -08001371 onpass="No Loss of connectivity",
1372 onfail="Loss of dataplane connectivity detected" )
1373 # NOTE: Since intents are not persisted with Hazelcast, we expect this
Jon Hall8f89dda2015-01-22 16:03:33 -08001374 LossInPings = main.FALSE
Jon Hall73cf9cc2014-11-20 22:28:38 -08001375
Jon Hall6aec96b2015-01-19 14:49:31 -08001376 # Test of LeadershipElection
Jon Hall8f89dda2015-01-22 16:03:33 -08001377 leaderList = []
1378 leaderResult = main.TRUE
1379 for controller in range( 1, numControllers + 1 ):
Jon Hall6aec96b2015-01-19 14:49:31 -08001380 # loop through ONOScli handlers
1381 node = getattr( main, ( 'ONOScli' + str( controller ) ) )
Jon Hall8f89dda2015-01-22 16:03:33 -08001382 leaderN = node.electionTestLeader()
1383 leaderList.append( leaderN )
Jon Hall669173b2014-12-17 11:36:30 -08001384 if leaderN == main.FALSE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001385 # error in response
1386 main.log.report( "Something is wrong with " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001387 "electionTestLeader function, check the" +
Jon Hall6aec96b2015-01-19 14:49:31 -08001388 " error logs" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001389 leaderResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001390 elif leaderN is None:
1391 main.log.report( "ONOS" + str( controller ) +
1392 " shows no leader for the election-app was" +
1393 " elected after the old one died" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001394 leaderResult = main.FALSE
1395 if len( set( leaderList ) ) != 1:
1396 leaderResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001397 main.log.error(
1398 "Inconsistent view of leader for the election test app" )
1399 # TODO: print the list
Jon Hall8f89dda2015-01-22 16:03:33 -08001400 if leaderResult:
1401 main.log.report( "Leadership election tests passed( consistent " +
Jon Hall6aec96b2015-01-19 14:49:31 -08001402 "view of leader across listeners and a new " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001403 "leader was re-elected if applicable )" )
Jon Hall6aec96b2015-01-19 14:49:31 -08001404 utilities.assert_equals(
1405 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001406 actual=leaderResult,
Jon Hall6aec96b2015-01-19 14:49:31 -08001407 onpass="Leadership election passed",
1408 onfail="Something went wrong with Leadership election" )
Jon Hall669173b2014-12-17 11:36:30 -08001409
Jon Hall8f89dda2015-01-22 16:03:33 -08001410 result = ( mastershipCheck and intentCheck and FlowTables and
1411 ( not LossInPings ) and rolesNotNull and leaderResult )
Jon Hall6aec96b2015-01-19 14:49:31 -08001412 result = int( result )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001413 if result == main.TRUE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001414 main.log.report( "Constant State Tests Passed" )
1415 utilities.assert_equals( expect=main.TRUE, actual=result,
Jon Hall8f89dda2015-01-22 16:03:33 -08001416 onpass="Constant State Tests Passed",
1417 onfail="Constant state tests failed" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001418
Jon Hall6aec96b2015-01-19 14:49:31 -08001419 def CASE8( self, main ):
1420 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001421 Compare topo
Jon Hall6aec96b2015-01-19 14:49:31 -08001422 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001423 import sys
Jon Hall6aec96b2015-01-19 14:49:31 -08001424 # FIXME add this path to params
1425 sys.path.append( "/home/admin/sts" )
1426 # assumes that sts is already in you PYTHONPATH
1427 from sts.topology.teston_topology import TestONTopology
Jon Hall73cf9cc2014-11-20 22:28:38 -08001428 import json
1429 import time
1430
Jon Hall6aec96b2015-01-19 14:49:31 -08001431 description = "Compare ONOS Topology view to Mininet topology"
1432 main.case( description )
1433 main.log.report( description )
1434 main.step( "Create TestONTopology object" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001435 ctrls = []
1436 count = 1
1437 while True:
1438 temp = ()
Jon Hall6aec96b2015-01-19 14:49:31 -08001439 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1440 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1441 temp = temp + ( "ONOS" + str( count ), )
1442 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1443 temp = temp + \
1444 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1445 ctrls.append( temp )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001446 count = count + 1
1447 else:
1448 break
Jon Hall6aec96b2015-01-19 14:49:31 -08001449 MNTopo = TestONTopology(
1450 main.Mininet1,
1451 ctrls ) # can also add Intent API info for intent operations
Jon Hall73cf9cc2014-11-20 22:28:38 -08001452
Jon Hall6aec96b2015-01-19 14:49:31 -08001453 main.step( "Comparing ONOS topology to MN" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001454 devicesResults = main.TRUE
1455 portsResults = main.TRUE
1456 linksResults = main.TRUE
1457 topoResult = main.FALSE
Jon Hall73cf9cc2014-11-20 22:28:38 -08001458 elapsed = 0
Jon Hallffb386d2014-11-21 13:43:38 -08001459 count = 0
Jon Hall6aec96b2015-01-19 14:49:31 -08001460 main.step( "Collecting topology information from ONOS" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001461 startTime = time.time()
1462 while topoResult == main.FALSE and elapsed < 60:
Jon Hallffb386d2014-11-21 13:43:38 -08001463 count = count + 1
Jon Hall94fd0472014-12-08 11:52:42 -08001464 if count > 1:
Jon Hall6aec96b2015-01-19 14:49:31 -08001465 # TODO: Depricate STS usage
1466 MNTopo = TestONTopology(
1467 main.Mininet1,
1468 ctrls )
Jon Hall8f89dda2015-01-22 16:03:33 -08001469 cliStart = time.time()
Jon Hall94fd0472014-12-08 11:52:42 -08001470 devices = []
1471 devices.append( main.ONOScli1.devices() )
1472 devices.append( main.ONOScli2.devices() )
1473 devices.append( main.ONOScli3.devices() )
1474 devices.append( main.ONOScli4.devices() )
1475 devices.append( main.ONOScli5.devices() )
1476 devices.append( main.ONOScli6.devices() )
1477 devices.append( main.ONOScli7.devices() )
1478 hosts = []
Jon Hall529a37f2015-01-28 10:02:00 -08001479 hosts.append( json.loads( main.ONOScli1.hosts() ) )
1480 hosts.append( json.loads( main.ONOScli2.hosts() ) )
1481 hosts.append( json.loads( main.ONOScli3.hosts() ) )
1482 hosts.append( json.loads( main.ONOScli4.hosts() ) )
1483 hosts.append( json.loads( main.ONOScli5.hosts() ) )
1484 hosts.append( json.loads( main.ONOScli6.hosts() ) )
1485 hosts.append( json.loads( main.ONOScli7.hosts() ) )
1486 for controller in range( 0, len( hosts ) ):
1487 controllerStr = str( controller + 1 )
1488 for host in hosts[ controller ]:
1489 host
1490 if host[ 'ips' ] == []:
1491 main.log.error(
1492 "DEBUG:Error with host ips on controller" +
1493 controllerStr + ": " + str( host ) )
Jon Hall94fd0472014-12-08 11:52:42 -08001494 ports = []
1495 ports.append( main.ONOScli1.ports() )
1496 ports.append( main.ONOScli2.ports() )
1497 ports.append( main.ONOScli3.ports() )
1498 ports.append( main.ONOScli4.ports() )
1499 ports.append( main.ONOScli5.ports() )
1500 ports.append( main.ONOScli6.ports() )
1501 ports.append( main.ONOScli7.ports() )
1502 links = []
1503 links.append( main.ONOScli1.links() )
1504 links.append( main.ONOScli2.links() )
1505 links.append( main.ONOScli3.links() )
1506 links.append( main.ONOScli4.links() )
1507 links.append( main.ONOScli5.links() )
1508 links.append( main.ONOScli6.links() )
1509 links.append( main.ONOScli7.links() )
1510 clusters = []
1511 clusters.append( main.ONOScli1.clusters() )
1512 clusters.append( main.ONOScli2.clusters() )
1513 clusters.append( main.ONOScli3.clusters() )
1514 clusters.append( main.ONOScli4.clusters() )
1515 clusters.append( main.ONOScli5.clusters() )
1516 clusters.append( main.ONOScli6.clusters() )
1517 clusters.append( main.ONOScli7.clusters() )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001518
Jon Hall8f89dda2015-01-22 16:03:33 -08001519 elapsed = time.time() - startTime
1520 cliTime = time.time() - cliStart
1521 print "CLI time: " + str( cliTime )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001522
Jon Hall8f89dda2015-01-22 16:03:33 -08001523 for controller in range( numControllers ):
1524 controllerStr = str( controller + 1 )
Jon Hall6aec96b2015-01-19 14:49:31 -08001525 if devices[ controller ] or "Error" not in devices[
1526 controller ]:
Jon Hall8f89dda2015-01-22 16:03:33 -08001527 currentDevicesResult = main.Mininet1.compareSwitches(
Jon Hall6aec96b2015-01-19 14:49:31 -08001528 MNTopo,
1529 json.loads(
1530 devices[ controller ] ) )
Jon Hall94fd0472014-12-08 11:52:42 -08001531 else:
Jon Hall8f89dda2015-01-22 16:03:33 -08001532 currentDevicesResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001533 utilities.assert_equals( expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001534 actual=currentDevicesResult,
1535 onpass="ONOS" + controllerStr +
1536 " Switches view is correct",
1537 onfail="ONOS" + controllerStr +
1538 " Switches view is incorrect" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001539
Jon Hall6aec96b2015-01-19 14:49:31 -08001540 if ports[ controller ] or "Error" not in ports[ controller ]:
Jon Hall8f89dda2015-01-22 16:03:33 -08001541 currentPortsResult = main.Mininet1.comparePorts(
Jon Hall6aec96b2015-01-19 14:49:31 -08001542 MNTopo,
1543 json.loads(
1544 ports[ controller ] ) )
Jon Hall94fd0472014-12-08 11:52:42 -08001545 else:
Jon Hall8f89dda2015-01-22 16:03:33 -08001546 currentPortsResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001547 utilities.assert_equals( expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001548 actual=currentPortsResult,
1549 onpass="ONOS" + controllerStr +
1550 " ports view is correct",
1551 onfail="ONOS" + controllerStr +
1552 " ports view is incorrect" )
Jon Hall94fd0472014-12-08 11:52:42 -08001553
Jon Hall6aec96b2015-01-19 14:49:31 -08001554 if links[ controller ] or "Error" not in links[ controller ]:
Jon Hall8f89dda2015-01-22 16:03:33 -08001555 currentLinksResult = main.Mininet1.compareLinks(
Jon Hall6aec96b2015-01-19 14:49:31 -08001556 MNTopo,
1557 json.loads(
1558 links[ controller ] ) )
Jon Hall94fd0472014-12-08 11:52:42 -08001559 else:
Jon Hall8f89dda2015-01-22 16:03:33 -08001560 currentLinksResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001561 utilities.assert_equals( expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001562 actual=currentLinksResult,
1563 onpass="ONOS" + controllerStr +
1564 " links view is correct",
1565 onfail="ONOS" + controllerStr +
1566 " links view is incorrect" )
1567 devicesResults = devicesResults and currentDevicesResult
1568 portsResults = portsResults and currentPortsResult
1569 linksResults = linksResults and currentLinksResult
Jon Hall94fd0472014-12-08 11:52:42 -08001570
Jon Hall529a37f2015-01-28 10:02:00 -08001571 # Compare json objects for hosts and dataplane clusters
Jon Hall94fd0472014-12-08 11:52:42 -08001572
Jon Hall6aec96b2015-01-19 14:49:31 -08001573 # hosts
Jon Hall8f89dda2015-01-22 16:03:33 -08001574 consistentHostsResult = main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -08001575 for controller in range( len( hosts ) ):
Jon Hall8f89dda2015-01-22 16:03:33 -08001576 controllerStr = str( controller + 1 )
Jon Hall6aec96b2015-01-19 14:49:31 -08001577 if "Error" not in hosts[ controller ]:
1578 if hosts[ controller ] == hosts[ 0 ]:
Jon Hall94fd0472014-12-08 11:52:42 -08001579 continue
Jon Hall6aec96b2015-01-19 14:49:31 -08001580 else: # hosts not consistent
Jon Hall8f89dda2015-01-22 16:03:33 -08001581 main.log.report( "hosts from ONOS" + controllerStr +
Jon Hall6aec96b2015-01-19 14:49:31 -08001582 " is inconsistent with ONOS1" )
1583 main.log.warn( repr( hosts[ controller ] ) )
Jon Hall8f89dda2015-01-22 16:03:33 -08001584 consistentHostsResult = main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -08001585
1586 else:
Jon Hall6aec96b2015-01-19 14:49:31 -08001587 main.log.report( "Error in getting ONOS hosts from ONOS" +
Jon Hall8f89dda2015-01-22 16:03:33 -08001588 controllerStr )
1589 consistentHostsResult = main.FALSE
1590 main.log.warn( "ONOS" + controllerStr +
Jon Hall6aec96b2015-01-19 14:49:31 -08001591 " hosts response: " +
1592 repr( hosts[ controller ] ) )
1593 utilities.assert_equals(
1594 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001595 actual=consistentHostsResult,
Jon Hall6aec96b2015-01-19 14:49:31 -08001596 onpass="Hosts view is consistent across all ONOS nodes",
1597 onfail="ONOS nodes have different views of hosts" )
Jon Hall94fd0472014-12-08 11:52:42 -08001598
Jon Hall6aec96b2015-01-19 14:49:31 -08001599 # Strongly connected clusters of devices
Jon Hall8f89dda2015-01-22 16:03:33 -08001600 consistentClustersResult = main.TRUE
Jon Hall94fd0472014-12-08 11:52:42 -08001601 for controller in range( len( clusters ) ):
Jon Hall8f89dda2015-01-22 16:03:33 -08001602 controllerStr = str( controller + 1 )
Jon Hall6aec96b2015-01-19 14:49:31 -08001603 if "Error" not in clusters[ controller ]:
1604 if clusters[ controller ] == clusters[ 0 ]:
Jon Hall94fd0472014-12-08 11:52:42 -08001605 continue
Jon Hall6aec96b2015-01-19 14:49:31 -08001606 else: # clusters not consistent
1607 main.log.report( "clusters from ONOS" +
Jon Hall8f89dda2015-01-22 16:03:33 -08001608 controllerStr +
Jon Hall6aec96b2015-01-19 14:49:31 -08001609 " is inconsistent with ONOS1" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001610 consistentClustersResult = main.FALSE
Jon Hall94fd0472014-12-08 11:52:42 -08001611
1612 else:
Jon Hall6aec96b2015-01-19 14:49:31 -08001613 main.log.report( "Error in getting dataplane clusters " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001614 "from ONOS" + controllerStr )
1615 consistentClustersResult = main.FALSE
1616 main.log.warn( "ONOS" + controllerStr +
Jon Hall6aec96b2015-01-19 14:49:31 -08001617 " clusters response: " +
1618 repr( clusters[ controller ] ) )
1619 utilities.assert_equals(
1620 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001621 actual=consistentClustersResult,
Jon Hall6aec96b2015-01-19 14:49:31 -08001622 onpass="Clusters view is consistent across all ONOS nodes",
1623 onfail="ONOS nodes have different views of clusters" )
1624 # there should always only be one cluster
Jon Hall8f89dda2015-01-22 16:03:33 -08001625 numClusters = len( json.loads( clusters[ 0 ] ) )
Jon Hall6aec96b2015-01-19 14:49:31 -08001626 utilities.assert_equals(
1627 expect=1,
Jon Hall8f89dda2015-01-22 16:03:33 -08001628 actual=numClusters,
Jon Hall6aec96b2015-01-19 14:49:31 -08001629 onpass="ONOS shows 1 SCC",
1630 onfail="ONOS shows " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001631 str( numClusters ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08001632 " SCCs" )
Jon Hall94fd0472014-12-08 11:52:42 -08001633
Jon Hall8f89dda2015-01-22 16:03:33 -08001634 topoResult = ( devicesResults and portsResults and linksResults
1635 and consistentHostsResult
Jon Hall529a37f2015-01-28 10:02:00 -08001636 and consistentClustersResult )
Jon Hall94fd0472014-12-08 11:52:42 -08001637
Jon Hall8f89dda2015-01-22 16:03:33 -08001638 topoResult = topoResult and int( count <= 2 )
1639 note = "note it takes about " + str( int( cliTime ) ) + \
1640 " seconds for the test to make all the cli calls to fetch " +\
1641 "the topology from each ONOS instance"
Jon Hall6aec96b2015-01-19 14:49:31 -08001642 main.log.report(
Jon Hall8f89dda2015-01-22 16:03:33 -08001643 "Very crass estimate for topology discovery/convergence( " +
1644 str( note ) + " ): " + str( elapsed ) + " seconds, " +
Jon Hall6aec96b2015-01-19 14:49:31 -08001645 str( count ) + " tries" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001646 utilities.assert_equals( expect=main.TRUE, actual=topoResult,
1647 onpass="Topology Check Test successful",
1648 onfail="Topology Check Test NOT successful" )
1649 if topoResult == main.TRUE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001650 main.log.report( "ONOS topology view matches Mininet topology" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001651
Jon Hall6aec96b2015-01-19 14:49:31 -08001652 def CASE9( self, main ):
1653 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001654 Link s3-s28 down
Jon Hall6aec96b2015-01-19 14:49:31 -08001655 """
1656 import time
1657 # NOTE: You should probably run a topology check after this
Jon Hall73cf9cc2014-11-20 22:28:38 -08001658
Jon Hall8f89dda2015-01-22 16:03:33 -08001659 linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001660
Jon Hall6aec96b2015-01-19 14:49:31 -08001661 description = "Turn off a link to ensure that Link Discovery " +\
Jon Hall8f89dda2015-01-22 16:03:33 -08001662 "is working properly"
Jon Hall6aec96b2015-01-19 14:49:31 -08001663 main.log.report( description )
1664 main.case( description )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001665
Jon Hall6aec96b2015-01-19 14:49:31 -08001666 main.step( "Kill Link between s3 and s28" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001667 LinkDown = main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
Jon Hall6aec96b2015-01-19 14:49:31 -08001668 main.log.info(
1669 "Waiting " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001670 str( linkSleep ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08001671 " seconds for link down to be discovered" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001672 time.sleep( linkSleep )
1673 utilities.assert_equals( expect=main.TRUE, actual=LinkDown,
1674 onpass="Link down succesful",
1675 onfail="Failed to bring link down" )
Jon Hall6aec96b2015-01-19 14:49:31 -08001676 # TODO do some sort of check here
Jon Hall73cf9cc2014-11-20 22:28:38 -08001677
Jon Hall6aec96b2015-01-19 14:49:31 -08001678 def CASE10( self, main ):
1679 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001680 Link s3-s28 up
Jon Hall6aec96b2015-01-19 14:49:31 -08001681 """
1682 import time
1683 # NOTE: You should probably run a topology check after this
Jon Hall73cf9cc2014-11-20 22:28:38 -08001684
Jon Hall8f89dda2015-01-22 16:03:33 -08001685 linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001686
Jon Hall6aec96b2015-01-19 14:49:31 -08001687 description = "Restore a link to ensure that Link Discovery is " + \
Jon Hall8f89dda2015-01-22 16:03:33 -08001688 "working properly"
Jon Hall6aec96b2015-01-19 14:49:31 -08001689 main.log.report( description )
1690 main.case( description )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001691
Jon Hall6aec96b2015-01-19 14:49:31 -08001692 main.step( "Bring link between s3 and s28 back up" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001693 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
Jon Hall6aec96b2015-01-19 14:49:31 -08001694 main.log.info(
1695 "Waiting " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001696 str( linkSleep ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08001697 " seconds for link up to be discovered" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001698 time.sleep( linkSleep )
1699 utilities.assert_equals( expect=main.TRUE, actual=LinkUp,
1700 onpass="Link up succesful",
1701 onfail="Failed to bring link up" )
Jon Hall6aec96b2015-01-19 14:49:31 -08001702 # TODO do some sort of check here
Jon Hall73cf9cc2014-11-20 22:28:38 -08001703
Jon Hall6aec96b2015-01-19 14:49:31 -08001704 def CASE11( self, main ):
1705 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001706 Switch Down
Jon Hall6aec96b2015-01-19 14:49:31 -08001707 """
1708 # NOTE: You should probably run a topology check after this
Jon Hall73cf9cc2014-11-20 22:28:38 -08001709 import time
1710
Jon Hall8f89dda2015-01-22 16:03:33 -08001711 switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001712
1713 description = "Killing a switch to ensure it is discovered correctly"
Jon Hall6aec96b2015-01-19 14:49:31 -08001714 main.log.report( description )
1715 main.case( description )
1716 switch = main.params[ 'kill' ][ 'switch' ]
1717 switchDPID = main.params[ 'kill' ][ 'dpid' ]
Jon Hall73cf9cc2014-11-20 22:28:38 -08001718
Jon Hall6aec96b2015-01-19 14:49:31 -08001719 # TODO: Make this switch parameterizable
1720 main.step( "Kill " + switch )
1721 main.log.report( "Deleting " + switch )
Jon Hall8f89dda2015-01-22 16:03:33 -08001722 main.Mininet1.delSwitch( switch )
1723 main.log.info( "Waiting " + str( switchSleep ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08001724 " seconds for switch down to be discovered" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001725 time.sleep( switchSleep )
1726 device = main.ONOScli1.getDevice( dpid=switchDPID )
Jon Hall6aec96b2015-01-19 14:49:31 -08001727 # Peek at the deleted switch
1728 main.log.warn( str( device ) )
Jon Hall94fd0472014-12-08 11:52:42 -08001729 result = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001730 if device and device[ 'available' ] is False:
Jon Hall94fd0472014-12-08 11:52:42 -08001731 result = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -08001732 utilities.assert_equals( expect=main.TRUE, actual=result,
Jon Hall8f89dda2015-01-22 16:03:33 -08001733 onpass="Kill switch succesful",
1734 onfail="Failed to kill switch?" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001735
Jon Hall6aec96b2015-01-19 14:49:31 -08001736 def CASE12( self, main ):
1737 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001738 Switch Up
Jon Hall6aec96b2015-01-19 14:49:31 -08001739 """
1740 # NOTE: You should probably run a topology check after this
Jon Hall73cf9cc2014-11-20 22:28:38 -08001741 import time
Jon Hall669173b2014-12-17 11:36:30 -08001742
Jon Hall8f89dda2015-01-22 16:03:33 -08001743 switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
Jon Hall6aec96b2015-01-19 14:49:31 -08001744 switch = main.params[ 'kill' ][ 'switch' ]
1745 switchDPID = main.params[ 'kill' ][ 'dpid' ]
1746 links = main.params[ 'kill' ][ 'links' ].split()
Jon Hall73cf9cc2014-11-20 22:28:38 -08001747 description = "Adding a switch to ensure it is discovered correctly"
Jon Hall6aec96b2015-01-19 14:49:31 -08001748 main.log.report( description )
1749 main.case( description )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001750
Jon Hall6aec96b2015-01-19 14:49:31 -08001751 main.step( "Add back " + switch )
1752 main.log.report( "Adding back " + switch )
Jon Hall8f89dda2015-01-22 16:03:33 -08001753 main.Mininet1.addSwitch( switch, dpid=switchDPID )
Jon Hall6aec96b2015-01-19 14:49:31 -08001754 # TODO: New dpid or same? Ask Thomas?
1755 for peer in links:
Jon Hall8f89dda2015-01-22 16:03:33 -08001756 main.Mininet1.addLink( switch, peer )
1757 main.Mininet1.assignSwController(
Jon Hall6aec96b2015-01-19 14:49:31 -08001758 sw=switch.split( 's' )[ 1 ],
Jon Hall8f89dda2015-01-22 16:03:33 -08001759 count=numControllers,
1760 ip1=ONOS1Ip,
1761 port1=ONOS1Port,
1762 ip2=ONOS2Ip,
1763 port2=ONOS2Port,
1764 ip3=ONOS3Ip,
1765 port3=ONOS3Port,
1766 ip4=ONOS4Ip,
1767 port4=ONOS4Port,
1768 ip5=ONOS5Ip,
1769 port5=ONOS5Port,
1770 ip6=ONOS6Ip,
1771 port6=ONOS6Port,
1772 ip7=ONOS7Ip,
1773 port7=ONOS7Port )
Jon Hall6aec96b2015-01-19 14:49:31 -08001774 main.log.info(
1775 "Waiting " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001776 str( switchSleep ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08001777 " seconds for switch up to be discovered" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001778 time.sleep( switchSleep )
1779 device = main.ONOScli1.getDevice( dpid=switchDPID )
Jon Hall6aec96b2015-01-19 14:49:31 -08001780 # Peek at the deleted switch
1781 main.log.warn( str( device ) )
Jon Hall94fd0472014-12-08 11:52:42 -08001782 result = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001783 if device and device[ 'available' ]:
Jon Hall94fd0472014-12-08 11:52:42 -08001784 result = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -08001785 utilities.assert_equals( expect=main.TRUE, actual=result,
Jon Hall8f89dda2015-01-22 16:03:33 -08001786 onpass="add switch succesful",
1787 onfail="Failed to add switch?" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001788
Jon Hall6aec96b2015-01-19 14:49:31 -08001789 def CASE13( self, main ):
1790 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001791 Clean up
Jon Hall6aec96b2015-01-19 14:49:31 -08001792 """
Jon Hall73cf9cc2014-11-20 22:28:38 -08001793 import os
1794 import time
Jon Hall6aec96b2015-01-19 14:49:31 -08001795 # TODO: make use of this elsewhere
1796 ips = []
Jon Hall8f89dda2015-01-22 16:03:33 -08001797 ips.append( ONOS1Ip )
1798 ips.append( ONOS2Ip )
1799 ips.append( ONOS3Ip )
1800 ips.append( ONOS4Ip )
1801 ips.append( ONOS5Ip )
1802 ips.append( ONOS6Ip )
1803 ips.append( ONOS7Ip )
Jon Hall6aec96b2015-01-19 14:49:31 -08001804
1805 # printing colors to terminal
Jon Hall669173b2014-12-17 11:36:30 -08001806 colors = {}
Jon Hall6aec96b2015-01-19 14:49:31 -08001807 colors[ 'cyan' ] = '\033[96m'
1808 colors[ 'purple' ] = '\033[95m'
1809 colors[ 'blue' ] = '\033[94m'
1810 colors[ 'green' ] = '\033[92m'
1811 colors[ 'yellow' ] = '\033[93m'
1812 colors[ 'red' ] = '\033[91m'
1813 colors[ 'end' ] = '\033[0m'
Jon Hall73cf9cc2014-11-20 22:28:38 -08001814 description = "Test Cleanup"
Jon Hall6aec96b2015-01-19 14:49:31 -08001815 main.log.report( description )
1816 main.case( description )
1817 main.step( "Killing tcpdumps" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001818 main.Mininet2.stopTcpdump()
Jon Hall73cf9cc2014-11-20 22:28:38 -08001819
Jon Hall6aec96b2015-01-19 14:49:31 -08001820 main.step( "Checking ONOS Logs for errors" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001821 for i in range( 7 ):
Jon Hall6aec96b2015-01-19 14:49:31 -08001822 print colors[ 'purple' ] + "Checking logs for errors on " + \
Jon Hall8f89dda2015-01-22 16:03:33 -08001823 "ONOS" + str( i + 1 ) + ":" + colors[ 'end' ]
1824 print main.ONOSbench.checkLogs( ips[ i ] )
Jon Hall94fd0472014-12-08 11:52:42 -08001825
Jon Hall6aec96b2015-01-19 14:49:31 -08001826 main.step( "Copying MN pcap and ONOS log files to test station" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001827 testname = main.TEST
Jon Hall8f89dda2015-01-22 16:03:33 -08001828 teststationUser = main.params[ 'TESTONUSER' ]
1829 teststationIP = main.params[ 'TESTONIP' ]
Jon Hall6aec96b2015-01-19 14:49:31 -08001830 # NOTE: MN Pcap file is being saved to ~/packet_captures
Jon Hall73cf9cc2014-11-20 22:28:38 -08001831 # scp this file as MN and TestON aren't necessarily the same vm
Jon Hall6aec96b2015-01-19 14:49:31 -08001832 # FIXME: scp
1833 # mn files
1834 # TODO: Load these from params
1835 # NOTE: must end in /
Jon Hall8f89dda2015-01-22 16:03:33 -08001836 logFolder = "/opt/onos/log/"
1837 logFiles = [ "karaf.log", "karaf.log.1" ]
Jon Hall6aec96b2015-01-19 14:49:31 -08001838 # NOTE: must end in /
Jon Hall8f89dda2015-01-22 16:03:33 -08001839 dstDir = "~/packet_captures/"
1840 for f in logFiles:
1841 for i in range( 7 ):
1842 main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
1843 logFolder + f + " " +
1844 teststationUser + "@" +
1845 teststationIP + ":" +
1846 dstDir + str( testname ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08001847 "-ONOS" + str( i + 1 ) + "-" +
1848 f )
1849 # std*.log's
1850 # NOTE: must end in /
Jon Hall8f89dda2015-01-22 16:03:33 -08001851 logFolder = "/opt/onos/var/"
1852 logFiles = [ "stderr.log", "stdout.log" ]
Jon Hall6aec96b2015-01-19 14:49:31 -08001853 # NOTE: must end in /
Jon Hall8f89dda2015-01-22 16:03:33 -08001854 dstDir = "~/packet_captures/"
1855 for f in logFiles:
1856 for i in range( 7 ):
1857 main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" +
1858 logFolder + f + " " +
1859 teststationUser + "@" +
1860 teststationIP + ":" +
1861 dstDir + str( testname ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08001862 "-ONOS" + str( i + 1 ) + "-" +
1863 f )
1864 # sleep so scp can finish
1865 time.sleep( 10 )
1866 main.step( "Packing and rotating pcap archives" )
1867 os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001868
Jon Hall6aec96b2015-01-19 14:49:31 -08001869 # TODO: actually check something here
1870 utilities.assert_equals( expect=main.TRUE, actual=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001871 onpass="Test cleanup successful",
1872 onfail="Test cleanup NOT successful" )
Jon Hall73cf9cc2014-11-20 22:28:38 -08001873
Jon Hall6aec96b2015-01-19 14:49:31 -08001874 def CASE14( self, main ):
1875 """
Jon Hall669173b2014-12-17 11:36:30 -08001876 start election app on all onos nodes
Jon Hall6aec96b2015-01-19 14:49:31 -08001877 """
Jon Hall8f89dda2015-01-22 16:03:33 -08001878 leaderResult = main.TRUE
Jon Hall6aec96b2015-01-19 14:49:31 -08001879 # install app on onos 1
1880 main.log.info( "Install leadership election app" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001881 main.ONOScli1.featureInstall( "onos-app-election" )
Jon Hall6aec96b2015-01-19 14:49:31 -08001882 # wait for election
1883 # check for leader
Jon Hall8f89dda2015-01-22 16:03:33 -08001884 leader = main.ONOScli1.electionTestLeader()
Jon Hall6aec96b2015-01-19 14:49:31 -08001885 # verify leader is ONOS1
Jon Hall8f89dda2015-01-22 16:03:33 -08001886 if leader == ONOS1Ip:
Jon Hall6aec96b2015-01-19 14:49:31 -08001887 # all is well
Jon Hall669173b2014-12-17 11:36:30 -08001888 pass
Jon Hall6aec96b2015-01-19 14:49:31 -08001889 elif leader is None:
1890 # No leader elected
1891 main.log.report( "No leader was elected" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001892 leaderResult = main.FALSE
Jon Hall669173b2014-12-17 11:36:30 -08001893 elif leader == main.FALSE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001894 # error in response
1895 # TODO: add check for "Command not found:" in the driver, this
1896 # means the app isn't loaded
Jon Hall8f89dda2015-01-22 16:03:33 -08001897 main.log.report( "Something is wrong with electionTestLeader" +
Jon Hall6aec96b2015-01-19 14:49:31 -08001898 " function, check the error logs" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001899 leaderResult = main.FALSE
Jon Hall669173b2014-12-17 11:36:30 -08001900 else:
Jon Hall6aec96b2015-01-19 14:49:31 -08001901 # error in response
1902 main.log.report(
Jon Hall8f89dda2015-01-22 16:03:33 -08001903 "Unexpected response from electionTestLeader function:'" +
1904 str( leader ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08001905 "'" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001906 leaderResult = main.FALSE
Jon Hall669173b2014-12-17 11:36:30 -08001907
Jon Hall6aec96b2015-01-19 14:49:31 -08001908 # install on other nodes and check for leader.
1909 # Should be onos1 and each app should show the same leader
Jon Hall8f89dda2015-01-22 16:03:33 -08001910 for controller in range( 2, numControllers + 1 ):
Jon Hall6aec96b2015-01-19 14:49:31 -08001911 # loop through ONOScli handlers
1912 node = getattr( main, ( 'ONOScli' + str( controller ) ) )
Jon Hall8f89dda2015-01-22 16:03:33 -08001913 node.featureInstall( "onos-app-election" )
1914 leaderN = node.electionTestLeader()
Jon Hall6aec96b2015-01-19 14:49:31 -08001915 # verify leader is ONOS1
Jon Hall8f89dda2015-01-22 16:03:33 -08001916 if leaderN == ONOS1Ip:
Jon Hall6aec96b2015-01-19 14:49:31 -08001917 # all is well
Jon Hall669173b2014-12-17 11:36:30 -08001918 pass
1919 elif leaderN == main.FALSE:
Jon Hall6aec96b2015-01-19 14:49:31 -08001920 # error in response
1921 # TODO: add check for "Command not found:" in the driver, this
1922 # means the app isn't loaded
1923 main.log.report( "Something is wrong with " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001924 "electionTestLeader function, check the" +
Jon Hall6aec96b2015-01-19 14:49:31 -08001925 " error logs" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001926 leaderResult = main.FALSE
Jon Hall669173b2014-12-17 11:36:30 -08001927 elif leader != leaderN:
Jon Hall8f89dda2015-01-22 16:03:33 -08001928 leaderResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08001929 main.log.report( "ONOS" + str( controller ) + " sees " +
1930 str( leaderN ) +
1931 " as the leader of the election app. Leader" +
1932 " should be " +
1933 str( leader ) )
Jon Hall8f89dda2015-01-22 16:03:33 -08001934 if leaderResult:
Jon Hall6aec96b2015-01-19 14:49:31 -08001935 main.log.report( "Leadership election tests passed( consistent " +
1936 "view of leader across listeners and a leader " +
Jon Hall8f89dda2015-01-22 16:03:33 -08001937 "was elected )" )
Jon Hall6aec96b2015-01-19 14:49:31 -08001938 utilities.assert_equals(
1939 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001940 actual=leaderResult,
Jon Hall6aec96b2015-01-19 14:49:31 -08001941 onpass="Leadership election passed",
1942 onfail="Something went wrong with Leadership election" )
Jon Hall669173b2014-12-17 11:36:30 -08001943
Jon Hall6aec96b2015-01-19 14:49:31 -08001944 def CASE15( self, main ):
1945 """
Jon Hall669173b2014-12-17 11:36:30 -08001946 Check that Leadership Election is still functional
Jon Hall6aec96b2015-01-19 14:49:31 -08001947 """
Jon Hall8f89dda2015-01-22 16:03:33 -08001948 leaderResult = main.TRUE
Jon Hall669173b2014-12-17 11:36:30 -08001949 description = "Check that Leadership Election is still functional"
Jon Hall6aec96b2015-01-19 14:49:31 -08001950 main.log.report( description )
1951 main.case( description )
1952 main.step( "Find current leader and withdraw" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001953 leader = main.ONOScli1.electionTestLeader()
Jon Hall6aec96b2015-01-19 14:49:31 -08001954 # TODO: do some sanity checking on leader before using it
Jon Hall8f89dda2015-01-22 16:03:33 -08001955 withdrawResult = main.FALSE
1956 if leader == ONOS1Ip:
1957 oldLeader = getattr( main, "ONOScli1" )
1958 elif leader == ONOS2Ip:
1959 oldLeader = getattr( main, "ONOScli2" )
1960 elif leader == ONOS3Ip:
1961 oldLeader = getattr( main, "ONOScli3" )
1962 elif leader == ONOS4Ip:
1963 oldLeader = getattr( main, "ONOScli4" )
1964 elif leader == ONOS5Ip:
1965 oldLeader = getattr( main, "ONOScli5" )
1966 elif leader == ONOS6Ip:
1967 oldLeader = getattr( main, "ONOScli6" )
1968 elif leader == ONOS7Ip:
1969 oldLeader = getattr( main, "ONOScli7" )
Jon Hall6aec96b2015-01-19 14:49:31 -08001970 elif leader is None or leader == main.FALSE:
1971 main.log.report(
1972 "Leader for the election app should be an ONOS node," +
1973 "instead got '" +
Jon Hall8f89dda2015-01-22 16:03:33 -08001974 str( leader ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08001975 "'" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001976 leaderResult = main.FALSE
1977 withdrawResult = oldLeader.electionTestWithdraw()
Jon Hall6aec96b2015-01-19 14:49:31 -08001978 utilities.assert_equals(
1979 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08001980 actual=withdrawResult,
Jon Hall6aec96b2015-01-19 14:49:31 -08001981 onpass="App was withdrawn from election",
1982 onfail="App was not withdrawn from election" )
Jon Hall669173b2014-12-17 11:36:30 -08001983
Jon Hall6aec96b2015-01-19 14:49:31 -08001984 main.step( "Make sure new leader is elected" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001985 leaderList = []
1986 for controller in range( 1, numControllers + 1 ):
Jon Hall6aec96b2015-01-19 14:49:31 -08001987 # loop through ONOScli handlers
1988 node = getattr( main, ( 'ONOScli' + str( controller ) ) )
Jon Hall8f89dda2015-01-22 16:03:33 -08001989 leaderList.append( node.electionTestLeader() )
1990 for leaderN in leaderList:
Jon Hall669173b2014-12-17 11:36:30 -08001991 if leaderN == leader:
Jon Hall6aec96b2015-01-19 14:49:31 -08001992 main.log.report(
1993 "ONOS" +
1994 str( controller ) +
1995 " still sees " +
1996 str( leader ) +
1997 " as leader after they withdrew" )
Jon Hall8f89dda2015-01-22 16:03:33 -08001998 leaderResult = main.FALSE
Jon Hall669173b2014-12-17 11:36:30 -08001999 elif leaderN == main.FALSE:
Jon Hall6aec96b2015-01-19 14:49:31 -08002000 # error in response
2001 # TODO: add check for "Command not found:" in the driver, this
2002 # means the app isn't loaded
2003 main.log.report( "Something is wrong with " +
Jon Hall8f89dda2015-01-22 16:03:33 -08002004 "electionTestLeader function, " +
Jon Hall6aec96b2015-01-19 14:49:31 -08002005 "check the error logs" )
Jon Hall8f89dda2015-01-22 16:03:33 -08002006 leaderResult = main.FALSE
2007 consistentLeader = main.FALSE
2008 if len( set( leaderList ) ) == 1:
Jon Hall6aec96b2015-01-19 14:49:31 -08002009 main.log.info( "Each Election-app sees '" +
Jon Hall8f89dda2015-01-22 16:03:33 -08002010 str( leaderList[ 0 ] ) +
Jon Hall6aec96b2015-01-19 14:49:31 -08002011 "' as the leader" )
Jon Hall8f89dda2015-01-22 16:03:33 -08002012 consistentLeader = main.TRUE
Jon Hall669173b2014-12-17 11:36:30 -08002013 else:
Jon Hall6aec96b2015-01-19 14:49:31 -08002014 main.log.report(
2015 "Inconsistent responses for leader of Election-app:" )
Jon Hall8f89dda2015-01-22 16:03:33 -08002016 for n in range( len( leaderList ) ):
Jon Hall6aec96b2015-01-19 14:49:31 -08002017 main.log.report( "ONOS" + str( n + 1 ) + " response: " +
Jon Hall8f89dda2015-01-22 16:03:33 -08002018 str( leaderList[ n ] ) )
2019 if leaderResult:
2020 main.log.report( "Leadership election tests passed( consistent " +
Jon Hall6aec96b2015-01-19 14:49:31 -08002021 "view of leader across listeners and a new " +
2022 "leader was elected when the old leader " +
Jon Hall8f89dda2015-01-22 16:03:33 -08002023 "resigned )" )
Jon Hall6aec96b2015-01-19 14:49:31 -08002024 utilities.assert_equals(
2025 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08002026 actual=leaderResult,
Jon Hall6aec96b2015-01-19 14:49:31 -08002027 onpass="Leadership election passed",
2028 onfail="Something went wrong with Leadership election" )
Jon Hall669173b2014-12-17 11:36:30 -08002029
Jon Hall6aec96b2015-01-19 14:49:31 -08002030 main.step(
Jon Hall8f89dda2015-01-22 16:03:33 -08002031 "Run for election on old leader( just so everyone is in the hat )" )
2032 runResult = oldLeader.electionTestRun()
Jon Hall6aec96b2015-01-19 14:49:31 -08002033 utilities.assert_equals(
2034 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08002035 actual=runResult,
Jon Hall6aec96b2015-01-19 14:49:31 -08002036 onpass="App re-ran for election",
2037 onfail="App failed to run for election" )
Jon Hall8f89dda2015-01-22 16:03:33 -08002038 if consistentLeader == main.TRUE:
2039 afterRun = main.ONOScli1.electionTestLeader()
Jon Hall6aec96b2015-01-19 14:49:31 -08002040 # verify leader didn't just change
Jon Hall8f89dda2015-01-22 16:03:33 -08002041 if afterRun == leaderList[ 0 ]:
2042 leaderResult = main.TRUE
Jon Hall669173b2014-12-17 11:36:30 -08002043 else:
Jon Hall8f89dda2015-01-22 16:03:33 -08002044 leaderResult = main.FALSE
Jon Hall6aec96b2015-01-19 14:49:31 -08002045 # TODO: assert on run and withdraw results?
Jon Hall669173b2014-12-17 11:36:30 -08002046
Jon Hall6aec96b2015-01-19 14:49:31 -08002047 utilities.assert_equals(
2048 expect=main.TRUE,
Jon Hall8f89dda2015-01-22 16:03:33 -08002049 actual=leaderResult,
Jon Hall6aec96b2015-01-19 14:49:31 -08002050 onpass="Leadership election passed",
2051 onfail="Something went wrong with Leadership election after " +
2052 "the old leader re-ran for election" )