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