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