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