admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 1 | |
| 2 | class RCOnosSanity4nodesJ : |
| 3 | |
| 4 | def __init__(self) : |
| 5 | self.default = '' |
| 6 | |
| 7 | #***************************************************************************************************************************************************************************************** |
| 8 | #Test startup |
| 9 | #Tests the startup of Zookeeper1, RamCloud1, and ONOS1 to be certain that all started up successfully |
| 10 | def CASE1(self,main) : #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version |
| 11 | import time |
| 12 | main.log.report("Pulling latest code from github to all nodes") |
| 13 | main.ONOS1.git_pull() |
| 14 | main.ONOS2.git_pull() |
| 15 | main.ONOS3.git_pull() |
| 16 | main.ONOS4.git_pull() |
| 17 | main.RamCloud1.git_pull() |
| 18 | main.RamCloud2.git_pull() |
| 19 | main.RamCloud3.git_pull() |
| 20 | main.RamCloud4.git_pull() |
| 21 | main.RamCloud1.start_coor() |
| 22 | main.RamCloud1.start_serv() |
| 23 | main.RamCloud2.start_serv() |
| 24 | main.RamCloud3.start_serv() |
| 25 | main.RamCloud4.start_serv() |
| 26 | time.sleep(20) |
| 27 | main.ONOS1.start() |
| 28 | time.sleep(10) |
| 29 | main.ONOS2.start() |
| 30 | main.ONOS3.start() |
| 31 | main.ONOS4.start() |
| 32 | main.ONOS1.start_rest() |
| 33 | time.sleep(5) |
| 34 | test= main.ONOS1.rest_status() |
| 35 | if test == main.FALSE: |
| 36 | main.ONOS1.start_rest() |
| 37 | main.ONOS1.get_version() |
| 38 | main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections") |
| 39 | main.case("Checking if the startup was clean...") |
| 40 | main.step("Testing startup Zookeeper") |
| 41 | data = main.Zookeeper1.isup() |
| 42 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...") |
| 43 | main.step("Testing startup RamCloud") |
| 44 | data = main.RamCloud1.isup() |
| 45 | if data == main.FALSE: |
| 46 | main.RamCloud1.stop_coor() |
| 47 | main.RamCloud1.stop_serv() |
| 48 | main.RamCloud2.stop_serv() |
| 49 | main.RamCloud3.stop_serv() |
| 50 | main.RamCloud4.stop_serv() |
| 51 | |
| 52 | time.sleep(5) |
| 53 | main.RamCloud1.start_coor() |
| 54 | main.RamCloud1.start_serv() |
| 55 | main.RamCloud2.start_serv() |
| 56 | main.RamCloud3.start_serv() |
| 57 | main.RamCloud4.start_serv() |
| 58 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...") |
| 59 | main.step("Testing startup ONOS") |
| 60 | data = main.ONOS1.isup() |
| 61 | if data == main.FALSE: |
| 62 | main.log.report("Something is funny... restarting ONOS") |
| 63 | main.ONOS1.stop() |
| 64 | time.sleep(3) |
| 65 | main.ONOS1.start() |
| 66 | time.sleep(5) |
| 67 | data = main.ONOS1.isup() |
| 68 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...") |
| 69 | |
| 70 | #********************************************************************************************************************************************************************************************** |
| 71 | #Assign Controllers |
| 72 | #This test first checks the ip of a mininet host, to be certain that the mininet exists(Host is defined in Params as <CASE1><destination>). |
| 73 | #Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers. |
| 74 | #NOTE: The reason why all four controllers are assigned although one was already assigned as the master is due to the 'ovs-vsctl set-controller' command erases all present controllers if |
| 75 | # the controllers already assigned to the switch are not specified. |
| 76 | |
| 77 | def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches |
| 78 | import time |
| 79 | main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4") |
| 80 | main.case("Checking if one MN host exists") |
| 81 | main.step("Host IP Checking using checkIP") |
| 82 | result = main.Mininet1.checkIP(main.params['CASE1']['destination']) |
| 83 | main.step("Verifying the result") |
| 84 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured") |
| 85 | main.step("assigning ONOS controllers to switches") |
| 86 | for i in range(25): |
| 87 | if i < 3: |
| 88 | j=i+1 |
| 89 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 90 | time.sleep(1) |
| 91 | main.Mininet1.assign_sw_controller(sw=str(j),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']) |
| 92 | elif i >= 3 and i < 5: |
| 93 | j=i+1 |
| 94 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 95 | time.sleep(1) |
| 96 | main.Mininet1.assign_sw_controller(sw=str(j),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']) |
| 97 | elif i >= 5 and i < 15: |
| 98 | j=i+1 |
| 99 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 100 | time.sleep(1) |
| 101 | main.Mininet1.assign_sw_controller(sw=str(j),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']) |
| 102 | else: |
| 103 | j=i+16 |
| 104 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 105 | time.sleep(1) |
| 106 | main.Mininet1.assign_sw_controller(sw=str(j),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']) |
| 107 | main.Mininet1.get_sw_controller("s1") |
| 108 | |
| 109 | # ********************************************************************************************************************************************************************************************** |
| 110 | #Add Flows |
| 111 | #Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test |
| 112 | #NOTE: THE FLOWDEF FILE MUST BE PRESENT ON TESTON VM!!! TestON will copy the file from its home machine into /tmp/flowtmp on the machine the ONOS instance is present on |
| 113 | |
| 114 | def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update |
| 115 | main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update") |
| 116 | import time |
| 117 | main.case("Taking care of these flows!") |
| 118 | main.step("Cleaning out any leftover flows...") |
| 119 | main.ONOS1.delete_flow("all") |
| 120 | strtTime = time.time() |
| 121 | main.ONOS1.add_flow(main.params['FLOWDEF']) |
| 122 | main.case("Checking flows") |
| 123 | |
| 124 | count = 1 |
| 125 | i = 6 |
| 126 | while i < 16 : |
| 127 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 128 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 129 | if ping == main.FALSE and count < 9: |
| 130 | count = count + 1 |
| 131 | i = 6 |
| 132 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 133 | time.sleep(2) |
| 134 | elif ping == main.FALSE and count ==9: |
| 135 | main.log.error("Ping test failed") |
| 136 | i = 17 |
| 137 | result = main.FALSE |
| 138 | elif ping == main.TRUE: |
| 139 | i = i + 1 |
| 140 | result = main.TRUE |
| 141 | endTime = time.time() |
| 142 | if result == main.TRUE: |
| 143 | main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
| 144 | else: |
| 145 | main.log.report("\tFlows failed check") |
| 146 | |
| 147 | result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 148 | main.step("Verifying the result") |
| 149 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
| 150 | |
| 151 | #********************************************************************************************************************************************************************************************** |
| 152 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 153 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 154 | #The ping test performs single pings on hosts from opposite sides of the topology. If one ping fails, the test waits 5 seconds before trying again. |
| 155 | #If the ping test fails 6 times, then the test case will return false |
| 156 | |
| 157 | def CASE4(self,main) : |
| 158 | main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 159 | import time |
| 160 | for i in range(25): |
| 161 | if i < 15: |
| 162 | j=i+1 |
| 163 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) #Assigning a single controller removes all other controllers |
| 164 | else: |
| 165 | j=i+16 |
| 166 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 167 | |
| 168 | strtTime = time.time() |
| 169 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 170 | for i in range(10): |
| 171 | if result == main.FALSE: |
| 172 | time.sleep(5) |
| 173 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 174 | else: |
| 175 | break |
| 176 | |
| 177 | count = 1 |
| 178 | i = 6 |
| 179 | while i < 16 : |
| 180 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 181 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 182 | if ping == main.FALSE and count < 6: |
| 183 | count = count + 1 |
| 184 | i = 6 |
| 185 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 186 | time.sleep(2) |
| 187 | elif ping == main.FALSE and count ==6: |
| 188 | main.log.error("Ping test failed") |
| 189 | i = 17 |
| 190 | result = main.FALSE |
| 191 | elif ping == main.TRUE: |
| 192 | i = i + 1 |
| 193 | result = main.TRUE |
| 194 | endTime = time.time() |
| 195 | if result == main.TRUE: |
| 196 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 197 | else: |
| 198 | main.log.report("\tPING TEST FAIL") |
| 199 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 200 | time.sleep(10) |
| 201 | |
| 202 | # ********************************************************************************************************************************************************************************************** |
| 203 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 204 | |
| 205 | def CASE5(self,main) : |
| 206 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 207 | import time |
| 208 | for i in range(25): |
| 209 | if i < 15: |
| 210 | j=i+1 |
| 211 | main.Mininet1.assign_sw_controller(sw=str(j),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']) |
| 212 | else: |
| 213 | j=i+16 |
| 214 | main.Mininet1.assign_sw_controller(sw=str(j),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']) |
| 215 | |
| 216 | strtTime = time.time() |
| 217 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 218 | for i in range(2): |
| 219 | if result == main.FALSE: |
| 220 | time.sleep(5) |
| 221 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 222 | else: |
| 223 | break |
| 224 | |
| 225 | count = 1 |
| 226 | i = 6 |
| 227 | while i < 16 : |
| 228 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 229 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 230 | if ping == main.FALSE and count < 6: |
| 231 | count = count + 1 |
| 232 | i = 6 |
| 233 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 234 | time.sleep(2) |
| 235 | elif ping == main.FALSE and count ==6: |
| 236 | main.log.error("Ping test failed") |
| 237 | i = 17 |
| 238 | result = main.FALSE |
| 239 | elif ping == main.TRUE: |
| 240 | i = i + 1 |
| 241 | result = main.TRUE |
| 242 | endTime = time.time() |
| 243 | if result == main.TRUE: |
| 244 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 245 | else: |
| 246 | main.log.report("\tPING TEST FAILED") |
| 247 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 248 | |
| 249 | # ********************************************************************************************************************************************************************************************** |
| 250 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 251 | |
| 252 | def CASE6(self,main) : |
| 253 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 254 | import time |
| 255 | main.case("Bringing Link down... ") |
| 256 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 257 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 258 | |
| 259 | strtTime = time.time() |
| 260 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 261 | for i in range(2): |
| 262 | if result == main.FALSE: |
| 263 | time.sleep(5) |
| 264 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 265 | else: |
| 266 | break |
| 267 | |
| 268 | count = 1 |
| 269 | i = 6 |
| 270 | while i < 16 : |
| 271 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 272 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 273 | if ping == main.FALSE and count < 10: |
| 274 | count = count + 1 |
| 275 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 276 | i = 6 |
| 277 | time.sleep(2) |
| 278 | elif ping == main.FALSE and count == 10: |
| 279 | main.log.error("Ping test failed") |
| 280 | i = 17 |
| 281 | result = main.FALSE |
| 282 | elif ping == main.TRUE: |
| 283 | i = i + 1 |
| 284 | result = main.TRUE |
| 285 | endTime = time.time() |
| 286 | if result == main.TRUE: |
| 287 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 288 | else: |
| 289 | main.log.report("\tPING TEST FAILED") |
| 290 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 291 | |
| 292 | # ********************************************************************************************************************************************************************************************** |
| 293 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 294 | |
| 295 | def CASE7(self,main) : |
| 296 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 297 | import time |
| 298 | main.case("Bringing Link up... ") |
| 299 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 300 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 301 | |
| 302 | strtTime = time.time() |
| 303 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 304 | for i in range(2): |
| 305 | if result == main.FALSE: |
| 306 | time.sleep(5) |
| 307 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 308 | else: |
| 309 | break |
| 310 | |
| 311 | strtTime = time.time() |
| 312 | count = 1 |
| 313 | i = 6 |
| 314 | while i < 16 : |
| 315 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 316 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 317 | if ping == main.FALSE and count < 10: |
| 318 | count = count + 1 |
| 319 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 320 | i = 6 |
| 321 | time.sleep(2) |
| 322 | elif ping == main.FALSE and count ==10: |
| 323 | main.log.error("Ping test failed") |
| 324 | i = 17 |
| 325 | result = main.FALSE |
| 326 | elif ping == main.TRUE: |
| 327 | i = i + 1 |
| 328 | result = main.TRUE |
| 329 | endTime = time.time() |
| 330 | if result == main.TRUE: |
| 331 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 332 | else: |
| 333 | main.log.report("\tPING TESTS FAILED") |
| 334 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 335 | |
| 336 | |
| 337 | # ****************************************************************************************************************************************************************** |
| 338 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 339 | |
| 340 | def CASE21(self,main) : |
| 341 | import json |
| 342 | from drivers.common.api.onosrestapidriver import * |
| 343 | main.log.report("Test device discovery function, by attach, detach, move host h1 from s1->s6->s1. Per mininet naming, switch port the host attaches will remain as 's1-eth1' throughout the test.") |
| 344 | main.log.report("Check initially hostMAC/IP exist on the mininet...") |
| 345 | host = main.params['YANK']['hostname'] |
| 346 | mac = main.params['YANK']['hostmac'] |
| 347 | hostip = main.params['YANK']['hostip'] |
| 348 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 349 | RestPort = main.params['RESTCALL']['restPort'] |
| 350 | url = main.params['RESTCALL']['restURL'] |
| 351 | |
| 352 | t_topowait = 0 |
| 353 | t_restwait = 10 |
| 354 | main.log.report( "Wait time from topo change to ping set to " + str(t_topowait)) |
| 355 | main.log.report( "Wait time from ping to rest call set to " + str(t_restwait)) |
| 356 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 357 | time.sleep(t_topowait) |
| 358 | 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" ) |
| 359 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 360 | time.sleep(t_restwait) |
| 361 | restcall = OnosRestApiDriver() |
| 362 | Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip) |
| 363 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 364 | if Reststatus == 1: |
| 365 | main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 366 | result1 = main.TRUE |
| 367 | elif Reststatus > 1: |
| 368 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 369 | main.log.report("switches are: " + "; ".join(Switch)) |
| 370 | main.log.report("Ports are: " + "; ".join(Port)) |
| 371 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 372 | result1 = main.FALSE |
| 373 | else: |
| 374 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED") |
| 375 | result1 = main.FALSE |
| 376 | |
| 377 | |
| 378 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 379 | |
| 380 | main.log.report("Yank out s1-eth1") |
| 381 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 382 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 383 | time.sleep(t_topowait) |
| 384 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
| 385 | |
| 386 | 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" ) |
| 387 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 388 | time.sleep(t_restwait) |
| 389 | restcall = OnosRestApiDriver() |
| 390 | Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip) |
| 391 | |
| 392 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 393 | if Reststatus == 1: |
| 394 | main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 395 | result2 = main.FALSE |
| 396 | elif Reststatus > 1: |
| 397 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 398 | main.log.report("switches are: " + "; ".join(Switch)) |
| 399 | main.log.report("Ports are: " + "; ".join(Port)) |
| 400 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 401 | result2 = main.FALSE |
| 402 | else: |
| 403 | 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.") |
| 404 | result2 = main.TRUE |
| 405 | |
| 406 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 407 | main.log.report("Plug s1-eth1 into s6") |
| 408 | main.case("Plug s1-eth1 to s6") |
| 409 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
| 410 | time.sleep(t_topowait) |
| 411 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...") |
| 412 | 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" ) |
| 413 | |
| 414 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 415 | time.sleep(t_restwait) |
| 416 | restcall = OnosRestApiDriver() |
| 417 | Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip) |
| 418 | |
| 419 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 420 | if Reststatus == 1: |
| 421 | main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 422 | result3 = main.TRUE |
| 423 | elif Reststatus > 1: |
| 424 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 425 | main.log.report("switches are: " + "; ".join(Switch)) |
| 426 | main.log.report("Ports are: " + "; ".join(Port)) |
| 427 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 428 | result3 = main.FALSE |
| 429 | else: |
| 430 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 431 | result3 = main.FALSE |
| 432 | |
| 433 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 434 | main.log.report("Move s1-eth1 back on to s1") |
| 435 | main.case("Move s1-eth1 back to s1") |
| 436 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 437 | time.sleep(t_topowait) |
| 438 | retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 439 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
| 440 | 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" ) |
| 441 | |
| 442 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 443 | time.sleep(t_restwait) |
| 444 | restcall = OnosRestApiDriver() |
| 445 | Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip) |
| 446 | |
| 447 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 448 | if Reststatus == 1: |
| 449 | main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 450 | result4 = main.TRUE |
| 451 | elif Reststatus > 1: |
| 452 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED") |
| 453 | main.log.report("switches are: " + "; ".join(Switch)) |
| 454 | main.log.report("Ports are: " + "; ".join(Port)) |
| 455 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 456 | result4 = main.FALSE |
| 457 | else: |
| 458 | main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 459 | result4 = main.FALSE |
| 460 | |
| 461 | result = result1 and result2 and result3 and result4 |
| 462 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 463 | |
| 464 | # Run a pure ping test. |
| 465 | |
| 466 | def CASE31(self, main): |
| 467 | main.log.report("Performing Ping Test") |
| 468 | count = 1 |
| 469 | i = 6 |
| 470 | while i < 16 : |
| 471 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 472 | strtTime = time.time() |
| 473 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 474 | if ping == main.FALSE and count < 6: |
| 475 | count = count + 1 |
| 476 | i = 6 |
| 477 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 478 | time.sleep(2) |
| 479 | elif ping == main.FALSE and count ==6: |
| 480 | main.log.error("Ping test failed") |
| 481 | i = 17 |
| 482 | result = main.FALSE |
| 483 | elif ping == main.TRUE: |
| 484 | i = i + 1 |
| 485 | result = main.TRUE |
| 486 | endTime = time.time() |
| 487 | if result == main.TRUE: |
| 488 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 489 | else: |
| 490 | main.log.report("\tPING TEST FAIL") |
| 491 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 492 | |