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