SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 1 | |
| 2 | class RCOnosCHO4nodes : |
| 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 |
SeanCorcoran | f4ee258 | 2014-04-16 17:12:30 -0700 | [diff] [blame] | 12 | main.Zookeeper1.start() |
| 13 | time.sleep(5) |
| 14 | main.Zookeeper2.start() |
| 15 | main.Zookeeper3.start() |
| 16 | main.Zookeeper4.start() |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame^] | 17 | main.log.report("Pulling latest code from github to all nodes") |
| 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() |
| 36 | main.ONOS1.print_version() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 37 | main.RamCloud1.start_coor() |
SeanCorcoran | f4ee258 | 2014-04-16 17:12:30 -0700 | [diff] [blame] | 38 | time.sleep(10) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 39 | main.RamCloud1.start_serv() |
| 40 | main.RamCloud2.start_serv() |
| 41 | main.RamCloud3.start_serv() |
| 42 | main.RamCloud4.start_serv() |
| 43 | time.sleep(20) |
| 44 | main.ONOS1.start() |
| 45 | time.sleep(30) |
| 46 | main.ONOS2.start() |
| 47 | main.ONOS3.start() |
| 48 | main.ONOS4.start() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 49 | main.log.report("Startup check Zookeeper1, RamCloud1, and ONOS1 connections") |
| 50 | main.case("Checking if the startup was clean...") |
| 51 | main.step("Testing startup Zookeeper") |
| 52 | data = main.Zookeeper1.isup() |
| 53 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...") |
| 54 | main.step("Testing startup RamCloud") |
SeanCorcoran | f4ee258 | 2014-04-16 17:12:30 -0700 | [diff] [blame] | 55 | data = main.RamCloud1.status() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 56 | if data == main.FALSE: |
| 57 | main.RamCloud1.stop_coor() |
| 58 | main.RamCloud1.stop_serv() |
| 59 | main.RamCloud2.stop_serv() |
| 60 | main.RamCloud3.stop_serv() |
| 61 | main.RamCloud4.stop_serv() |
| 62 | |
| 63 | time.sleep(5) |
| 64 | |
| 65 | main.RamCloud1.start_coor() |
| 66 | main.RamCloud1.start_serv() |
| 67 | main.RamCloud2.start_serv() |
| 68 | main.RamCloud3.start_serv() |
| 69 | main.RamCloud4.start_serv() |
| 70 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="RamCloud is up!",onfail="RamCloud is down...") |
| 71 | main.step("Testing startup ONOS") |
| 72 | data = main.ONOS1.isup() |
| 73 | data = data and main.ONOS2.isup() |
| 74 | data = data and main.ONOS3.isup() |
| 75 | data = data and main.ONOS4.isup() |
| 76 | if data == main.FALSE: |
| 77 | main.log.report("Something is funny... restarting ONOS") |
| 78 | main.ONOS1.stop() |
| 79 | main.ONOS2.stop() |
| 80 | main.ONOS3.stop() |
| 81 | main.ONOS4.stop() |
| 82 | time.sleep(5) |
| 83 | main.ONOS1.start() |
| 84 | time.sleep(30) |
| 85 | main.ONOS2.start() |
| 86 | main.ONOS3.start() |
| 87 | main.ONOS4.start() |
| 88 | data = main.ONOS1.isup() |
SeanCorcoran | f4ee258 | 2014-04-16 17:12:30 -0700 | [diff] [blame] | 89 | main.ONOS1.start_rest() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 90 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...") |
| 91 | |
| 92 | #********************************************************************************************************************************************************************************************** |
| 93 | #Assign Controllers |
| 94 | #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>). |
| 95 | #Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers. |
| 96 | #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 |
| 97 | # the controllers already assigned to the switch are not specified. |
| 98 | |
| 99 | def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches |
| 100 | import time |
| 101 | main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4") |
| 102 | main.case("Checking if one MN host exists") |
| 103 | main.step("Host IP Checking using checkIP") |
| 104 | result = main.Mininet1.checkIP(main.params['CASE1']['destination']) |
| 105 | main.step("Verifying the result") |
| 106 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured") |
| 107 | main.step("assigning ONOS controllers to switches") |
| 108 | for i in range(25): |
| 109 | if i < 3: |
| 110 | j=i+1 |
| 111 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 112 | time.sleep(1) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame^] | 113 | 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']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 114 | elif i >= 3 and i < 5: |
| 115 | j=i+1 |
| 116 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 117 | time.sleep(1) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame^] | 118 | 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']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 119 | elif i >= 5 and i < 15: |
| 120 | j=i+1 |
| 121 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 122 | time.sleep(1) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame^] | 123 | 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']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 124 | else: |
| 125 | j=i+16 |
| 126 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 127 | time.sleep(1) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame^] | 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']) |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 129 | main.Mininet1.get_sw_controller("s1") |
| 130 | |
| 131 | for i in range(9): |
| 132 | if result == main.FALSE: |
| 133 | time.sleep(3) |
| 134 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 135 | else: |
| 136 | break |
| 137 | |
| 138 | # ********************************************************************************************************************************************************************************************** |
| 139 | #Add Flows |
| 140 | #Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test |
| 141 | #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 |
| 142 | |
| 143 | def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update |
| 144 | main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update") |
| 145 | import time |
| 146 | |
| 147 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 148 | for counter in range(9): |
| 149 | if result == main.FALSE: |
| 150 | time.sleep(3) |
| 151 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 152 | else: |
| 153 | break |
| 154 | |
| 155 | main.case("Taking care of these flows!") |
| 156 | main.step("Cleaning out any leftover flows...") |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame^] | 157 | #main.ONOS1.delete_flow("all") |
| 158 | main.ONOS1.rm_flow() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 159 | time.sleep(5) |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame^] | 160 | main.ONOS1.purge() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 161 | strtTime = time.time() |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame^] | 162 | #main.ONOS1.add_flow(main.params['FLOWDEF']) |
| 163 | main.ONOS1.ad_flow() |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 164 | main.case("Checking flows") |
| 165 | |
| 166 | pingAttempts = main.params['pingAttempts'] |
| 167 | pingSleep = main.params['pingSleep'] |
| 168 | |
| 169 | count = 1 |
| 170 | i = 6 |
| 171 | while i < 16 : |
| 172 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 173 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 174 | if ping == main.FALSE and count < int(pingAttempts): |
| 175 | count = count + 1 |
| 176 | i = 6 |
| 177 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 178 | time.sleep(int(pingSleep)) |
| 179 | elif ping == main.FALSE and count == int(pingAttempts): |
| 180 | main.log.error("Ping test failed") |
| 181 | i = 17 |
| 182 | result = main.FALSE |
| 183 | elif ping == main.TRUE: |
| 184 | i = i + 1 |
| 185 | result = main.TRUE |
| 186 | endTime = time.time() |
| 187 | if result == main.TRUE: |
| 188 | main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
| 189 | else: |
| 190 | main.log.report("\tFlows failed check") |
| 191 | |
| 192 | main.step("Verifying the result") |
| 193 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
| 194 | |
| 195 | #********************************************************************************************************************************************************************************************** |
| 196 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 197 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 198 | #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. |
| 199 | #If the ping test fails 6 times, then the test case will return false |
| 200 | |
| 201 | def CASE4(self,main) : |
| 202 | main.log.report("Remove all but one ONOS then ping until all hosts are reachable or fail after 6 attempts") |
| 203 | import time |
| 204 | import random |
| 205 | |
| 206 | random.seed(None) |
| 207 | |
| 208 | num = random.randint(1,4) |
| 209 | if num == 1: |
| 210 | ip = main.params['CTRL']['ip1'] |
| 211 | port = main.params['CTRL']['port1'] |
| 212 | elif num == 2: |
| 213 | ip = main.params['CTRL']['ip2'] |
| 214 | port = main.params['CTRL']['port2'] |
| 215 | elif num == 3: |
| 216 | ip = main.params['CTRL']['ip3'] |
| 217 | port = main.params['CTRL']['port3'] |
| 218 | else: |
| 219 | ip = main.params['CTRL']['ip4'] |
| 220 | port = main.params['CTRL']['port4'] |
| 221 | |
| 222 | main.log.report("ONOS"+str(num)+" will be the sole controller") |
| 223 | for i in range(25): |
| 224 | if i < 15: |
| 225 | j=i+1 |
| 226 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) #Assigning a single controller removes all other controllers |
| 227 | else: |
| 228 | j=i+16 |
| 229 | main.Mininet1.assign_sw_controller(sw=str(j),ip1=ip,port1=port) |
| 230 | |
| 231 | strtTime = time.time() |
| 232 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 233 | for counter in range(9): |
| 234 | if result == main.FALSE: |
| 235 | time.sleep(3) |
| 236 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 237 | else: |
| 238 | break |
| 239 | |
| 240 | pingAttempts = main.params['pingAttempts'] |
| 241 | pingSleep = main.params['pingSleep'] |
| 242 | |
| 243 | count = 1 |
| 244 | i = 6 |
| 245 | while i < 16 : |
| 246 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 247 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 248 | if ping == main.FALSE and count < int(pingAttempts): |
| 249 | count = count + 1 |
| 250 | i = 6 |
| 251 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 252 | time.sleep(int(pingSleep)) |
| 253 | elif ping == main.FALSE and count == int(pingAttempts): |
| 254 | main.log.error("Ping test failed") |
| 255 | i = 17 |
| 256 | result = main.FALSE |
| 257 | elif ping == main.TRUE: |
| 258 | i = i + 1 |
| 259 | result = main.TRUE |
| 260 | endTime = time.time() |
| 261 | if result == main.TRUE: |
| 262 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 263 | else: |
| 264 | main.log.report("\tPING TEST FAIL") |
| 265 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 266 | |
| 267 | # ********************************************************************************************************************************************************************************************** |
| 268 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 269 | |
| 270 | def CASE5(self,main) : |
| 271 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 272 | import time |
| 273 | for i in range(25): |
| 274 | if i < 15: |
| 275 | j=i+1 |
| 276 | main.Mininet1.assign_sw_controller(sw=str(j),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']) |
| 277 | else: |
| 278 | j=i+16 |
| 279 | main.Mininet1.assign_sw_controller(sw=str(j),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']) |
| 280 | |
| 281 | strtTime = time.time() |
| 282 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 283 | for counter in range(9): |
| 284 | if result == main.FALSE: |
| 285 | time.sleep(3) |
| 286 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 287 | else: |
| 288 | break |
| 289 | |
| 290 | pingAttempts = main.params['pingAttempts'] |
| 291 | pingSleep = main.params['pingSleep'] |
| 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 < int(pingAttempts): |
| 299 | count = count + 1 |
| 300 | i = 6 |
| 301 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
| 302 | time.sleep(int(pingSleep)) |
| 303 | elif ping == main.FALSE and count == int(pingAttempts): |
| 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 counter in range(9): |
| 330 | if result == main.FALSE: |
| 331 | time.sleep(3) |
| 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 | pingAttempts = main.params['pingAttempts'] |
| 337 | pingSleep = main.params['pingSleep'] |
| 338 | |
| 339 | count = 1 |
| 340 | i = 6 |
| 341 | while i < 16 : |
| 342 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 343 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 344 | if ping == main.FALSE and count < int(pingAttempts): |
| 345 | count = count + 1 |
| 346 | main.log.report("Ping failed, making attempt number "+str(count)+" in "+str(pingSleep)+" seconds") |
Jon Hall | 0e09e6a | 2014-04-25 13:42:15 -0700 | [diff] [blame^] | 347 | #i = 6 |
SeanCorcoran | c3ed743 | 2014-04-09 16:32:27 -0700 | [diff] [blame] | 348 | time.sleep(int(pingSleep)) |
| 349 | elif ping == main.FALSE and count == int(pingAttempts): |
| 350 | main.log.error("Ping test failed") |
| 351 | i = 17 |
| 352 | result = main.FALSE |
| 353 | elif ping == main.TRUE: |
| 354 | i = i + 1 |
| 355 | result = main.TRUE |
| 356 | endTime = time.time() |
| 357 | if result == main.TRUE: |
| 358 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 359 | else: |
| 360 | main.log.report("\tPING TEST FAILED") |
| 361 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 362 | |
| 363 | # ********************************************************************************************************************************************************************************************** |
| 364 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 365 | |
| 366 | def CASE7(self,main) : |
| 367 | main.log.report("Bring Link between s1 and s2 up, then ping until all hosts are reachable or fail after 10 attempts") |
| 368 | import time |
| 369 | main.case("Bringing Link up... ") |
| 370 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="up") |
| 371 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link UP!",onfail="Link not brought up...") |
| 372 | |
| 373 | strtTime = time.time() |
| 374 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 375 | for counter in range(9): |
| 376 | if result == main.FALSE: |
| 377 | time.sleep(3) |
| 378 | result = main.ONOS1.check_status_report(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links']) |
| 379 | else: |
| 380 | break |
| 381 | |
| 382 | pingAttempts = main.params['pingAttempts'] |
| 383 | pingSleep = main.params['pingSleep'] |
| 384 | |
| 385 | strtTime = time.time() |
| 386 | count = 1 |
| 387 | i = 6 |
| 388 | while i < 16 : |
| 389 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 390 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 391 | if ping == main.FALSE and count < int(pingAttempts): |
| 392 | count = count + 1 |
| 393 | main.log.report("Ping failed, making attempt number "+str(count)+" in " +str(pingSleep)+" seconds") |
| 394 | i = 6 |
| 395 | time.sleep(int(pingSleep)) |
| 396 | elif ping == main.FALSE and count == int(pingAttempts): |
| 397 | main.log.error("Ping test failed") |
| 398 | i = 17 |
| 399 | result = main.FALSE |
| 400 | elif ping == main.TRUE: |
| 401 | i = i + 1 |
| 402 | result = main.TRUE |
| 403 | endTime = time.time() |
| 404 | if result == main.TRUE: |
| 405 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 406 | else: |
| 407 | main.log.report("\tPING TESTS FAILED") |
| 408 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 409 | |
| 410 | |
| 411 | # ****************************************************************************************************************************************************************** |
| 412 | # Test Device Discovery function by yanking s6:s6-eth0 interface and re-plug it into a switch |
| 413 | |
| 414 | def CASE21(self,main) : |
| 415 | import json |
| 416 | from drivers.common.api.onosrestapidriver import * |
| 417 | main.log.report("Test device discovery function, by attach/detach/move host h1 from s1->s6->s1.") |
| 418 | main.log.report("Check initially hostMAC exist on the mininet...") |
| 419 | host = main.params['YANK']['hostname'] |
| 420 | mac = main.params['YANK']['hostmac'] |
| 421 | RestIP1 = main.params['RESTCALL']['restIP1'] |
| 422 | RestIP2 = main.params['RESTCALL']['restIP2'] |
| 423 | RestPort = main.params['RESTCALL']['restPort'] |
| 424 | url = main.params['RESTCALL']['restURL'] |
| 425 | #print "host=" + host + "; RestIP=" + RestIP1 + "; RestPort=" + str(RestPort) |
| 426 | |
| 427 | 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" ) |
| 428 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 429 | restcall = OnosRestApiDriver() |
| 430 | Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac) |
| 431 | try: |
| 432 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
| 433 | ip_found = Hoststatus[0]['ipv4'][0] |
| 434 | except: |
| 435 | Reststatus = 0 |
| 436 | |
| 437 | if Reststatus == 1: |
| 438 | main.log.report("\tFound host " + host + " attached to switchDPID = " + attachedSW) |
| 439 | if ip_found != None: |
| 440 | main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).") |
| 441 | result = main.TRUE |
| 442 | else: |
| 443 | main.log.report("\t Found host attached to switch, but no IP address discovered.") |
| 444 | result = main.FALSE |
| 445 | else: |
| 446 | main.log.report("\t Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED") |
| 447 | result = main.FALSE |
| 448 | |
| 449 | ##### Step to yank out "s1-eth1" from s1, which is on autoONOS1 ##### |
| 450 | |
| 451 | main.log.report("Yank out s1-eth1") |
| 452 | main.case("Yankout s6-eth1 (link to h1) from s1") |
| 453 | result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf']) |
| 454 | time.sleep(3) |
| 455 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...") |
| 456 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 457 | Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac) |
| 458 | try: |
| 459 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
| 460 | except: |
| 461 | Reststatus = 0 |
| 462 | if Reststatus == 0: |
| 463 | main.log.report("Attempt to yank out s1-eth1 from s1 sucessfully") |
| 464 | result = main.TRUE |
| 465 | else: |
| 466 | main.log.report("Attempt to yank out s1-eht1 from s1 failed.") |
| 467 | result = main.FALSE |
| 468 | |
| 469 | ##### Step to plug "s1-eth1" to s6, which is on autoONOS3 ###### |
| 470 | main.log.report("Plug s1-eth1 into s6") |
| 471 | main.case("Plug s1-eth1 to s6") |
| 472 | result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf']) |
| 473 | time.sleep(3) |
| 474 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...") |
| 475 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 476 | Reststatus, Hoststatus = restcall.find_host(RestIP2,RestPort,url,mac) |
| 477 | try: |
| 478 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
| 479 | ip_found = Hoststatus[0]['ipv4'][0] |
| 480 | except: |
| 481 | Reststatus = 0 |
| 482 | if Reststatus == 0: |
| 483 | main.log.report("Attempt to plug s1-eth1 to s6 FAILED") |
| 484 | result = main.FALSE |
| 485 | elif attachedSW == "00:00:00:00:00:00:00:06": |
| 486 | main.log.report("Attempt to plug s1-eht1 to s6 succeded.") |
| 487 | if ip_found != None: |
| 488 | main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).") |
| 489 | result = main.TRUE |
| 490 | else: |
| 491 | main.log.report("\t Found host attached to switch, but no IP address discovered.") |
| 492 | result = main.FALSE |
| 493 | else: |
| 494 | main.log.report( "FAILED to attach s1-eth1 to s6 correctly!") |
| 495 | result = main.FALSE |
| 496 | |
| 497 | ###### Step to put interface "s1-eth1" back to s1"##### |
| 498 | main.log.report("Move s1-eth1 back on to s1") |
| 499 | main.case("Move s1-eth1 back to s1") |
| 500 | result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf']) |
| 501 | time.sleep(3) |
| 502 | retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf']) |
| 503 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...") |
| 504 | ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254") |
| 505 | Reststatus, Hoststatus = restcall.find_host(RestIP1,RestPort,url,mac) |
| 506 | try: |
| 507 | attachedSW = Hoststatus[0]['attachmentPoint'][0]['switchDPID'] |
| 508 | ip_found = Hoststatus[0]['ipv4'][0] |
| 509 | except: |
| 510 | Reststatus = 0 |
| 511 | if Reststatus == 0: |
| 512 | main.log.report("Attempt to plug s1-eth1 back to s1 FAILED") |
| 513 | result = main.FALSE |
| 514 | elif attachedSW == "00:00:00:00:00:00:00:01": |
| 515 | main.log.report("Attempt to plug s1-eht1 back to s1 succeded.") |
| 516 | if ip_found != None: |
| 517 | main.log.report("\t IP discovered is ip_found ( " + ip_found + " ).") |
| 518 | result = main.TRUE |
| 519 | else: |
| 520 | main.log.report("\t Found host attached to switch, but no IP address discovered.") |
| 521 | result = main.FALSE |
| 522 | else: |
| 523 | main.log.report( "FAIL to attach s1-eth1 to s1 correctly!") |
| 524 | result = main.FALSE |
| 525 | |
| 526 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED") |
| 527 | |
| 528 | |
| 529 | |
| 530 | |