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