admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | |
| 2 | class OnosCHO8nodes : |
| 3 | |
| 4 | def __init__(self) : |
| 5 | self.default = '' |
| 6 | |
| 7 | #********************************************************************************************************************************************************************************************** |
| 8 | #Test startup |
| 9 | #Tests the startup of Zookeeper1, Cassandra1, 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 | main.log.report("Startup check Zookeeper1, Cassandra1, and ONOS1 connections") |
| 12 | import time |
| 13 | main.case("Checking if the startup was clean...") |
| 14 | main.step("Testing startup Zookeeper") |
| 15 | data = main.Zookeeper1.isup() |
| 16 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...") |
| 17 | main.step("Testing startup Cassandra") |
| 18 | data = main.Cassandra1.isup() |
| 19 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...") |
| 20 | main.step("Testing startup ONOS") |
| 21 | data = main.ONOS1.isup() |
| 22 | if data == main.FALSE: |
| 23 | main.log.report("Something is funny... restarting ONOS") |
| 24 | main.ONOS1.stop() |
| 25 | time.sleep(3) |
| 26 | main.ONOS1.start() |
| 27 | time.sleep(5) |
| 28 | data = main.ONOS1.isup() |
| 29 | main.log.report("\n\n\t\t\t\t ONOS VERSION") |
| 30 | main.ONOS1.get_version() |
| 31 | main.log.info("\n\n") |
| 32 | utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...") |
| 33 | |
| 34 | #********************************************************************************************************************************************************************************************** |
| 35 | #Assign Controllers |
| 36 | #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>). |
| 37 | #Then the program assignes each ONOS instance a single controller to a switch(To be the initial master), then assigns all controllers. |
| 38 | #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 |
| 39 | # the controllers already assigned to the switch are not specified. |
| 40 | |
| 41 | def CASE2(self,main) : #Make sure mininet exists, then assign controllers to switches |
| 42 | import time |
| 43 | main.log.report("Check if mininet started properly, then assign controllers ONOS 1,2,3 and 4") |
| 44 | main.case("Checking if one MN host exists") |
| 45 | main.step("Host IP Checking using checkIP") |
| 46 | result = main.Mininet1.checkIP(main.params['CASE1']['destination']) |
| 47 | main.step("Verifying the result") |
| 48 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured") |
| 49 | main.step("assigning ONOS controllers to switches") |
| 50 | for i in range(25): |
| 51 | if i < 3: |
| 52 | j=i+1 |
| 53 | main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 54 | time.sleep(3) |
| 55 | main.Mininet1.assign_sw_controller(sw="s"+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'],ip5=main.params['CTRL']['ip5'],port5=main.params['CTRL']['port5'],ip6=main.params['CTRL']['ip6'],port6=main.params['CTRL']['port6'],ip7=main.params['CTRL']['ip7'],port7=main.params['CTRL']['port7'],ip8=main.params['CTRL']['ip8'],port8=main.params['CTRL']['port8']) |
| 56 | time.sleep(3) |
| 57 | elif i >= 3 and i < 5: |
| 58 | j=i+1 |
| 59 | main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip2'],port1=main.params['CTRL']['port2']) |
| 60 | time.sleep(3) |
| 61 | main.Mininet1.assign_sw_controller(sw="s"+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'],ip5=main.params['CTRL']['ip5'],port5=main.params['CTRL']['port5'],ip6=main.params['CTRL']['ip6'],port6=main.params['CTRL']['port6'],ip7=main.params['CTRL']['ip7'],port7=main.params['CTRL']['port7'],ip8=main.params['CTRL']['ip8'],port8=main.params['CTRL']['port8']) |
| 62 | time.sleep(3) |
| 63 | elif i >= 5 and i < 15: |
| 64 | j=i+1 |
| 65 | main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip3'],port1=main.params['CTRL']['port3']) |
| 66 | time.sleep(3) |
| 67 | main.Mininet1.assign_sw_controller(sw="s"+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'],ip5=main.params['CTRL']['ip5'],port5=main.params['CTRL']['port5'],ip6=main.params['CTRL']['ip6'],port6=main.params['CTRL']['port6'],ip7=main.params['CTRL']['ip7'],port7=main.params['CTRL']['port7'],ip8=main.params['CTRL']['ip8'],port8=main.params['CTRL']['port8']) |
| 68 | time.sleep(3) |
| 69 | else: |
| 70 | j=i+16 |
| 71 | main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip4'],port1=main.params['CTRL']['port4']) |
| 72 | time.sleep(3) |
| 73 | main.Mininet1.assign_sw_controller(sw="s"+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'],ip5=main.params['CTRL']['ip5'],port5=main.params['CTRL']['port5'],ip6=main.params['CTRL']['ip6'],port6=main.params['CTRL']['port6'],ip7=main.params['CTRL']['ip7'],port7=main.params['CTRL']['port7'],ip8=main.params['CTRL']['ip8'],port8=main.params['CTRL']['port8']) |
| 74 | time.sleep(3) |
| 75 | main.Mininet1.get_sw_controller("s1") |
| 76 | |
| 77 | # ********************************************************************************************************************************************************************************************** |
| 78 | #Add Flows |
| 79 | #Deletes any remnant flows from any previous test, add flows from the file labeled <FLOWDEF>, then runs the check flow test |
| 80 | #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 |
| 81 | |
| 82 | def CASE3(self,main) : #Delete any remnant flows, then add flows, and time how long it takes flow tables to update |
| 83 | main.log.report("Delete any flows from previous tests, then add flows from FLOWDEF file, then wait for switch flow tables to update") |
| 84 | import time |
| 85 | main.case("Taking care of these flows!") |
| 86 | main.step("Cleaning out any leftover flows...") |
| 87 | main.ONOS1.delete_flow("all") |
| 88 | time.sleep(5) |
| 89 | strtTime = time.time() |
| 90 | main.ONOS1.add_flow(main.params['FLOWDEF']) |
| 91 | main.case("Checking flows") |
| 92 | tmp = main.FALSE |
| 93 | count = 1 |
| 94 | main.log.info("Wait for flows to settle, then check") |
| 95 | while tmp == main.FALSE: |
| 96 | main.step("Waiting") |
| 97 | time.sleep(10) |
| 98 | main.step("Checking") |
| 99 | tmp = main.ONOS1.check_flow() |
| 100 | if tmp == main.FALSE and count < 6: |
| 101 | count = count + 1 |
| 102 | main.log.report("Flow failed, waiting 10 seconds then making attempt number "+str(count)) |
| 103 | elif tmp == main.FALSE and count == 6: |
| 104 | result = main.FALSE |
| 105 | break |
| 106 | else: |
| 107 | result = main.TRUE |
| 108 | break |
| 109 | endTime = time.time() |
| 110 | if result == main.TRUE: |
| 111 | main.log.report("\n\t\t\t\tTime to add flows: "+str(round(endTime-strtTime,2))+" seconds") |
| 112 | else: |
| 113 | main.log.report("\tFlows failed check") |
| 114 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Flow check PASS",onfail="Flow check FAIL") |
| 115 | |
| 116 | #********************************************************************************************************************************************************************************************** |
| 117 | #This test case removes Controllers 2,3, and 4 then performs a ping test. |
| 118 | #The assign controller is used because the ovs-vsctl module deletes all current controllers when a new controller is assigned. |
| 119 | #The ping test performs single pings on hosts from opposite sides of the topology. If one ping fails, the test waits 10 seconds before trying again. |
| 120 | #If the ping test fails 6 times, then the test case will return false |
| 121 | |
| 122 | def CASE4(self,main) : |
| 123 | main.log.report("Remove ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 124 | import time |
| 125 | for i in range(25): |
| 126 | if i < 15: |
| 127 | j=i+1 |
| 128 | main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) #Assigning a single controller removes all other controllers |
| 129 | time.sleep(3) |
| 130 | else: |
| 131 | j=i+16 |
| 132 | main.Mininet1.assign_sw_controller(sw="s"+str(j),ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1']) |
| 133 | time.sleep(3) |
| 134 | strtTime = time.time() |
| 135 | count = 1 |
| 136 | i = 6 |
| 137 | while i < 16 : |
| 138 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 139 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 140 | if ping == main.FALSE and count < 6: |
| 141 | count = count + 1 |
| 142 | i = 6 |
| 143 | main.log.info("Ping failed, making attempt number "+str(count)+" in 15 seconds") |
| 144 | time.sleep(15) |
| 145 | elif ping == main.FALSE and count ==6: |
| 146 | main.log.error("Ping test failed") |
| 147 | i = 17 |
| 148 | result = main.FALSE |
| 149 | elif ping == main.TRUE: |
| 150 | i = i + 1 |
| 151 | result = main.TRUE |
| 152 | endTime = time.time() |
| 153 | if result == main.TRUE: |
| 154 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 155 | else: |
| 156 | main.log.report("\tPING TEST FAIL") |
| 157 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 158 | |
| 159 | # ********************************************************************************************************************************************************************************************** |
| 160 | #This test case restores the controllers removed by Case 4 then performs a ping test. |
| 161 | |
| 162 | def CASE5(self,main) : |
| 163 | main.log.report("Restore ONOS 2,3,4 then ping until all hosts are reachable or fail after 6 attempts") |
| 164 | import time |
| 165 | for i in range(25): |
| 166 | if i < 15: |
| 167 | j=i+1 |
| 168 | main.Mininet1.assign_sw_controller(sw="s"+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'],ip5=main.params['CTRL']['ip5'],port5=main.params['CTRL']['port5'],ip6=main.params['CTRL']['ip6'],port6=main.params['CTRL']['port6'],ip7=main.params['CTRL']['ip7'],port7=main.params['CTRL']['port7'],ip8=main.params['CTRL']['ip8'],port8=main.params['CTRL']['port8']) |
| 169 | time.sleep(3) |
| 170 | else: |
| 171 | j=i+16 |
| 172 | main.Mininet1.assign_sw_controller(sw="s"+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'],ip5=main.params['CTRL']['ip5'],port5=main.params['CTRL']['port5'],ip6=main.params['CTRL']['ip6'],port6=main.params['CTRL']['port6'],ip7=main.params['CTRL']['ip7'],port7=main.params['CTRL']['port7'],ip8=main.params['CTRL']['ip8'],port8=main.params['CTRL']['port8']) |
| 173 | time.sleep(3) |
| 174 | strtTime = time.time() |
| 175 | count = 1 |
| 176 | i = 6 |
| 177 | while i < 16 : |
| 178 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 179 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 180 | if ping == main.FALSE and count < 6: |
| 181 | count = count + 1 |
| 182 | i = 6 |
| 183 | main.log.info("Ping failed, making attempt number "+str(count)+" in 15 seconds") |
| 184 | time.sleep(15) |
| 185 | elif ping == main.FALSE and count ==6: |
| 186 | main.log.error("Ping test failed") |
| 187 | i = 17 |
| 188 | result = main.FALSE |
| 189 | elif ping == main.TRUE: |
| 190 | i = i + 1 |
| 191 | result = main.TRUE |
| 192 | endTime = time.time() |
| 193 | if result == main.TRUE: |
| 194 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 195 | else: |
| 196 | main.log.report("\tPING TEST FAILED") |
| 197 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 198 | |
| 199 | # ********************************************************************************************************************************************************************************************** |
| 200 | #Brings a link that all flows pass through in the mininet down, then runs a ping test to view reroute time |
| 201 | |
| 202 | def CASE6(self,main) : |
| 203 | main.log.report("Bring Link between s1 and s2 down, then ping until all hosts are reachable or fail after 6 attempts") |
| 204 | import time |
| 205 | main.case("Bringing Link down... ") |
| 206 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 207 | time.sleep(3) |
| 208 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 209 | strtTime = time.time() |
| 210 | count = 1 |
| 211 | i = 6 |
| 212 | while i < 16 : |
| 213 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 214 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 215 | if ping == main.FALSE and count < 6: |
| 216 | count = count + 1 |
| 217 | main.log.info("Ping failed, making attempt number "+str(count)+" in 15 seconds") |
| 218 | i = 6 |
| 219 | time.sleep(15) |
| 220 | elif ping == main.FALSE and count ==6: |
| 221 | main.log.error("Ping test failed") |
| 222 | i = 17 |
| 223 | result = main.FALSE |
| 224 | elif ping == main.TRUE: |
| 225 | i = i + 1 |
| 226 | result = main.TRUE |
| 227 | endTime = time.time() |
| 228 | if result == main.TRUE: |
| 229 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 230 | else: |
| 231 | main.log.report("\tPING TEST FAILED") |
| 232 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 233 | |
| 234 | # ********************************************************************************************************************************************************************************************** |
| 235 | #Brings the link that Case 6 took down back up, then runs a ping test to view reroute time |
| 236 | |
| 237 | def CASE7(self,main) : |
| 238 | main.log.report("Bring Link between S1 and S2 up, then ping until all hosts are reachable or fail after 6 attempts") |
| 239 | import time |
| 240 | main.case("Bringing Link back up... ") |
| 241 | result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down") |
| 242 | time.sleep(3) |
| 243 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...") |
| 244 | strtTime = time.time() |
| 245 | count = 1 |
| 246 | i = 6 |
| 247 | while i < 16 : |
| 248 | main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) ) |
| 249 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25)) |
| 250 | if ping == main.FALSE and count < 6: |
| 251 | count = count + 1 |
| 252 | main.log.info("Ping failed, making attempt number "+str(count)+" in 15 seconds") |
| 253 | i = 6 |
| 254 | time.sleep(15) |
| 255 | elif ping == main.FALSE and count ==6: |
| 256 | main.log.error("Ping test failed") |
| 257 | i = 17 |
| 258 | result = main.FALSE |
| 259 | elif ping == main.TRUE: |
| 260 | i = i + 1 |
| 261 | result = main.TRUE |
| 262 | endTime = time.time() |
| 263 | if result == main.TRUE: |
| 264 | main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds") |
| 265 | else: |
| 266 | main.log.report("\tPING TESTS FAILED") |
| 267 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE") |
| 268 | |