Jon Hall | 97f859d | 2014-08-11 14:23:42 -0700 | [diff] [blame] | 1 | ''' |
| 2 | Description: This case is to ensure that in the event of Zookeeper failures (including the leader node) |
| 3 | the cluster should continue to function properly by the passing of Zookeeper functionality to the |
| 4 | remaining nodes. In this test, a quorum of the Zookeeper instances must be kept alive. |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 5 | |
Jon Hall | 97f859d | 2014-08-11 14:23:42 -0700 | [diff] [blame] | 6 | ''' |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 7 | class HATestZK: |
| 8 | |
| 9 | global topology |
| 10 | global masterSwitchList |
| 11 | global highIntentList |
| 12 | global lowIntentList |
| 13 | global flows |
| 14 | flows = [] |
| 15 | |
| 16 | def __init__(self) : |
| 17 | self.default = '' |
| 18 | |
| 19 | ''' |
| 20 | CASE1 is to close any existing instances of ONOS, clean out the |
| 21 | RAMCloud database, and start up ONOS instances. |
| 22 | ''' |
| 23 | def CASE1(self,main) : |
| 24 | main.case("Initial Startup") |
| 25 | main.step("Stop ONOS") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 26 | main.ONOS1.stop_all() |
| 27 | main.ONOS2.stop_all() |
| 28 | main.ONOS3.stop_all() |
| 29 | main.ONOS4.stop_all() |
| 30 | main.ONOS5.stop_all() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 31 | main.ONOS1.stop_rest() |
| 32 | main.ONOS2.stop_rest() |
| 33 | main.ONOS3.stop_rest() |
| 34 | main.ONOS4.stop_rest() |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 35 | main.ONOS5.stop_rest() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 36 | result = main.ONOS1.status() or main.ONOS2.status() \ |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 37 | or main.ONOS3.status() or main.ONOS4.status() or main.ONOS5.status() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 38 | utilities.assert_equals(expect=main.FALSE,actual=result,onpass="ONOS stopped successfully",onfail="ONOS WAS NOT KILLED PROPERLY") |
| 39 | main.step("Startup Zookeeper") |
| 40 | main.ZK1.start() |
| 41 | main.ZK2.start() |
| 42 | main.ZK3.start() |
| 43 | main.ZK4.start() |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 44 | main.ZK5.start() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 45 | result = main.ZK1.isup() and main.ZK2.isup()\ |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 46 | and main.ZK3.isup() and main.ZK4.isup() and main.ZK5.isup() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 47 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Zookeeper started successfully",onfail="ZOOKEEPER FAILED TO START") |
| 48 | main.step("Cleaning RC Database and Starting All") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 49 | main.RC1.del_db() |
| 50 | main.RC2.del_db() |
| 51 | main.RC3.del_db() |
| 52 | main.RC4.del_db() |
| 53 | main.RC5.del_db() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 54 | main.ONOS1.start_all() |
| 55 | main.ONOS2.start_all() |
| 56 | main.ONOS3.start_all() |
| 57 | main.ONOS4.start_all() |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 58 | main.ONOS5.start_all() |
| 59 | # main.ONOS1.start_rest() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 60 | main.step("Testing Startup") |
| 61 | result1 = main.ONOS1.rest_status() |
| 62 | vm1 = main.RC1.status_coor and main.RC1.status_serv and \ |
| 63 | main.ONOS1.isup() |
| 64 | vm2 = main.RC2.status_coor and main.ONOS2.isup() |
| 65 | vm3 = main.RC3.status_coor and main.ONOS3.isup() |
| 66 | vm4 = main.RC4.status_coor and main.ONOS4.isup() |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 67 | vm5 = main.RC5.status_coor and main.ONOS5.isup() |
| 68 | result = result1 and vm1 and vm2 and vm3 and vm4 and vm5 |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 69 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Everything started successfully",onfail="EVERYTHING FAILED TO START") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 70 | if result==main.FALSE: |
| 71 | main.cleanup() |
| 72 | main.exit() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 73 | |
| 74 | ''' |
| 75 | CASE2 |
| 76 | ''' |
| 77 | def CASE2(self,main) : |
| 78 | import time |
| 79 | import json |
| 80 | import re |
| 81 | main.log.report("Assigning Controllers") |
| 82 | main.case("Assigning Controllers") |
| 83 | main.step("Assign Master Controllers") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 84 | for i in range(1,29): |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 85 | if i ==1: |
| 86 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 87 | elif i>=2 and i<5: |
| 88 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 89 | elif i>=5 and i<8: |
| 90 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 91 | elif i>=8 and i<18: |
| 92 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 93 | elif i>=18 and i<28: |
| 94 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip5'],port1=main.params['CTRL']['port5']) |
| 95 | else: |
| 96 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 97 | |
| 98 | result = main.TRUE |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 99 | for i in range (1,29): |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 100 | if i==1: |
| 101 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 102 | print("Response is " + str(response)) |
| 103 | if re.search("tcp:"+main.params['CTRL']['ip1'],response): |
| 104 | result = result and main.TRUE |
| 105 | else: |
| 106 | result = main.FALSE |
| 107 | elif i>=2 and i<5: |
| 108 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 109 | print("Response is " + str(response)) |
| 110 | if re.search("tcp:"+main.params['CTRL']['ip2'],response): |
| 111 | result = result and main.TRUE |
| 112 | else: |
| 113 | result = main.FALSE |
| 114 | elif i>=5 and i<8: |
| 115 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 116 | print("Response is " + str(response)) |
| 117 | if re.search("tcp:"+main.params['CTRL']['ip3'],response): |
| 118 | result = result and main.TRUE |
| 119 | else: |
| 120 | result = main.FALSE |
| 121 | elif i>=8 and i<18: |
| 122 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 123 | print("Response is " + str(response)) |
| 124 | if re.search("tcp:"+main.params['CTRL']['ip4'],response): |
| 125 | result = result and main.TRUE |
| 126 | else: |
| 127 | result = main.FALSE |
| 128 | elif i>=18 and i<28: |
| 129 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 130 | print("Response is " + str(response)) |
| 131 | if re.search("tcp:"+main.params['CTRL']['ip5'],response): |
| 132 | result = result and main.TRUE |
| 133 | else: |
| 134 | result = main.FALSE |
| 135 | else: |
| 136 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 137 | print("Response is" + str(response)) |
| 138 | if re.search("tcp:" +main.params['CTRL']['ip1'],response): |
| 139 | result = result and main.TRUE |
| 140 | else: |
| 141 | result = main.FALSE |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 142 | |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 143 | utilities.assert_equals(expect = main.TRUE,actual=result,onpass="MasterControllers assigned correctly") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 144 | for i in range (1,29): |
| 145 | main.Mininet1.assign_sw_controller(sw=str(i),count=5,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'],ip5=main.params['CTRL']['ip5'],port5=main.params['CTRL']['port5']) |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 146 | |
| 147 | def CASE3(self,main) : |
| 148 | import time |
| 149 | import json |
| 150 | import re |
| 151 | main.case("Adding Intents") |
| 152 | intentIP = main.params['CTRL']['ip1'] |
| 153 | intentPort=main.params['INTENTS']['intentPort'] |
| 154 | intentURL=main.params['INTENTS']['intentURL'] |
| 155 | count = 1 |
| 156 | for i in range(8,18): |
| 157 | srcMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 158 | dstMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 159 | srcDPID = '00:00:00:00:00:00:30:'+str(i).zfill(2) |
| 160 | dstDPID= '00:00:00:00:00:00:60:' +str(i+10) |
| 161 | main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID,src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
| 162 | count+=1 |
| 163 | dstDPID = '00:00:00:00:00:00:30:'+str(i).zfill(2) |
| 164 | srcDPID= '00:00:00:00:00:00:60:' +str(i+10) |
| 165 | dstMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 166 | srcMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 167 | main.ONOS1.add_intent(intent_id=str(count),src_dpid=srcDPID,dst_dpid=dstDPID,src_mac=srcMac,dst_mac=dstMac,intentIP=intentIP,intentPort=intentPort,intentURL=intentURL) |
| 168 | count+=1 |
| 169 | count = 1 |
| 170 | i = 8 |
| 171 | result = main.TRUE |
| 172 | while i <18 : |
| 173 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10)) |
| 174 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 175 | if ping ==main.FALSE and count <9: |
| 176 | count+=1 |
| 177 | i = 8 |
| 178 | result = main.FALSE |
| 179 | main.log.info("Ping FAILED! Making attempt number "+str(count) + "in 2 seconds") |
| 180 | time.sleep(2) |
| 181 | elif ping==main.FALSE: |
| 182 | main.log.info("PINGS FAILED! MAX RETRIES REACHED!") |
| 183 | i=19 |
| 184 | result = main.FALSE |
| 185 | elif ping==main.TRUE: |
| 186 | main.log.info("Ping passed!") |
| 187 | i+=1 |
| 188 | result = main.TRUE |
| 189 | else: |
| 190 | main.log.info("ERROR!!") |
| 191 | result = main.ERROR |
| 192 | if result==main.FALSE: |
| 193 | main.log.info("INTENTS HAVE NOT BEEN INSTALLED CORRECTLY!! EXITING!!!") |
| 194 | main.cleanup() |
| 195 | main.exit() |
| 196 | |
| 197 | |
| 198 | def CASE4(self,main) : |
| 199 | import time |
| 200 | from subprocess import Popen, PIPE |
| 201 | main.case("Setting up and Gathering data for current state") |
| 202 | main.step("Get the current In-Memory Topology on each ONOS Instance") |
| 203 | |
| 204 | ''' |
| 205 | ctrls = [] |
| 206 | count = 1 |
| 207 | while True: |
| 208 | temp = () |
| 209 | if ('ip'+str(count)) in main.params['CTRL']: |
| 210 | temp = temp+(getattr(main,('ONOS'+str(count))),) |
| 211 | temp = temp + ("ONOS"+str(count),) |
| 212 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 213 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 214 | ctrls.append(temp) |
| 215 | count+=1 |
| 216 | else: |
| 217 | break |
| 218 | topo_result = main.TRUE |
| 219 | |
| 220 | for n in range(1,count): |
| 221 | temp_result = main.Mininet1.compare_topo(ctrls,main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 222 | ''' |
| 223 | |
| 224 | main.step("Get the Mastership of each switch") |
| 225 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['switchURL']],stdout=PIPE).communicate() |
| 226 | global masterSwitchList1 |
| 227 | masterSwitchList1 = stdout |
| 228 | |
| 229 | main.step("Get the High Level Intents") |
| 230 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['intentHighURL']],stdout=PIPE).communicate() |
| 231 | global highIntentList1 |
| 232 | highIntentList1 = stdout |
| 233 | |
| 234 | main.step("Get the Low level Intents") |
| 235 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['intentLowURL']],stdout=PIPE).communicate() |
| 236 | global lowIntentList1 |
| 237 | lowIntentList1= stdout |
| 238 | |
| 239 | main.step("Get the OF Table entries") |
| 240 | global flows |
| 241 | flows=[] |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 242 | for i in range(1,29): |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 243 | flows.append(main.Mininet2.get_flowTable("s"+str(i))) |
| 244 | |
| 245 | |
| 246 | main.step("Start continuous pings") |
| 247 | main.Mininet2.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'],pingTime=500) |
| 248 | main.Mininet2.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'],pingTime=500) |
| 249 | main.Mininet2.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'],pingTime=500) |
| 250 | main.Mininet2.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'],pingTime=500) |
| 251 | main.Mininet2.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'],pingTime=500) |
| 252 | main.Mininet2.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'],pingTime=500) |
| 253 | main.Mininet2.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'],pingTime=500) |
| 254 | main.Mininet2.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'],pingTime=500) |
| 255 | main.Mininet2.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'],pingTime=500) |
| 256 | main.Mininet2.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'],pingTime=500) |
| 257 | |
Jon Hall | 97f859d | 2014-08-11 14:23:42 -0700 | [diff] [blame] | 258 | main.step("Create TestONTopology object") |
| 259 | ctrls = [] |
| 260 | count = 1 |
| 261 | while True: |
| 262 | temp = () |
| 263 | if ('ip' + str(count)) in main.params['CTRL']: |
| 264 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 265 | temp = temp + ("ONOS"+str(count),) |
| 266 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 267 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 268 | ctrls.append(temp) |
| 269 | count = count + 1 |
| 270 | else: |
| 271 | break |
| 272 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 273 | global MNTopo |
| 274 | Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 275 | MNTopo = Topo |
| 276 | |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 277 | |
| 278 | def CASE5(self,main) : |
| 279 | import re |
| 280 | main.case("MAIN COMPONENT FAILURE AND SCENARIO SPECIFIC TESTS") |
| 281 | main.step("Zookeeper Server Failure!") |
| 282 | result = main.TRUE |
| 283 | master1 = main.ZK1.status() |
| 284 | print master1 |
| 285 | if re.search("leader",master1): |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 286 | main.ZK1.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 287 | main.log.info("ZK1 was Master and Killed! Also Killing ZK2") |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 288 | main.ZK2.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 289 | time.sleep(10) |
| 290 | if re.search("leader",main.ZK3.status()) or re.search("leader",main.ZK4.status()) or re.search("leader",main.ZK5.status()): |
| 291 | result = main.TRUE |
| 292 | main.log.info("New Leader Elected") |
| 293 | else: |
| 294 | result = main.FALSE |
| 295 | main.log.info("NO NEW ZK LEADER ELECTED!!!") |
| 296 | else: |
| 297 | master2 = main.ZK2.status() |
| 298 | if re.search("leader",master2): |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 299 | main.ZK2.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 300 | main.log.info("ZK2 was Master and Killed! Also Killing ZK3") |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 301 | main.ZK3.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 302 | time.sleep(10) |
| 303 | if re.search("leader",main.ZK1.status()) or re.search("leader",main.ZK4.status()) or re.search("leader",main.ZK5.status()): |
| 304 | result = main.TRUE |
| 305 | main.log.info("New Leader Elected") |
| 306 | else: |
| 307 | result = main.FALSE |
| 308 | main.log.info("NO NEW ZK LEADER ELECTED!!!") |
| 309 | else: |
| 310 | master3 = main.ZK3.status() |
| 311 | if re.search("leader",master3): |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 312 | main.ZK3.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 313 | main.log.info("ZK3 was Master and Killed! Also Killing ZK4") |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 314 | main.ZK4.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 315 | time.sleep(10) |
| 316 | if re.search("leader",main.ZK1.status()) or re.search("leader",main.ZK2.status()) or re.search("leader",main.ZK5.status()): |
| 317 | result = main.TRUE |
| 318 | main.log.info("New Leader Elected") |
| 319 | else: |
| 320 | result = main.FALSE |
| 321 | main.log.info("NO NEW ZK LEADER ELECTED!!!") |
| 322 | else: |
| 323 | master4 = main.ZK4.status() |
| 324 | if re.search("leader",master4): |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 325 | main.ZK4.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 326 | main.log.info("ZK4 was Master and Killed! Also Killing ZK5") |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 327 | main.ZK5.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 328 | time.sleep(10) |
| 329 | if re.search("leader",main.ZK1.status()) or re.search("leader",main.ZK2.status()) or re.search("leader",main.ZK3.status()): |
| 330 | result = main.TRUE |
| 331 | main.log.info("New Leader Elected") |
| 332 | else: |
| 333 | result = main.FALSE |
| 334 | main.log.info("NO NEW ZK LEADER ELECTED!!!") |
| 335 | else: |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 336 | main.ZK5.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 337 | main.log.info("ZK5 was Master and Killed! Also Killing ZK1") |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 338 | main.ZK1.kill() |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 339 | time.sleep(10) |
| 340 | if re.search("leader",main.ZK3.status()) or re.search("leader",main.ZK4.status()) or re.search("leader",main.ZK2.status()): |
| 341 | result = main.TRUE |
| 342 | main.log.info("New Leader Elected") |
| 343 | else: |
| 344 | result = main.FALSE |
| 345 | main.log.info("NO NEW ZK LEADER ELECTED!!!") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 346 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="New Leader was Elected!",onfail="NO NEW LEADER WAS ELECTED!!!!") |
| 347 | |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 348 | |
| 349 | |
| 350 | def CASE6(self,main) : |
| 351 | import os |
| 352 | main.case("Running ONOS Constant State Tests") |
| 353 | main.step("Get the current In-Memory Topology on each ONOS Instance and Compare it to the Topology before component failure") |
| 354 | |
| 355 | main.step("Get the Mastership of each switch and compare to the Mastership before component failure") |
| 356 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['switchURL']],stdout=PIPE).communicate() |
| 357 | result = main.TRUE |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 358 | for i in range(1,29): |
| 359 | switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i))) |
| 360 | switchDPID = switchDPID[:2]+":"+switchDPID[2:4]+":"+switchDPID[4:6]+":"+switchDPID[6:8]+":"+switchDPID[8:10]+":"+switchDPID[10:12]+":"+switchDPID[12:14]+":"+switchDPID[14:] |
| 361 | master1 = main.ZK1.findMaster(switchDPID=switchDPID,switchList=masterSwitchList1) |
| 362 | master2 = main.ZK1.findMaster(switchDPID=switchDPID,switchList=stdout) |
| 363 | if main.ZK1.findMaster(switchDPID=switchDPID,switchList=masterSwitchList1)==main.ZK1.findMaster(switchDPID=switchDPID,switchList=stdout): |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 364 | result = result and main.TRUE |
| 365 | else: |
| 366 | result = main.FALSE |
| 367 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Mastership of Switches was not changed",onfail="MASTERSHIP OF SWITCHES HAS CHANGED!!!") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 368 | result1 = result |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 369 | |
| 370 | main.step("Get the High Level Intents and compare to before component failure") |
| 371 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['intentHighURL']],stdout=PIPE).communicate() |
| 372 | changesInIntents=main.ONOS1.comp_intents(preIntents=highIntentList1,postIntents=stdout) |
| 373 | if not changesInIntents: |
| 374 | result = main.TRUE |
| 375 | else: |
| 376 | main.log.info("THERE WERE CHANGES TO THE HIGH LEVEL INTENTS! CHANGES WERE: "+str(changesInIntents)) |
| 377 | result = main.FALSE |
| 378 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No changes to High level Intents",onfail="CHANGES WERE MADE TO HIGH LEVEL INTENTS") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 379 | result2=result |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 380 | |
| 381 | main.step("Get the Low level Intents and compare to before component failure") |
| 382 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['intentLowURL']],stdout=PIPE).communicate() |
| 383 | changesInIntents=main.ONOS1.comp_low(preIntents=lowIntentList1,postIntents=stdout) |
| 384 | if not changesInIntents: |
| 385 | result = main.TRUE |
| 386 | else: |
| 387 | main.log.info("THERE WERE CHANGES TO THE LOW LEVEL INTENTS! CHANGES WERE: "+str(changesInIntents)) |
| 388 | result = main.FALSE |
| 389 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No changes to Low level Intents",onfail="CHANGES WERE MADE TO LOW LEVEL INTENTS") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 390 | result3=result |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 391 | |
| 392 | |
| 393 | main.step("Get the OF Table entries and compare to before component failure") |
| 394 | result = main.TRUE |
| 395 | flows2=[] |
| 396 | for i in range(27): |
| 397 | flows2.append(main.Mininet2.get_flowTable(sw="s"+str(i+1))) |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 398 | result = result and main.Mininet2.flow_comp(flow1=flows[i], flow2=main.Mininet2.get_flowTable(sw="s"+str(i+1))) |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 399 | if result == main.FALSE: |
| 400 | main.log.info("DIFFERENCES IN FLOW TABLES FOR SWITCH "+str(i)) |
| 401 | break |
| 402 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No changes in the flow tables",onfail="CHANGES IN THE FLOW TABLES!!") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 403 | result4 = result |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 404 | |
| 405 | main.step("Check the continuous pings to ensure that no packets were dropped during component failure") |
| 406 | main.Mininet2.pingKill() |
| 407 | result = main.FALSE |
| 408 | for i in range(8,18): |
| 409 | result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i)) |
| 410 | if result==main.TRUE: |
| 411 | main.log.info("LOSS IN THE PINGS!") |
| 412 | elif result == main.ERROR: |
| 413 | main.log.info("There are multiple mininet process running!!") |
| 414 | else: |
| 415 | main.log.info("No Loss in the pings!") |
| 416 | utilities.assert_equals(expect=main.FALSE,actual=result,onpass="No Loss of connectivity!",onfail="LOSS OF CONNECTIVITY") |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 417 | result5=not result |
Jon Hall | 97f859d | 2014-08-11 14:23:42 -0700 | [diff] [blame] | 418 | |
| 419 | main.step("Check that ONOS Topology is consistent with MN Topology") |
Jon Hall | 65bfea1 | 2014-08-11 15:11:09 -0700 | [diff] [blame^] | 420 | ctrls = [] |
| 421 | count = 1 |
| 422 | while True: |
| 423 | temp = () |
| 424 | if ('ip' + str(count)) in main.params['CTRL']: |
| 425 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 426 | temp = temp + ("ONOS"+str(count),) |
| 427 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 428 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 429 | ctrls.append(temp) |
| 430 | count = count + 1 |
| 431 | else: |
| 432 | break |
Jon Hall | 97f859d | 2014-08-11 14:23:42 -0700 | [diff] [blame] | 433 | |
| 434 | |
| 435 | result6 = main.TRUE |
| 436 | for n in range(1,5): |
| 437 | result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest'])) |
| 438 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS" + str(n) + " Topology matches MN Topology",onfail="ONOS" + str(n) + " Topology does not match MN Topology") |
| 439 | result6 = result6 and result |
| 440 | result = result1 and result2 and result3 and result4 and result5 and result6 |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 441 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Constant State Tests Passed!",onfail="CONSTANT STATE TESTS FAILED!!") |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 442 | |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 443 | def CASE7 (self,main): |
| 444 | main.case("Killing a link to Ensure that Link Discovery is Working Properly") |
| 445 | main.step("Start continuous pings") |
| 446 | main.Mininet2.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'],pingTime=500) |
| 447 | main.Mininet2.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'],pingTime=500) |
| 448 | main.Mininet2.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'],pingTime=500) |
| 449 | main.Mininet2.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'],pingTime=500) |
| 450 | main.Mininet2.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'],pingTime=500) |
| 451 | main.Mininet2.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'],pingTime=500) |
| 452 | main.Mininet2.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'],pingTime=500) |
| 453 | main.Mininet2.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'],pingTime=500) |
| 454 | main.Mininet2.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'],pingTime=500) |
| 455 | main.Mininet2.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'],pingTime=500) |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 456 | |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 457 | main.step("Determine the current number of switches and links") |
| 458 | (number,active)=main.ONOS1.num_switch(RestIP=main.params['CTRL']['ip1']) |
| 459 | links = main.ONOS1.num_link(RestIP=main.params['CTRL']['ip1']) |
| 460 | main.log.info("Currently there are %s switches, %s are active, and %s links" %(number,active,links)) |
| 461 | |
| 462 | main.step("Kill Link between s3 and s28") |
| 463 | main.Mininet1.link(END1="s3",END2="s28",OPTION="down") |
| 464 | result = main.ONOS1.check_status_report(main.params['CTRL']['ip1'],active,str(int(links)-2)) |
| 465 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link Down discovered properly",onfail="LINKS NOT DISCOVERED PROPERLY") |
| 466 | result1 = result |
| 467 | result = main.Mininet1.link(END1="s3",END2="s28",OPTION="up") |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 468 | |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 469 | main.step("Check for loss in pings when Link is brought down") |
| 470 | main.Mininet2.pingKill() |
| 471 | result = main.FALSE |
| 472 | for i in range(8,18): |
| 473 | result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i)) |
| 474 | if result==main.TRUE: |
| 475 | main.log.info("LOSS IN THE PINGS!") |
| 476 | elif result == main.ERROR: |
| 477 | main.log.info("There are multiple mininet process running!!") |
| 478 | else: |
| 479 | main.log.info("No Loss in the pings!") |
| 480 | utilities.assert_equals(expect=main.FALSE,actual=result,onpass="No Loss of connectivity!",onfail="LOSS OF CONNECTIVITY") |
| 481 | result2 = result |
| 482 | result = result1 and not result2 |
| 483 | utilities.assert_equals(expect=main.FALSE,actual=result,onpass="Link failure is discovered correctly and no traffic is lost!",onfail="Link Discovery failed or traffic was dropped!!!") |
| 484 | |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 485 | |
admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 486 | |
| 487 | def CASE8 (self, main) : |
| 488 | import time |
| 489 | main.case("Killing a switch to ensure switch discovery is working properly") |
| 490 | main.step("Start continuous pings") |
| 491 | main.Mininet2.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'],pingTime=500) |
| 492 | main.Mininet2.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'],pingTime=500) |
| 493 | main.Mininet2.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'],pingTime=500) |
| 494 | main.Mininet2.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'],pingTime=500) |
| 495 | main.Mininet2.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'],pingTime=500) |
| 496 | main.Mininet2.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'],pingTime=500) |
| 497 | main.Mininet2.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'],pingTime=500) |
| 498 | main.Mininet2.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'],pingTime=500) |
| 499 | main.Mininet2.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'],pingTime=500) |
| 500 | main.Mininet2.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'],pingTime=500) |
| 501 | |
| 502 | main.step("Determine the current number of switches and links") |
| 503 | (number,active)=main.ONOS1.num_switch(RestIP=main.params['CTRL']['ip1']) |
| 504 | links = main.ONOS1.num_link(RestIP=main.params['CTRL']['ip1']) |
| 505 | main.log.info("Currently there are %s switches, %s are active, and %s links" %(number,active,links)) |
| 506 | |
| 507 | main.step("Kill s28 ") |
| 508 | main.Mininet2.del_switch("s28") |
| 509 | time.sleep(31) |
| 510 | result = main.ONOS1.check_status_report(main.params['CTRL']['ip1'],str(int(active)-1),str(int(links)-4)) |
| 511 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Switch Discovery is Working",onfail="Switch Discovery FAILED TO WORK PROPERLY!") |
| 512 | |
| 513 | main.step("Add back s28") |
| 514 | main.Mininet2.add_switch("s28") |
| 515 | main.Mininet1.assign_sw_controller(sw="28",ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 516 | main.Mininet1.assign_sw_controller(sw="28",count=5,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'],ip5=main.params['CTRL']['ip5'],port5=main.params['CTRL']['port5']) |
| 517 | time.sleep(31) |
| 518 | result = main.ONOS1.check_status_report(main.params['CTRL']['ip1'],active,links) |
| 519 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Switch Discovery is Working",onfail="Switch Discovery FAILED TO WORK PROPERLY!") |
| 520 | result1=result |
| 521 | |
| 522 | main.step("Checking for Traffic Loss") |
| 523 | main.Mininet2.pingKill() |
| 524 | result = main.FALSE |
| 525 | for i in range(8,18): |
| 526 | result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i)) |
| 527 | if result==main.TRUE: |
| 528 | main.log.info("LOSS IN THE PINGS!") |
| 529 | elif result == main.ERROR: |
| 530 | main.log.info("There are multiple mininet process running!!") |
| 531 | else: |
| 532 | main.log.info("No Loss in the pings!") |
| 533 | utilities.assert_equals(expect=main.FALSE,actual=result,onpass="No Loss of connectivity!",onfail="LOSS OF CONNECTIVITY") |
| 534 | result = not result and result1 |
| 535 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Switch Discovered Correctly and No Loss of traffic",onfail="Switch discovery failed or there was loss of traffic") |
admin | 4927d4f | 2014-07-30 09:47:49 -0700 | [diff] [blame] | 536 | |
admin | 795d34a | 2014-08-08 15:14:21 -0700 | [diff] [blame] | 537 | # Authored by James Lee |
| 538 | # Just wanted to see how many people were paying attention here. |
| 539 | # Elayne Boosler once said "I have six locks on my door all in a row |
| 540 | # When I go out, I lock every other one. I figure no matter how long |
| 541 | # somebody stands there picking the locks, they are always locking three" |
| 542 | |