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...") |
| 144 | main.ONOS1.delete_flow("all") |
| 145 | strtTime = time.time() |
| 146 | main.ONOS1.add_flow(main.params['FLOWDEF']) |
| 147 | main.case("Checking flows") |
| 148 | |
| 149 | count = 1 |
| 150 | i = 6 |
| 151 | while i < 16 : |
| 152 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 153 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 154 | if ping == main.FALSE and count < 9: |
| 155 | count = count + 1 |
| 156 | i = 6 |
| 157 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 158 | time.sleep(2) |
| 159 | elif ping == main.FALSE and count ==9: |
| 160 | main.log.error("Ping test failed") |
| 161 | i = 17 |
| 162 | result = main.FALSE |
| 163 | elif ping == main.TRUE: |
| 164 | i = i + 1 |
| 165 | result = main.TRUE |
| 166 | endTime = time.time() |
| 167 | if result == main.TRUE: |
| 168 | main.log.report("\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
| 169 | else: |
| 170 | main.log.report("\tFlows failed check") |
| 171 | |
| 172 | result2 = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 173 | main.step("Verifying the result") |
| 174 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
| 175 | |
| 176 | #********************************************************************************************************************************************************************************************** |
| 177 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 178 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 179 | #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. |
| 180 | #If the ping test fails 6 times, then the test case will return false |
| 181 | def CASE41(self,main) : |
| 182 | main.log.report("Testing Removal") |
| 183 | main.ONOS2.stop() |
| 184 | main.ONOS3.stop() |
| 185 | main.ONOS4.stop() |
| 186 | strtTime = time.time() |
| 187 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 188 | for i in range(10): |
| 189 | if result == main.FALSE: |
| 190 | time.sleep(5) |
| 191 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 192 | else: |
| 193 | break |
| 194 | |
| 195 | count = 1 |
| 196 | i = 6 |
| 197 | while i < 16 : |
| 198 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 199 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 200 | if ping == main.FALSE and count < 6: |
| 201 | count = count + 1 |
| 202 | i = 6 |
| 203 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 204 | time.sleep(2) |
| 205 | elif ping == main.FALSE and count ==6: |
| 206 | main.log.error("Ping test failed") |
| 207 | i = 17 |
| 208 | result = main.FALSE |
| 209 | elif ping == main.TRUE: |
| 210 | i = i + 1 |
| 211 | result = main.TRUE |
| 212 | endTime = time.time() |
| 213 | if result == main.TRUE: |
| 214 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 215 | else: |
| 216 | main.log.report("\tPING TEST FAIL") |
| 217 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 218 | time.sleep(10) |
| 219 | main.ONOS2.start() |
| 220 | main.ONOS3.start() |
| 221 | main.ONOS4.start() |
| 222 | time.sleep(10) |
| 223 | |
| 224 | |
| 225 | def CASE4(self,main) : |
| 226 | main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 227 | import time |
| 228 | for i in range(25): |
| 229 | if i < 15: |
| 230 | j=i+1 |
| 231 | 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 |
| 232 | else: |
| 233 | j=i+16 |
| 234 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 235 | |
| 236 | strtTime = time.time() |
| 237 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 238 | for i in range(10): |
| 239 | if result == main.FALSE: |
| 240 | time.sleep(5) |
| 241 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 242 | else: |
| 243 | break |
| 244 | |
| 245 | count = 1 |
| 246 | i = 6 |
| 247 | while i < 16 : |
| 248 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 249 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 250 | if ping == main.FALSE and count < 6: |
| 251 | count = count + 1 |
| 252 | i = 6 |
| 253 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 254 | time.sleep(2) |
| 255 | elif ping == main.FALSE and count ==6: |
| 256 | main.log.error("Ping test failed") |
| 257 | i = 17 |
| 258 | result = main.FALSE |
| 259 | elif ping == main.TRUE: |
| 260 | i = i + 1 |
| 261 | result = main.TRUE |
| 262 | endTime = time.time() |
| 263 | if result == main.TRUE: |
| 264 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 265 | else: |
| 266 | main.log.report("\tPING TEST FAIL") |
| 267 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 268 | time.sleep(10) |
| 269 | |
| 270 | # ********************************************************************************************************************************************************************************************** |
| 271 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 272 | |
| 273 | def CASE5(self,main) : |
| 274 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 275 | import time |
| 276 | for i in range(25): |
| 277 | if i < 15: |
| 278 | j=i+1 |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 279 | 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] | 280 | else: |
| 281 | j=i+16 |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 282 | 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] | 283 | |
| 284 | strtTime = time.time() |
| 285 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 286 | for i in range(2): |
| 287 | if result == main.FALSE: |
| 288 | time.sleep(5) |
| 289 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 290 | else: |
| 291 | break |
| 292 | |
| 293 | count = 1 |
| 294 | i = 6 |
| 295 | while i < 16 : |
| 296 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 297 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 298 | if ping == main.FALSE and count < 6: |
| 299 | count = count + 1 |
| 300 | i = 6 |
| 301 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 302 | time.sleep(2) |
| 303 | elif ping == main.FALSE and count ==6: |
| 304 | main.log.error("Ping test failed") |
| 305 | i = 17 |
| 306 | result = main.FALSE |
| 307 | elif ping == main.TRUE: |
| 308 | i = i + 1 |
| 309 | result = main.TRUE |
| 310 | endTime = time.time() |
| 311 | if result == main.TRUE: |
| 312 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 313 | else: |
| 314 | main.log.report("\tPING TEST FAILED") |
| 315 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 316 | |
| 317 | # ********************************************************************************************************************************************************************************************** |
| 318 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 319 | |
| 320 | def CASE6(self,main) : |
| 321 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 10 attempts") |
| 322 | import time |
| 323 | main.case("Bringing Link down... ") |
| 324 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 325 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 326 | |
| 327 | strtTime = time.time() |
| 328 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 329 | for i in range(2): |
| 330 | if result == main.FALSE: |
| 331 | time.sleep(5) |
| 332 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],str(int(main.params['NR_Links'])-2)) |
| 333 | else: |
| 334 | break |
| 335 | |
| 336 | count = 1 |
| 337 | i = 6 |
| 338 | while i < 16 : |
| 339 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 340 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 341 | if ping == main.FALSE and count < 10: |
| 342 | count = count + 1 |
| 343 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 344 | i = 6 |
| 345 | time.sleep(2) |
| 346 | elif ping == main.FALSE and count == 10: |
| 347 | main.log.error("Ping test failed") |
| 348 | i = 17 |
| 349 | result = main.FALSE |
| 350 | elif ping == main.TRUE: |
| 351 | i = i + 1 |
| 352 | result = main.TRUE |
| 353 | endTime = time.time() |
| 354 | if result == main.TRUE: |
| 355 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 356 | else: |
| 357 | main.log.report("\tPING TEST FAILED") |
| 358 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 359 | |
| 360 | # ********************************************************************************************************************************************************************************************** |
| 361 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 362 | |
| 363 | def CASE7(self,main) : |
| 364 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 365 | import time |
| 366 | main.case("Bringing Link up... ") |
| 367 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 368 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 369 | |
| 370 | strtTime = time.time() |
| 371 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 372 | for i in range(2): |
| 373 | if result == main.FALSE: |
| 374 | time.sleep(5) |
| 375 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 376 | else: |
| 377 | break |
| 378 | |
| 379 | strtTime = time.time() |
| 380 | count = 1 |
| 381 | i = 6 |
| 382 | while i < 16 : |
| 383 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 384 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 385 | if ping == main.FALSE and count < 10: |
| 386 | count = count + 1 |
| 387 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 388 | i = 6 |
| 389 | time.sleep(2) |
| 390 | elif ping == main.FALSE and count ==10: |
| 391 | main.log.error("Ping test failed") |
| 392 | i = 17 |
| 393 | result = main.FALSE |
| 394 | elif ping == main.TRUE: |
| 395 | i = i + 1 |
| 396 | result = main.TRUE |
| 397 | endTime = time.time() |
| 398 | if result == main.TRUE: |
| 399 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 400 | else: |
| 401 | main.log.report("\tPING TESTS FAILED") |
| 402 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 403 | |
| 404 | |
| 405 | # ****************************************************************************************************************************************************************** |
| 406 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 407 | |
| 408 | def CASE21(self,main) : |
| 409 | import json |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 410 | 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.") |
| 411 | main.log.report("Check initially hostMAC/IP exist on the mininet...") |
| 412 | host = main.params['YANK']['hostname'] |
| 413 | mac = main.params['YANK']['hostmac'] |
| 414 | hostip = main.params['YANK']['hostip'] |
| 415 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 416 | RestPort = main.params['RESTCALL']['restPort'] |
| 417 | url = main.params['RESTCALL']['restURL'] |
| 418 | |
| 419 | t_topowait = 0 |
| 420 | t_restwait = 10 |
| 421 | main.log.report( "Wait time from topo change to ping set to " + str(t_topowait)) |
| 422 | main.log.report( "Wait time from ping to rest call set to " + str(t_restwait)) |
| 423 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 424 | time.sleep(t_topowait) |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 425 | 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] | 426 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 427 | time.sleep(t_restwait) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 428 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 429 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 430 | if Reststatus == 1: |
| 431 | main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 432 | result1 = main.TRUE |
| 433 | elif Reststatus > 1: |
| 434 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 435 | main.log.report("switches are: " + "; ".join(Switch)) |
| 436 | main.log.report("Ports are: " + "; ".join(Port)) |
| 437 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 438 | result1 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 439 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 440 | main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED") |
| 441 | result1 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 442 | else:# check if rest server is working |
| 443 | main.log.error("Issue with find host") |
| 444 | result1 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 445 | |
| 446 | |
| 447 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 448 | |
| 449 | main.log.report("Yank out s1-eth1") |
| 450 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 451 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 452 | time.sleep(t_topowait) |
| 453 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
| 454 | |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 455 | 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] | 456 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 457 | time.sleep(t_restwait) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 458 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 459 | |
| 460 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 461 | if Reststatus == 1: |
| 462 | main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 463 | result2 = main.FALSE |
| 464 | elif Reststatus > 1: |
| 465 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 466 | main.log.report("switches are: " + "; ".join(Switch)) |
| 467 | main.log.report("Ports are: " + "; ".join(Port)) |
| 468 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 469 | result2 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 470 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 471 | 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.") |
| 472 | result2 = main.TRUE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 473 | else:# check if rest server is working |
| 474 | main.log.error("Issue with find host") |
| 475 | result2 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 476 | |
| 477 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 478 | main.log.report("Plug s1-eth1 into s6") |
| 479 | main.case("Plug s1-eth1 to s6") |
| 480 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
| 481 | time.sleep(t_topowait) |
| 482 | 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] | 483 | 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] | 484 | |
| 485 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 486 | time.sleep(t_restwait) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 487 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 488 | |
| 489 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 490 | if Reststatus == 1: |
| 491 | main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 492 | result3 = main.TRUE |
| 493 | elif Reststatus > 1: |
| 494 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED") |
| 495 | main.log.report("switches are: " + "; ".join(Switch)) |
| 496 | main.log.report("Ports are: " + "; ".join(Port)) |
| 497 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 498 | result3 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 499 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 500 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 501 | result3 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 502 | else:# check if rest server is working |
| 503 | main.log.error("Issue with find host") |
| 504 | result3 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 505 | |
| 506 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 507 | main.log.report("Move s1-eth1 back on to s1") |
| 508 | main.case("Move s1-eth1 back to s1") |
| 509 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 510 | time.sleep(t_topowait) |
| 511 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 512 | 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] | 513 | 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] | 514 | |
| 515 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 516 | time.sleep(t_restwait) |
Jon Hall | 3f6ce3c | 2014-04-11 18:17:10 -0700 | [diff] [blame] | 517 | Reststatus, Switch, Port, MAC = main.ONOS1.find_host(RestIP1,RestPort,url, hostip) |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 518 | |
| 519 | main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus)) |
| 520 | if Reststatus == 1: |
| 521 | main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port)) |
| 522 | result4 = main.TRUE |
| 523 | elif Reststatus > 1: |
| 524 | main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED") |
| 525 | main.log.report("switches are: " + "; ".join(Switch)) |
| 526 | main.log.report("Ports are: " + "; ".join(Port)) |
| 527 | main.log.report("MACs are: " + "; ".join(MAC)) |
| 528 | result4 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 529 | elif Reststatus == 0 and Switch == []: |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 530 | main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 531 | result4 = main.FALSE |
Jon Hall | 208b3a2 | 2014-04-16 11:30:24 -0700 | [diff] [blame] | 532 | else:# check if rest server is working |
| 533 | main.log.error("Issue with find host") |
| 534 | result4 = main.FALSE |
admin | 733ae0a | 2014-04-09 15:01:12 -0700 | [diff] [blame] | 535 | |
| 536 | result = result1 and result2 and result3 and result4 |
| 537 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 538 | |
| 539 | # Run a pure ping test. |
| 540 | |
| 541 | def CASE31(self, main): |
| 542 | main.log.report("Performing Ping Test") |
| 543 | count = 1 |
| 544 | i = 6 |
| 545 | while i < 16 : |
| 546 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 547 | strtTime = time.time() |
| 548 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 549 | if ping == main.FALSE and count < 6: |
| 550 | count = count + 1 |
| 551 | i = 6 |
| 552 | main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds") |
| 553 | time.sleep(2) |
| 554 | elif ping == main.FALSE and count ==6: |
| 555 | main.log.error("Ping test failed") |
| 556 | i = 17 |
| 557 | result = main.FALSE |
| 558 | elif ping == main.TRUE: |
| 559 | i = i + 1 |
| 560 | result = main.TRUE |
| 561 | endTime = time.time() |
| 562 | if result == main.TRUE: |
| 563 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 564 | else: |
| 565 | main.log.report("\tPING TEST FAIL") |
| 566 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 567 | |