admin | ecb9265 | 2014-08-04 09:27:21 -0700 | [diff] [blame] | 1 | |
| 2 | class HATestONOS2: |
| 3 | |
| 4 | global topology |
| 5 | global masterSwitchList |
| 6 | global highIntentList |
| 7 | global lowIntentList |
| 8 | global flows |
| 9 | flows = [] |
| 10 | |
| 11 | def __init__(self) : |
| 12 | self.default = '' |
| 13 | |
| 14 | ''' |
| 15 | CASE1 is to close any existing instances of ONOS, clean out the |
| 16 | RAMCloud database, and start up ONOS instances. |
| 17 | ''' |
| 18 | def CASE1(self,main) : |
| 19 | main.case("Initial Startup") |
| 20 | main.step("Stop ONOS") |
| 21 | main.ONOS1.stop_all() |
| 22 | main.ONOS2.stop_all() |
| 23 | main.ONOS3.stop_all() |
| 24 | main.ONOS4.stop_all() |
| 25 | main.ONOS5.stop_all() |
| 26 | main.ONOS1.stop_rest() |
| 27 | main.ONOS2.stop_rest() |
| 28 | main.ONOS3.stop_rest() |
| 29 | main.ONOS4.stop_rest() |
| 30 | main.ONOS5.stop_rest() |
| 31 | result = main.ONOS1.status() or main.ONOS2.status() \ |
| 32 | or main.ONOS3.status() or main.ONOS4.status() or main.ONOS5.status() |
| 33 | utilities.assert_equals(expect=main.FALSE,actual=result,onpass="ONOS stopped successfully",onfail="ONOS WAS NOT KILLED PROPERLY") |
| 34 | main.step("Startup Zookeeper") |
| 35 | main.ZK1.start() |
| 36 | main.ZK2.start() |
| 37 | main.ZK3.start() |
| 38 | main.ZK4.start() |
| 39 | main.ZK5.start() |
| 40 | result = main.ZK1.isup() and main.ZK2.isup()\ |
| 41 | and main.ZK3.isup() and main.ZK4.isup() and main.ZK5.isup() |
| 42 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Zookeeper started successfully",onfail="ZOOKEEPER FAILED TO START") |
| 43 | main.step("Cleaning RC Database and Starting All") |
| 44 | main.RC1.del_db() |
| 45 | main.RC2.del_db() |
| 46 | main.RC3.del_db() |
| 47 | main.RC4.del_db() |
| 48 | main.RC5.del_db() |
| 49 | main.ONOS1.start_all() |
| 50 | main.ONOS2.start_all() |
| 51 | main.ONOS3.start_all() |
| 52 | main.ONOS4.start_all() |
| 53 | main.ONOS5.start_all() |
| 54 | # main.ONOS1.start_rest() |
| 55 | main.step("Testing Startup") |
| 56 | result1 = main.ONOS1.rest_status() |
| 57 | vm1 = main.RC1.status_coor and main.RC1.status_serv and \ |
| 58 | main.ONOS1.isup() |
| 59 | vm2 = main.RC2.status_coor and main.ONOS2.isup() |
| 60 | vm3 = main.RC3.status_coor and main.ONOS3.isup() |
| 61 | vm4 = main.RC4.status_coor and main.ONOS4.isup() |
| 62 | vm5 = main.RC5.status_coor and main.ONOS5.isup() |
| 63 | result = result1 and vm1 and vm2 and vm3 and vm4 and vm5 |
| 64 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Everything started successfully",onfail="EVERYTHING FAILED TO START") |
| 65 | |
| 66 | ''' |
| 67 | CASE2 |
| 68 | ''' |
| 69 | def CASE2(self,main) : |
| 70 | import time |
| 71 | import json |
| 72 | import re |
| 73 | main.log.report("Assigning Controllers") |
| 74 | main.case("Assigning Controllers") |
| 75 | main.step("Assign Master Controllers") |
| 76 | for i in range(1,29): |
| 77 | if i ==1: |
| 78 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 79 | elif i>=2 and i<5: |
| 80 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 81 | elif i>=5 and i<8: |
| 82 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 83 | elif i>=8 and i<18: |
| 84 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 85 | elif i>=18 and i<28: |
| 86 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip5'],port1=main.params['CTRL']['port5']) |
| 87 | else: |
| 88 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 89 | |
| 90 | result = main.TRUE |
| 91 | for i in range (1,29): |
| 92 | if i==1: |
| 93 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 94 | print("Response is " + str(response)) |
| 95 | if re.search("tcp:"+main.params['CTRL']['ip1'],response): |
| 96 | result = result and main.TRUE |
| 97 | else: |
| 98 | result = main.FALSE |
| 99 | elif i>=2 and i<5: |
| 100 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 101 | print("Response is " + str(response)) |
| 102 | if re.search("tcp:"+main.params['CTRL']['ip2'],response): |
| 103 | result = result and main.TRUE |
| 104 | else: |
| 105 | result = main.FALSE |
| 106 | elif i>=5 and i<8: |
| 107 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 108 | print("Response is " + str(response)) |
| 109 | if re.search("tcp:"+main.params['CTRL']['ip3'],response): |
| 110 | result = result and main.TRUE |
| 111 | else: |
| 112 | result = main.FALSE |
| 113 | elif i>=8 and i<18: |
| 114 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 115 | print("Response is " + str(response)) |
| 116 | if re.search("tcp:"+main.params['CTRL']['ip4'],response): |
| 117 | result = result and main.TRUE |
| 118 | else: |
| 119 | result = main.FALSE |
| 120 | elif i>=18 and i<28: |
| 121 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 122 | print("Response is " + str(response)) |
| 123 | if re.search("tcp:"+main.params['CTRL']['ip5'],response): |
| 124 | result = result and main.TRUE |
| 125 | else: |
| 126 | result = main.FALSE |
| 127 | else: |
| 128 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 129 | print("Response is" + str(response)) |
| 130 | if re.search("tcp:" +main.params['CTRL']['ip1'],response): |
| 131 | result = result and main.TRUE |
| 132 | else: |
| 133 | result = main.FALSE |
| 134 | |
| 135 | utilities.assert_equals(expect = main.TRUE,actual=result,onpass="MasterControllers assigned correctly") |
| 136 | for i in range (1,29): |
| 137 | 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']) |
| 138 | |
| 139 | def CASE3(self,main) : |
| 140 | import time |
| 141 | import json |
| 142 | import re |
| 143 | main.case("Adding Intents") |
| 144 | intentIP = main.params['CTRL']['ip1'] |
| 145 | intentPort=main.params['INTENTS']['intentPort'] |
| 146 | intentURL=main.params['INTENTS']['intentURL'] |
| 147 | count = 1 |
| 148 | for i in range(8,18): |
| 149 | srcMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 150 | dstMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 151 | srcDPID = '00:00:00:00:00:00:30:'+str(i).zfill(2) |
| 152 | dstDPID= '00:00:00:00:00:00:60:' +str(i+10) |
| 153 | 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) |
| 154 | count+=1 |
| 155 | dstDPID = '00:00:00:00:00:00:30:'+str(i).zfill(2) |
| 156 | srcDPID= '00:00:00:00:00:00:60:' +str(i+10) |
| 157 | dstMac = '00:00:00:00:00:' + str(hex(i)[2:]).zfill(2) |
| 158 | srcMac = '00:00:00:00:00:'+str(hex(i+10)[2:]) |
| 159 | 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) |
| 160 | count+=1 |
| 161 | count = 1 |
| 162 | i = 8 |
| 163 | result = main.TRUE |
| 164 | while i <18 : |
| 165 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10)) |
| 166 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 167 | if ping ==main.FALSE and count <9: |
| 168 | count+=1 |
| 169 | i = 8 |
| 170 | result = main.FALSE |
| 171 | main.log.info("Ping FAILED! Making attempt number "+str(count) + "in 2 seconds") |
| 172 | time.sleep(2) |
| 173 | elif ping==main.FALSE: |
| 174 | main.log.info("PINGS FAILED! MAX RETRIES REACHED!") |
| 175 | i=19 |
| 176 | result = main.FALSE |
| 177 | elif ping==main.TRUE: |
| 178 | main.log.info("Ping passed!") |
| 179 | i+=1 |
| 180 | result = main.TRUE |
| 181 | else: |
| 182 | main.log.info("ERROR!!") |
| 183 | result = main.ERROR |
| 184 | if result==main.FALSE: |
| 185 | main.log.info("INTENTS HAVE NOT BEEN INSTALLED CORRECTLY!! EXITING!!!") |
| 186 | main.cleanup() |
| 187 | main.exit() |
| 188 | |
| 189 | |
| 190 | def CASE4(self,main) : |
| 191 | import time |
| 192 | from subprocess import Popen, PIPE |
| 193 | main.case("Setting up and Gathering data for current state") |
| 194 | main.step("Get the current In-Memory Topology on each ONOS Instance") |
| 195 | |
| 196 | ''' |
| 197 | ctrls = [] |
| 198 | count = 1 |
| 199 | while True: |
| 200 | temp = () |
| 201 | if ('ip'+str(count)) in main.params['CTRL']: |
| 202 | temp = temp+(getattr(main,('ONOS'+str(count))),) |
| 203 | temp = temp + ("ONOS"+str(count),) |
| 204 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 205 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 206 | ctrls.append(temp) |
| 207 | count+=1 |
| 208 | else: |
| 209 | break |
| 210 | topo_result = main.TRUE |
| 211 | |
| 212 | for n in range(1,count): |
| 213 | 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'])) |
| 214 | ''' |
| 215 | main.step("Get the Mastership of each switch") |
| 216 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['switchURL']],stdout=PIPE).communicate() |
| 217 | global masterSwitchList1 |
| 218 | masterSwitchList1 = stdout |
| 219 | |
| 220 | main.step("Get the High Level Intents") |
| 221 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['intentHighURL']],stdout=PIPE).communicate() |
| 222 | global highIntentList1 |
| 223 | highIntentList1 = stdout |
| 224 | |
| 225 | main.step("Get the Low level Intents") |
| 226 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['intentLowURL']],stdout=PIPE).communicate() |
| 227 | global lowIntentList1 |
| 228 | lowIntentList1= stdout |
| 229 | |
| 230 | main.step("Get the OF Table entries") |
| 231 | global flows |
| 232 | flows=[] |
| 233 | for i in range(1,29): |
| 234 | flows.append(main.Mininet2.get_flowTable("s"+str(i))) |
| 235 | |
| 236 | |
| 237 | main.step("Start continuous pings") |
| 238 | main.Mininet2.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'],pingTime=500) |
| 239 | main.Mininet2.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'],pingTime=500) |
| 240 | main.Mininet2.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'],pingTime=500) |
| 241 | main.Mininet2.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'],pingTime=500) |
| 242 | main.Mininet2.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'],pingTime=500) |
| 243 | main.Mininet2.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'],pingTime=500) |
| 244 | main.Mininet2.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'],pingTime=500) |
| 245 | main.Mininet2.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'],pingTime=500) |
| 246 | main.Mininet2.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'],pingTime=500) |
| 247 | main.Mininet2.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'],pingTime=500) |
| 248 | |
| 249 | |
| 250 | def CASE5(self,main) : |
| 251 | import re |
| 252 | from random import randint |
| 253 | main.case("MAIN COMPONENT FAILURE AND SCENARIO SPECIFIC TESTS") |
| 254 | main.step("ONOS CORE All - Failure!") |
| 255 | main.ONOS1.stop() |
| 256 | main.ONOS2.stop() |
| 257 | main.ONOS3.stop() |
| 258 | main.ONOS4.stop() |
| 259 | main.ONOS5.stop() |
| 260 | time.sleep(2) |
| 261 | main.ONOS1.start() |
| 262 | main.ONOS2.start() |
| 263 | main.ONOS3.start() |
| 264 | main.ONOS4.start() |
| 265 | main.ONOS5.start() |
| 266 | if main.ONOS1.isup() and main.ONOS2.isup() and main.ONOS3.isup() and main.ONOS4.isup() and main.ONOS5.isup(): |
| 267 | main.log.info("ONOS BACK UP!") |
| 268 | result = main.TRUE |
| 269 | else: |
| 270 | main.log.info("ONOS DID NOT COME BACK UP!!!") |
| 271 | result = main.FALSE |
| 272 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS has been brought back up!",onfail = "ONOS HAS FAILED TO RESTART!") |
| 273 | |
| 274 | def CASE6(self,main) : |
| 275 | import os |
| 276 | main.case("Running ONOS Constant State Tests") |
| 277 | main.step("Get the current In-Memory Topology on each ONOS Instance and Compare it to the Topology before component failure") |
| 278 | |
| 279 | main.step("Get the Mastership of each switch and compare to the Mastership before component failure") |
| 280 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['switchURL']],stdout=PIPE).communicate() |
| 281 | result = main.TRUE |
| 282 | for i in range(1,29): |
| 283 | switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i))) |
| 284 | switchDPID = switchDPID[:2]+":"+switchDPID[2:4]+":"+switchDPID[4:6]+":"+switchDPID[6:8]+":"+switchDPID[8:10]+":"+switchDPID[10:12]+":"+switchDPID[12:14]+":"+switchDPID[14:] |
| 285 | master1 = main.ZK1.findMaster(switchDPID=switchDPID,switchList=masterSwitchList1) |
| 286 | master2 = main.ZK1.findMaster(switchDPID=switchDPID,switchList=stdout) |
| 287 | if main.ZK1.findMaster(switchDPID=switchDPID,switchList=masterSwitchList1)==main.ZK1.findMaster(switchDPID=switchDPID,switchList=stdout): |
| 288 | result = result and main.TRUE |
| 289 | else: |
| 290 | result = main.FALSE |
| 291 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Mastership of Switches was not changed",onfail="MASTERSHIP OF SWITCHES HAS CHANGED!!!") |
| 292 | |
| 293 | main.step("Get the High Level Intents and compare to before component failure") |
| 294 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['intentHighURL']],stdout=PIPE).communicate() |
| 295 | changesInIntents=main.ONOS1.comp_intents(preIntents=highIntentList1,postIntents=stdout) |
| 296 | if not changesInIntents: |
| 297 | result = main.TRUE |
| 298 | else: |
| 299 | main.log.info("THERE WERE CHANGES TO THE HIGH LEVEL INTENTS! CHANGES WERE: "+str(changesInIntents)) |
| 300 | result = main.FALSE |
| 301 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No changes to High level Intents",onfail="CHANGES WERE MADE TO HIGH LEVEL INTENTS") |
| 302 | |
| 303 | main.step("Get the Low level Intents and compare to before component failure") |
| 304 | (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['intentLowURL']],stdout=PIPE).communicate() |
| 305 | changesInIntents=main.ONOS1.comp_low(preIntents=lowIntentList1,postIntents=stdout) |
| 306 | if not changesInIntents: |
| 307 | result = main.TRUE |
| 308 | else: |
| 309 | main.log.info("THERE WERE CHANGES TO THE LOW LEVEL INTENTS! CHANGES WERE: "+str(changesInIntents)) |
| 310 | result = main.FALSE |
| 311 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No changes to Low level Intents",onfail="CHANGES WERE MADE TO LOW LEVEL INTENTS") |
| 312 | |
| 313 | |
| 314 | main.step("Get the OF Table entries and compare to before component failure") |
| 315 | result = main.TRUE |
| 316 | flows2=[] |
| 317 | for i in range(27): |
| 318 | flows2.append(main.Mininet2.get_flowTable(sw="s"+str(i+1))) |
| 319 | result = result and main.Mininet2.flow_comp(flow1=flows[i], flow2=main.Mininet2.get_flowTable(sw="s"+str(i+1))) |
| 320 | if result == main.FALSE: |
| 321 | main.log.info("DIFFERENCES IN FLOW TABLES FOR SWITCH "+str(i)) |
| 322 | break |
| 323 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="No changes in the flow tables",onfail="CHANGES IN THE FLOW TABLES!!") |
| 324 | |
| 325 | main.step("Check the continuous pings to ensure that no packets were dropped during component failure") |
| 326 | main.Mininet2.pingKill() |
| 327 | result = main.FALSE |
| 328 | for i in range(8,18): |
| 329 | result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i)) |
| 330 | if result==main.TRUE: |
| 331 | main.log.info("LOSS IN THE PINGS!") |
| 332 | elif result == main.ERROR: |
| 333 | main.log.info("There are multiple mininet process running!!") |
| 334 | else: |
| 335 | main.log.info("No Loss in the pings!") |
| 336 | utilities.assert_equals(expect=main.FALSE,actual=result,onpass="No Loss of connectivity!",onfail="LOSS OF CONNECTIVITY") |
| 337 | |
| 338 | def CASE7 (self,main): |
| 339 | main.case("Killing a link to Ensure that Link Discovery is Working Properly") |
| 340 | main.step("Start continuous pings") |
| 341 | main.Mininet2.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'],pingTime=500) |
| 342 | main.Mininet2.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'],pingTime=500) |
| 343 | main.Mininet2.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'],pingTime=500) |
| 344 | main.Mininet2.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'],pingTime=500) |
| 345 | main.Mininet2.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'],pingTime=500) |
| 346 | main.Mininet2.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'],pingTime=500) |
| 347 | main.Mininet2.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'],pingTime=500) |
| 348 | main.Mininet2.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'],pingTime=500) |
| 349 | main.Mininet2.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'],pingTime=500) |
| 350 | main.Mininet2.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'],pingTime=500) |
| 351 | |
| 352 | main.step("Determine the current number of switches and links") |
| 353 | (number,active)=main.ONOS1.num_switch(RestIP=main.params['CTRL']['ip1']) |
| 354 | links = main.ONOS1.num_link(RestIP=main.params['CTRL']['ip1']) |
| 355 | main.log.info("Currently there are %s switches, %s are active, and %s links" %(number,active,links)) |
| 356 | |
| 357 | main.step("Kill Link between s3 and s28") |
| 358 | main.Mininet1.link(END1="s3",END2="s28",OPTION="down") |
| 359 | time.sleep(5) |
| 360 | result = main.ONOS1.check_status_report(main.params['CTRL']['ip1'],active,str(int(links)-2)) |
| 361 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link Down discovered properly",onfail="LINKS NOT DISCOVERED PROPERLY") |
| 362 | result1 = result |
| 363 | result = main.Mininet1.link(END1="s3",END2="s28",OPTION="up") |
| 364 | |
| 365 | main.step("Check for loss in pings when Link is brought down") |
| 366 | main.Mininet2.pingKill() |
| 367 | result = main.FALSE |
| 368 | for i in range(8,18): |
| 369 | result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i)) |
| 370 | if result==main.TRUE: |
| 371 | main.log.info("LOSS IN THE PINGS!") |
| 372 | elif result == main.ERROR: |
| 373 | main.log.info("There are multiple mininet process running!!") |
| 374 | else: |
| 375 | main.log.info("No Loss in the pings!") |
| 376 | utilities.assert_equals(expect=main.FALSE,actual=result,onpass="No Loss of connectivity!",onfail="LOSS OF CONNECTIVITY") |
| 377 | result2 = result |
| 378 | result = result1 and not result2 |
| 379 | 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!!!") |
| 380 | |
| 381 | def CASE8 (self, main) : |
| 382 | import time |
| 383 | main.case("Killing a switch to ensure switch discovery is working properly") |
| 384 | main.step("Start continuous pings") |
| 385 | main.Mininet2.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'],pingTime=500) |
| 386 | main.Mininet2.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'],pingTime=500) |
| 387 | main.Mininet2.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'],pingTime=500) |
| 388 | main.Mininet2.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'],pingTime=500) |
| 389 | main.Mininet2.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'],pingTime=500) |
| 390 | main.Mininet2.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'],pingTime=500) |
| 391 | main.Mininet2.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'],pingTime=500) |
| 392 | main.Mininet2.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'],pingTime=500) |
| 393 | main.Mininet2.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'],pingTime=500) |
| 394 | main.Mininet2.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'],pingTime=500) |
| 395 | |
| 396 | main.step("Determine the current number of switches and links") |
| 397 | (number,active)=main.ONOS1.num_switch(RestIP=main.params['CTRL']['ip1']) |
| 398 | links = main.ONOS1.num_link(RestIP=main.params['CTRL']['ip1']) |
| 399 | main.log.info("Currently there are %s switches, %s are active, and %s links" %(number,active,links)) |
| 400 | |
| 401 | main.step("Kill s28 ") |
| 402 | main.Mininet2.del_switch("s28") |
| 403 | time.sleep(31) |
| 404 | result = main.ONOS1.check_status_report(main.params['CTRL']['ip1'],str(int(active)-1),str(int(links)-4)) |
| 405 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Switch Discovery is Working",onfail="Switch Discovery FAILED TO WORK PROPERLY!") |
| 406 | |
| 407 | main.step("Add back s28") |
| 408 | main.Mininet2.add_switch("s28") |
| 409 | main.Mininet1.assign_sw_controller(sw="28",ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 410 | 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']) |
| 411 | time.sleep(31) |
| 412 | result = main.ONOS1.check_status_report(main.params['CTRL']['ip1'],active,links) |
| 413 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Switch Discovery is Working",onfail="Switch Discovery FAILED TO WORK PROPERLY!") |
| 414 | result1=result |
| 415 | |
| 416 | main.step("Checking for Traffic Loss") |
| 417 | main.Mininet2.pingKill() |
| 418 | result = main.FALSE |
| 419 | for i in range(8,18): |
| 420 | result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i)) |
| 421 | if result==main.TRUE: |
| 422 | main.log.info("LOSS IN THE PINGS!") |
| 423 | elif result == main.ERROR: |
| 424 | main.log.info("There are multiple mininet process running!!") |
| 425 | else: |
| 426 | main.log.info("No Loss in the pings!") |
| 427 | utilities.assert_equals(expect=main.FALSE,actual=result,onpass="No Loss of connectivity!",onfail="LOSS OF CONNECTIVITY") |
| 428 | result = not result and result1 |
| 429 | 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") |