admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 1 | |
| 2 | |
| 3 | class JamesTest : |
| 4 | |
| 5 | def __init__(self) : |
| 6 | self.default = '' |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | #*************************************************************************************************************** |
| 12 | |
| 13 | |
| 14 | def CASE1(self,main) : |
| 15 | main.case("\nStart-Up of Zookeeper, RAMCloud, ONOS, and Mininet") |
| 16 | import time |
| 17 | main.step("\n**********************Git pulls and Rebuilds******************") |
| 18 | for i in range(2): |
| 19 | main.log.report("ONOS1 Git Pull") |
| 20 | uptodate = main.ONOS1.git_pull() |
| 21 | ver1 = main.ONOS1.get_version() |
| 22 | main.log.report("ONOS2 Git Pull") |
| 23 | main.ONOS2.git_pull() |
| 24 | main.log.report("ONOS3 Git Pull") |
| 25 | main.ONOS3.git_pull() |
| 26 | main.log.report("ONOS4 Git Pull") |
| 27 | main.ONOS4.git_pull() |
| 28 | ver2 = main.ONOS4.get_version() |
| 29 | if ver1==ver2: |
| 30 | break |
| 31 | elif i==1: |
| 32 | main.log.report("Versions differ. Doing Git pulls from ONOS1") |
| 33 | main.ONOS2.git_pull("ONOS1 master") |
| 34 | main.ONOS3.git_pull("ONOS1 master") |
| 35 | main.ONOS4.git_pull("ONOS1 master") |
| 36 | if uptodate==0: |
admin | 8fc0282 | 2014-04-16 13:31:23 -0700 | [diff] [blame] | 37 | for i in range(2): |
| 38 | main.log.report("Building ONOS1") |
| 39 | build1 = main.ONOS1.git_compile() |
| 40 | if build1: |
| 41 | break |
| 42 | elif i==1: |
| 43 | main.cleanup() |
| 44 | main.exit() |
| 45 | for i in range(2): |
| 46 | main.log.report("Building ONOS2") |
| 47 | build2 = main.ONOS2.git_compile() |
| 48 | if build2: |
| 49 | break |
| 50 | elif i==1: |
| 51 | main.cleanup() |
| 52 | main.exit() |
| 53 | for i in range(2): |
| 54 | main.log.report("Building ONOS3") |
| 55 | build3 = main.ONOS3.git_compile() |
| 56 | if build3: |
| 57 | break |
| 58 | elif i==1: |
| 59 | main.cleanup() |
| 60 | main.exit() |
| 61 | for i in range(2): |
| 62 | main.log.report("Building ONOS4") |
| 63 | build4 = main.ONOS4.git_compile() |
| 64 | if build4: |
| 65 | break |
| 66 | elif i==1: |
| 67 | main.cleanup() |
| 68 | main.exit() |
admin | 844bcb5 | 2014-04-15 11:13:14 -0700 | [diff] [blame] | 69 | |
| 70 | |
| 71 | main.step("\n********************Testing Zookeeper Startup**************") |
| 72 | data1 = main.Zookeeper1.isup() |
| 73 | utilities.assert_equals(expect=main.TRUE,actual=data1,onpass="Zookeeper is up!",onfail="Zookeeper is down...") |
| 74 | if data1==main.FALSE: |
| 75 | main.log.report("Zookeeper is Down, Exiting the Test!") |
| 76 | main.cleanup() |
| 77 | main.exit() |
| 78 | |
| 79 | main.step("\n********************Starting Up RAMCloud*********************") |
| 80 | main.RamCloud1.start_coor() |
| 81 | time.sleep(2) |
| 82 | main.RamCloud1.start_serv() |
| 83 | main.RamCloud2.start_serv() |
| 84 | main.RamCloud3.start_serv() |
| 85 | main.RamCloud4.start_serv() |
| 86 | time.sleep(5) |
| 87 | |
| 88 | main.step("\n********************Testing RAMCloud Startup**************") |
| 89 | data2 = main.RamCloud1.status_serv() |
| 90 | print(data2) |
| 91 | for i in range(3): |
| 92 | if data2 == main.FALSE: |
| 93 | main.RamCloud1.stop_serv() |
| 94 | main.RamCloud2.stop_serv() |
| 95 | main.RamCloud3.stop_serv() |
| 96 | main.RamCloud4.stop_serv() |
| 97 | main.RamCloud1.stop_coor() |
| 98 | main.RamCloud1.start_coor() |
| 99 | time.sleep(2) |
| 100 | main.RamCloud1.start_serv() |
| 101 | main.RamCloud2.start_serv() |
| 102 | main.RamCloud3.start_serv() |
| 103 | main.RamCloud4.start_serv() |
| 104 | time.sleep(5) |
| 105 | data2 = main.RamCloud1.status_serv() |
| 106 | else: |
| 107 | break |
| 108 | utilities.assert_equals(expect=main.TRUE,actual=data2,onpass="RAMCloud is up!",onfail="RAMCloud is down...") |
| 109 | if data2==main.FALSE: |
| 110 | main.log.report("RAMCloud is Down, Exiting the Test!") |
| 111 | main.cleanup() |
| 112 | main.exit() |
| 113 | |
| 114 | main.step("\n************************Starting Up ONOS and Rest*****************") |
| 115 | main.ONOS1.start() |
| 116 | time.sleep(10) |
| 117 | main.ONOS2.start() |
| 118 | main.ONOS3.start() |
| 119 | main.ONOS4.start() |
| 120 | main.ONOS1.start_rest() |
| 121 | time.sleep(5) |
| 122 | test = main.ONOS1.rest_status() |
| 123 | for i in range(3): |
| 124 | if test == main.FALSE: |
| 125 | main.ONOS1.start_rest() |
| 126 | time.sleep(5) |
| 127 | test = main.ONOS1.rest_status() |
| 128 | else: |
| 129 | break |
| 130 | |
| 131 | main.step("\n************************Testing ONOS Startup***************") |
| 132 | data3 = main.ONOS1.isup() |
| 133 | for i in range(3): |
| 134 | if data3 == main.FALSE: |
| 135 | main.log.report("ONOS did not start, restarting ONOS") |
| 136 | main.ONOS1.stop() |
| 137 | main.ONOS2.stop() |
| 138 | main.ONOS3.stop() |
| 139 | main.ONOS4.stop() |
| 140 | time.sleep(2) |
| 141 | main.ONOS1.start() |
| 142 | time.sleep(10) |
| 143 | main.ONOS2.start() |
| 144 | main.ONOS3.start() |
| 145 | main.ONOS4.start() |
| 146 | data3 = main.ONOS1.isup() |
| 147 | else: |
| 148 | break |
| 149 | utilities.assert_equals(expect=main.TRUE,actual=data3,onpass="ONOS is up!",onfail="ONOS is down...") |
| 150 | if data3==main.FALSE: |
| 151 | main.log.report("ONOS did not START!! Exiting the Test") |
| 152 | main.cleanup() |
| 153 | main.exit() |
| 154 | |
| 155 | main.step("\n****************************Testing Mininet Startup***************") |
| 156 | data4 = main.Mininet1.checkIP(main.params['CASE1']['destination']) |
| 157 | utilities.assert_equals(expect=main.TRUE,actual=data4,onpass="Host IP address configured",onfail="Host IP address not configured") |
| 158 | |
| 159 | finalAssert = data1 and data2 and data3 |
| 160 | utilities.assert_equals(expect=main.TRUE,actual=finalAssert,onpass="Good to Go!",onfail="NO GO FOR LAUNCH") |
| 161 | |
| 162 | #***************************************************************************************** |
| 163 | |
| 164 | def CASE2(self,main) : |
| 165 | import time |
| 166 | main.case("\nAssign ONOS Controllers to Switches and run Initial Ping Test") |
| 167 | main.step("\n**********************Assign initial master controller to switches**********************") |
| 168 | for i in range(25): |
| 169 | if i < 3: |
| 170 | main.Mininet1.assign_sw_controller(sw=str(i+1),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 171 | time.sleep(1) |
| 172 | elif i>=3 and i <5: |
| 173 | main.Mininet1.assign_sw_controller(sw=str(i+1),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 174 | time.sleep(1) |
| 175 | elif i>=5 and i<15: |
| 176 | main.Mininet1.assign_sw_controller(sw=str(i+1),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 177 | time.sleep(1) |
| 178 | else: |
| 179 | main.Mininet1.assign_sw_controller(sw=str(i+16),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 180 | time.sleep(1) |
| 181 | |
| 182 | main.step("\n**********************Assign all ONOS instances to all Switches*************************") |
| 183 | for i in range(25): |
| 184 | if i < 15: |
| 185 | main.Mininet1.assign_sw_controller(sw=str(i+1),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']) |
| 186 | time.sleep(1) |
| 187 | else: |
| 188 | main.Mininet1.assign_sw_controller(sw=str(i+16),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']) |
| 189 | |
| 190 | |
| 191 | def CASE3(self,main): |
| 192 | main.case("\nPerforming Initial Ping Test") |
| 193 | main.step("\n**********************Initial Ping Test***************") |
| 194 | count = 1 |
| 195 | i = 6 |
| 196 | while i < 16: |
| 197 | main.log.info("\n\t\t\th" + str(i) + " IS PINGING h" + str(i+25) ) |
| 198 | strtTime = time.time() |
| 199 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 200 | if ping == main.FALSE and count<6: |
| 201 | count+=1 |
| 202 | i = 6 |
| 203 | main.log.info("Ping failed, making attempt number " + str(count)+" in 2 seconds") |
| 204 | time.sleep(2) |
| 205 | elif ping == main.FALSE and count==6: |
| 206 | main.log.error("Ping test failed") |
| 207 | i = 17 |
| 208 | result = main.FALSE |
| 209 | elif ping == main.TRUE: |
| 210 | i += 1 |
| 211 | result = main.TRUE |
| 212 | endTime = time.time() |
| 213 | if result == main.TRUE: |
| 214 | main.log.report("\tTime to complete ping test: " + str(round(endTime-strtTime,2))+ " seconds") |
| 215 | else: |
| 216 | main.log.report("\tPING TEST FAILED!") |
| 217 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOSS!!!! HOST IS NOT REACHABLE!!!!!!") |
| 218 | |
| 219 | |
| 220 | |
| 221 | def CASE4(self,main): |
| 222 | main.case("\nWhat happens when 3 of the ONOS instances die?") |
| 223 | main.step("\n********************Removing 3 ONOS instances****************************") |
| 224 | main.ONOS2.stop() |
| 225 | main.ONOS3.stop() |
| 226 | main.ONOS4.stop() |
| 227 | main.step("\n*******************Checking for the correct topology*********************") |
| 228 | data1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 229 | print("%s" % data1) |
| 230 | for i in range(10): |
| 231 | if data1 == main.FALSE: |
| 232 | time.sleep(5) |
| 233 | data1 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 234 | else: |
| 235 | break |
| 236 | main.step("\n********************Running PING Test****************************") |
| 237 | count = 1 |
| 238 | i = 6 |
| 239 | while i < 16: |
| 240 | main.log.info("\n\t\t\tH" + str(i) + " is PINGING H" + str(i+25)) |
| 241 | strtTime = time.time() |
| 242 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 243 | if ping == main.FALSE and count<6: |
| 244 | count+=1 |
| 245 | i = 6 |
| 246 | main.log.info("Ping failed, making attempt number " + str(count)+" in 2 seconds") |
| 247 | time.sleep(2) |
| 248 | elif ping == main.FALSE and count==6: |
| 249 | main.log.error("Ping test failed") |
| 250 | i = 17 |
| 251 | result2 = main.FALSE |
| 252 | elif ping == main.TRUE: |
| 253 | i += 1 |
| 254 | result2 = main.TRUE |
| 255 | endTime = time.time() |
| 256 | if result2 == main.TRUE: |
| 257 | main.log.report("\tTime to complete ping test: " + str(round(endTime-strtTime,2))+ " seconds") |
| 258 | else: |
| 259 | main.log.report("\tPING TEST FAILED!") |
| 260 | finalResult = data1 and result2 |
| 261 | utilities.assert_equals(expect=main.TRUE,actual=finalResult,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOSS!!!! HOST IS NOT REACHABLE!!!!!!") |
| 262 | time.sleep(5) |
| 263 | |
| 264 | |
| 265 | def CASE5(self,main): |
| 266 | main.case("\nRestart the 3 ONOS instances and run a PING test") |
| 267 | main.step("\n************************Bringing Back up ONOS Instances*****************************") |
| 268 | main.ONOS2.start() |
| 269 | main.ONOS3.start() |
| 270 | main.ONOS4.start() |
| 271 | time.sleep(4) |
| 272 | main.step("\n********************Running PING Test****************************") |
| 273 | count = 1 |
| 274 | i = 6 |
| 275 | while i < 16: |
| 276 | main.log.info("\n\t\t\tH" + str(i) + " is PINGING H" + str(i+25)) |
| 277 | strtTime = time.time() |
| 278 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 279 | if ping == main.FALSE and count<6: |
| 280 | count+=1 |
| 281 | i = 6 |
| 282 | main.log.info("Ping failed, making attempt number " + str(count)+" in 2 seconds") |
| 283 | time.sleep(2) |
| 284 | elif ping == main.FALSE and count==6: |
| 285 | main.log.error("Ping test failed") |
| 286 | i = 17 |
| 287 | result2 = main.FALSE |
| 288 | elif ping == main.TRUE: |
| 289 | i += 1 |
| 290 | result2 = main.TRUE |
| 291 | endTime = time.time() |
| 292 | if result2 == main.TRUE: |
| 293 | main.log.report("\tTime to complete ping test: " + str(round(endTime-strtTime,2))+ " seconds") |
| 294 | else: |
| 295 | main.log.report("\tPING TEST FAILED!") |
| 296 | finalResult = result2 |
| 297 | utilities.assert_equals(expect=main.TRUE,actual=finalResult,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOSS!!!! HOST IS NOT REACHABLE!!!!!!") |
| 298 | time.sleep(5) |
| 299 | |
| 300 | |
| 301 | def CASE6(self,main): |
| 302 | main.case("Bring links between S1 and S2 down, then ping untill all hosts are reachable or fail after 10 attempts") |
| 303 | import time |
| 304 | main.step("\n*****************Bringing Link DOWN!!!************************") |
| 305 | data1 = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 306 | utilities.assert_equals(expect=main.TRUE,actual=data1,onpass="Link Brought DOWN!",onfail="Link still up...") |
| 307 | main.step("\n******************Waiting for Topology Convergence****************") |
| 308 | strtTime = time.time() |
| 309 | data2 = main.FALSE |
| 310 | data2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 311 | print("hello world") |
| 312 | for i in range(2): |
| 313 | if data2 == main.FALSE: |
| 314 | time.sleep(5) |
| 315 | data2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 316 | else: |
| 317 | break |
| 318 | utilities.assert_equals(expect=main.TRUE,actual=data2,onpass="Topology Converged",onfail="Topology FAILED to Converge") |
| 319 | main.case("\n*******************Ping Test***********************") |
| 320 | count = 1 |
| 321 | i = 6 |
| 322 | while i < 16: |
| 323 | main.log.info("\n\t\t\tH" + str(i) + " is PINGING H" + str(i+25)) |
| 324 | strtTime = time.time() |
| 325 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 326 | if ping == main.FALSE and count<6: |
| 327 | count+=1 |
| 328 | i = 6 |
| 329 | main.log.info("Ping failed, making attempt number " + str(count)+" in 2 seconds") |
| 330 | time.sleep(2) |
| 331 | elif ping == main.FALSE and count==6: |
| 332 | main.log.error("Ping test failed") |
| 333 | i = 17 |
| 334 | data3 = main.FALSE |
| 335 | elif ping == main.TRUE: |
| 336 | i += 1 |
| 337 | data3 = main.TRUE |
| 338 | endTime = time.time() |
| 339 | if data3 == main.TRUE: |
| 340 | main.log.report("\tTime to complete ping test: " + str(round(endTime-strtTime,2))+ " seconds") |
| 341 | else: |
| 342 | main.log.report("\tPING TEST FAILED!") |
| 343 | utilities.assert_equals(expect=main.TRUE,actual=data3,onpass="Ping test PASSED!",onfail="Ping Test FAILED!!!!") |
| 344 | finalResult = data1 and data2 and data3 |
| 345 | utilities.assert_equals(expect=main.TRUE,actual=finalResult,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOSS!!!! HOST IS NOT REACHABLE!!!!!!") |
| 346 | time.sleep(5) |
| 347 | |
| 348 | def CASE31(self,main) : |
| 349 | import time |
| 350 | main.case("\nClear out flows, then add flows from FLOWDEF file") |
| 351 | main.step("\n\n***************Cleaning out OLD flows!*************") |
| 352 | main.ONOS1.delete_flow("all") |
| 353 | main.step("\n\n***************Adding Flows from FLOWDEF File**********") |
| 354 | strtTime = time.time() |
| 355 | main.ONOS1.add_flow(main.params['FLOWDEF']) |
| 356 | main.step("\n\n**************Checking Flows***********************") |
| 357 | count = 1 |
| 358 | i = 6 |
| 359 | while i <16: |
| 360 | main.log.info("\n\t\t\t\th" + str(i) + " IS PINGING h" + str(i+25)) |
| 361 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 362 | if ping == main.FALSE and count < 9: |
| 363 | count +=1 |
| 364 | i = 6 |
| 365 | main.log.info("Ping failed, making attempt number " + str(count) + " in 2 seconds") |
| 366 | time.sleep(2) |
| 367 | elif ping == main.FALSE and count == 9: |
| 368 | main.log.error("Ping test failed") |
| 369 | i = 17 |
| 370 | result = main.FALSE |
| 371 | elif ping == main.TRUE: |
| 372 | i = i+1 |
| 373 | result = main.TRUE |
| 374 | endTime = time.time() |
| 375 | if result == main.TRUE: |
| 376 | main.log.report("\tTime to add flows: " + str(round(endTime-strtTime,2))+" seconds") |
| 377 | else: |
| 378 | main.log.report("\tFlows failed check") |
| 379 | result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 380 | finalResult = result and result2 |
| 381 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flows added and Checked!",onfail="Flows did not add properly") |
| 382 | |
| 383 | |
| 384 | |
| 385 | def CASE21(self,main) : |
| 386 | import json |
| 387 | main.case("Test device discovery function by attaching, metaching, moving host1 from s1 -> s6 -> s1. Per mininet naming, when switching ports, the host attaches will still remain as 's1-eth1' throughout the entire test") |
| 388 | main.step("\n\n******Checking that the initial host MAC/IP exists on the mininet******") |
| 389 | host = main.params['YANK']['hostname'] |
| 390 | mac = main.params['YANK']['hostmac'] |
| 391 | hostip = main.params['YANK']['hostip'] |
| 392 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 393 | RestPort = main.params['RESTCALL']['restPort'] |
| 394 | url = main.params['RESTCALL']['restURL'] |
| 395 | t_topowait = 0 |
| 396 | t_restwait = 10 |
| 397 | main.log.report("Wait time from topo change to ping set to " + str(t_topowait)) |
| 398 | main.log.report("Wait time from ping to rest call set to " + str(t_restwait)) |
| 399 | time.sleep(t_topowait) |
| 400 | main.log.info("\n\t\t\t\t Ping: Issue 1 ping from " + str(host) + " to generate arp to switch. Ping result is not important") |
| 401 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 402 | time.sleep(t_restwait) |
| 403 | Reststatus, Swtich, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url,hostip) |
| 404 | main.log.report("Number of hosts with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 405 | if Reststatus ==1: |
| 406 | main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC)+"; attached to switchDPPID = " + "".join(Switch)+ "; at port = " + "".join(Port)) |
| 407 | result1 = main.TRUE |
| 408 | elif Reststatus >1: |
| 409 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 410 | main.log.report("switches are: " + "; ".join(Switch)) |
| 411 | main.log.report("Ports are: " + "; ".join(Port)) |
| 412 | main.log.report("MACS are: " + "; ".join(MAC)) |
| 413 | result1 = main.FALSE |
| 414 | else: |
| 415 | main.log.report("\]t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED") |
| 416 | result1 = main.FALSE |
| 417 | |
| 418 | #*****************Step to yank out s1-eth1 from s1 |
| 419 | |
| 420 | main.step("Yank out s1-eth1") |
| 421 | main.log.report("Yankout s6-eth1 (link to h1) from s1") |
| 422 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 423 | time.sleep(t_topowait) |
| 424 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
| 425 | |
| 426 | main.step("\n\n Ping: Issue 1 ping from " + str(host) + " to generate arp to switch. Ping result is not important") |
| 427 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 428 | time.sleep(t_restwait) |
| 429 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url,hostip) |
| 430 | main.log.report("Number of hosts with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 431 | if Reststatus ==1: |
| 432 | main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "".join(Port)) |
| 433 | result2 = main.FALSE |
| 434 | elif Reststatus >1: |
| 435 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 436 | main.log.report("Switches are: " + "; ".join(Switch)) |
| 437 | main.log.report("Ports are: " + "; ".join(Port)) |
| 438 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 439 | result2 = main.FALSE |
| 440 | else: |
| 441 | main.log.report("\t PASSED - Host" + host + " with MAC:" + str(mac) + " does not exist. PASSED - host is not supposed to be attached to the switch.") |
| 442 | result2 = main.TRUE |
| 443 | utilities.assert_equals(expect=main.TRUE,actual=result2,onpass="s1-eth1 yanked!",onfail="s1-eth1 failed to be yanked!") |
| 444 | |
| 445 | # Step to plug "s1-eth1" to s6 |
| 446 | main.step("Plug s1-eth1 into s6") |
| 447 | result3 = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
| 448 | time.sleep(t_topowait) |
| 449 | utilities.assert_equals(expect=main.TRUE,actual=result3,onpass="Plug command suceeded",onfail="Plug command failed ... ") |
| 450 | main.step("\n\nPing issue one ping from " + str(host) + "to generate arp to switch. Ping result is not important") |
| 451 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 452 | time.sleep(t_restwait) |
| 453 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url,hostip) |
| 454 | |
| 455 | main.log.report("Number of hosts with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 456 | if Reststatus ==1: |
| 457 | main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 458 | result4 = main.TRUE |
| 459 | elif Reststatus >1: |
| 460 | main.log.report("\t FAILED - Host " + host + " with MAC: " + str(mac) + " has " + str(Reststatus) + "duplicated IP addresses. FAILED") |
| 461 | main.log.report("switches are: " + "; ".join(Switch)) |
| 462 | main.log.report("Ports are: " + "; ".join(Port)) |
| 463 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 464 | result4 = main.FALSE |
| 465 | else: |
| 466 | main.log.report("\t FAILED - Host " + host + " with MAC: " + str(mac) + " does not exist. FAILED") |
| 467 | result4 = main.FALSE |
| 468 | |
| 469 | # Step to put "s1-eth1" back to s1 |
| 470 | main.step("Move s1-eth1 back to s1") |
| 471 | result5 = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 472 | time.sleep(t_topowait) |
| 473 | result6 = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 474 | utilities.assert_equals(expect=main.TRUE,actual=(result5 and result6),onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
| 475 | main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" ) |
| 476 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 477 | time.sleep(t_restwait) |
| 478 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
| 479 | |
| 480 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 481 | if Reststatus == 1: |
| 482 | main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 483 | result7 = main.TRUE |
| 484 | elif Reststatus > 1: |
| 485 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED") |
| 486 | main.log.report("switches are: " + "; ".join(Switch)) |
| 487 | main.log.report("Ports are: " + "; ".join(Port)) |
| 488 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 489 | result7 = main.FALSE |
| 490 | else: |
| 491 | main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 492 | result7 = main.FALSE |
| 493 | |
| 494 | result = result1 and result2 and result3 and result4 and result5 and result6 and result7 |
| 495 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 496 | |
| 497 | def CASE7(self, main) : |
| 498 | import time |
| 499 | main.case("Bring Link between s1 and s2 up, then ping untill all hosts are reachable or fail after 10 attemtps!") |
| 500 | main.step("Bringing Link up... " ) |
| 501 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 502 | utilities.assert_equlas(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 503 | main.step("\n\n\t\tPing Test!") |
| 504 | strtTime = time.time() |
| 505 | result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 506 | for i in range(2): |
| 507 | if result2 == main.FALSE: |
| 508 | time.sleep(5) |
| 509 | result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 510 | else: |
| 511 | break |
| 512 | strtTime = time.time() |
| 513 | count = 1 |
| 514 | i = 6 |
| 515 | while i <16 : |
| 516 | main.log.info("\n\t\t\t\th" + str(i) + " IS PINGING h" + str(i+25)) |
| 517 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 518 | if ping ==main.FALSE and count<10: |
| 519 | count +=1 |
| 520 | main.log.info("Ping failed, making attempt number " + str(count) + " in 2 seconds") |
| 521 | i = 6 |
| 522 | time.sleep(2) |
| 523 | elif ping ==main.FALSE and count==10: |
| 524 | main.log.error("Ping test failed") |
| 525 | i = 17 |
| 526 | result3 = main.FALSE |
| 527 | elif ping ==main.TRUE: |
| 528 | i += 1 |
| 529 | result3 = main.TRUE |
| 530 | endTime = time.time() |
| 531 | if result3 ==main.TRUE: |
| 532 | main.log.report("\t Time to complete ping test: " + str(round(endTime-strtTime,2)) + " seconds") |
| 533 | else: |
| 534 | main.log.report("\tPing Tests FAILED!!") |
| 535 | finalResult = result and result2 and result3 and result4 |
| 536 | utilities.assert_equals(expect=main.TRUE,actual=finalResult,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 537 | |
| 538 | |
| 539 | |