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