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