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