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