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