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